本文整理汇总了C#中CompilationContext.Emit方法的典型用法代码示例。如果您正苦于以下问题:C# CompilationContext.Emit方法的具体用法?C# CompilationContext.Emit怎么用?C# CompilationContext.Emit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CompilationContext
的用法示例。
在下文中一共展示了CompilationContext.Emit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Compile
public override void Compile(CompilationContext context)
{
CompilationHelper.CheckIsValue(itemType);
array.Compile(context);
context.Emit(OpCodes.Ldc_I4, index);
context.Emit(OpCodes.Ldelema, itemType);
}
示例2: Compile
public void Compile(CompilationContext context)
{
if(localType.IsValueType)
{
context.Emit(OpCodes.Ldloca, localIndex);
context.Emit(OpCodes.Initobj, localType);
}
}
示例3: Compile
public void Compile(CompilationContext context)
{
Label ifNotNullLabel = context.ilGenerator.DefineLabel();
_value.Compile(context);
context.Emit(OpCodes.Dup);
context.Emit(OpCodes.Brtrue_S, ifNotNullLabel);
context.Emit(OpCodes.Pop);
_ifNullValue.Compile(context);
context.ilGenerator.MarkLabel(ifNotNullLabel);
}
示例4: PrepareValueOnStack
public static void PrepareValueOnStack(CompilationContext context, Type desiredType, Type typeOnStack)
{
if (typeOnStack.IsValueType && !desiredType.IsValueType)
{
context.Emit(OpCodes.Box, typeOnStack);
}
else if (!typeOnStack.IsValueType && desiredType.IsValueType)
{
context.Emit(OpCodes.Unbox_Any, desiredType);
}
else if (desiredType != typeOnStack)
{
context.Emit(OpCodes.Castclass, desiredType);
}
}
示例5: Compile
public void Compile(CompilationContext context)
{
targetObject.Compile(context);
value.Compile(context);
CompilationHelper.PrepareValueOnStack(context, fieldInfo.FieldType, value.itemType);
context.Emit(OpCodes.Stfld, fieldInfo);
}
示例6: Compile
public void Compile(CompilationContext context)
{
new AstCallMethod(methodInfo, invocationObject, arguments).Compile(context);
if (methodInfo.ReturnType != typeof(void))
{
context.Emit(OpCodes.Pop);
}
}
示例7: Compile
public void Compile(CompilationContext context)
{
value.Compile(context);
if (value.itemType.IsValueType)
{
context.Emit(OpCodes.Box, itemType);
}
}
示例8: Compile
public virtual void Compile(CompilationContext context)
{
switch (argumentIndex)
{
case 0:
context.Emit(OpCodes.Ldarg_0);
break;
case 1:
context.Emit(OpCodes.Ldarg_1);
break;
case 2:
context.Emit(OpCodes.Ldarg_2);
break;
case 3:
context.Emit(OpCodes.Ldarg_3);
break;
default:
context.Emit(OpCodes.Ldarg, argumentIndex);
break;
}
}
示例9: Compile
override public void Compile(CompilationContext context)
{
CompilationHelper.CheckIsValue(itemType);
if (itemType == typeof(Int32))
{
context.Emit(OpCodes.Ldind_I4);
}
else
{
throw new Exception("Unsupported type");
}
}
示例10: Compile
public void Compile(CompilationContext context)
{
if (!(value is IAstRef) && !ReflectionUtils.IsNullable(value.itemType))
{
context.Emit(OpCodes.Ldc_I4_1);
}
else if (ReflectionUtils.IsNullable(value.itemType))
{
AstBuildHelper.ReadPropertyRV(
new AstValueToAddr((IAstValue)value),
value.itemType.GetProperty("HasValue")
).Compile(context);
context.Emit(OpCodes.Ldc_I4_0);
context.Emit(OpCodes.Ceq);
}
else
{
value.Compile(context);
new AstConstantNull().Compile(context);
context.Emit(OpCodes.Ceq);
}
}
示例11: Compile
public void Compile(CompilationContext context)
{
Label elseLabel = context.ilGenerator.DefineLabel();
Label endIfLabel = context.ilGenerator.DefineLabel();
condition.Compile(context);
context.Emit(OpCodes.Brfalse, elseLabel);
if (trueBranch != null)
{
trueBranch.Compile(context);
}
if (falseBranch != null)
{
context.Emit(OpCodes.Br, endIfLabel);
}
context.ilGenerator.MarkLabel(elseLabel);
if (falseBranch != null)
{
falseBranch.Compile(context);
}
context.ilGenerator.MarkLabel(endIfLabel);
}
示例12: Compile
public virtual void Compile(CompilationContext context)
{
if (_value.itemType != _targetType)
{
if (!_value.itemType.IsValueType && !_targetType.IsValueType)
{
_value.Compile(context);
context.Emit(OpCodes.Castclass, _targetType);
return;
}
else if (_targetType.IsValueType && !_value.itemType.IsValueType)
{
new AstUnbox() { refObj = (IAstRef)_value, unboxedType = _targetType }.Compile(context);
return;
}
throw new EmitMapperException();
}
else
{
_value.Compile(context);
}
}
示例13: Compile
override public void Compile(CompilationContext context)
{
CompilationHelper.CheckIsValue(itemType);
sourceObject.Compile(context);
context.Emit(OpCodes.Ldflda, fieldInfo);
}
示例14: Compile
public void Compile(CompilationContext context)
{
value.Compile(context);
CompilationHelper.PrepareValueOnStack(context, localType, value.itemType);
context.Emit(OpCodes.Stloc, localIndex);
}
示例15: Compile
public void Compile(CompilationContext context)
{
context.Emit(OpCodes.Ldc_I4, value);
}