Skip to content

Commit ad0226d

Browse files
committed
WIP: Improve handling of calls
1 parent 19f8ca2 commit ad0226d

File tree

2 files changed

+441
-15
lines changed

2 files changed

+441
-15
lines changed

Clojure/Clojure/CljCompiler/Ast/InstanceFieldExpr.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,7 @@ public override void Emit(RHC rhc, ObjExpr objx, GenContext context)
133133
if (targetType != null && _tinfo != null)
134134
{
135135
_target.Emit(RHC.Expression, objx, context);
136-
// TODO: Transfer this mechanism for calls on value types to MethodExpr, InstanceZeroArityCallExpr, StaticFieldExpr
137-
if (FieldDeclaringType.IsValueType)
138-
{
139-
ilg.Emit(OpCodes.Unbox_Any, FieldDeclaringType);
140-
LocalBuilder vtTemp = ilg.DeclareLocal(FieldDeclaringType);
141-
Compiler.MaybeSetLocalSymName(context, vtTemp, "valueTemp");
142-
ilg.Emit(OpCodes.Stloc, vtTemp);
143-
ilg.Emit(OpCodes.Ldloca, vtTemp);
144-
}
145-
else
146-
ilg.Emit(OpCodes.Castclass, FieldDeclaringType);
136+
MethodExpr.EmitPrepForCall(context, typeof(object), FieldDeclaringType);
147137
EmitGet(ilg);
148138
HostExpr.EmitBoxReturn(objx, context, FieldType);
149139
}
@@ -175,7 +165,7 @@ public override void EmitUnboxed(RHC rhc, ObjExpr objx, GenContext context)
175165
if (targetType != null && _tinfo != null)
176166
{
177167
_target.Emit(RHC.Expression, objx, context);
178-
ilg.Emit(OpCodes.Isinst, targetType);
168+
MethodExpr.EmitPrepForCall(context, typeof(object), FieldDeclaringType);
179169
EmitGet(ilg);
180170
}
181171
else

0 commit comments

Comments
 (0)