Skip to content
Browse files

Encapsulate setting of .v on existing StashEnts

  • Loading branch information...
1 parent 54cf51a commit 750c097c0c05db8bb843417feea88837a82b00b1 @sorear committed Nov 4, 2011
Showing with 12 additions and 7 deletions.
  1. +2 −1 lib/Builtins.cs
  2. +1 −1 lib/CodeGen.cs
  3. +9 −5 lib/Kernel.cs
View
3 lib/Builtins.cs
@@ -2149,7 +2149,8 @@ class CrossSource: ItemSource {
}
public static Variable stash_bind_key(P6any st, string key, Variable to) {
- return Kernel.GetVar(Kernel.UnboxAny<string>(st), key).v = to;
+ Kernel.GetVar(Kernel.UnboxAny<string>(st), key).Bind(to);
+ return to;
}
public static Variable stash_delete_key(P6any st, string key) {
View
2 lib/CodeGen.cs
@@ -4319,7 +4319,7 @@ public class DowncallReceiver : CallReceiver {
ru.InitTime();
Frame fret = null;
StashEnt b = Kernel.GetVar("::PROCESS", "$OUTPUT_USED");
- b.v = Kernel.FalseV;
+ b.Bind(Kernel.FalseV);
Frame ir = Kernel.GetInferiorRoot();
fret = ru.mainline.protosub.Invoke(ir, Variable.None, null);
fret.MarkShared();
View
14 lib/Kernel.cs
@@ -327,6 +327,10 @@ public class StashEnt : IFreeze {
public string file;
public int line;
+ public void Bind(Variable v) {
+ this.v = v;
+ }
+
void IFreeze.Freeze(FreezeBuffer fb) {
fb.Byte((byte)SerializationCode.StashEnt);
fb.ObjRef(v);
@@ -1133,11 +1137,11 @@ public class LICommon : LexInfo {
internal string VarName() { return hkey.Substring(1 + (int)hkey[0]); }
public override object Get(Frame f) {
- return Kernel.currentGlobals[hkey].v;
+ return Kernel.GetGlobal(hkey);
}
public override void Set(Frame f, object to) {
- Kernel.currentGlobals[hkey].v = (Variable)to;
+ Kernel.BindGlobal(hkey, (Variable)to);
}
internal override ClrOp GetCode(int up) {
@@ -1173,6 +1177,7 @@ public class LIHint : LexInfo {
EmitUnit.Current.RefConstant(name, "E", var, null).head);
}
+ // XXX should die() with constant improvements
internal override ClrOp SetCode(int up, ClrOp to) {
return new ClrSetField(Tokens.StashEnt_v,
EmitUnit.Current.RefConstant(name, "E", var, null).head, to);
@@ -3763,7 +3768,7 @@ public struct StashCursor {
if (Kernel.currentGlobals.TryGetValue("\x8::GLOBAL" + key, out bv) ||
Kernel.currentGlobals.TryGetValue("\x9::PROCESS" + key, out bv)) {
- if (rbar_w) { bv.v = o; } else { o = bv.v; }
+ if (rbar_w) { bv.Bind(o); } else { o = bv.v; }
return true;
}
}
@@ -5047,7 +5052,6 @@ public class MMDCandidateLongname {
else
v = currentGlobals[key] = new StashEnt();
-
if (name.StartsWith("@")) {
v.v = CreateArray();
} else if (name.StartsWith("%")) {
@@ -5494,7 +5498,7 @@ class LastFrameNode {
}
public static void BindGlobal(string key, Variable to) {
- currentGlobals[key].v = to;
+ currentGlobals[key].Bind(to);
}
internal static void CreateBasicTypes() {

0 comments on commit 750c097

Please sign in to comment.
Something went wrong with that request. Please try again.