Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove all calls to now-noop NewROScalar
  • Loading branch information
sorear committed May 27, 2012
1 parent cbe27a0 commit 581727d
Show file tree
Hide file tree
Showing 13 changed files with 137 additions and 164 deletions.
4 changes: 0 additions & 4 deletions docs/nam.pod
Expand Up @@ -288,10 +288,6 @@ Wraps C<$obj> in a read-only variable with the list nature.

Creates a new variable of type Any containing C<$obj>.

=head3 newscalar($obj)

Wraps C<$obj> in a read-only variable.

=head3 newvarrayvar

=head3 newvhashvar
Expand Down
49 changes: 24 additions & 25 deletions lib/Builtins.cs
Expand Up @@ -151,7 +151,7 @@ class SubstrLValue: Variable {
int right = ((length > (str.Length - left)) ? (str.Length - left) :
(length < 0) ? 0 : length) + left;
string lfr = str.Substring(0, left);
string mfr = v.mo.mro_raw_Str.Get(Kernel.NewROScalar(v));
string mfr = v.mo.mro_raw_Str.Get(v);
string rfr = str.Substring(right);
backing.Store(Kernel.BoxRaw<string>(lfr + mfr + rfr, Kernel.StrMO));
}
Expand Down Expand Up @@ -225,7 +225,7 @@ public partial class Builtins {
P6opaque newJunc = new P6opaque(Kernel.JunctionMO);
newJunc.slots[0] = j_.slots[0];
newJunc.slots[1] = newList;
return Kernel.NewROScalar(newJunc);
return newJunc;
}

// These three functions implement type checking and junctional
Expand Down Expand Up @@ -1060,7 +1060,7 @@ public partial class Builtins {
else
return MakeInt(red);
}
return Kernel.NewROScalar(n1);
return n1;
}

static readonly Func<Variable,Variable,Variable> gcd_d = gcd;
Expand Down Expand Up @@ -1513,7 +1513,7 @@ public partial class Builtins {
v.AssignO(o1.mo.mro_succ.Get(v), false);
if (!o1.IsDefined()) // note: slightly wrong for my Bool $x; $x++
o1 = Kernel.BoxRaw<int>(0, Kernel.IntMO);
return Kernel.NewROScalar(o1);
return o1;
}

public static Variable preinc(Variable v) {
Expand All @@ -1526,7 +1526,7 @@ public partial class Builtins {
v.AssignO(o1.mo.mro_pred.Get(v), false);
if (!o1.IsDefined()) // note: slightly wrong for my Bool $x; $x--
o1 = Kernel.BoxRaw<int>(0, Kernel.IntMO);
return Kernel.NewROScalar(o1);
return o1;
}

public static Variable predec(Variable v) {
Expand Down Expand Up @@ -1619,7 +1619,7 @@ public partial class Builtins {
P6opaque nj = new P6opaque(Kernel.JunctionMO);
nj.slots[0] = Kernel.BoxRaw(type, Kernel.IntMO);
nj.slots[1] = Kernel.BoxRaw(elems, Kernel.ParcelMO);
return Kernel.NewROScalar(nj);
return nj;
}

public static Variable Make(Frame fr, Variable v) {
Expand Down Expand Up @@ -1652,7 +1652,7 @@ public partial class Builtins {
P6opaque p = new P6opaque(Kernel.PairMO);
p.slots[0] = Kernel.BoxAnyMO<string>(kv.Key, Kernel.StrMO);
p.slots[1] = kv.Value;
lv.Push(Kernel.NewROScalar(p));
lv.Push(p);
break;
}
}
Expand Down Expand Up @@ -1933,7 +1933,7 @@ public partial class Builtins {
}

public static Variable pair(Variable key, Variable value) {
return Kernel.NewROScalar(MakePair(key, value));
return MakePair(key, value);
}

public static VarDeque start_iter(Variable thing) {
Expand All @@ -1948,7 +1948,7 @@ public partial class Builtins {
VarDeque items = new VarDeque();
while (Kernel.IterHasFlat(rest, true))
items.Push(Kernel.NewMuScalar(rest.Shift().Fetch()));
return Kernel.NewROScalar(MakeArray(items, rest));
return MakeArray(items, rest);
}

public static string frame_subname(Frame fr) {
Expand Down Expand Up @@ -2168,14 +2168,14 @@ class CrossSource: ItemSource {
thunk.slots[1] = Kernel.NewMuScalar(Kernel.AnyP);
P6opaque lst = new P6opaque(Kernel.ListMO);
lst.slots[0] = outq;
lst.slots[1] = new VarDeque(Kernel.NewROScalar(thunk));
lst.slots[1] = new VarDeque(thunk);
th.caller.resultSlot = Kernel.NewRWListVar(lst);
th.lexi0 = 1;
return th.Return();
}
if (pen == null) {
if (tailmode != 0)
return Kernel.Take(th, Kernel.NewROScalar(Kernel.EMPTYP));
return Kernel.Take(th, Kernel.EMPTYP);
P6opaque lst = new P6opaque(Kernel.ListMO);
lst.slots[0] = outq;
lst.slots[1] = new VarDeque();
Expand Down Expand Up @@ -2292,7 +2292,7 @@ class CrossSource: ItemSource {
thunk.slots[1] = Kernel.NewMuScalar(Kernel.AnyP);
P6opaque lst = new P6opaque(Kernel.ListMO);
lst.slots[0] = outq;
lst.slots[1] = new VarDeque(Kernel.NewROScalar(thunk));
lst.slots[1] = new VarDeque(thunk);
th.caller.resultSlot = Kernel.NewRWListVar(lst);
th.lexi0 = 1;
return th.Return();
Expand All @@ -2302,7 +2302,7 @@ class CrossSource: ItemSource {
}
if (pen == null) {
if (tailmode != 0)
return Kernel.Take(th, Kernel.NewROScalar(Kernel.EMPTYP));
return Kernel.Take(th, Kernel.EMPTYP);
P6opaque lst = new P6opaque(Kernel.ListMO);
lst.slots[0] = outq;
lst.slots[1] = new VarDeque();
Expand Down Expand Up @@ -2637,7 +2637,7 @@ class CrossSource: ItemSource {

n.how = Kernel.BoxAny<STable>(n, obj.mo.how).Fetch();
n.typeObject = n.initObject = new P6opaque(n);
n.typeVar = n.initVar = Kernel.NewROScalar(n.typeObject);
n.typeVar = n.initVar = n.typeObject;
((P6opaque)n.typeObject).slots = null;

n.mo.superclasses.Add(obj.mo);
Expand All @@ -2660,7 +2660,7 @@ class CrossSource: ItemSource {
BuildMostDerived(obj);
if (aname != null)
Kernel.Assign((Variable)obj.GetSlot(n, aname), init);
return Kernel.NewROScalar(obj);
return obj;
} else {
return n.typeVar;
}
Expand All @@ -2671,7 +2671,7 @@ class CrossSource: ItemSource {
nobj.ChangeType(type.Fetch().mo);
nobj.SetSlot(Kernel.PseudoStrMO, "$!value",
Kernel.UnboxAny<string>(str.Fetch()));
return Kernel.NewROScalar(nobj);
return nobj;
}

public static void EstablishSlot(P6any n, P6how.AttrInfo ai,
Expand Down Expand Up @@ -2709,21 +2709,21 @@ class CrossSource: ItemSource {
Variable vx = null;
if (ai.init != null) {
vx = Kernel.RunInferior(ai.init.Invoke(Kernel.GetInferiorRoot(),
new [] { Kernel.NewROScalar(obj) }, null));
new [] { obj }, null));
}
EstablishSlot(obj, ai, vx);
}

if (build != null)
Kernel.RunInferior(build.Invoke(Kernel.GetInferiorRoot(),
new Variable[] { Kernel.NewROScalar(obj) }, null));
new Variable[] { obj }, null));
}

public static Variable enum_mixin_role(string name, P6any meth) {
STable r = new STable('{' + name + '}');
r.mo.FillRole(new STable[0], null);
r.typeObject = r.initObject = new P6opaque(r);
r.typeVar = r.initVar = Kernel.NewROScalar(r.typeObject);
r.typeVar = r.initVar = r.typeObject;
r.mo.AddMethod(0, name, meth);
r.mo.Revalidate();
r.SetupVTables();
Expand All @@ -2735,7 +2735,7 @@ class CrossSource: ItemSource {
STable r = new STable('{' + name + '}');
r.mo.FillRole(new STable[0], null);
r.typeObject = r.initObject = new P6opaque(r);
r.typeVar = r.initVar = Kernel.NewROScalar(r.typeObject);
r.typeVar = r.initVar = r.typeObject;
r.mo.AddMethod(P6how.M_MULTI, name, meth);
r.mo.Revalidate();
r.SetupVTables();
Expand All @@ -2749,7 +2749,7 @@ class CrossSource: ItemSource {

r.mo.FillRole(new STable[0], null);
r.typeObject = r.initObject = new P6opaque(r);
r.typeVar = r.initVar = Kernel.NewROScalar(r.typeObject);
r.typeVar = r.initVar = r.typeObject;
r.mo.AddMethod(0, name, meth.Fetch());
r.mo.AddMethod(P6how.V_PRIVATE, name, meth.Fetch());
r.mo.AddAttribute(name, P6how.A_PUBLIC, null, stype);
Expand Down Expand Up @@ -2800,8 +2800,7 @@ public class Blackhole : Variable {

public static Variable sig_params(P6any sig) {
VarDeque items = new VarDeque();
foreach (Parameter p in ((Signature)sig).parms)
items.Push(Kernel.NewROScalar(p));
items.PushN(((Signature)sig).parms);
return Kernel.NewRWListVar(MakeList(items, new VarDeque()));
}

Expand All @@ -2820,9 +2819,9 @@ public class Blackhole : Variable {
if (si.param != null && si.param[0] is P6any[]) {
foreach (P6any cand in (P6any[])si.param[0])
if (cand != null)
items.Push(Kernel.NewROScalar(cand));
items.Push(cand);
} else {
items.Push(Kernel.NewROScalar(sub));
items.Push(sub);
}
return Kernel.NewRWListVar(MakeList(items, new VarDeque()));
}
Expand Down

0 comments on commit 581727d

Please sign in to comment.