本文整理汇总了C#中CodeGen.EmitBoxing方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGen.EmitBoxing方法的具体用法?C# CodeGen.EmitBoxing怎么用?C# CodeGen.EmitBoxing使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeGen
的用法示例。
在下文中一共展示了CodeGen.EmitBoxing方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Emit
public override void Emit(CodeGen cg) {
if (_valueTypeType != null)
{
EmitLocation(cg);
cg.EmitMissingValue(_valueTypeType); // seems ok?
}
else
{
for (int i = 0; i < _parameterInfos.Length; i++)
{
_arguments[i].Emit(cg);
if (_arguments[i].Type != _parameterInfos[i].ParameterType && _arguments[i].Type.IsValueType && typeof(SymbolId) != _arguments[i].Type)
{
cg.EmitBoxing(_arguments[i].Type);
}
}
EmitLocation(cg);
cg.EmitNew(_constructor);
}
if (ScriptDomainManager.Options.LightweightDebugging && Span.IsValid)
{
cg.EmitConstant(SpanToLong(Span));
cg.EmitCall(Debugging.DebugMethods.ExpressionOut);
}
}
示例2: EmitArgument
public static ReturnFixer EmitArgument(CodeGen cg, Slot argSlot)
{
argSlot.EmitGet(cg);
if (argSlot.Type.IsByRef) {
Type elementType = argSlot.Type.GetElementType();
Type concreteType = typeof(StrongBox<>).MakeGenericType(elementType);
Slot refSlot = cg.GetLocalTmp(concreteType);
cg.EmitLoadValueIndirect(elementType);
cg.EmitNew(concreteType, new Type[] { elementType });
refSlot.EmitSet(cg);
refSlot.EmitGet(cg);
return new ReturnFixer(refSlot, argSlot);
} else {
cg.EmitBoxing(argSlot.Type);
return null;
}
}
示例3: EmitGetAs
public void EmitGetAs(CodeGen cg, Type asType)
{
Contract.RequiresNotNull(cg, "cg");
Contract.RequiresNotNull(asType, "asType");
EmitGet(cg);
if (asType == typeof(object) && this.Type.IsValueType) {
cg.EmitBoxing(this.Type);
return;
}
if (asType.IsAssignableFrom(this.Type)) {
return;
}
if (asType.IsAssignableFrom(_knownType)) {
cg.EmitUnbox(asType);
} else {
// A special case for int-> double until we can do the proper matrix
if (asType == typeof(double)) {
if (this.Type == typeof(int)) {
cg.Emit(OpCodes.Conv_R8);
return;
} else if (this.KnownType == typeof(int)) {
cg.EmitUnbox(typeof(int));
cg.Emit(OpCodes.Conv_R8);
return;
}
}
if (this.Type != typeof(object)) {
// TODO make this efficient, for now just go to object and back
//throw new InvalidOperationException();
cg.EmitBoxing(this.Type);
}
cg.EmitConvertFromObject(asType);
}
}
示例4: Emit
public override void Emit(CodeGen cg)
{
var et = _type.GetElementType();
cg.EmitArray(
et,
_expressions.Count,
delegate(int index) {
var ex = _expressions[index];
ex.Emit(cg);
if (ex.Type != et && ex.Type.IsValueType)
{
cg.EmitBoxing(ex.Type);
}
}
);
// fake it...
EmitLocation(cg);
if (ScriptDomainManager.Options.LightweightDebugging)
{
cg.EmitConstant(SpanToLong(Span));
cg.EmitCall(Debugging.DebugMethods.ExpressionOut);
}
}
示例5: EmitAsObject
/// <summary>
/// Generates the code for the expression, leaving it on
/// the stack typed as object.
/// </summary>
/// <param name="cg">Where to emit the code.</param>
public void EmitAsObject(CodeGen cg)
{
this.Emit(cg); // emit as Type
cg.EmitBoxing(Type);
}