Skip to content

Commit

Permalink
Eliminate .item
Browse files Browse the repository at this point in the history
Discussion with TimToady leads to the conclusion that Parcel lives outside Any
and turns into Seq during fallback.
  • Loading branch information
Stefan O'Rear committed Jul 15, 2010
1 parent 4d47d8d commit 2e6fcc0
Showing 1 changed file with 1 addition and 52 deletions.
53 changes: 1 addition & 52 deletions Kernel.cs
Expand Up @@ -65,14 +65,8 @@ public enum Context {
// @foo: binds listy lvalues; calls .list on other stuff and uses
// the result
List,
// $foo: binds scalary lvalues; calls .item on other stuff and
// wraps it in a container
// $foo: binds scalary lvalues; wraps other stuff in a container
Scalar,
// self: binds scalary lvalues, but doesn't call .item; could wind
// up bound to a Parcel
WeakScalar,
// ¢foo: binds any lvalue, no munging, needed for = rhs etc
Capture
}
public LValue lv;
public bool bvalue;
Expand Down Expand Up @@ -503,26 +497,6 @@ public class Kernel {
return n;
}

private static Frame BindScalarizeC(Frame th) {
LValue rhs;
switch (th.ip) {
case 0:
rhs = (LValue) th.lex["o"];
th.ip = 1;
return rhs.container.InvokeMethod(th, "item",
new LValue[1] { rhs }, null);
case 1:
rhs = ((Variable) th.resultSlot).lv;
if (rhs.islist) {
throw new Exception(".item didn't do its job and returned a list!");
}
((Variable)th.lex["c"]).lv = rhs;
return th.caller;
default:
throw new Exception("IP invalid");
}
}

private static Frame BindListizeC(Frame th) {
LValue rhs;
switch (th.ip) {
Expand All @@ -549,18 +523,6 @@ public class Kernel {
Frame n;
switch (lhs.context) {
case Variable.Context.Scalar:
if (rhs.islist) {
n = new Frame(th, null,
new DynBlockDelegate(BindScalarizeC));
n.lex["o"] = rhs;
n.lex["c"] = lhs;
return n;
} else {
lhs.lv = rhs;
if (ro) { lhs.lv.rw = false; }
return th;
}
case Variable.Context.WeakScalar:
if (rhs.islist) {
lhs.lv.rw = false;
lhs.lv.islist = false;
Expand All @@ -583,9 +545,6 @@ public class Kernel {
n.lex["c"] = lhs;
return n;
}
case Variable.Context.Capture:
lhs.lv = rhs;
return th;
default:
throw new Exception("invalid context?");
}
Expand All @@ -609,16 +568,6 @@ public class Kernel {
new LValue(true, true, container));
}

public static Variable NewCaptureVar() {
return new Variable(true, Variable.Context.Capture,
new LValue(false, false, MakeSC(null)));
}

public static Variable NewWeakScalar() {
return new Variable(true, Variable.Context.WeakScalar,
new LValue(false, false, MakeSC(null)));
}

static Kernel() {
SubPMO = new DynProtoMetaObject();
SubPMO.name = "Sub";
Expand Down

0 comments on commit 2e6fcc0

Please sign in to comment.