Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add missing casts for type object setup
  • Loading branch information
sorear committed Dec 23, 2010
1 parent 4acf199 commit 11ec6d1
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/CLRBackend.cs
Expand Up @@ -918,6 +918,7 @@ abstract class ClrOp {
: new NotImplementedException();
}

protected static void TypeCheck(Type sub, Type super) { TypeCheck(sub,super,""); }
protected static void TypeCheck(Type sub, Type super, string msg) {
if (!super.IsAssignableFrom(sub))
throw new Exception(msg + " " + sub + " not subtype of " + super);
Expand Down Expand Up @@ -1159,6 +1160,7 @@ class ClrGetField : ClrOp {
}

public ClrGetField(FieldInfo f, ClrOp zyg) {
TypeCheck(zyg.Returns, f.DeclaringType);
Returns = f.FieldType;
this.f = f;
this.zyg = zyg;
Expand All @@ -1177,6 +1179,8 @@ class ClrSetField : ClrOp {
}

public ClrSetField(FieldInfo f, ClrOp zyg1, ClrOp zyg2) {
TypeCheck(zyg1.Returns, f.DeclaringType);
TypeCheck(zyg2.Returns, f.FieldType);
Returns = Tokens.Void;
this.f = f;
this.zyg1 = zyg1;
Expand Down Expand Up @@ -1208,6 +1212,7 @@ class ClrSetSField : ClrOp {
}

public ClrSetSField(FieldInfo f, ClrOp zyg) {
TypeCheck(zyg.Returns, f.FieldType);
Returns = Tokens.Void;
this.f = f;
this.zyg = zyg;
Expand Down Expand Up @@ -1248,6 +1253,7 @@ class ClrPadSet : ClrOp {
}

public ClrPadSet(int up, int index, ClrOp zyg) {
TypeCheck(zyg.Returns, Tokens.Variable);
Returns = Tokens.Void;
this.zyg = zyg;
this.up = up;
Expand All @@ -1268,6 +1274,8 @@ class ClrProtoSet : ClrOp {
}

public ClrProtoSet(int ix, ClrOp zyg1, ClrOp zyg2) {
TypeCheck(zyg1.Returns, Tokens.Frame);
TypeCheck(zyg2.Returns, Tokens.Variable);
Returns = Tokens.Void;
this.ix = ix;
this.zyg1 = zyg1;
Expand Down Expand Up @@ -3159,7 +3167,8 @@ public class CLRBackend {
CpsOp.ConstructorCall(Tokens.DynObject_ctor, new CpsOp[] {
CpsOp.GetSField(m.metaObject) })));
thaw.Add(CpsOp.SetField(Tokens.DynObject_slots,
CpsOp.GetSField(m.typeObject), CpsOp.Null(typeof(object[]))));
CpsOp.UnboxAny(Tokens.DynObject, CpsOp.GetSField(m.typeObject)),
CpsOp.Null(typeof(object[]))));
thaw.Add(CpsOp.SetField(Tokens.DMO_typeObject,
CpsOp.GetSField(m.metaObject), CpsOp.GetSField(m.typeObject)));
thaw.Add(CpsOp.SetSField(m.typeVar, CpsOp.MethodCall(null,
Expand Down Expand Up @@ -3232,7 +3241,7 @@ public class CLRBackend {
thaw.Add(CpsOp.MethodCall(null, Tokens.DMO_Invalidate,
new CpsOp [] { CpsOp.GetSField(m.metaObject) }));
thaw.Add(CpsOp.SetField(Tokens.DMO_how, CpsOp.GetSField(m.metaObject),
CpsOp.MethodCall(null, Tokens.Kernel.GetMethod("BoxAnyMO").MakeGenericMethod(Tokens.DynMetaObject), new CpsOp[] { CpsOp.GetSField(m.metaObject), CpsOp.GetSField( ((Class) unit.GetCorePackage("ClassHOW")).metaObject ) })));
CpsOp.MethodCall(null, Tokens.Kernel.GetMethod("BoxRaw").MakeGenericMethod(Tokens.DynMetaObject), new CpsOp[] { CpsOp.GetSField(m.metaObject), CpsOp.GetSField( ((Class) unit.GetCorePackage("ClassHOW")).metaObject ) })));
});

unit.VisitSubsPostorder(delegate(int ix, StaticSub obj) {
Expand Down

0 comments on commit 11ec6d1

Please sign in to comment.