本文整理汇总了C#中System.Reflection.Emit.CodeGenerator.EmitEcho方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGenerator.EmitEcho方法的具体用法?C# CodeGenerator.EmitEcho怎么用?C# CodeGenerator.EmitEcho使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.Emit.CodeGenerator
的用法示例。
在下文中一共展示了CodeGenerator.EmitEcho方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Emit
/// <include file='Doc/Nodes.xml' path='doc/method[@name="Emit"]/*'/>
internal override PhpTypeCode Emit(CodeGenerator/*!*/ codeGenerator)
{
Debug.Assert(access == AccessType.Read || access == AccessType.None);
Statistics.AST.AddNode("UnaryEx");
ILEmitter il = codeGenerator.IL;
PhpTypeCode returned_typecode, o_typecode;
switch (operation)
{
case Operations.AtSign: // special arrangement
// Template:
// context.DisableErrorReporting();
// s;
// context.EnableErrorReporting();
codeGenerator.EmitLoadScriptContext();
il.Emit(OpCodes.Call, Methods.ScriptContext.DisableErrorReporting);
returned_typecode = expr.Emit(codeGenerator);
codeGenerator.EmitLoadScriptContext();
il.Emit(OpCodes.Call, Methods.ScriptContext.EnableErrorReporting);
break;
case Operations.BitNegation:
//Template: "~x" Operators.BitNot(x)
codeGenerator.EmitBoxing(expr.Emit(codeGenerator));
il.Emit(OpCodes.Call, Methods.Operators.BitNot);
returned_typecode = PhpTypeCode.Object;
break;
case Operations.Clone:
// Template: clone x Operators.Clone(x,DTypeDesc,ScriptContext)
codeGenerator.EmitBoxing(expr.Emit(codeGenerator));
codeGenerator.EmitLoadClassContext();
codeGenerator.EmitLoadScriptContext();
il.Emit(OpCodes.Call, Methods.Operators.Clone);
returned_typecode = PhpTypeCode.Object;
break;
case Operations.LogicNegation:
//Template: "!x" !Convert.ObjectToBoolean(x);
if (((returned_typecode = expr.Emit(codeGenerator)) != PhpTypeCode.Boolean))
{
codeGenerator.EmitBoxing(returned_typecode);
il.Emit(OpCodes.Call, Methods.Convert.ObjectToBoolean);
}
il.Emit(OpCodes.Ldc_I4_0);
il.Emit(OpCodes.Ceq);
returned_typecode = PhpTypeCode.Boolean;
break;
case Operations.Minus:
//Template: "-x" Operators.Minus(x)
switch (o_typecode = expr.Emit(codeGenerator))
{
case PhpTypeCode.Double:
il.Emit(OpCodes.Neg);
returned_typecode = PhpTypeCode.Double;
break;
default:
codeGenerator.EmitBoxing(o_typecode);
returned_typecode = codeGenerator.EmitMethodCall(Methods.Operators.Minus);
break;
}
break;
case Operations.ObjectCast:
//Template: "(object)x" Convert.ObjectToDObject(x,ScriptContext)
codeGenerator.EmitBoxing(expr.Emit(codeGenerator));
codeGenerator.EmitLoadScriptContext();
il.Emit(OpCodes.Call, Methods.Convert.ObjectToDObject);
returned_typecode = PhpTypeCode.Object;
break;
case Operations.Plus:
//Template: "+x" Operators.Plus(x)
codeGenerator.EmitBoxing(expr.Emit(codeGenerator));
il.Emit(OpCodes.Call, Methods.Operators.Plus);
returned_typecode = PhpTypeCode.Object;
break;
case Operations.Print:
codeGenerator.EmitEcho(this.expr);
// Always returns 1
il.Emit(OpCodes.Ldc_I4_1);
returned_typecode = PhpTypeCode.Integer;
break;
case Operations.BoolCast:
//Template: "(bool)x" Convert.ObjectToBoolean(x)
if (((returned_typecode = expr.Emit(codeGenerator)) != PhpTypeCode.Boolean))
{
codeGenerator.EmitBoxing(returned_typecode);
il.Emit(OpCodes.Call, Methods.Convert.ObjectToBoolean);
returned_typecode = PhpTypeCode.Boolean;
}
break;
case Operations.Int8Cast:
//.........这里部分代码省略.........
示例2: Emit
/// <include file='Doc/Nodes.xml' path='doc/method[@name="Emit"]/*'/>
/// <remarks>
/// Nothing is expected on the evaluation stack. Nothing is left on the evaluation stack.
/// </remarks>
internal override void Emit(CodeGenerator/*!*/ codeGenerator)
{
Statistics.AST.AddNode("EchoStmt");
codeGenerator.MarkSequencePoint(position.FirstLine, position.FirstColumn, position.LastLine, position.LastColumn + 2);
foreach (Expression parameter in parameters)
{
// skip empty evaluated expression
if (parameter.HasValue &&
(
parameter.Value == null ||
(parameter.Value is string && ((string)parameter.Value) == string.Empty) ||
Convert.ObjectToPhpBytes(parameter.Value).Length == 0
))
{
continue;
}
// emit the echo of parameter expression
codeGenerator.EmitEcho(parameter);
}
}