Permalink
Browse files

ThawBuffer knows its setting

  • Loading branch information...
1 parent 6287229 commit b344401edd3660710f7412247d08f2416efcfcaf @sorear committed Sep 18, 2012
Showing with 16 additions and 14 deletions.
  1. +8 −8 lib/Kernel.cs
  2. +8 −6 lib/Serialize.cs
View
@@ -1043,8 +1043,8 @@ public sealed class RuntimeUnit : IFreeze {
foreach (MethodInfo mi in n.type.GetMethods())
meth[mi.Name] = mi;
- Compartment.Top.reg.methods[n.asm_name] = meth;
- Compartment.Top.reg.instances[n.asm_name] = n.constTable;
+ tb.reg.methods[n.asm_name] = meth;
+ tb.reg.instances[n.asm_name] = n.constTable;
while (ncon-- > 0) {
FieldInfo fi = fields[tb.String()];
object val = tb.ObjRef();
@@ -1077,7 +1077,7 @@ public sealed class RuntimeUnit : IFreeze {
(f1, f2) => string.CompareOrdinal(f1.Name, f2.Name));
foreach (FieldInfo f in kf) {
if (f.GetCustomAttributes(typeof(CORESavedAttribute), true).Length != 0) {
- f.SetValue(Compartment.Top, tb.ObjRef());
+ f.SetValue(tb.setting, tb.ObjRef());
//Console.WriteLine("Thaw {0} {1}", f, f.GetValue(Compartment.Top));
}
}
@@ -2131,11 +2131,11 @@ public class UsedInScopeInfo {
} else {
Dictionary<string,MethodInfo> t1;
- if (!Compartment.Top.reg.methods.TryGetValue(tn, out t1) ||
+ if (!tb.reg.methods.TryGetValue(tn, out t1) ||
!t1.TryGetValue(mn, out mi)) {
throw new Exception("Thawed sub references nonexistant method " + tn + "::" + mn);
}
- obj = Compartment.Top.reg.instances[tn];
+ obj = tb.reg.instances[tn];
}
n.code = (DynBlockDelegate) Delegate.CreateDelegate(
typeof(DynBlockDelegate), obj, mi);
@@ -2251,11 +2251,11 @@ public class UsedInScopeInfo {
}
if (phaser == Kernel.PHASER_CHECK)
- Compartment.Top.check.Add(this, false);
+ setting.check.Add(this, false);
if (phaser == Kernel.PHASER_INIT)
- Compartment.Top.init.Add(this, false);
+ setting.init.Add(this, false);
if (phaser == Kernel.PHASER_END)
- Compartment.Top.end.Add(this, false);
+ setting.end.Add(this, false);
if ((special & UNSAFE) != 0)
Kernel.CheckUnsafe(this);
View
@@ -156,7 +156,7 @@ struct ObjRef {
su.name = name;
su.hash = NewHash().ComputeHash(bytes);
- ThawBuffer tb = new ThawBuffer(this, su, bytes);
+ ThawBuffer tb = new ThawBuffer(Compartment.Top, this, su, bytes);
units[name] = su;
bool success = false;
@@ -551,7 +551,8 @@ interface IFixup {
class ThawBuffer {
byte[] data;
int rpointer;
- ObjectRegistry reg;
+ internal readonly ObjectRegistry reg;
+ internal readonly Compartment setting;
SerUnit[] unit_map = new SerUnit[8];
int refed_units;
@@ -562,10 +563,11 @@ class ThawBuffer {
public Type type;
- internal ThawBuffer(ObjectRegistry reg, SerUnit unit, byte[] data) {
- this.data = data;
- this.reg = reg;
- this.unit = unit;
+ internal ThawBuffer(Compartment setting, ObjectRegistry reg, SerUnit unit, byte[] data) {
+ this.data = data;
+ this.setting = setting;
+ this.reg = reg;
+ this.unit = unit;
}
internal void RunFixups() {

0 comments on commit b344401

Please sign in to comment.