本文整理汇总了C#中Expression.Emit方法的典型用法代码示例。如果您正苦于以下问题:C# Expression.Emit方法的具体用法?C# Expression.Emit怎么用?C# Expression.Emit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Expression
的用法示例。
在下文中一共展示了Expression.Emit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitAssign
public void EmitAssign (EmitContext ec, Expression source, bool leave_copy, bool isCompound)
{
if (isCompound)
throw new NotImplementedException ();
source.Emit (ec);
Store (ec);
if (leave_copy)
Emit (ec);
}
示例2: EmitCallInstance
static TypeSpec EmitCallInstance (EmitContext ec, Expression instance, TypeSpec declaringType, OpCode callOpcode)
{
var instance_type = instance.Type;
//
// Push the instance expression
//
if ((instance_type.IsStruct && (callOpcode == OpCodes.Callvirt || (callOpcode == OpCodes.Call && declaringType.IsStruct))) ||
instance_type.IsGenericParameter || declaringType.IsNullableType) {
//
// If the expression implements IMemoryLocation, then
// we can optimize and use AddressOf on the
// return.
//
// If not we have to use some temporary storage for
// it.
var iml = instance as IMemoryLocation;
if (iml != null) {
iml.AddressOf (ec, AddressOp.Load);
} else {
LocalTemporary temp = new LocalTemporary (instance_type);
instance.Emit (ec);
temp.Store (ec);
temp.AddressOf (ec, AddressOp.Load);
}
return ReferenceContainer.MakeType (ec.Module, instance_type);
}
if (instance_type.IsEnum || instance_type.IsStruct) {
instance.Emit (ec);
ec.Emit (OpCodes.Box, instance_type);
return ec.BuiltinTypes.Object;
}
instance.Emit (ec);
return instance_type;
}