Permalink
Browse files

Top removal: inferior runloop system

  • Loading branch information...
sorear committed Nov 13, 2012
1 parent 8864bf6 commit 3db2fe180842861e00d15c28982de22011b7606c
Showing with 23 additions and 22 deletions.
  1. +8 −6 lib/Builtins.cs
  2. +1 −1 lib/CodeGen.cs
  3. +14 −15 lib/Kernel.cs
View
@@ -535,21 +535,23 @@ public partial class Builtins {
}
public static Variable InvokeSub(P6any obj, params Variable[] pos) {
- return Kernel.RunInferior(obj.Invoke(Kernel.GetInferiorRoot(), pos, null));
+ return Kernel.RunInferior(obj.Invoke(Kernel.GetInferiorRoot(obj.mo.setting), pos, null));
}
public static Variable InvokeSub(P6any obj, Variable[] pos, VarHash nam) {
- return Kernel.RunInferior(obj.Invoke(Kernel.GetInferiorRoot(), pos, nam));
+ return Kernel.RunInferior(obj.Invoke(Kernel.GetInferiorRoot(obj.mo.setting), pos, nam));
}
public static Variable InvokeMethod(string name, params Variable[] pos) {
- return Kernel.RunInferior(pos[0].Fetch().InvokeMethod(
- Kernel.GetInferiorRoot(), name, pos, null));
+ var o = pos[0].Fetch();
+ return Kernel.RunInferior(o.InvokeMethod(
+ Kernel.GetInferiorRoot(o.mo.setting), name, pos, null));
}
public static Variable InvokeMethod(string name, Variable[] pos, VarHash nam) {
- return Kernel.RunInferior(pos[0].Fetch().InvokeMethod(
- Kernel.GetInferiorRoot(), name, pos, nam));
+ var o = pos[0].Fetch();
+ return Kernel.RunInferior(o.InvokeMethod(
+ Kernel.GetInferiorRoot(o.mo.setting), name, pos, nam));
}
public static bool ToBool(Variable v) {
View
@@ -4662,7 +4662,7 @@ public class DowncallReceiver : CallReceiver {
ru.setting.init.Run();
StashEnt b = ru.setting.GetVar("::PROCESS", "$OUTPUT_USED");
b.Bind(ru.setting.FalseV);
- Frame ir = Kernel.GetInferiorRoot();
+ Frame ir = Kernel.GetInferiorRoot(ru.setting);
fret = ru.mainline.protosub.Invoke(ir, Variable.None, null);
fret.MarkShared();
Variable r = Kernel.RunInferior(fret);
View
@@ -826,7 +826,7 @@ public sealed class RuntimeUnit : IFreeze {
csr = o;
}
- Kernel.RunInferior(Kernel.GetInferiorRoot().
+ Kernel.RunInferior(Kernel.GetInferiorRoot(setting).
MakeChild(null, csr.mainline, setting.AnyP));
}
@@ -2605,7 +2605,7 @@ public class Frame: P6any, IFixup {
ref jun_pivot, ref jun_pivot_n, ref jun_rank);
}
if (c is SubInfo) {
- Frame thn = Kernel.GetInferiorRoot()
+ Frame thn = Kernel.GetInferiorRoot(setting)
.MakeChild(th, (SubInfo)c, setting.AnyP);
var sm = Kernel.RunInferior(thn);
bool res = Kernel.ACCEPTS(arg, sm);
@@ -2720,7 +2720,7 @@ public class Frame: P6any, IFixup {
if (param.def is Variable) {
src = (Variable)param.def;
} else {
- Frame thn = Kernel.GetInferiorRoot()
+ Frame thn = Kernel.GetInferiorRoot(setting)
.MakeChild(th, (SubInfo)param.def, setting.AnyP);
src = Kernel.RunInferior(thn);
if (src == null)
@@ -5144,7 +5144,7 @@ internal class MMDCandidate : MultiCandidate {
Frame o = (Frame)impl.GetSlot(info.setting.CodeMO, "$!outer");
// XXX sucks a bit to have an inf runloop here
var res = Kernel.RunInferior(info.SetupCall(
- Kernel.GetInferiorRoot(), o, impl, pos, named, true, null));
+ Kernel.GetInferiorRoot(info.setting), o, impl, pos, named, true, null));
return (res == info.setting.TrueV);
}
@@ -6124,7 +6124,7 @@ class ExitRunloopException : Exception {
class LastFrameNode {
public LastFrameNode next, prev;
public Frame cur, root;
- public Compartment compartment = Compartment.Top;
+ public Compartment compartment;
}
[ThreadStatic] static LastFrameNode rlstack;
public static void SetTopFrame(Frame f) {
@@ -6140,22 +6140,21 @@ class LastFrameNode {
// it is an error to throw an exception between GetInferiorRoot
// and RunInferior
- public static Frame GetInferiorRoot() {
+ public static Frame GetInferiorRoot(Compartment s) {
LastFrameNode lfn = rlstack;
if (lfn == null)
- lfn = rlstack = new LastFrameNode();
+ lfn = rlstack = new LastFrameNode() { compartment = s };
if (lfn.next == null) {
- lfn.next = new LastFrameNode();
- lfn.next.prev = lfn;
+ lfn.next = new LastFrameNode() { compartment = s, prev = lfn };
}
Frame l = lfn.cur;
- if (lfn.compartment != Compartment.Top)
+ if (lfn.compartment != s)
l = null; // hide other objects
rlstack = lfn.next;
- lfn.next.compartment = Compartment.Top;
+ lfn.next.compartment = s;
return lfn.next.cur = lfn.next.root = ((l == null ?
- new Frame(null, null, Compartment.Top.ExitRunloopSI, Compartment.Top.AnyP) :
- l.MakeChild(null, Compartment.Top.ExitRunloopSI, Compartment.Top.AnyP)));
+ new Frame(null, null, s.ExitRunloopSI, s.AnyP) :
+ l.MakeChild(null, s.ExitRunloopSI, s.AnyP)));
//lfn.next.cur = lfn.next.root = ((l == null ?
// new Frame(null, null, ExitRunloopSI, Compartment.Top.AnyP) :
// l.MakeChild(null, ExitRunloopSI, Compartment.Top.AnyP)));
@@ -6517,7 +6516,7 @@ class LastFrameNode {
if (type == SubInfo.ON_DIE && csr.info.catch_ != null) {
Frame nfr = s.RunCATCH_I.SetupCall(
- Kernel.GetInferiorRoot(), null, null, null, null,
+ Kernel.GetInferiorRoot(s), null, null, null, null,
false, null);
nfr.lex0 = Kernel.MakeSub(csr.info.catch_, csr);
nfr.lex1 = payload;
@@ -6535,7 +6534,7 @@ class LastFrameNode {
if (type != SubInfo.ON_DIE && csr.info.control != null) {
P6any sub = Kernel.MakeSub(csr.info.control, csr);
Frame nfr = csr.info.control.SetupCall(
- Kernel.GetInferiorRoot(), csr, sub,
+ Kernel.GetInferiorRoot(s), csr, sub,
new Variable[] {
s.MakeParcel(s.MakeInt(type),
Kernel.BoxAnyMO(name, s.StrMO),

0 comments on commit 3db2fe1

Please sign in to comment.