Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix fixup call order (oops!), serialization-compatible calling of pha…
…sers
  • Loading branch information
sorear committed Oct 16, 2011
1 parent 9b6504a commit c0af787
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
2 changes: 0 additions & 2 deletions lib/CodeGen.cs
Expand Up @@ -4058,8 +4058,6 @@ public class DowncallReceiver : CallReceiver {
SubInfo s = (SubInfo)Handle.Unbox(args[1]);
int p = (int)args[2];
s.phaser = p;
if (s.protosub != null)
Kernel.AddPhaser(p, s.protosub);
if (p == Kernel.PHASER_CATCH)
s.outer.catch_ = s;
if (p == Kernel.PHASER_CONTROL)
Expand Down
27 changes: 10 additions & 17 deletions lib/Kernel.cs
Expand Up @@ -443,8 +443,8 @@ class IdentityComparer : IEqualityComparer<object> {
Kernel.TraceCount = Kernel.TraceFreq = 1;
}

Kernel.FirePhasers(Kernel.PHASER_UNIT_INIT, false);
Kernel.FirePhasers(Kernel.PHASER_INIT, false);
Kernel.FirePhasers(this, Kernel.PHASER_UNIT_INIT, false);
Kernel.FirePhasers(this, Kernel.PHASER_INIT, false);
}

internal CpsOp TypeConstant(STable s) {
Expand Down Expand Up @@ -3636,12 +3636,6 @@ public struct StashCursor {
// A bunch of stuff which raises big circularity issues if done in the
// setting itself.
public class Kernel {
private static VarDeque[] PhaserBanks;

public static void AddPhaser(int i, P6any v) {
PhaserBanks[i].Push(NewROScalar(v));
}

// not listed: BEGIN, CHECK (cannot be implemented in this model),
// START (desugared using state), FIRST, NEXT, LAST (use masak code)
public const int PHASER_INIT = 0;
Expand All @@ -3657,11 +3651,14 @@ public class Kernel {
public const int PHASER_CONTROL = 10;
public const int PHASER_TYPES = 11;

public static void FirePhasers(int i, bool lifo) {
while (PhaserBanks[i].Count() != 0)
RunInferior((lifo ? PhaserBanks[i].Pop() :
PhaserBanks[i].Shift()).Fetch().Invoke(
GetInferiorRoot(), Variable.None, null));
// XXX do lifo
public static void FirePhasers(RuntimeUnit ru, int i, bool lifo) {
foreach (SubInfo z in ru.our_subs) {
if (z.phaser == i && z.protosub != null) {
RunInferior(z.protosub.Invoke(GetInferiorRoot(),
Variable.None, null));
}
}
}

internal static HashSet<string> ModulesStarted = new HashSet<string>();
Expand Down Expand Up @@ -5009,10 +5006,6 @@ class LastFrameNode {
}

internal static void CreateBasicTypes() {
// XXX maybe wrong place
PhaserBanks = new VarDeque[PHASER_TYPES];
for (int i = 0; i < PHASER_TYPES; i++)
PhaserBanks[i] = new VarDeque();
CodeMO = new STable("Code"); // forward decl
MuMO = new STable("Mu");
Handler_Vonly(MuMO, "defined", new CtxBoolNativeDefined(),
Expand Down
2 changes: 1 addition & 1 deletion lib/Serialize.cs
Expand Up @@ -130,8 +130,8 @@ struct ObjRef {
if (rver != version)
throw new ThawException("version mismatch loading " + file);

tb.RunFixups();
su.root = tb.ObjRef();
tb.RunFixups();
success = true;
} finally {
// don't leave half-read units in the map
Expand Down

0 comments on commit c0af787

Please sign in to comment.