From 38799f422c931bbc689257cde19ebe6f5dc6a83d Mon Sep 17 00:00:00 2001 From: adroitwhiz Date: Tue, 5 Jan 2021 10:04:40 -0500 Subject: [PATCH] Don't yield procedure calls in warp procedures --- src/io/leopard/toLeopard.ts | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/io/leopard/toLeopard.ts b/src/io/leopard/toLeopard.ts index ac8a8718..47dd93c0 100644 --- a/src/io/leopard/toLeopard.ts +++ b/src/io/leopard/toLeopard.ts @@ -766,16 +766,24 @@ export default function toLeopard( return `${selectedWatcherSource}.visible = true`; case OpCode.data_hidelist: return `${selectedWatcherSource}.visible = false`; - case OpCode.procedures_call: - return `yield* this.${ - // Get name of custom block script with given PROCCODE: - target.scripts.find( - script => - script.hat !== null && - script.hat.opcode === OpCode.procedures_definition && - script.hat.inputs.PROCCODE.value === block.inputs.PROCCODE.value - ).name - }(${block.inputs.INPUTS.value.map(inputToJS).join(", ")})`; + case OpCode.procedures_call: { + // Get name of custom block script with given PROCCODE: + const procName = target.scripts.find( + script => + script.hat !== null && + script.hat.opcode === OpCode.procedures_definition && + script.hat.inputs.PROCCODE.value === block.inputs.PROCCODE.value + ).name; + + const procArgs = `${block.inputs.INPUTS.value.map(inputToJS).join(", ")}`; + + // Warp-mode procedures execute all child procedures in warp mode as well + if (warp) { + return `this.warp(this.${procName})(${procArgs})`; + } else { + return `yield* this.${procName}(${procArgs})`; + } + } case OpCode.argument_reporter_string_number: case OpCode.argument_reporter_boolean: return customBlockArgNameMap.get(script)[block.inputs.VALUE.value]; @@ -1009,7 +1017,7 @@ export default function toLeopard( ${[...target.variables, ...target.lists] .map(variable => `this.vars.${variable.name} = ${toOptimalJavascriptRepresentation(variable.value)};`) .join("\n")} - + ${[...target.variables, ...target.lists] .map( variable =>