本文整理汇总了C#中IInstructionDecoder.Decode方法的典型用法代码示例。如果您正苦于以下问题:C# IInstructionDecoder.Decode方法的具体用法?C# IInstructionDecoder.Decode怎么用?C# IInstructionDecoder.Decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IInstructionDecoder
的用法示例。
在下文中一共展示了IInstructionDecoder.Decode方法的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);
// 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");
}
}
示例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);
// Retrieve the number of branch targets
uint count;
decoder.Decode(out count);
ctx.Branch = new Branch(count + 1);
// Populate the array
for (uint i = 0; i < count; i++) {
decoder.Decode(out ctx.Branch.Targets[i]);
}
}
示例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);
// 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);
*/
}
示例4: 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(Context ctx, IInstructionDecoder decoder)
{
// Decode base classes first
base.Decode(ctx, decoder);
ushort argIdx;
// Opcode specific handling
switch (_opcode) {
case OpCode.Ldarg:
decoder.Decode(out argIdx);
break;
case OpCode.Ldarg_s: {
byte arg;
decoder.Decode(out arg);
argIdx = arg;
}
break;
case OpCode.Ldarg_0:
argIdx = 0;
break;
case OpCode.Ldarg_1:
argIdx = 1;
break;
case OpCode.Ldarg_2:
argIdx = 2;
break;
case OpCode.Ldarg_3:
argIdx = 3;
break;
default:
throw new System.NotImplementedException();
}
// Push the loaded value onto the evaluation stack
Operand parameterOperand = decoder.Compiler.GetParameterOperand(argIdx);
Operand result = LoadInstruction.CreateResultOperand(decoder, parameterOperand.StackType, parameterOperand.Type);
ctx.Operand1 = parameterOperand;
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);
// Opcode specific handling
ushort locIdx;
switch (_opcode) {
case OpCode.Ldloc:
decoder.Decode(out locIdx);
break;
case OpCode.Ldloc_s: {
byte loc;
decoder.Decode(out loc);
locIdx = loc;
}
break;
case OpCode.Ldloc_0:
locIdx = 0;
break;
case OpCode.Ldloc_1:
locIdx = 1;
break;
case OpCode.Ldloc_2:
locIdx = 2;
break;
case OpCode.Ldloc_3:
locIdx = 3;
break;
default:
throw new System.NotImplementedException();
}
// Push the loaded value onto the evaluation stack
Operand localVariableOperand = decoder.Compiler.GetLocalOperand(locIdx);
Operand result = LoadInstruction.CreateResultOperand(decoder, localVariableOperand.StackType, localVariableOperand.Type);
ctx.Operand1 = localVariableOperand;
ctx.Result = result;
}
示例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)
{
// Decode base classes first
base.Decode(ctx, decoder);
byte alignment;
decoder.Decode(out alignment);
ctx.Other = alignment;
}
示例7: 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(Context ctx, IInstructionDecoder decoder)
{
// Decode base classes first
base.Decode(ctx, decoder);
ushort argIdx;
// Opcode specific handling
switch (_opcode) {
case OpCode.Ldarg:
decoder.Decode(out argIdx);
break;
case OpCode.Ldarg_s: {
byte arg;
decoder.Decode(out arg);
argIdx = arg;
}
break;
case OpCode.Ldarg_0:
argIdx = 0;
break;
case OpCode.Ldarg_1:
argIdx = 1;
break;
case OpCode.Ldarg_2:
argIdx = 2;
break;
case OpCode.Ldarg_3:
argIdx = 3;
break;
default:
throw new NotImplementedException();
}
// Push the loaded value onto the evaluation stack
ctx.Result = decoder.Compiler.GetParameterOperand(argIdx);
ctx.Ignore = true;
}
示例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 base classes first
base.Decode(ctx, decoder);
byte nocheck;
decoder.Decode(out nocheck);
ctx.Other = nocheck;
}
示例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);
// Opcode specific handling
ushort locIdx;
switch (_opcode) {
case OpCode.Ldloc:
decoder.Decode(out locIdx);
break;
case OpCode.Ldloc_s: {
byte loc;
decoder.Decode(out loc);
locIdx = loc;
}
break;
case OpCode.Ldloc_0:
locIdx = 0;
break;
case OpCode.Ldloc_1:
locIdx = 1;
break;
case OpCode.Ldloc_2:
locIdx = 2;
break;
case OpCode.Ldloc_3:
locIdx = 3;
break;
default:
throw new NotImplementedException();
}
// Push the loaded value onto the evaluation stack
ctx.Result = decoder.Compiler.GetLocalOperand(locIdx);
ctx.Ignore = true;
}
示例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);
// Retrieve the provider token to check against
TokenTypes token;
decoder.Decode (out token);
throw new NotImplementedException ();
}
示例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);
ushort locIdx;
// Destination depends on the opcode
switch (_opcode) {
case OpCode.Stloc:
decoder.Decode(out locIdx);
break;
case OpCode.Stloc_s: {
byte loc;
decoder.Decode(out loc);
locIdx = loc;
}
break;
case OpCode.Stloc_0:
locIdx = 0;
break;
case OpCode.Stloc_1:
locIdx = 1;
break;
case OpCode.Stloc_2:
locIdx = 2;
break;
case OpCode.Stloc_3:
locIdx = 3;
break;
default:
throw new NotImplementedException();
}
ctx.Result = decoder.Compiler.GetLocalOperand(locIdx);
}
示例12: 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);
// Retrieve the provider token to check against
TokenTypes token;
decoder.Decode(out token);
ctx.Result = decoder.Compiler.CreateTemporary(new ClassSigType(token));
}
示例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);
ushort locIdx;
// Opcode specific handling
if (_opcode == OpCode.Ldloca_s) {
byte loc;
decoder.Decode(out loc);
locIdx = loc;
}
else {
decoder.Decode(out locIdx);
}
ctx.Operand1 = decoder.Compiler.GetLocalOperand(locIdx);
ctx.Result = decoder.Compiler.CreateTemporary(new RefSigType(ctx.Operand1.Type));
}
示例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);
ushort argIdx;
// Opcode specific handling
if (_opcode == OpCode.Ldarga_s) {
byte arg;
decoder.Decode(out arg);
argIdx = arg;
}
else {
decoder.Decode(out argIdx);
}
ctx.Operand1 = decoder.Compiler.GetParameterOperand(argIdx);
ctx.Result = decoder.Compiler.CreateTemporary(new RefSigType(ctx.Operand1.Type));
}
示例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);
// Retrieve a type reference from the immediate argument
// FIXME: Limit the token types
TokenTypes token;
decoder.Decode(out token);
throw new NotImplementedException();
//_typeRef = MetadataTypeReference.FromToken(decoder.Metadata, token);
}