Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactor Frame to always have a valid sub

  • Loading branch information...
commit 219f822dee02e9dedff65ece315eb4890ddb737b 1 parent 9acb21f
Stefan O'Rear authored
Showing with 11 additions and 8 deletions.
  1. +2 −1  lib/Builtins.cs
  2. +9 −7 lib/Kernel.cs
3  lib/Builtins.cs
View
@@ -2528,7 +2528,8 @@ class CrossSource: ItemSource {
new Variable[] { v }, null)).Fetch());
}
else {
- Frame o = new Frame();
+ // this is quite dubious really, Frame and LexPad should be separated
+ Frame o = new Frame(null, null, c.setting.TEMP_SI, null);
o.lex0 = v;
o.lex1 = v.Fetch();
fr.PushLeave(type, Kernel.MakeSub(c.setting.TEMP_SI, o));
16 lib/Kernel.cs
View
@@ -2331,7 +2331,7 @@ public class Frame: P6any, IFixup {
lexn = (info_.nspill > 0) ? new object[info_.nspill] : null;
}
- public Frame() { mo = Compartment.Top.CallFrameMO; }
+ Frame() { }
public static readonly bool TraceCalls =
Environment.GetEnvironmentVariable("NIECZA_TRACE_CALLS") != null;
@@ -2369,6 +2369,7 @@ public class Frame: P6any, IFixup {
reusable_child.caller = this;
reusable_child.outer = outer;
reusable_child.info = info;
+ reusable_child.mo = info.setting.CallFrameMO; // we want callframe() to always be the expected type
reusable_child.sub = sub;
reusable_child.code = info.code;
reusable_child.pos = null;
@@ -2420,16 +2421,16 @@ public class Frame: P6any, IFixup {
}
public Variable GetArgs() {
- P6any nw = new P6opaque(Compartment.Top.CaptureMO);
+ P6any nw = new P6opaque(mo.setting.CaptureMO);
var poscap = pos ?? new Variable[0];
- if (sub != null && poscap.Length > 0 && sub.Does(Compartment.Top.MethodMO)) {
+ if (sub != null && poscap.Length > 0 && sub.Does(mo.setting.MethodMO)) {
// Hide the self value so that using |callframe.args in a
// nextwith call will DTRT
poscap = new Variable[pos.Length - 1];
Array.Copy(pos, 1, poscap, 0, poscap.Length);
}
- nw.SetSlot(Compartment.Top.CaptureMO, "$!positionals", poscap);
- nw.SetSlot(Compartment.Top.CaptureMO, "$!named", named);
+ nw.SetSlot(mo.setting.CaptureMO, "$!positionals", poscap);
+ nw.SetSlot(mo.setting.CaptureMO, "$!named", named);
return nw;
}
@@ -2529,7 +2530,7 @@ public class Frame: P6any, IFixup {
}
csr = csr.outer;
}
- return Compartment.Top.AnyP;
+ return mo.setting.AnyP;
}
public void LexicalBind(string name, Variable to) {
@@ -2790,7 +2791,7 @@ public class Frame: P6any, IFixup {
bool rw = ((flags & Parameter.READWRITE) != 0) && !islist;
P6any srco = src.Fetch();
- // XXX: in order for calling methods on Compartment.Top.Nil to work,
+ // XXX: in order for calling methods on Nil to work,
// self needs to be ignored here.
if (srco == setting.NilP && obj_src != -1 &&
(flags & Parameter.INVOCANT) == 0) {
@@ -3022,6 +3023,7 @@ public class Frame: P6any, IFixup {
}
void IFixup.Fixup() {
code = info.code;
+ mo = info.setting.CallFrameMO;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.