Add special case for Magic (flow control) to node api

This commit is contained in:
d98762625 2020-02-12 09:22:57 +00:00
parent 3ca1c22945
commit a80c8ae0c0
3 changed files with 359 additions and 30 deletions

View file

@ -191,7 +191,30 @@ export function _wrap(OpClass) {
*/
wrapped = async (input, args=null) => {
const {transformedInput, transformedArgs} = prepareOp(opInstance, input, args);
// SPECIAL CASE for Magic.
if (opInstance.flowControl) {
opInstance.ingValues = transformedArgs;
let state = {
"progress": 0,
"dish": ensureIsDish(transformedInput),
"opList": [opInstance],
"numJumps": 0,
"numRegisters": 0,
"forkOffset": 0
}
const updatedState = await opInstance.run(state);
return new NodeDish({
value: updatedState.dish.value,
type: opInstance.outputType,
});
}
const result = await opInstance.run(transformedInput, transformedArgs);
return new NodeDish({
value: result,
type: opInstance.outputType,