Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement newboundvar
  • Loading branch information
sorear committed Dec 21, 2010
1 parent 4c5e093 commit 52eb58c
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions lib/CLRBackend.cs
Expand Up @@ -679,6 +679,8 @@ sealed class Tokens {
typeof(Kernel).GetMethod("RunLoop");
public static readonly MethodInfo Kernel_NewROScalar =
typeof(Kernel).GetMethod("NewROScalar");
public static readonly MethodInfo Kernel_NewBoundVar =
typeof(Kernel).GetMethod("NewBoundVar");
public static readonly MethodInfo Console_WriteLine =
typeof(Console).GetMethod("WriteLine", new Type[] { typeof(string) });
public static readonly MethodInfo Console_Write =
Expand All @@ -692,6 +694,8 @@ sealed class Tokens {
IP6.GetField("mo");
public static readonly FieldInfo BValue_v =
BValue.GetField("v");
public static readonly FieldInfo Kernel_AnyMO =
Kernel.GetField("AnyMO");
public static readonly FieldInfo Frame_ip =
typeof(Frame).GetField("ip");
public static readonly FieldInfo Frame_caller =
Expand Down Expand Up @@ -1411,8 +1415,8 @@ class CpsOp {
return new CpsOp(new ClrIntLiteral(Tokens.Int32, x));
}

public static CpsOp BoolLiteral(int x) {
return new CpsOp(new ClrIntLiteral(Tokens.Boolean, x));
public static CpsOp BoolLiteral(bool x) {
return new CpsOp(new ClrIntLiteral(Tokens.Boolean, x ? 1 : 0));
}

public static CpsOp Label(string name, bool case_too) {
Expand Down Expand Up @@ -1478,6 +1482,10 @@ class CpsOp {
});
}

public static CpsOp GetSField(FieldInfo fi) {
return new CpsOp(new ClrGetSField(fi));
}

public static CpsOp Sink(CpsOp zyg) {
return new CpsOp(zyg.stmts, zyg.head.Sink());
}
Expand Down Expand Up @@ -1570,6 +1578,17 @@ class NamProcessor {
CpsOp boxee = th.Scan(zyg[2]);
return CpsOp.MethodCall(null, Tokens.Kernel.GetMethod("BoxAnyMO").MakeGenericMethod(boxee.head.Returns), new CpsOp[2] { boxee, mo });
};
handlers["newboundvar"] = delegate(NamProcessor th, object[] zyg) {
CpsOp rhs = th.Scan(zyg[3]);
bool ro = ((JScalar)zyg[1]).num != 0;
bool list = ((JScalar)zyg[2]).num != 0;
return CpsOp.MethodCall(Tokens.Variable,
Tokens.Kernel_NewBoundVar, new CpsOp[] {
CpsOp.BoolLiteral(ro),
CpsOp.BoolLiteral(list),
CpsOp.GetSField(Tokens.Kernel_AnyMO),
rhs });
};
handlers["scopedlex"] =
handlers["letvar"] =
handlers["corelex"] = delegate(NamProcessor th, object[] zyg) {
Expand Down

0 comments on commit 52eb58c

Please sign in to comment.