Skip to content

Commit

Permalink
toLeopard: extra pass fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
towerofnix committed Dec 18, 2023
1 parent 88f5af7 commit 7c1af13
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/io/leopard/toLeopard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ export default function toLeopard(

function increase(leftSide: string, input: BlockInput.Any, allowIncrementDecrement: boolean): string {
const n = parseNumber(input);
if (n === null) {
if (typeof n !== "number") {
return `${leftSide} += ${inputToJS(input, InputShape.Number)}`;
}

Expand All @@ -506,7 +506,7 @@ export default function toLeopard(

function decrease(leftSide: string, input: BlockInput.Any, allowIncrementDecrement: boolean) {
const n = parseNumber(input);
if (n === null) {
if (typeof n !== "number") {
return `${leftSide} -= ${inputToJS(input, InputShape.Number)}`;
}

Expand Down Expand Up @@ -1469,7 +1469,8 @@ export default function toLeopard(
case OpCode.sensing_askandwait: {
satisfiesInputShape = InputShape.Stack;

blockSource = `yield* this.askAndWait(${inputToJS(block.inputs.QUESTION, InputShape.Any)})`;
const question = inputToJS(block.inputs.QUESTION, InputShape.Any);
blockSource = `yield* this.askAndWait(${question})`;

break;
}
Expand All @@ -1485,7 +1486,8 @@ export default function toLeopard(
case OpCode.sensing_keypressed: {
satisfiesInputShape = InputShape.Boolean;

blockSource = `this.keyPressed(${inputToJS(block.inputs.KEY_OPTION, InputShape.String)})`;
const key = inputToJS(block.inputs.KEY_OPTION, InputShape.String);
blockSource = `this.keyPressed(${key})`;

break;
}
Expand Down

0 comments on commit 7c1af13

Please sign in to comment.