Skip to content

Commit

Permalink
Use procedure variant in snapshots instead of just procedure code
Browse files Browse the repository at this point in the history
  • Loading branch information
GarboMuffin committed May 23, 2024
1 parent 6ce931b commit 16415ba
Show file tree
Hide file tree
Showing 31 changed files with 76 additions and 69 deletions.
6 changes: 6 additions & 0 deletions src/compiler/intermediate.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ class IntermediateScript {
*/
this.isProcedure = false;

/**
* This procedure's variant, if any.
* @type {string}
*/
this.procedureVariant = '';

/**
* This procedure's code, if any.
* @type {string}
Expand Down
1 change: 1 addition & 0 deletions src/compiler/irgen.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class ScriptTreeGenerator {
setProcedureVariant (procedureVariant) {
const procedureCode = parseProcedureCode(procedureVariant);

this.script.procedureVariant = procedureVariant;
this.script.procedureCode = procedureCode;
this.script.isProcedure = true;
this.script.yields = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "aZ", n
retire(); return;
}; })

// Sprite1 run test
// Sprite1 Wrun test
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = stage.variables["mfV;yS}9e:%h5UZ)QyiY"];
const b1 = stage.variables["`jEk@4|i[#Fk?(8x)AV.-my variable"];
Expand Down Expand Up @@ -46,7 +46,7 @@ if (hasResumedFromPromise) {hasResumedFromPromise = false;continue;}
return "";
}; })

// Sprite1 setup values
// Sprite1 Wsetup values
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = stage.variables["n^wm8jw#b24sggt.S^tD"];
return function funXYZ_setup_values () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "l", nu
retire(); return;
}; })

// Sprite1 block name
// Sprite1 Zblock name
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function funXYZ_block_name () {
return 40;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ retire(); return;
retire(); return;
}; })

// Sprite1 no refresh
// Sprite1 Wno refresh
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = runtime.getOpcodeFunction("music_restForBeats");
const b1 = runtime.getOpcodeFunction("music_playDrumForBeats");
Expand All @@ -41,14 +41,14 @@ runtime.ext_scratch3_motion._moveSteps(0, target);
return "";
}; })

// Sprite1 runs below with no refresh
// Sprite1 Wruns below with no refresh
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function* genXYZ_runs_below_with_no_r () {
yield* thread.procedures["Whas refresh"]();
return "";
}; })

// Sprite1 has refresh
// Sprite1 Whas refresh
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = runtime.getOpcodeFunction("music_restForBeats");
const b1 = runtime.getOpcodeFunction("music_playDrumForBeats");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "g", nu
retire(); return;
}; })

// Sprite1 foo %s
// Sprite1 Zfoo %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function funXYZ_foo_ (p0) {
return "";
return "";
}; })

// Sprite1 no op
// Sprite1 Zno op
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function funXYZ_no_op () {
return "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "Q^(MKg
retire(); return;
}; })

// Player Set Costume
// Player ZSet Costume
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = runtime.getOpcodeFunction("looks_say");
return function* genXYZ_Set_Costume () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "$R-1lb
retire(); return;
}; })

// Sprite1 number or text %s %s
// Sprite1 Znumber or text %s %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_number_or_text__ (p0,p1) {
Expand All @@ -22,7 +22,7 @@ yield* executeInCompatibilityLayer({"MESSAGE":"pass",}, b0, false, false, "HH`yR
return "";
}; })

// Sprite1 boolean %b %b
// Sprite1 Zboolean %b %b
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = runtime.getOpcodeFunction("looks_say");
return function* genXYZ_boolean__ (p0,p1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, ",vD-ZG
retire(); return;
}; })

// Sprite1 do something
// Sprite1 Zdo something
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = stage.variables["`jEk@4|i[#Fk?(8x)AV.-my variable"];
return function funXYZ_do_something () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "P", nu
retire(); return;
}; })

// Sprite1 invalid params - reporter
// Sprite1 Zinvalid params - reporter
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function funXYZ_invalid_params___rep () {
return 0;
return "";
}; })

// Sprite1 invalid params - boolean
// Sprite1 Zinvalid params - boolean
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function funXYZ_invalid_params___boo () {
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "av", n
retire(); return;
}; })

// Sprite1 non warp recursion should yield %s
// Sprite1 Znon warp recursion should yield %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function* genXYZ_non_warp_recursion_s (p0) {
if (compareGreaterThan(p0, 0)) {
Expand All @@ -39,7 +39,7 @@ return (yield* yieldThenCallGenerator(thread.procedures["Znon warp recursion sho
return "";
}; })

// Sprite1 warp recursion should not yield %s
// Sprite1 Wwarp recursion should not yield %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function funXYZ_warp_recursion_shoul (p0) {
if (compareGreaterThan(p0, 0)) {
Expand All @@ -48,7 +48,7 @@ return thread.procedures["Wwarp recursion should not yield %s"](((+p0 || 0) - 1)
return "";
}; })

// Sprite1 fib %s
// Sprite1 Zfib %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function* genXYZ_fib_ (p0) {
if (compareLessThan(p0, 2)) {
Expand All @@ -59,7 +59,7 @@ return ((+(yield* yieldThenCallGenerator(thread.procedures["Zfib %s"], ((+p0 ||
return "";
}; })

// Sprite1 recursing yields between each %s
// Sprite1 Zrecursing yields between each %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = stage.variables["Go=PJS7BFXYo_qi2S:kQ"];
const b1 = stage.variables["`jEk@4|i[#Fk?(8x)AV.-my variable"];
Expand All @@ -83,7 +83,7 @@ yield* executeInCompatibilityLayer({"MESSAGE":("fail recursing between calls yie
return "";
}; })

// Sprite1 recursing arguments eval order %s %s %s %s
// Sprite1 Zrecursing arguments eval order %s %s %s %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = stage.variables["4HH82mPlVMOONdl(Ot*7"];
const b1 = stage.variables["Go=PJS7BFXYo_qi2S:kQ"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,29 @@ yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "`", nu
retire(); return;
}; })

// Sprite1 simplest
// Sprite1 Zsimplest
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function funXYZ_simplest () {
return "It works!";
return "";
}; })

// Sprite1 nesting 1
// Sprite1 Znesting 1
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function funXYZ_nesting_1 () {
thread.procedures["Znesting 2"]();
return (("" + thread.procedures["Znesting 3 %s %s"](6,7)) + ("" + thread.procedures["Znesting 3 %s %s"](-1,54)));
return "";
}; })

// Sprite1 warp fib %s
// Sprite1 Wwarp fib %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function funXYZ_warp_fib_ (p0) {
return thread.procedures["Wfib %s"](p0);
return "";
}; })

// Sprite1 factorial %s
// Sprite1 Wfactorial %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function funXYZ_factorial_ (p0) {
if (compareGreaterThan(p0, 1)) {
Expand All @@ -59,7 +59,7 @@ return 1;
return "";
}; })

// Sprite1 no shadowing 1 %s %s
// Sprite1 Zno shadowing 1 %s %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = runtime.getOpcodeFunction("looks_say");
const b1 = stage.variables["`jEk@4|i[#Fk?(8x)AV.-my variable"];
Expand All @@ -78,21 +78,21 @@ yield* executeInCompatibilityLayer({"MESSAGE":"pass shadow check 3",}, b0, false
return "";
}; })

// Sprite1 nesting 2
// Sprite1 Znesting 2
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function funXYZ_nesting_2 () {
return "discard nesting 2";
return "";
}; })

// Sprite1 nesting 3 %s %s
// Sprite1 Znesting 3 %s %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function funXYZ_nesting_3__ (p0,p1) {
return ((+p0 || 0) * (+p1 || 0));
return "";
}; })

// Sprite1 fib %s
// Sprite1 Wfib %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function funXYZ_fib_ (p0) {
if (compareLessThan(p0, 2)) {
Expand All @@ -103,7 +103,7 @@ return ((+thread.procedures["Wfib %s"](((+p0 || 0) - 1)) || 0) + (+thread.proced
return "";
}; })

// Sprite1 no shadowing 2 %s %s
// Sprite1 Zno shadowing 2 %s %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function funXYZ_no_shadowing_2__ (p0,p1) {
return "discard shadow 2";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "v", nu
retire(); return;
}; })

// Sprite1 return stops the script immediately
// Sprite1 Wreturn stops the script immediately
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = stage.variables["PsAI*C{QHI3*4?O8p#TM"];
const b1 = runtime.getOpcodeFunction("looks_say");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "N", nu
retire(); return;
}; })

// Sprite1 non warp
// Sprite1 Znon warp
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = stage.variables["Go=PJS7BFXYo_qi2S:kQ"];
const b1 = runtime.getOpcodeFunction("looks_say");
Expand Down Expand Up @@ -73,7 +73,7 @@ yield* executeInCompatibilityLayer({"MESSAGE":"pass non warp 2",}, b1, false, fa
return "";
}; })

// Sprite1 verify runs warp %s
// Sprite1 Wverify runs warp %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = stage.variables["Go=PJS7BFXYo_qi2S:kQ"];
const b1 = runtime.getOpcodeFunction("looks_say");
Expand All @@ -95,7 +95,7 @@ return ("warp: " + ("" + p0));
return "";
}; })

// Sprite1 verify runs non warp %s
// Sprite1 Zverify runs non warp %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = stage.variables["Go=PJS7BFXYo_qi2S:kQ"];
const b1 = runtime.getOpcodeFunction("looks_say");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "$R-1lb
retire(); return;
}; })

// Sprite1 switch %s
// Sprite1 Zswitch %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function funXYZ_switch_ (p0) {
runtime.ext_scratch3_looks._setCostume(target, p0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "s", nu
retire(); return;
}; })

// Sprite1 run without screen refresh
// Sprite1 Wrun without screen refresh
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = stage.variables["F?*}X,`9XBpN_[piGRrz"];
const b1 = runtime.getOpcodeFunction("looks_say");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "aZ", n
retire(); return;
}; })

// Sprite1 run test
// Sprite1 Wrun test
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = stage.variables["mfV;yS}9e:%h5UZ)QyiY"];
const b1 = stage.variables["`jEk@4|i[#Fk?(8x)AV.-my variable"];
Expand Down Expand Up @@ -48,7 +48,7 @@ if (isStuck()) yield;
return "";
}; })

// Sprite1 setup values
// Sprite1 Wsetup values
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = stage.variables["n^wm8jw#b24sggt.S^tD"];
return function funXYZ_setup_values () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "l", nu
retire(); return;
}; })

// Sprite1 block name
// Sprite1 Zblock name
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function funXYZ_block_name () {
return 40;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ retire(); return;
retire(); return;
}; })

// Sprite1 no refresh
// Sprite1 Wno refresh
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = runtime.getOpcodeFunction("music_restForBeats");
const b1 = runtime.getOpcodeFunction("music_playDrumForBeats");
Expand All @@ -42,14 +42,14 @@ if (isStuck()) yield;
return "";
}; })

// Sprite1 runs below with no refresh
// Sprite1 Wruns below with no refresh
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function* genXYZ_runs_below_with_no_r () {
yield* thread.procedures["Whas refresh"]();
return "";
}; })

// Sprite1 has refresh
// Sprite1 Whas refresh
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = runtime.getOpcodeFunction("music_restForBeats");
const b1 = runtime.getOpcodeFunction("music_playDrumForBeats");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "g", nu
retire(); return;
}; })

// Sprite1 foo %s
// Sprite1 Zfoo %s
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function funXYZ_foo_ (p0) {
return "";
return "";
}; })

// Sprite1 no op
// Sprite1 Zno op
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
return function funXYZ_no_op () {
return "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "Q^(MKg
retire(); return;
}; })

// Player Set Costume
// Player ZSet Costume
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = runtime.getOpcodeFunction("looks_say");
return function* genXYZ_Set_Costume () {
Expand Down
Loading

0 comments on commit 16415ba

Please sign in to comment.