本文整理汇总了C#中IInstructionDecoder类的典型用法代码示例。如果您正苦于以下问题:C# IInstructionDecoder类的具体用法?C# IInstructionDecoder怎么用?C# IInstructionDecoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IInstructionDecoder类属于命名空间,在下文中一共展示了IInstructionDecoder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:illuminus86,项目名称:MOSA-Project,代码行数:31,代码来源:StfldInstruction.cs
示例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;
}
开发者ID:Boddlnagg,项目名称:MOSA-Project,代码行数:30,代码来源:LdlocInstruction.cs
示例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);
}
}
开发者ID:davidleon,项目名称:MOSA-Project,代码行数:38,代码来源:StfldInstruction.cs
示例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;
}
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:30,代码来源:LdlocInstruction.cs
示例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);
*/
}
开发者ID:shanebrown99,项目名称:MOSA-Project,代码行数:30,代码来源:NewarrInstruction.cs
示例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);
}
开发者ID:pdelprat,项目名称:MOSA-Project,代码行数:35,代码来源:LdfldaInstruction.cs
示例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();
}
开发者ID:jeffreye,项目名称:MOSA-Project,代码行数:12,代码来源:ArglistInstruction.cs
示例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.
}
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:30,代码来源:StargInstruction.cs
示例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.");
}
}
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:31,代码来源:UnaryBranchInstruction.cs
示例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");
}
}
开发者ID:hj1980,项目名称:Mosa,代码行数:31,代码来源:BinaryBranchInstruction.cs
示例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);
}
开发者ID:davidleon,项目名称:MOSA-Project,代码行数:34,代码来源:LdfldInstruction.cs
示例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;
}
开发者ID:yonglehou,项目名称:MOSA-Project,代码行数:35,代码来源:LdargInstruction.cs
示例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));
}
开发者ID:davidleon,项目名称:MOSA-Project,代码行数:13,代码来源:RefanytypeInstruction.cs
示例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;
}
开发者ID:Boddlnagg,项目名称:MOSA-Project,代码行数:13,代码来源:UnalignedPrefixInstruction.cs
示例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);
}
开发者ID:Boddlnagg,项目名称:MOSA-Project,代码行数:13,代码来源:BinaryComparisonInstruction.cs
示例16: 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);
// FIXME: Validate operands & verify instruction
ctx.Result = decoder.Compiler.CreateVirtualRegister(decoder.TypeSystem.BuiltIn.I4);
}
开发者ID:pacificIT,项目名称:MOSA-Project,代码行数:13,代码来源:RefanytypeInstruction.cs
示例17: 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);
// Push the address on the stack
ctx.Result = decoder.Compiler.CreateVirtualRegister(decoder.TypeSystem.BuiltIn.U);
}
开发者ID:yonglehou,项目名称:MOSA-Project,代码行数:13,代码来源:LocalallocInstruction.cs
示例18: 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);
// Push the address on the stack
ctx.Result = decoder.Compiler.CreateTemporary(BuiltInSigType.IntPtr);
}
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:13,代码来源:LocalallocInstruction.cs
示例19: 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 = decoder.DecodeByte();
ctx.Other = alignment;
}
开发者ID:illuminus86,项目名称:MOSA-Project,代码行数:13,代码来源:UnalignedPrefixInstruction.cs
示例20: 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.CreateTemporary(BuiltInSigType.Int32);
}
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:13,代码来源:BinaryComparisonInstruction.cs
注:本文中的IInstructionDecoder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论