Skip to content

Commit

Permalink
Merge pull request #56 from adroitwhiz/fix-nested-warp
Browse files Browse the repository at this point in the history
  • Loading branch information
PullJosh authored Jan 9, 2021
2 parents f27f5a5 + 38799f4 commit 33de971
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/io/leopard/toLeopard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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 =>
Expand Down

0 comments on commit 33de971

Please sign in to comment.