Skip to content

Commit

Permalink
Tidy up STable fields a bit, add TiedVariable serialize
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed Oct 11, 2011
1 parent d91ecdf commit ab35238
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 15 deletions.
10 changes: 8 additions & 2 deletions lib/Kernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,14 @@ public override void Store(P6any v) {
public override Variable GetVar() {
return Kernel.BoxAnyMO<Variable>(this, Kernel.ScalarMO);
}
public override void Freeze(FreezeBuffer fb) { throw new NotImplementedException(); }
}
public override void Freeze(FreezeBuffer fb) {
fb.Byte((byte)SerializationCode.TiedVariable);
fb.ObjRef(type);
fb.ObjRef(fetch);
fb.ObjRef(store);
fb.ObjRef(whence);
}
}

// Used to make Variable sharing explicit in some cases; will eventually be
// the only way to share a bvalue
Expand Down
30 changes: 20 additions & 10 deletions lib/ObjModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ public string Compose() {
// (Although due to quirks of the C# implementation, Cursor and
// BoxObject can share the P6opaque STable)
public class STable: IFreeze {
/// well-known context handlers {{{
public static readonly ContextHandler<Variable> CallStr
= new CtxCallMethod("Str");
public static readonly ContextHandler<Variable> CallBool
Expand Down Expand Up @@ -684,18 +685,35 @@ public static readonly PushyHandler CallPush
= new PushyCallMethod("push");
public static readonly PushyHandler CallUnshift
= new PushyCallMethod("unshift");
/// }}}

/// "true" state {{{
public P6how mo;

public P6any how, who;
public P6any typeObject, initObject;
public Variable typeVar, initVar;
public int fixups_from;
public string name;
public bool isSubset;

public Type box_type;
/// }}}

/// compositon-created cache {{{
public LexerCache lexcache;

public Dictionary<string, int> slotMap = new Dictionary<string, int>();
public int nslots = 0;
public string[] all_slot;
/// }}}

/// caches set up by Revalidate {{{
public Dictionary<string, DispatchEnt> mro_methods;
public Dictionary<string, P6any> private_mro;
public P6how.AttrInfo[] init_program;
/// }}}

/// caches set up in SetupVTables {{{
public ContextHandler<Variable> mro_Str, mro_Numeric, mro_Bool,
mro_defined, mro_iterator, mro_item, mro_list, mro_hash,
mro_shift, mro_pop;
Expand All @@ -713,17 +731,9 @@ public static readonly PushyHandler CallUnshift
public InvokeHandler mro_INVOKE;
public PushyHandler mro_push, mro_unshift;

public Dictionary<string, DispatchEnt> mro_methods;
public Dictionary<string, P6any> private_mro;

public Dictionary<string, int> slotMap = new Dictionary<string, int>();
public int nslots = 0;
public string[] all_slot;
public P6how.AttrInfo[] init_program;

public int num_rank = -1;
public bool is_any = false;
public Type box_type;
/// }}}

public STable(string name) {
this.name = name;
Expand Down
7 changes: 4 additions & 3 deletions lib/Serialize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,13 @@ enum SerializationCode : byte {
// miscellany
Variant, // allow 5, see FallbackFreeze

// variables - allow 4 codes each for flag compaction
SimpleVariable = Variant + 5,
// variables
SimpleVariable = Variant + 5, // allow 4 for flags
SubstrLValue = SimpleVariable + 4,
TiedVariable,

// vivification hooks
SubViviHook = SubstrLValue + 4,
SubViviHook,
ArrayViviHook,
NewArrayViviHook,
HashViviHook,
Expand Down

0 comments on commit ab35238

Please sign in to comment.