The raw, unpresented dish is now returned to the app after baking, where it can be retrieved as various different data types.

This commit is contained in:
n1474335 2018-04-21 12:25:48 +01:00
parent 30aa4e05ef
commit 76a066ab74
12 changed files with 163 additions and 73 deletions

View file

@ -130,10 +130,12 @@ class Recipe {
* - The final progress through the recipe
*/
async execute(dish, startFrom=0, forkState={}) {
let op, input, output, lastRunOp,
let op, input, output,
numJumps = 0,
numRegisters = forkState.numRegisters || 0;
if (startFrom === 0) this.lastRunOp = null;
log.debug(`[*] Executing recipe of ${this.opList.length} operations, starting at ${startFrom}`);
for (let i = startFrom; i < this.opList.length; i++) {
@ -169,7 +171,7 @@ class Recipe {
numRegisters = state.numRegisters;
} else {
output = await op.run(input, op.ingValues);
lastRunOp = op;
this.lastRunOp = op;
dish.set(output, op.outputType);
}
} catch (err) {
@ -188,18 +190,24 @@ class Recipe {
}
}
// Present the results of the final operation
if (lastRunOp) {
// TODO try/catch
output = await lastRunOp.present(output);
dish.set(output, lastRunOp.presentType);
}
log.debug("Recipe complete");
return this.opList.length;
}
/**
* Present the results of the final operation.
*
* @param {Dish} dish
*/
async present(dish) {
if (!this.lastRunOp) return;
const output = await this.lastRunOp.present(await dish.get(this.lastRunOp.outputType));
dish.set(output, this.lastRunOp.presentType);
}
/**
* Returns the recipe configuration in string format.
*