Ejemplo n.º 1
0
 public override void GenerateCode(MethodBodyGenerator generator, MethodCompileOption option)
 {
     if (Method.IsAbstract && Method.DeclaringType == typeof(IDynamicInvocable))
     {
         Target.GenerateCode(generator);
         if (Target.Type.IsValueType)
         {
             generator.Box(Target.Type);
         }
     }
     else
     {
         Target.GenerateCode(generator, MethodCompileOption.EmitStartAddress);
     }
     if (Target.NodeType == ExpressionType.MemberAccess)
     {
         MemberExpression target = (MemberExpression)Target;
         if (target.Target.Type.IsValueType)
         {
             switch (target.Target.NodeType)
             {
             case ExpressionType.Indexer:
             case ExpressionType.MemberAccess:
                 var temp = generator.DeclareVariable(target.Target.Type);
                 generator.StoreVariable(temp);
                 generator.LoadAddressOfVariable(temp);
                 break;
             }
         }
     }
     else if (Target.NodeType == ExpressionType.Identifier)
     {
         // if it an identifier expression this might be local member call
         var exp = (NameExpression)Target;
         if (exp.Binder == null && Method.IsStatic == false)
         {
             generator.LoadArgument(0);
         }
     }
     generator.EmitArguments(Arguments, Conversions);
     generator.Call(Method);
     // if current value must not be returned for assigment
     if ((option & MethodCompileOption.Return) == 0 && Type is object && Type != TypeProvider.VoidType)
     {
         generator.Pop();
     }
 }