Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't eagerly cast boolean arguments to boolean #223

Merged
merged 2 commits into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/compiler/irgen.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class ScriptTreeGenerator {
};
}
return {
kind: 'args.stringNumber',
kind: 'procedures.argument',
index: index
};
}
Expand All @@ -223,7 +223,7 @@ class ScriptTreeGenerator {
};
}
return {
kind: 'args.boolean',
kind: 'procedures.argument',
index: index
};
}
Expand Down
7 changes: 2 additions & 5 deletions src/compiler/jsgen.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,6 @@ class JSGenerator {
case 'addons.call':
return new TypedInput(`(${this.descendAddonCall(node)})`, TYPE_UNKNOWN);

case 'args.boolean':
return new TypedInput(`toBoolean(p${node.index})`, TYPE_BOOLEAN);
case 'args.stringNumber':
return new TypedInput(`p${node.index}`, TYPE_UNKNOWN);

case 'compat':
// Compatibility layer inputs never use flags.
return new TypedInput(`(${this.generateCompatibilityLayerCall(node, false)})`, TYPE_UNKNOWN);
Expand Down Expand Up @@ -665,6 +660,8 @@ class JSGenerator {
}
return new TypedInput(`${procedureReference}(${joinedArgs})`, TYPE_UNKNOWN);
}
case 'procedures.argument':
return new TypedInput(`p${node.index}`, TYPE_UNKNOWN);

case 'sensing.answer':
return new TypedInput(`runtime.ext_scratch3_sensing._answer`, TYPE_STRING);
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// TW Snapshot
// Input SHA-256: 9ecff9e3c4b1dcdf3e23d0e49c0a2da3de446b6d626a2b5ee39d761be20344ca

// Sprite1 script
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = runtime.getOpcodeFunction("looks_say");
return function* genXYZ () {
yield* executeInCompatibilityLayer({"MESSAGE":"plan 1",}, b0, false, false, "f", null);
yield* thread.procedures["ZBlock A %s"]("Hai!!!");
yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "k", null);
retire(); return;
}; })

// Sprite1 ZBlock A %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = runtime.getOpcodeFunction("looks_say");
return function* genXYZ_Block_A_ (p0) {
if ((("" + p0).toLowerCase() === "Hai!!!".toLowerCase())) {
yield* executeInCompatibilityLayer({"MESSAGE":"pass did not cast",}, b0, false, false, "m", null);
} else {
yield* executeInCompatibilityLayer({"MESSAGE":"fail was casted",}, b0, false, false, "n", null);
}
return "";
}; })
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// TW Snapshot
// Input SHA-256: 9ecff9e3c4b1dcdf3e23d0e49c0a2da3de446b6d626a2b5ee39d761be20344ca

// Sprite1 script
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = runtime.getOpcodeFunction("looks_say");
return function* genXYZ () {
yield* executeInCompatibilityLayer({"MESSAGE":"plan 1",}, b0, false, false, "f", null);
yield* thread.procedures["ZBlock A %s"]("Hai!!!");
yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "k", null);
retire(); return;
}; })

// Sprite1 ZBlock A %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = runtime.getOpcodeFunction("looks_say");
return function* genXYZ_Block_A_ (p0) {
if ((("" + p0).toLowerCase() === "Hai!!!".toLowerCase())) {
yield* executeInCompatibilityLayer({"MESSAGE":"pass did not cast",}, b0, false, false, "m", null);
} else {
yield* executeInCompatibilityLayer({"MESSAGE":"fail was casted",}, b0, false, false, "n", null);
}
return "";
}; })