}
public void EmitReadGlobal (object global)
+ {
+ EmitReadGlobal (global, global.GetType ());
+ }
+
+ public void EmitReadGlobal (object global, Type type)
{
EmitScope ();
ig.Emit (OpCodes.Ldc_I4, index);
ig.Emit (OpCodes.Ldelem, typeof (object));
- var type = global.GetType ().MakeStrongBoxType ();
+ var strongbox = type.MakeStrongBoxType ();
- ig.Emit (OpCodes.Isinst, type);
- ig.Emit (OpCodes.Ldfld, type.GetField ("Value"));
+ ig.Emit (OpCodes.Isinst, strongbox);
+ ig.Emit (OpCodes.Ldfld, strongbox.GetField ("Value"));
}
}
Visit (expression);
}
- protected override void VisitConstant (ConstantExpression constant)
+ protected override void VisitUnary (UnaryExpression unary)
{
- if (constant.Value == null)
+ if (unary.NodeType != ExpressionType.Quote) {
+ base.VisitUnary (unary);
return;
+ }
+
+ AddGlobal (unary.Operand, typeof (Expression));
+ }
+ protected override void VisitConstant (ConstantExpression constant)
+ {
var value = constant.Value;
- var type = value.GetType ();
+ if (value == null)
+ return;
+
+ AddGlobal (value, value.GetType ());
+ }
+
+ void AddGlobal (object value, Type type)
+ {
if (Type.GetTypeCode (type) != TypeCode.Object)
return;