本文整理汇总了C#中Microsoft.JScript.AST.Emit方法的典型用法代码示例。如果您正苦于以下问题:C# AST.Emit方法的具体用法?C# AST.Emit怎么用?C# AST.Emit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.JScript.AST
的用法示例。
在下文中一共展示了AST.Emit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: emit_default_case
static void emit_default_case(EmitContext ec, AST ast, OpCode op, Label lbl)
{
ast.Emit (ec);
if (need_convert_to_boolean (ast))
emit_to_boolean (ast, ec.ig, 0);
ec.ig.Emit (op, lbl);
}
示例2: ft_binary_recursion
static void ft_binary_recursion(EmitContext ec, AST ast, Label lbl)
{
ILGenerator ig = ec.ig;
if (ast is Binary) {
Binary b = ast as Binary;
switch (b.op) {
case JSToken.LogicalOr:
Label ftLb = ig.DefineLabel ();
fall_false (ec, b.left, ftLb);
fall_true (ec, b.right, lbl);
ig.MarkLabel (ftLb);
break;
case JSToken.LogicalAnd:
fall_true (ec, b.left, lbl);
fall_true (ec, b.right, lbl);
break;
case JSToken.LessThan:
ig.Emit (OpCodes.Ldc_I4_0);
ig.Emit (OpCodes.Conv_R8);
ig.Emit (OpCodes.Blt, lbl);
break;
default:
ast.Emit (ec);
ig.Emit (OpCodes.Ldc_I4_1);
ig.Emit (OpCodes.Call, typeof (Convert).GetMethod ("ToBoolean", new Type [] {typeof (object), typeof (bool)}));
ig.Emit (OpCodes.Brfalse, lbl);
break;
}
}
}
示例3: emit_non_numeric_unary
private void emit_non_numeric_unary(EmitContext ec, AST operand, byte oper)
{
ILGenerator ig = ec.ig;
Type unary_type = typeof (NumericUnary);
LocalBuilder unary_builder = ig.DeclareLocal (unary_type);
ig.Emit (OpCodes.Ldc_I4_S, oper);
ig.Emit (OpCodes.Newobj, unary_type.GetConstructor (new Type [] { typeof (int) }));
ig.Emit (OpCodes.Stloc, unary_builder);
ig.Emit (OpCodes.Ldloc, unary_builder);
operand.Emit (ec);
ig.Emit (OpCodes.Call, unary_type.GetMethod ("EvaluateUnary"));
}