本文整理汇总了C#中CodeGen.EmitExprOrNone方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGen.EmitExprOrNone方法的具体用法?C# CodeGen.EmitExprOrNone怎么用?C# CodeGen.EmitExprOrNone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeGen
的用法示例。
在下文中一共展示了CodeGen.EmitExprOrNone方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Emit
internal override void Emit(CodeGen cg)
{
if (Options.DebugMode) {
cg.EmitPosition(this);
cg.EmitTestTrue(test);
Label endLabel = cg.DefineLabel();
cg.Emit(OpCodes.Brtrue, endLabel);
cg.EmitExprOrNone(message);
cg.EmitConvertFromObject(typeof(string));
cg.EmitCall(typeof(Ops), "AssertionError", new Type[] { typeof(string) });
cg.Emit(OpCodes.Throw);
cg.MarkLabel(endLabel);
}
}
示例2: Emit
internal override void Emit(CodeGen cg)
{
Label done = new Label();
bool emitDone = false;
Expression[] exprs = new Expression[args.Length - extraArgs];
Expression argsTuple = null, keywordDict = null;
string[] keywordNames = new string[keywordCount];
int index = 0, keywordIndex = 0;
foreach (Arg arg in args) {
if (arg.Name == SymbolTable.Star) {
argsTuple = arg.Expression; continue;
} else if (arg.Name == SymbolTable.StarStar) {
keywordDict = arg.Expression; continue;
} else if (arg.Name != SymbolTable.Empty) {
keywordNames[keywordIndex++] = arg.Name.GetString();
}
exprs[index++] = arg.Expression;
}
if (hasKeywordDict || (hasArgsTuple && keywordCount > 0)) {
cg.EmitCallerContext();
target.Emit(cg);
cg.EmitObjectArray(exprs);
cg.EmitStringArray(keywordNames);
cg.EmitExprOrNone(argsTuple);
cg.EmitExprOrNone(keywordDict);
cg.EmitCall(typeof(Ops), "CallWithArgsTupleAndKeywordDictAndContext",
new Type[] { typeof(ICallerContext), typeof(object), typeof(object[]), typeof(string[]),
typeof(object), typeof(object)});
} else if (hasArgsTuple) {
cg.EmitCallerContext();
target.Emit(cg);
cg.EmitObjectArray(exprs);
cg.EmitExprOrNone(argsTuple);
cg.EmitCall(typeof(Ops), "CallWithArgsTupleAndContext",
new Type[] { typeof(ICallerContext), typeof(object), typeof(object[]), typeof(object) });
} else if (keywordCount > 0) {
cg.EmitCallerContext();
target.Emit(cg);
cg.EmitObjectArray(exprs);
cg.EmitStringArray(keywordNames);
cg.EmitCall(typeof(Ops), "Call",
new Type[] { typeof(ICallerContext), typeof(object), typeof(object[]), typeof(string[]) });
} else {
cg.EmitCallerContext();
target.Emit(cg);
if (args.Length <= Ops.MaximumCallArgs) {
Type[] argTypes = new Type[args.Length + 2];
int i = 0;
argTypes[i++] = typeof(ICallerContext);
argTypes[i++] = typeof(object);
foreach (Expression e in exprs) {
e.Emit(cg);
argTypes[i++] = typeof(object);
}
cg.EmitCall(typeof(Ops), "CallWithContext", argTypes);
} else {
cg.EmitObjectArray(exprs);
cg.EmitCall(typeof(Ops), "CallWithContext",
new Type[] { typeof(ICallerContext), typeof(object), typeof(object[]) });
}
}
if (emitDone) {
cg.MarkLabel(done);
}
}
示例3: EmitOuterLocalIDs
private void EmitOuterLocalIDs(CodeGen cg)
{
if (EmitLocalDictionary) {
int size = 0;
foreach (KeyValuePair<SymbolId, Binding> kv in names) {
if (kv.Value.IsFree) size++;
}
// Emit null if no outer symbol IDs
if (size == 0) {
cg.EmitExprOrNone(null);
} else {
cg.EmitInt(size);
cg.Emit(OpCodes.Newarr, typeof(SymbolId));
int index = 0;
foreach (KeyValuePair<SymbolId, Binding> kv in names) {
if (kv.Value.IsFree) {
cg.Emit(OpCodes.Dup);
cg.EmitInt(index++);
cg.Emit(OpCodes.Ldelema, typeof(SymbolId));
cg.EmitSymbolIdId(kv.Key);
cg.Emit(OpCodes.Call, typeof(SymbolId).GetConstructor(new Type[] { typeof(int) }));
}
}
}
} else {
cg.EmitExprOrNone(null);
}
}