本文整理汇总了C#中Microsoft.JScript.AST.TranslateToILReference方法的典型用法代码示例。如果您正苦于以下问题:C# AST.TranslateToILReference方法的具体用法?C# AST.TranslateToILReference怎么用?C# AST.TranslateToILReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.JScript.AST
的用法示例。
在下文中一共展示了AST.TranslateToILReference方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PlaceArgumentsOnStack
internal static void PlaceArgumentsOnStack(ILGenerator il, ParameterInfo[] pars, ASTList args, int offset, int rhoffset, AST missing){
int k = args.count;
int n = k+offset;
int m = pars.Length-rhoffset;
bool varargs = m > 0 && pars[m-1].IsDefined(Typeob.ParamArrayAttribute, false) &&
!(k == m && Convert.IsArrayType(args[k-1].InferType(null)));
Type varargElemType = varargs ? pars[--m].ParameterType.GetElementType() : null;
if (n > m) n = m;
for (int i = offset; i < n; i++){
Type ptype = pars[i].ParameterType;
AST arg = args[i-offset];
if (arg is ConstantWrapper && ((ConstantWrapper)arg).value == System.Reflection.Missing.Value){
Object defVal = pars[i].DefaultValue;
((ConstantWrapper)arg).value = defVal != System.Convert.DBNull ? defVal : null;
}
if (ptype.IsByRef)
arg.TranslateToILReference(il, ptype.GetElementType());
else
arg.TranslateToIL(il, ptype);
}
if (n < m){
for (int i = n; i < m; i++){
Type ptype = pars[i].ParameterType;
if (pars[i].DefaultValue == System.Convert.DBNull) //No default value was specified
if (ptype.IsByRef)
missing.TranslateToILReference(il, ptype.GetElementType());
else
missing.TranslateToIL(il, ptype);
else
if (ptype.IsByRef)
(new ConstantWrapper(pars[i].DefaultValue, null)).TranslateToILReference(il, ptype.GetElementType());
else
(new ConstantWrapper(pars[i].DefaultValue, null)).TranslateToIL(il, ptype);
}
}
if (varargs){
n -= offset; //The number of arguments in argList that are already on the stack
m = k>n ? k-n : 0; //The number of arguments in argList that are to be placed in the vararg array
ConstantWrapper.TranslateToILInt(il, m);
il.Emit(OpCodes.Newarr, varargElemType);
bool doLdelema = varargElemType.IsValueType && !varargElemType.IsPrimitive;
for (int i = 0; i < m; i++){
il.Emit(OpCodes.Dup);
ConstantWrapper.TranslateToILInt(il, i);
if (doLdelema)
il.Emit(OpCodes.Ldelema, varargElemType);
args[i+n].TranslateToIL(il, varargElemType);
Binding.TranslateToStelem(il, varargElemType);
}
}
}