Permalink
Browse files

Move most of the [CompartmentGlobal] stuff into the compartment object

  • Loading branch information...
1 parent d67e96f commit 2ae0f72a8c43d14260cff3c801292c69ccc877f5 @sorear committed Sep 15, 2012
Showing with 88 additions and 90 deletions.
  1. +9 −9 lib/Builtins.cs
  2. +11 −11 lib/CodeGen.cs
  3. +66 −68 lib/Kernel.cs
  4. +2 −2 lib/NieczaCLR.cs
View
@@ -2232,7 +2232,7 @@ class CrossSource: ItemSource {
P6any fcni = fcn.Fetch();
int arity = get_count(fcni);
- Frame fr = th.MakeChild(null, Kernel.CommonMEMap_I, Compartment.Top.AnyP);
+ Frame fr = th.MakeChild(null, Compartment.Top.CommonMEMap_I, Compartment.Top.AnyP);
fr.lexi0 = 0;
fr.lex0 = new BatchSource(arity, iter);
fr.lex1 = new VarDeque();
@@ -2244,7 +2244,7 @@ class CrossSource: ItemSource {
Func<Variable,Variable> fcn) {
VarDeque iter = new VarDeque(Kernel.NewRWListVar(lst));
- Frame fr = th.MakeChild(null, Kernel.CommonMEMap_I, Compartment.Top.AnyP);
+ Frame fr = th.MakeChild(null, Compartment.Top.CommonMEMap_I, Compartment.Top.AnyP);
fr.lexi0 = 0;
fr.lex0 = new BatchSource(1, iter);
fr.lex1 = new VarDeque();
@@ -2262,7 +2262,7 @@ class CrossSource: ItemSource {
}
public static Frame MEZip(Frame th, bool with, Variable[] pcl) {
- Frame fr = th.MakeChild(null, Kernel.CommonMEMap_I, Compartment.Top.AnyP);
+ Frame fr = th.MakeChild(null, Compartment.Top.CommonMEMap_I, Compartment.Top.AnyP);
Kernel.SetTopFrame(fr);
fr.lexi0 = 0;
fr.lex2 = ExtractWith(with, ref pcl);
@@ -2272,7 +2272,7 @@ class CrossSource: ItemSource {
}
public static Frame MECross(Frame th, bool with, Variable[] pcl) {
- Frame fr = th.MakeChild(null, Kernel.CommonMEMap_I, Compartment.Top.AnyP);
+ Frame fr = th.MakeChild(null, Compartment.Top.CommonMEMap_I, Compartment.Top.AnyP);
Kernel.SetTopFrame(fr);
fr.lexi0 = 0;
fr.lex2 = ExtractWith(with, ref pcl);
@@ -2354,7 +2354,7 @@ class CrossSource: ItemSource {
Variable fcn = iter.Shift();
iter = Kernel.IterFlatten(iter);
- Frame fr = th.MakeChild(null, Kernel.CommonGrep_I, Compartment.Top.AnyP);
+ Frame fr = th.MakeChild(null, Compartment.Top.CommonGrep_I, Compartment.Top.AnyP);
fr.lexi0 = 0;
fr.lex0 = iter;
fr.lex1 = new VarDeque();
@@ -2422,7 +2422,7 @@ class CrossSource: ItemSource {
public static Variable stash_exists_key(P6any st, string key) {
string lkey = Kernel.UnboxAny<string>(st);
lkey = (char)lkey.Length + lkey + key;
- return Kernel.currentGlobals.ContainsKey(lkey) ? Compartment.Top.TrueV : Compartment.Top.FalseV;
+ return Compartment.Top.currentGlobals.ContainsKey(lkey) ? Compartment.Top.TrueV : Compartment.Top.FalseV;
}
public static Variable stash_at_key(P6any st, string key) {
@@ -2438,9 +2438,9 @@ class CrossSource: ItemSource {
string lkey = Kernel.UnboxAny<string>(st);
lkey = (char)lkey.Length + lkey + key;
StashEnt r;
- if (!Kernel.currentGlobals.TryGetValue(lkey, out r))
+ if (!Compartment.Top.currentGlobals.TryGetValue(lkey, out r))
return Compartment.Top.AnyP;
- Kernel.currentGlobals.Remove(key);
+ Compartment.Top.currentGlobals.Remove(key);
return r.v;
}
@@ -2471,7 +2471,7 @@ class CrossSource: ItemSource {
Frame o = new Frame();
o.lex0 = v;
o.lex1 = v.Fetch();
- fr.PushLeave(type, Kernel.MakeSub(Kernel.TEMP_SI, o));
+ fr.PushLeave(type, Kernel.MakeSub(Compartment.Top.TEMP_SI, o));
}
return v;
View
@@ -3681,26 +3681,26 @@ public class DowncallReceiver : CallReceiver {
(string)args[2], (string)args[3],
(bool)args[4], (bool)args[5]);
- if (Kernel.containerRootUnit == null) {
+ if (Compartment.Top.containerRootUnit == null) {
// this is a module unit
Kernel.InitCompartment();
- Kernel.containerRootUnit = ru;
+ Compartment.Top.containerRootUnit = ru;
ru.depended_units.Add(ru);
ru.owner = ru;
- ru.globals = Kernel.currentGlobals =
+ ru.globals = Compartment.Top.currentGlobals =
new Dictionary<string,StashEnt>();
} else {
// needs to use the same globals as the other units in
// this serialization unit
- ru.globals = Kernel.currentGlobals;
- ru.owner = Kernel.containerRootUnit;
+ ru.globals = Compartment.Top.currentGlobals;
+ ru.owner = Compartment.Top.containerRootUnit;
ru.owner.subordinates.Add(ru);
}
return new Handle(ru);
}
public static object unit_get_incs(object[] args) {
StashEnt bv;
- if (!Kernel.currentGlobals.TryGetValue("\u0008::GLOBAL@INC", out bv))
+ if (!Compartment.Top.currentGlobals.TryGetValue("\u0008::GLOBAL@INC", out bv))
return new string[0];
return Builtins.UnboxLoS(bv.v);
}
@@ -3717,7 +3717,7 @@ public class DowncallReceiver : CallReceiver {
RuntimeUnit tg;
try {
- tg = (RuntimeUnit) RuntimeUnit.reg.LoadUnit(oname).root;
+ tg = (RuntimeUnit) Compartment.Top.reg.LoadUnit(oname).root;
} catch (Exception ex) {
if (Config.SerFailInfo)
Console.WriteLine("Thaw {0} failed: >>>{1}<<<", oname, ex);
@@ -3726,7 +3726,7 @@ public class DowncallReceiver : CallReceiver {
"compile_unit", oname });
if (r1 != null)
return r1;
- tg = (RuntimeUnit) RuntimeUnit.reg.LoadUnit(oname).root;
+ tg = (RuntimeUnit) Compartment.Top.reg.LoadUnit(oname).root;
}
string err = ru.owner.LinkUnit(tg);
return err == null ? (object)new Handle(tg) : new Exception(err);
@@ -3898,7 +3898,7 @@ public class DowncallReceiver : CallReceiver {
if (li is LIConstant) {
((LIConstant)li).value = v;
} else if (li is LICommon) {
- StashEnt hkey = Kernel.currentGlobals[((LICommon)li).hkey];
+ StashEnt hkey = Compartment.Top.currentGlobals[((LICommon)li).hkey];
hkey.constant = true;
hkey.v = v;
} else {
@@ -4049,7 +4049,7 @@ public class DowncallReceiver : CallReceiver {
var lcomm = li as LICommon;
if (lcomm != null) {
StashEnt se;
- Kernel.currentGlobals.TryGetValue(lcomm.hkey, out se);
+ Compartment.Top.currentGlobals.TryGetValue(lcomm.hkey, out se);
r = new object[] { "common",null,null,null, lcomm.Stash(), lcomm.VarName(), (se.constant ? Handle.Wrap(se.v) : null) };
}
@@ -4659,7 +4659,7 @@ public class DowncallReceiver : CallReceiver {
bool evalmode = (bool)args[2];
Kernel.commandArgs = new string[args.Length - 3];
Array.Copy(args, 3, Kernel.commandArgs, 0, args.Length - 3);
- Kernel.currentGlobals = ru.globals;
+ Compartment.Top.currentGlobals = ru.globals;
ru.PrepareEval();
Compartment.Top.check.Run();
Compartment.Top.init.Run();
Oops, something went wrong.

0 comments on commit 2ae0f72

Please sign in to comment.