Skip to content

Commit

Permalink
No need to coerce on list binding after all
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed Jul 19, 2010
1 parent 325388d commit 4ad1567
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions Kernel.cs
Expand Up @@ -38,10 +38,9 @@ public interface IP6 {
// and STORE as a method to the container.
//
// List->scalar context: create a simple container holding the list's
// object, but .item. Read only.
// object, but !islist. Read only.
//
// Scalar->list: call .list or something to get a suitable list object.
// Bind it same rwness.
// Scalar->list: bind islist, must be Iterable. Bind it same rwness.
public struct LValue {
public IP6 container;
public bool rw;
Expand All @@ -62,8 +61,7 @@ public struct LValue {
// Variables also have type constraints, that's how %foo and @foo differ...
public class Variable {
public enum Context {
// @foo: binds listy lvalues; calls .list on other stuff and uses
// the result
// @foo: binds listy lvalues
List,
// $foo: binds scalary lvalues; wraps other stuff in a container
Scalar,
Expand Down Expand Up @@ -483,19 +481,14 @@ public class Kernel {
}

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

0 comments on commit 4ad1567

Please sign in to comment.