本文整理汇总了C#中IInstructionDecoder类的典型用法代码示例。如果您正苦于以下问题:C# IInstructionDecoder类的具体用法?C# IInstructionDecoder怎么用?C# IInstructionDecoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IInstructionDecoder类属于命名空间,在下文中一共展示了IInstructionDecoder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Decode
/// <summary>
/// Decodes the specified instruction.
/// </summary>
/// <param name="ctx">The context.</param>
/// <param name="decoder">The instruction decoder, which holds the code stream.</param>
public override void Decode(Context ctx, IInstructionDecoder decoder)
{
// Decode base classes first
base.Decode(ctx, decoder);
// Load the _stackFrameIndex token from the immediate
TokenTypes token = decoder.DecodeTokenType();
//Console.WriteLine("Stfld used in {0}.{1}", decoder.Method.DeclaringType.FullName, decoder.Method.Name);
Debug.Assert(TokenTypes.Field == (TokenTypes.TableMask & token) || TokenTypes.MemberRef == (TokenTypes.TableMask & token), @"Invalid token type.");
ctx.RuntimeField = decoder.ModuleTypeSystem.GetField(token);
if (ctx.RuntimeField.ContainsGenericParameter)
{
foreach (RuntimeField field in decoder.Method.DeclaringType.Fields)
if (field.Name == ctx.RuntimeField.Name)
{
ctx.RuntimeField = field;
break;
}
Debug.Assert(!ctx.RuntimeField.ContainsGenericParameter);
}
}
示例2: Decode
/// <summary>
/// Decodes the specified instruction.
/// </summary>
/// <param name="ctx">The context.</param>
/// <param name="decoder">The instruction decoder, which holds the code stream.</param>
public override void Decode(Context ctx, IInstructionDecoder decoder)
{
// Decode base classes first
base.Decode(ctx, decoder);
// Opcode specific handling
int index;
switch (opcode)
{
case OpCode.Ldloc:
case OpCode.Ldloc_s: index = (int)decoder.Instruction.Operand; break;
case OpCode.Ldloc_0: index = 0; break;
case OpCode.Ldloc_1: index = 1; break;
case OpCode.Ldloc_2: index = 2; break;
case OpCode.Ldloc_3: index = 3; break;
default: throw new InvalidMetadataException();
}
// Push the loaded value onto the evaluation stack
var local = decoder.Compiler.GetLocalOperand(index);
var result = LoadInstruction.CreateResultOperand(decoder, local.Type);
ctx.Operand1 = local;
ctx.Result = result;
}
示例3: Decode
/// <summary>
/// Decodes the specified instruction.
/// </summary>
/// <param name="ctx">The context.</param>
/// <param name="decoder">The instruction decoder, which holds the code stream.</param>
public override void Decode(Context ctx, IInstructionDecoder decoder)
{
// Decode base classes first
base.Decode(ctx, decoder);
// Load the _stackFrameIndex token from the immediate
Token token = decoder.DecodeTokenType();
//Console.WriteLine("Stfld used in {0}.{1}", decoder.Method.DeclaringType.FullName, decoder.Method.Name);
Debug.Assert(token.Table == TableType.Field || token.Table == TableType.MemberRef, @"Invalid token type.");
ITypeModule module = null;
Mosa.Runtime.TypeSystem.Generic.CilGenericType genericType = decoder.Method.DeclaringType as Mosa.Runtime.TypeSystem.Generic.CilGenericType;
if (genericType != null)
module = (decoder.Method.DeclaringType as Mosa.Runtime.TypeSystem.Generic.CilGenericType).BaseGenericType.Module;
else
module = decoder.Method.Module;
ctx.RuntimeField = module.GetField(token);
if (ctx.RuntimeField.ContainsGenericParameter)
{
foreach (RuntimeField field in decoder.Method.DeclaringType.Fields)
if (field.Name == ctx.RuntimeField.Name)
{
ctx.RuntimeField = field;
break;
}
Debug.Assert(!ctx.RuntimeField.ContainsGenericParameter);
}
}
示例4: Decode
/// <summary>
/// Decodes the specified instruction.
/// </summary>
/// <param name="ctx">The context.</param>
/// <param name="decoder">The instruction decoder, which holds the code stream.</param>
public override void Decode(InstructionNode ctx, IInstructionDecoder decoder)
{
// Decode base classes first
base.Decode(ctx, decoder);
// Opcode specific handling
int index;
switch (opcode)
{
case OpCode.Ldloc:
case OpCode.Ldloc_s: index = (int)decoder.Instruction.Operand; break;
case OpCode.Ldloc_0: index = 0; break;
case OpCode.Ldloc_1: index = 1; break;
case OpCode.Ldloc_2: index = 2; break;
case OpCode.Ldloc_3: index = 3; break;
default: throw new InvalidMetadataException();
}
// Push the loaded value onto the evaluation stack
var local = decoder.Compiler.LocalVariables[index];
var result = AllocateVirtualRegisterOrStackSlot(decoder.Compiler, local.Type);
ctx.Operand1 = local;
ctx.Result = result;
}
示例5: Decode
/// <summary>
/// Decodes the specified instruction.
/// </summary>
/// <param name="ctx">The context.</param>
/// <param name="decoder">The instruction decoder, which holds the code stream.</param>
public override void Decode(Context ctx, IInstructionDecoder decoder)
{
// Decode base classes first
base.Decode(ctx, decoder);
// Read the type specification
TokenTypes arrayEType;
decoder.Decode(out arrayEType);
ctx.Token = arrayEType;
Mosa.Runtime.Vm.RuntimeType type = RuntimeBase.Instance.TypeLoader.GetType(decoder.Compiler.Assembly, arrayEType);
//ctx.Result =
/*
TypeReference eType = MetadataTypeReference.FromToken(decoder.Metadata, arrayEType);
// FIXME: If _operands[0] is an integral constant, we can infer the maximum size of the array
// and instantiate an ArrayTypeSpecification with max. sizes. This way we could eliminate bounds
// checks in an optimization stage later on, if we find that a value never exceeds the array
// bounds.
// Build a type specification
ArrayTypeSpecification typeRef = new ArrayTypeSpecification(eType);
_results[0] = CreateResultOperand(typeRef);
*/
}
示例6: Decode
/// <summary>
/// Decodes the specified instruction.
/// </summary>
/// <param name="ctx">The context.</param>
/// <param name="decoder">The instruction decoder, which holds the code stream.</param>
public override void Decode(Context ctx, IInstructionDecoder decoder)
{
base.Decode(ctx, decoder);
Token token = decoder.DecodeTokenType();
ctx.RuntimeField = decoder.Method.Module.GetField(token);
// FIXME: Can this be put into a re-used method?
if (ctx.RuntimeField.ContainsGenericParameter || ctx.RuntimeField.DeclaringType.ContainsOpenGenericParameters)
{
foreach (var field in decoder.Method.DeclaringType.Fields)
{
if (field.Name == ctx.RuntimeField.Name)
{
ctx.RuntimeField = field;
break;
}
}
if (ctx.RuntimeField.ContainsGenericParameter)
{
ctx.RuntimeField = decoder.GenericTypePatcher.PatchField(decoder.TypeModule, decoder.Method.DeclaringType as CilGenericType, ctx.RuntimeField);
}
decoder.Compiler.Scheduler.TrackFieldReferenced(ctx.RuntimeField);
Debug.Assert(!ctx.RuntimeField.ContainsGenericParameter);
}
SigType sigType = new RefSigType(ctx.RuntimeField.SignatureType);
ctx.Result = LoadInstruction.CreateResultOperand(decoder, Operand.StackTypeFromSigType(sigType), sigType);
}
示例7: Decode
/// <summary>
/// Decodes the specified instruction.
/// </summary>
/// <param name="ctx">The context.</param>
/// <param name="decoder">The instruction decoder, which holds the code stream.</param>
public override void Decode(Context ctx, IInstructionDecoder decoder)
{
// Decode base classes first
base.Decode(ctx, decoder);
throw new NotImplementedException();
}
示例8: Decode
/// <summary>
/// Decodes the specified instruction.
/// </summary>
/// <param name="ctx">The context.</param>
/// <param name="decoder">The instruction decoder, which holds the code stream.</param>
public override void Decode(Context ctx, IInstructionDecoder decoder)
{
// Decode the base first
base.Decode(ctx, decoder);
ushort argIdx;
// Opcode specific handling
if (opcode == OpCode.Starg_s)
{
byte arg = decoder.DecodeByte();
argIdx = arg;
}
else
{
argIdx = decoder.DecodeUShort();
}
// The argument is the result
ctx.Result = decoder.Compiler.GetParameterOperand(argIdx);
// FIXME: Do some type compatibility checks
// See verification for this instruction and
// verification types.
}
示例9: Decode
/// <summary>
/// Decodes the specified instruction.
/// </summary>
/// <param name="ctx">The context.</param>
/// <param name="decoder">The instruction decoder, which holds the code stream.</param>
public override void Decode(Context ctx, IInstructionDecoder decoder)
{
// Decode base classes first
base.Decode(ctx, decoder);
// Read the branch target
// Is this a short branch target?
if (opcode == OpCode.Brfalse_s || opcode == OpCode.Brtrue_s)
{
sbyte target = decoder.DecodeSByte();
ctx.SetBranch(target);
}
else if (opcode == OpCode.Brfalse || opcode == OpCode.Brtrue)
{
int target = decoder.DecodeInt();
ctx.SetBranch(target);
}
else if (opcode == OpCode.Switch)
{
// Don't do anything, the derived class will do everything
}
else
{
throw new NotSupportedException(@"Invalid opcode " + opcode.ToString() + " specified for UnaryBranchInstruction.");
}
}
示例10: Decode
/// <summary>
/// Decodes the specified instruction.
/// </summary>
/// <param name="ctx">The context.</param>
/// <param name="decoder">The instruction decoder, which holds the code stream.</param>
public override void Decode(Context ctx, IInstructionDecoder decoder)
{
// Decode base classes first
base.Decode(ctx, decoder);
// Read the branch target
// Is this a short branch target?
// FIXME: Remove unary branch instructions from this list.
if (_opcode == OpCode.Beq_s || _opcode == OpCode.Bge_s || _opcode == OpCode.Bge_un_s || _opcode == OpCode.Bgt_s ||
_opcode == OpCode.Bgt_un_s || _opcode == OpCode.Ble_s || _opcode == OpCode.Ble_un_s || _opcode == OpCode.Blt_s ||
_opcode == OpCode.Blt_un_s || _opcode == OpCode.Bne_un_s) {
sbyte target;
decoder.Decode(out target);
ctx.SetBranch(target);
}
else if (_opcode == OpCode.Beq || _opcode == OpCode.Bge || _opcode == OpCode.Bge_un || _opcode == OpCode.Bgt ||
_opcode == OpCode.Bgt_un || _opcode == OpCode.Ble || _opcode == OpCode.Ble_un || _opcode == OpCode.Blt ||
_opcode == OpCode.Blt_un || _opcode == OpCode.Bne_un) {
int target;
decoder.Decode(out target);
ctx.SetBranch(target);
}
else {
throw new NotSupportedException(@"Invalid branch opcode specified for BinaryBranchInstruction");
}
}
示例11: Decode
/// <summary>
/// Decodes the specified instruction.
/// </summary>
/// <param name="ctx">The context.</param>
/// <param name="decoder">The instruction decoder, which holds the code stream.</param>
public override void Decode(Context ctx, IInstructionDecoder decoder)
{
// Decode base classes first
base.Decode(ctx, decoder);
Token token = decoder.DecodeTokenType();
ITypeModule module = null;
Mosa.Runtime.TypeSystem.Generic.CilGenericType genericType = decoder.Method.DeclaringType as Mosa.Runtime.TypeSystem.Generic.CilGenericType;
if (genericType != null)
module = (decoder.Method.DeclaringType as Mosa.Runtime.TypeSystem.Generic.CilGenericType).BaseGenericType.Module;
else
module = decoder.Method.Module;
ctx.RuntimeField = module.GetField(token);
if (ctx.RuntimeField.ContainsGenericParameter)
{
foreach (RuntimeField field in decoder.Method.DeclaringType.Fields)
if (field.Name == ctx.RuntimeField.Name)
{
ctx.RuntimeField = field;
break;
}
Debug.Assert(!ctx.RuntimeField.ContainsGenericParameter);
}
SigType sigType = ctx.RuntimeField.SignatureType;
ctx.Result = LoadInstruction.CreateResultOperand(decoder, Operand.StackTypeFromSigType(sigType), sigType);
}
示例12: Decode
/// <summary>
/// Decodes the specified CIL instruction.
/// </summary>
/// <param name="ctx">The context.</param>
/// <param name="decoder">The instruction decoder, which holds the code stream.</param>
/// <remarks>
/// This method is used by instructions to retrieve immediate operands
/// From the instruction stream.
/// </remarks>
public override void Decode(InstructionNode ctx, IInstructionDecoder decoder)
{
// Decode base classes first
base.Decode(ctx, decoder);
int index;
// Opcode specific handling
switch (opcode)
{
case OpCode.Ldarg:
case OpCode.Ldarg_s: index = (int)decoder.Instruction.Operand; break;
case OpCode.Ldarg_0: index = 0; break;
case OpCode.Ldarg_1: index = 1; break;
case OpCode.Ldarg_2: index = 2; break;
case OpCode.Ldarg_3: index = 3; break;
default: throw new System.NotImplementedException();
}
// Push the loaded value onto the evaluation stack
var parameterOperand = decoder.Compiler.GetParameterOperand(index);
var result = LoadInstruction.CreateResultOperand(decoder, parameterOperand.Type);
ctx.Operand1 = parameterOperand;
ctx.Result = result;
}
示例13: Decode
/// <summary>
/// Decodes the specified instruction.
/// </summary>
/// <param name="ctx">The context.</param>
/// <param name="decoder">The instruction decoder, which holds the code stream.</param>
public override void Decode(Context ctx, IInstructionDecoder decoder)
{
// Decode base classes first
base.Decode(ctx, decoder);
// FIXME: Validate operands & verify instruction
ctx.Result = decoder.Compiler.CreateTemporary(new SigType(CilElementType.I4));
}
示例14: Decode
/// <summary>
/// Decodes the specified instruction.
/// </summary>
/// <param name="ctx">The context.</param>
/// <param name="decoder">The instruction decoder, which holds the code stream.</param>
public override void Decode(Context ctx, IInstructionDecoder decoder)
{
// Decode base classes first
base.Decode(ctx, decoder);
byte alignment = (byte)decoder.Instruction.Operand;
ctx.Other = alignment;
}
示例15: Decode
/// <summary>
/// Decodes the specified instruction.
/// </summary>
/// <param name="ctx">The context.</param>
/// <param name="decoder">The instruction decoder, which holds the code stream.</param>
public override void Decode(Context ctx, IInstructionDecoder decoder)
{
// Decode base classes first
base.Decode(ctx, decoder);
// Set the result
ctx.Result = decoder.Compiler.CreateVirtualRegister(decoder.TypeSystem.BuiltIn.I4);
}