Permalink
Browse files

Top removal: Parameter & Signature

  • Loading branch information...
1 parent f43fe40 commit eafdf64c9bdbe32c596ef394dd9c75e9d4dec43a @sorear committed Nov 6, 2012
Showing with 43 additions and 40 deletions.
  1. +3 −3 lib/CodeGen.cs
  2. +31 −28 lib/Kernel.cs
  3. +6 −6 lib/NieczaCLR.cs
  4. +1 −1 lib/ObjModel.cs
  5. +2 −2 lib/Serialize.cs
View
@@ -4525,7 +4525,7 @@ public class DowncallReceiver : CallReceiver {
string attr = (string)args[ix++];
STable atype = (STable)Handle.Unbox(args[ix++]);
- return Handle.Wrap(new Parameter(flags,
+ return Handle.Wrap(new Parameter(tgt.setting, flags,
(slot == null ? -1 : tgt.dylex[slot].SigIndex()),
name, (names.Count == 0 ? null : names.ToArray()),
deflt, type ?? tgt.setting.AnyMO, attr, atype));
@@ -4546,7 +4546,7 @@ public class DowncallReceiver : CallReceiver {
sig.Add((Parameter)Handle.Unbox(args[ix++]));
object[] pc = tgt.post_constraints;
Array.Resize(ref pc, pc == null ? 1 : pc.Length + 1);
- pc[pc.Length - 1] = new Signature(sig.ToArray());
+ pc[pc.Length - 1] = new Signature(tgt.mo.setting, sig.ToArray());
tgt.post_constraints = pc;
return null;
}
@@ -4556,7 +4556,7 @@ public class DowncallReceiver : CallReceiver {
List<Parameter> sig = new List<Parameter>();
while (ix != args.Length)
sig.Add((Parameter)Handle.Unbox(args[ix++]));
- tgt.sig = new Signature(sig.ToArray());
+ tgt.sig = new Signature(tgt.setting, sig.ToArray());
return null;
}
public static object sub_contains_phaser(object[] args) {
View
@@ -1513,10 +1513,10 @@ public class Parameter : P6any, IFixup {
public override string ReprName() { return "P6parameter"; }
private Parameter() { }
- public Parameter(int flags, int slot, string name,
+ internal Parameter(Compartment c, int flags, int slot, string name,
string[] names, object def, STable type, string attr,
STable atype) {
- this.mo = Compartment.Top.ParameterMO;
+ this.mo = c.ParameterMO;
this.flags = flags;
this.name = name;
this.slot = slot;
@@ -1527,14 +1527,14 @@ public class Parameter : P6any, IFixup {
this.attribute_type = atype;
}
- public static Parameter TPos(string name, int slot) {
- return new Parameter(RWTRANS | POSITIONAL, slot, name,
- null, null, Compartment.Top.AnyMO, null, null);
+ internal static Parameter TPos(Compartment c, string name, int slot) {
+ return new Parameter(c, RWTRANS | POSITIONAL, slot, name,
+ null, null, c.AnyMO, null, null);
}
- public static Parameter TNamedOpt(string name, int slot) {
- return new Parameter(RWTRANS | OPTIONAL, slot, name,
- new string[] { name }, null, Compartment.Top.AnyMO, null, null);
+ internal static Parameter TNamedOpt(Compartment c, string name, int slot) {
+ return new Parameter(c, RWTRANS | OPTIONAL, slot, name,
+ new string[] { name }, null, c.AnyMO, null, null);
}
// Value processing
@@ -1601,15 +1601,15 @@ public class Parameter : P6any, IFixup {
return n;
}
- void IFixup.Fixup() { mo = Compartment.Top.ParameterMO; }
+ void IFixup.Fixup(Compartment c) { mo = c.ParameterMO; }
}
public class Signature : P6any, IFixup {
public Parameter[] parms;
public override string ReprName() { return "P6sig"; }
- public Signature(params Parameter[] parms) { this.mo = Compartment.Top.SignatureMO; this.parms = parms; }
+ internal Signature(Compartment c, params Parameter[] parms) { this.mo = c.SignatureMO; this.parms = parms; }
private Signature() { }
public override void Freeze(FreezeBuffer fb) {
@@ -1625,7 +1625,7 @@ public class Signature : P6any, IFixup {
n.parms = tb.RefsA<Parameter>();
return n;
}
- void IFixup.Fixup() { mo = Compartment.Top.SignatureMO; }
+ void IFixup.Fixup(Compartment c) { mo = c.SignatureMO; }
}
// This stores all the invariant stuff about a Sub, i.e. everything
@@ -2226,7 +2226,7 @@ public class UsedInScopeInfo {
return n;
}
- void IFixup.Fixup() {
+ void IFixup.Fixup(Compartment c) {
SubInfo sc = outer;
LexInfo li = null;
for (outer_topic_rank = 1; sc != null; sc = sc.outer) {
@@ -3023,7 +3023,7 @@ public class Frame: P6any, IFixup {
tb.PushFixup(n);
return n;
}
- void IFixup.Fixup() {
+ void IFixup.Fixup(Compartment c) {
code = info.code;
mo = info.setting.CallFrameMO;
}
@@ -5630,7 +5630,7 @@ internal class MMDCandidate : MultiCandidate {
ContextHandler<Variable> cvb, object cvu) {
SubInfo si = new SubInfo("KERNEL " + kl.name + "." + name,
WrapHandler0cb);
- si.sig = new Signature(Parameter.TPos("self", 0));
+ si.sig = new Signature(kl.setting,Parameter.TPos(kl.setting,"self", 0));
si.param = new object[] { cvu, cvb };
kl.AddMethod(0, name, MakeSub(si, null));
}
@@ -5646,8 +5646,9 @@ internal class MMDCandidate : MultiCandidate {
IndexHandler cv) {
SubInfo si = new SubInfo("KERNEL " + kl.name + "." + name,
WrapHandler1cb);
- si.sig = new Signature(Parameter.TPos("self", 0),
- Parameter.TPos("$key", 1));
+ si.sig = new Signature(kl.setting,
+ Parameter.TPos(kl.setting,"self", 0),
+ Parameter.TPos(kl.setting,"$key", 1));
si.param = new object[] { null, cv };
kl.AddMethod(0, name, MakeSub(si, null));
}
@@ -5666,8 +5667,9 @@ internal class MMDCandidate : MultiCandidate {
PushyHandler cv) {
SubInfo si = new SubInfo("KERNEL " + kl.name + "." + name,
WrapPushycb);
- si.sig = new Signature(Parameter.TPos("self", 0),
- new Parameter(Parameter.RWTRANS | Parameter.SLURPY_PCL, 1, "$args", null, null, null, null, null)
+ si.sig = new Signature(kl.setting,
+ Parameter.TPos(kl.setting, "self", 0),
+ new Parameter(kl.setting, Parameter.RWTRANS | Parameter.SLURPY_PCL, 1, "$args", null, null, null, null, null)
);
si.param = new object[] { null, cv };
kl.AddMethod(0, name, MakeSub(si, null));
@@ -5723,19 +5725,20 @@ internal class MMDCandidate : MultiCandidate {
BindHandler bind) {
SubInfo si = new SubInfo("KERNEL " + kl.name + "." + name,
DispIndexy);
+ var c = kl.setting;
List<Parameter> lp = new List<Parameter>();
- lp.Add(Parameter.TPos("self", 0));
- lp.Add(new Parameter(Parameter.RWTRANS | Parameter.SLURPY_PCL, -1,
+ lp.Add(Parameter.TPos(c, "self", 0));
+ lp.Add(new Parameter(c, Parameter.RWTRANS | Parameter.SLURPY_PCL, -1,
"args", null, null, null, null, null));
if (del != null) {
- lp.Add(Parameter.TNamedOpt("exists", -1));
- lp.Add(Parameter.TNamedOpt("delete", -1));
- }
- lp.Add(Parameter.TNamedOpt("k", -1));
- lp.Add(Parameter.TNamedOpt("kv", -1));
- lp.Add(Parameter.TNamedOpt("p", -1));
- lp.Add(Parameter.TNamedOpt("BIND_VALUE", -1));
- si.sig = new Signature(lp.ToArray());
+ lp.Add(Parameter.TNamedOpt(c, "exists", -1));
+ lp.Add(Parameter.TNamedOpt(c, "delete", -1));
+ }
+ lp.Add(Parameter.TNamedOpt(c, "k", -1));
+ lp.Add(Parameter.TNamedOpt(c, "kv", -1));
+ lp.Add(Parameter.TNamedOpt(c, "p", -1));
+ lp.Add(Parameter.TNamedOpt(c, "BIND_VALUE", -1));
+ si.sig = new Signature(c, lp.ToArray());
si.param = new object[] { at, exist, del, bind, name };
kl.AddMethod(0, name, MakeSub(si, null));
}
View
@@ -715,28 +715,28 @@ public class CLRWrapperProvider {
SubInfo si;
si = new SubInfo("KERNEL dispose-hack", dispose_handler);
- si.sig = new Signature(Parameter.TPos("self", 0));
+ si.sig = new Signature(s,Parameter.TPos(s, "self", 0));
m.AddMethod(0, "dispose-hack", Kernel.MakeSub(si, null));
}
if (t == typeof(object)) {
SubInfo si;
si = new SubInfo("KERNEL default", default_handler);
- si.sig = new Signature(Parameter.TPos("self", 0));
+ si.sig = new Signature(s, Parameter.TPos(s, "self", 0));
m.AddMethod(0, "default", Kernel.MakeSub(si, null));
si = new SubInfo("KERNEL marshal", marshal_handler);
- si.sig = new Signature(Parameter.TPos("self", 0),
- Parameter.TPos("$obj", 1));
+ si.sig = new Signature(s, Parameter.TPos(s, "self", 0),
+ Parameter.TPos(s, "$obj", 1));
m.AddMethod(0, "marshal", Kernel.MakeSub(si, null));
si = new SubInfo("KERNEL unmarshal", unmarshal_handler);
- si.sig = new Signature(Parameter.TPos("self", 0));
+ si.sig = new Signature(s, Parameter.TPos(s, "self", 0));
m.AddMethod(0, "unmarshal", Kernel.MakeSub(si, null));
si = new SubInfo("KERNEL Str", Str_handler);
- si.sig = new Signature(Parameter.TPos("self", 0));
+ si.sig = new Signature(s, Parameter.TPos(s, "self", 0));
m.AddMethod(0, "Str", Kernel.MakeSub(si, null));
m.AddMethod(0, "gist", Kernel.MakeSub(si, null));
}
View
@@ -818,7 +818,7 @@ public class DispatchSet {
return n;
}
- void IFixup.Fixup() {
+ void IFixup.Fixup(Compartment c) {
SetMRO(mro);
}
}
View
@@ -545,7 +545,7 @@ public interface IFreeze {
}
// implement this if you need to copy in data from other objects, &c
interface IFixup {
- void Fixup();
+ void Fixup(Compartment c);
}
class ThawBuffer {
@@ -573,7 +573,7 @@ class ThawBuffer {
internal void RunFixups() {
P6how.BulkRevalidate(revalidate);
foreach (IFixup f in fixups_needed)
- f.Fixup();
+ f.Fixup(setting);
fixups_needed.Clear();
}

0 comments on commit eafdf64

Please sign in to comment.