Example #1
0
 public void EmitArguments(INodeList <Expression> arguments, ArgumentConversions conversions)
 {
     if (arguments.Count > 0)
     {
         for (int i = 0; i < arguments.Count; i++)
         {
             var arg  = arguments[i];
             var conv = conversions[i];
             if (conv != null)
             {
                 if (conv.ConversionType == ConversionType.Normal)
                 {
                     arg.GenerateCode(this, Expression.AssignOption);
                     EmitConvert(conv);
                 }
                 else if (conv.ConversionType == ConversionType.ParamArray)
                 {
                     var args = new Expression[arguments.Count - i];
                     arguments.CopyTo(args, conv.Index);
                     EmitConvert((ParamArrayConversion)conv, args);
                     break;
                 }
             }
             else
             {
                 arg.GenerateCode(this, Expression.AssignOption);
             }
         }
     }
     // remaing Conversions like optional or param array
     if (arguments.Count < conversions.Count)
     {
         for (var i = arguments.Count; i < conversions.Count; i++)
         {
             Conversion conv = conversions[i];
             if (conv.ConversionType == ConversionType.Normal)
             {
                 arguments[i].GenerateCode(this, Expression.AssignOption);
                 EmitConvert(conv);
             }
             else if (conv.ConversionType == ConversionType.ParamArray)
             {
                 // remaining arguments
                 var args = new Expression[arguments.Count - i];
                 arguments.CopyTo(args, conv.Index);
                 EmitConvert((ParamArrayConversion)conv, args);
                 break;
             }
         }
     }
 }