本文整理汇总了C#中BaseMethodCompiler.CreateVirtualRegister方法的典型用法代码示例。如果您正苦于以下问题:C# BaseMethodCompiler.CreateVirtualRegister方法的具体用法?C# BaseMethodCompiler.CreateVirtualRegister怎么用?C# BaseMethodCompiler.CreateVirtualRegister使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseMethodCompiler
的用法示例。
在下文中一共展示了BaseMethodCompiler.CreateVirtualRegister方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Resolve
/// <summary>
/// Validates the instruction operands and creates a matching variable for the result.
/// </summary>
/// <param name="ctx"></param>
/// <param name="compiler">The compiler.</param>
public override void Resolve(Context ctx, BaseMethodCompiler compiler)
{
base.Resolve(ctx, compiler);
// Validate the typecode & determine the resulting stack type
MosaType resultType;
switch (opcode)
{
case OpCode.Conv_u: goto case OpCode.Conv_i;
case OpCode.Conv_i: resultType = compiler.TypeSystem.BuiltIn.I; break;
case OpCode.Conv_i1: resultType = compiler.TypeSystem.BuiltIn.I1; break;
case OpCode.Conv_i2: resultType = compiler.TypeSystem.BuiltIn.I2; break;
case OpCode.Conv_i4: resultType = compiler.TypeSystem.BuiltIn.I4; break;
case OpCode.Conv_i8: resultType = compiler.TypeSystem.BuiltIn.I8; break;
case OpCode.Conv_r4: resultType = compiler.TypeSystem.BuiltIn.R4; break;
case OpCode.Conv_r8: resultType = compiler.TypeSystem.BuiltIn.R8; break;
case OpCode.Conv_u1: resultType = compiler.TypeSystem.BuiltIn.U1; break;
case OpCode.Conv_u2: resultType = compiler.TypeSystem.BuiltIn.U2; break;
case OpCode.Conv_u4: resultType = compiler.TypeSystem.BuiltIn.U4; break;
case OpCode.Conv_u8: resultType = compiler.TypeSystem.BuiltIn.U8; break;
case OpCode.Conv_ovf_i: goto case OpCode.Conv_i;
case OpCode.Conv_ovf_u: goto case OpCode.Conv_i;
case OpCode.Conv_ovf_i_un: goto case OpCode.Conv_i;
case OpCode.Conv_ovf_u_un: goto case OpCode.Conv_i;
case OpCode.Conv_r_un: resultType = compiler.TypeSystem.BuiltIn.R8; break;
default: throw new NotSupportedException(@"Overflow checking conversions not supported.");
}
ctx.Result = compiler.CreateVirtualRegister(resultType.GetStackType());
}
示例2: Resolve
/// <summary>
/// Validates the instruction operands and creates a matching variable for the result.
/// </summary>
/// <param name="ctx">The context.</param>
/// <param name="compiler">The compiler.</param>
public override void Resolve(Context ctx, BaseMethodCompiler compiler)
{
base.Resolve(ctx, compiler);
// Simple result is the same type as the unary argument
ctx.Result = compiler.CreateVirtualRegister(ctx.Operand1.Type);
}
示例3: GetRuntimeTypeHandle
private Operand GetRuntimeTypeHandle(Context context, BaseMethodCompiler methodCompiler)
{
var typeDef = Operand.CreateUnmanagedSymbolPointer(methodCompiler.TypeSystem, StringClassTypeDefinitionSymbolName);
var runtimeTypeHandle = methodCompiler.CreateVirtualRegister(methodCompiler.TypeSystem.GetTypeByName("System", "RuntimeTypeHandle"));
var before = context.InsertBefore();
before.SetInstruction(IRInstruction.Move, runtimeTypeHandle, typeDef);
return runtimeTypeHandle;
}
示例4: Validate
/// <summary>
/// Validates the instruction operands and creates a matching variable for the result.
/// </summary>
/// <param name="ctx">The context.</param>
/// <param name="compiler">The compiler.</param>
public override void Validate(Context ctx, BaseMethodCompiler compiler)
{
base.Validate(ctx, compiler);
SZArraySigType arrayType = ctx.Operand1.Type as SZArraySigType;
if (arrayType == null)
throw new InvalidProgramException(@"Operand to ldlen is not a vector.");
ctx.Result = compiler.CreateVirtualRegister(BuiltInSigType.IntPtr);
}
示例5: Resolve
/// <summary>
/// Validates the instruction operands and creates a matching variable for the result.
/// </summary>
/// <param name="ctx">The context.</param>
/// <param name="compiler">The compiler.</param>
public override void Resolve(Context ctx, BaseMethodCompiler compiler)
{
base.Resolve(ctx, compiler);
var result = operandTable[(int)ctx.Operand1.Type.GetStackTypeCode()][(int)ctx.Operand2.Type.GetStackTypeCode()];
Debug.Assert(StackTypeCode.Unknown != result, @"Can't shift with the given virtualLocal operands.");
if (StackTypeCode.Unknown == result)
throw new InvalidOperationException(@"Invalid virtualLocal state for pairing (" + ctx.Operand1.Type.GetStackType() + ", " + ctx.Operand2.Type.GetStackType() + ")");
ctx.Result = compiler.CreateVirtualRegister(compiler.TypeSystem.GetStackTypeFromCode(result));
}
示例6: Resolve
/// <summary>
/// Validates the instruction operands and creates a matching variable for the result.
/// </summary>
/// <param name="ctx"></param>
/// <param name="compiler">The compiler.</param>
public override void Resolve(Context ctx, BaseMethodCompiler compiler)
{
base.Resolve(ctx, compiler);
// Validate the operand
var result = opTable[(int)ctx.Operand1.Type.GetStackTypeCode()];
if (StackTypeCode.Unknown == result)
throw new InvalidOperationException(@"Invalid operand to Not instruction.");
ctx.Result = compiler.CreateVirtualRegister(ctx.Operand1.Type);
}
示例7: Validate
/// <summary>
/// Validates the instruction operands and creates a matching variable for the result.
/// </summary>
/// <param name="ctx">The context.</param>
/// <param name="compiler">The compiler.</param>
public override void Validate(Context ctx, BaseMethodCompiler compiler)
{
base.Validate(ctx, compiler);
StackTypeCode result = _operandTable[(int)ctx.Operand1.StackType][(int)ctx.Operand2.StackType];
Debug.Assert(StackTypeCode.Unknown != result, @"Can't shift with the given stack operands.");
if (StackTypeCode.Unknown == result)
throw new InvalidOperationException(@"Invalid stack state for pairing (" + ctx.Operand1.StackType + ", " + ctx.Operand2.StackType + ")");
ctx.Result = compiler.CreateVirtualRegister(Operand.SigTypeFromStackType(result));
}
示例8: Validate
/// <summary>
/// Validates the instruction operands and creates a matching variable for the result.
/// </summary>
/// <param name="ctx"></param>
/// <param name="compiler">The compiler.</param>
public override void Validate(Context ctx, BaseMethodCompiler compiler)
{
base.Validate(ctx, compiler);
// Validate the operand
StackTypeCode result = _typeCodes[(int)ctx.Operand1.StackType];
if (StackTypeCode.Unknown == result)
throw new InvalidOperationException(@"Invalid operand to Neg instruction [" + result + "]");
ctx.Result = compiler.CreateVirtualRegister(ctx.Operand1.Type);
}
示例9: Resolve
/// <summary>
/// Validates the instruction operands and creates a matching variable for the result.
/// </summary>
/// <param name="ctx">The context.</param>
/// <param name="compiler">The compiler.</param>
public override void Resolve(Context ctx, BaseMethodCompiler compiler)
{
base.Resolve(ctx, compiler);
var stackTypeForOperand1 = ctx.Operand1.Type.GetStackTypeCode();
var stackTypeForOperand2 = ctx.Operand2.Type.GetStackTypeCode();
var result = opTable[(int)stackTypeForOperand1][(int)stackTypeForOperand2];
if (result == StackTypeCode.Unknown)
{
throw new InvalidOperationException(@"Invalid virtualLocal result of instruction: " + result.ToString() + " (" + ctx.Operand1.ToString() + ")");
}
ctx.Result = compiler.CreateVirtualRegister(compiler.TypeSystem.GetStackTypeFromCode(result));
}
示例10: Resolve
/// <summary>
/// Validates the instruction operands and creates a matching variable for the result.
/// </summary>
/// <param name="ctx">The context.</param>
/// <param name="compiler">The compiler.</param>
public override void Resolve(Context ctx, BaseMethodCompiler compiler)
{
base.Resolve(ctx, compiler);
StackTypeCode result = StackTypeCode.Unknown;
switch (opcode)
{
case OpCode.Add: result = addTable[(int)ctx.Operand1.Type.GetStackTypeCode()][(int)ctx.Operand2.Type.GetStackTypeCode()]; break;
case OpCode.Sub: result = subTable[(int)ctx.Operand1.Type.GetStackTypeCode()][(int)ctx.Operand2.Type.GetStackTypeCode()]; break;
default: result = operandTable[(int)ctx.Operand1.Type.GetStackTypeCode()][(int)ctx.Operand2.Type.GetStackTypeCode()]; break;
}
if (result == StackTypeCode.Unknown)
{
throw new InvalidOperationException(@"Invalid operand types passed to " + opcode);
}
MosaType resultType = null;
if (StackTypeCode.UnmanagedPointer != result)
{
resultType = compiler.TypeSystem.GetStackTypeFromCode(result);
if (result == StackTypeCode.F && ctx.Operand1.Type.IsR4 && ctx.Operand2.Type.IsR4)
resultType = compiler.TypeSystem.BuiltIn.R4;
}
else
{
if (ctx.Operand1.Type.IsPointer)
{
resultType = ctx.Operand1.Type;
}
else if (ctx.Operand2.Type.IsPointer)
{
resultType = ctx.Operand2.Type;
}
else
throw new InvalidOperationException(@"Invalid operand types passed to " + opcode);
}
//Debug.Assert(resultType != null, ctx.ToString());
ctx.Result = compiler.CreateVirtualRegister(resultType);
}
示例11: Resolve
/// <summary>
/// Validates the instruction operands and creates a matching variable for the result.
/// </summary>
/// <param name="ctx">The context.</param>
/// <param name="compiler">The compiler.</param>
public override void Resolve(Context ctx, BaseMethodCompiler compiler)
{
base.Resolve(ctx, compiler);
// If we're ldind.i8, fix an IL deficiency that the result may be U8
if (opcode == OpCode.Ldind_i8 && elementType.Value == MosaTypeCode.I8)
{
if (ctx.Operand1.Type.ElementType != null && ctx.Operand1.Type.ElementType.IsU8)
{
ctx.Result = compiler.CreateVirtualRegister(compiler.TypeSystem.BuiltIn.U8);
}
}
}
示例12: SetInvokeTarget
/// <summary>
/// Sets the invoke target.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="compiler">The compiler.</param>
/// <param name="method">The method.</param>
private static void SetInvokeTarget(InstructionNode context, BaseMethodCompiler compiler, MosaMethod method)
{
context.InvokeMethod = method;
// Fix the parameter list
int paramCount = method.Signature.Parameters.Count;
if (method.HasThis && !method.HasExplicitThis)
paramCount++;
// Setup operands for parameters and the return value
if (!method.Signature.ReturnType.IsVoid)
{
context.ResultCount = 1;
context.Result = compiler.CreateVirtualRegister(method.Signature.ReturnType.GetStackType());
}
else
{
context.ResultCount = 0;
}
context.OperandCount = (byte)paramCount;
}
示例13: Resolve
/// <summary>
/// Validates the instruction operands and creates a matching variable for the result.
/// </summary>
/// <param name="ctx">The context.</param>
/// <param name="compiler">The compiler.</param>
public override void Resolve(Context ctx, BaseMethodCompiler compiler)
{
base.Resolve(ctx, compiler);
ctx.Result = compiler.CreateVirtualRegister(compiler.TypeSystem.BuiltIn.U);
}
示例14: Validate
/// <summary>
/// Validates the instruction operands and creates a matching variable for the result.
/// </summary>
/// <param name="ctx">The context.</param>
/// <param name="compiler">The compiler.</param>
public override void Validate(Context ctx, BaseMethodCompiler compiler)
{
base.Validate(ctx, compiler);
StackTypeCode result = StackTypeCode.Unknown;
switch (opcode)
{
case OpCode.Add_ovf_un:
result = _addovfunTable[(int)ctx.Operand1.StackType][(int)ctx.Operand2.StackType];
break;
case OpCode.Sub_ovf_un:
result = _subovfunTable[(int)ctx.Operand1.StackType][(int)ctx.Operand2.StackType];
break;
default:
result = _operandTable[(int)ctx.Operand1.StackType][(int)ctx.Operand2.StackType];
break;
}
if (StackTypeCode.Unknown == result)
throw new InvalidOperationException(@"Invalid operand types passed to " + opcode);
ctx.Result = compiler.CreateVirtualRegister(Operand.SigTypeFromStackType(result));
}
示例15: SetInvokeTarget
/// <summary>
/// Sets the invoke target.
/// </summary>
/// <param name="ctx">The context.</param>
/// <param name="compiler">The compiler.</param>
/// <param name="method">The method.</param>
private static void SetInvokeTarget(Context ctx, BaseMethodCompiler compiler, RuntimeMethod method)
{
if (method == null)
throw new ArgumentNullException(@"method");
// Signature of the call target
// Number of parameters required for the call
ctx.InvokeTarget = method;
// Retrieve the target signature
MethodSignature signature = ctx.InvokeTarget.Signature;
// Fix the parameter list
byte paramCount = (byte)signature.Parameters.Length;
if (signature.HasThis && !signature.HasExplicitThis)
paramCount++;
// Setup operands for parameters and the return value
if (signature.ReturnType.Type != CilElementType.Void)
{
ctx.ResultCount = 1;
ctx.Result = compiler.CreateVirtualRegister(signature.ReturnType);
}
else
ctx.ResultCount = 0;
ctx.OperandCount = paramCount;
}