Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Thaw routines for Frame
  • Loading branch information
sorear committed Oct 16, 2011
1 parent 2671ab4 commit 9b6504a
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
53 changes: 52 additions & 1 deletion lib/Kernel.cs
Expand Up @@ -1784,7 +1784,7 @@ public class UsedInScopeInfo {

// This object fills the combined roles of Parrot LexPad and CallContext
// objects.
public class Frame: P6any {
public class Frame: P6any, IFixup {
// Used by trampoline to find destination
public int ip = 0;
public DynBlockDelegate code;
Expand Down Expand Up @@ -2121,6 +2121,57 @@ public class Frame: P6any {
fb.ObjRef(named);
fb.Byte(checked((byte)flags));
}
internal static Frame Thaw(ThawBuffer tb) {
Frame n = new Frame();
tb.Register(n);
n.ip = tb.Int();
// code will be reloaded from info.code
n.lex0 = tb.ObjRef();
n.lex1 = tb.ObjRef();
n.lex2 = tb.ObjRef();
n.lex3 = tb.ObjRef();
n.lex4 = tb.ObjRef();
n.lex5 = tb.ObjRef();
n.lex6 = tb.ObjRef();
n.lex7 = tb.ObjRef();
n.lex8 = tb.ObjRef();
n.lex9 = tb.ObjRef();
n.resultSlot = tb.ObjRef(); // probably not necessary
n.lexi0 = tb.Int();
n.lexi1 = tb.Int();
n.lexn = tb.RefsA<object>();
n.caller = (Frame)tb.ObjRef(); // XXX this might serialize too much
n.outer = (Frame)tb.ObjRef();
n.info = (SubInfo)tb.ObjRef();
// we won't store reuse info :)
n.coro_return = (Frame)tb.ObjRef();
n.curDisp = (DispatchEnt)tb.ObjRef();
n.rx = (RxFrame)tb.ObjRef();
n.sub = (P6any)tb.ObjRef();

LeaveHook fin = null;
int type = tb.Byte();
while (type != LeaveHook.SENTINEL) {
if (fin == null) {
fin = n.on_leave = new LeaveHook();
} else {
fin.next = new LeaveHook();
fin = fin.next;
}
fin.type = type;
fin.thunk = (P6any) tb.ObjRef();
type = tb.Byte();
}

n.pos = tb.RefsA<Variable>();
n.named = (VarHash)tb.ObjRef();
n.flags = tb.Byte();
tb.PushFixup(n);
return n;
}
void IFixup.Fixup() {
code = info.code;
}
}

public class NieczaException: Exception {
Expand Down
3 changes: 2 additions & 1 deletion lib/Serialize.cs
Expand Up @@ -632,7 +632,8 @@ class ThawBuffer {
return ReflectObj.Thaw(this);
case SerializationCode.P6opaque:
return P6opaque.Thaw(this);
//Frame,
case SerializationCode.Frame:
return Frame.Thaw(this);
//Cursor,

case SerializationCode.String:
Expand Down

0 comments on commit 9b6504a

Please sign in to comment.