本文整理汇总了C#中OpCode类的典型用法代码示例。如果您正苦于以下问题:C# OpCode类的具体用法?C# OpCode怎么用?C# OpCode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OpCode类属于命名空间,在下文中一共展示了OpCode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BinaryOperation
public BinaryOperation(string sOp, Expression x, Expression y)
{
operation = sOp;
opcode = StringToOpCode(sOp);
operand1 = x;
operand2 = y;
}
示例2: Packet
protected Packet( OpCode opCode )
{
if( !Enum.IsDefined( typeof( OpCode ), OpCode ) ) {
throw new ArgumentOutOfRangeException( "opCode" );
}
OpCode = opCode;
}
示例3: OpCodes
//wicky.patch.start
static OpCodes()
{
//Start from first index to ignore nop (onebyte)
for (int i = 1; i < OneByteOpCode.Length; i++)
{
//arglist: FE 00
if (OneByteOpCode[i].Op2 == 0x00 && OneByteOpCode[i].Code != Code.Arglist)
{
OneByteOpCode[i] = new OpCode(
0xff << 0 | (byte)i << 8 | (byte)Code.Unused << 16 | (byte)FlowControl.Next << 24,
(byte)OpCodeType.Primitive << 0 | (byte)OperandType.InlineNone << 8 | (byte)StackBehaviour.Pop0 << 16 | (byte)StackBehaviour.Push0 << 24);
}
}
//Start from first index to ignore arglist (twobyte)
for (int i = 1; i < TwoBytesOpCode.Length; i++)
{
//arglist: FE 00
if (TwoBytesOpCode[i].Op2 == 0x00 && TwoBytesOpCode[i].Code != Code.Arglist)
{
TwoBytesOpCode[i] = new OpCode(
0xfe << 0 | (byte)i << 8 | (byte)Code.Unused << 16 | (byte)FlowControl.Next << 24,
(byte)OpCodeType.Primitive << 0 | (byte)OperandType.InlineNone << 8 | (byte)StackBehaviour.Pop0 << 16 | (byte)StackBehaviour.Push0 << 24);
}
}
}
示例4: AddCodes
public static void AddCodes(NodeBase caller, BlockBase parent, NodeBase target, OpModule codes, string op, Addr32 dest)
{
if (target is TypeOf) target = (target as TypeOf).Target;
var v = target as Variant;
if (v != null && parent.GetFunction(v.Name) == null)
{
var fpname = (target as Variant).Name;
var fpt = Types.GetType(parent, fpname);
if (fpt == null || !fpt.Check())
throw caller.Abort("undefined type: {0}", fpname);
codes.AddCodesV(op, dest, codes.GetTypeObject(fpt));
return;
}
var tt = target.Type;
var tr = tt as TypeReference;
var tts = tt.Type as TypeStruct;
if (tr != null && (tr.IsArray || (tts != null && tts.IsClass)))
{
target.AddCodesV(codes, "mov", null);
var label = new OpCode();
codes.Add(I386.Test(Reg32.EAX, Reg32.EAX));
codes.Add(I386.Jcc(Cc.Z, label.Address));
codes.Add(I386.MovRA(Reg32.EAX, Addr32.NewRO(Reg32.EAX, -16)));
codes.Add(label);
codes.AddCodes(op, dest);
}
else
codes.AddCodesV(op, dest, codes.GetTypeObject(tt));
}
示例5: WriteCodes
public static void WriteCodes(BinaryWriter bw, OpCode[] ops)
{
for (int i = 0; i < ops.Length; i++)
{
bw.Write(ops[i].GetCodes());
}
}
示例6: Emit_UnknownOpCode_ThrowsNotSupportedException
public void Emit_UnknownOpCode_ThrowsNotSupportedException()
{
var ilGenerator = new ILGenerator(null);
var opCode = new OpCode(-1);
ExceptionAssert.Throws<NotSupportedException>(() => ilGenerator.Emit(opCode));
}
示例7: IsCall
static bool IsCall(OpCode opCode)
{
return opCode == OpCodes.Call ||
opCode == OpCodes.Callvirt ||
opCode == OpCodes.Calli ||
opCode == OpCodes.Ldftn;
}
示例8: StobjInstruction
/// <summary>
/// Initializes a new instance of the <see cref="StobjInstruction"/> class.
/// </summary>
/// <param name="opcode">The opcode.</param>
public StobjInstruction(OpCode opcode)
: base(opcode)
{
switch (opcode) {
case OpCode.Stind_i1:
_valueType = new SigType(CilElementType.I1);
break;
case OpCode.Stind_i2:
_valueType = new SigType(CilElementType.I2);
break;
case OpCode.Stind_i4:
_valueType = new SigType(CilElementType.I4);
break;
case OpCode.Stind_i8:
_valueType = new SigType(CilElementType.I8);
break;
case OpCode.Stind_r4:
_valueType = new SigType(CilElementType.R4);
break;
case OpCode.Stind_r8:
_valueType = new SigType(CilElementType.R8);
break;
case OpCode.Stind_i:
_valueType = new SigType(CilElementType.I);
break;
case OpCode.Stind_ref: // FIXME: Really object?
_valueType = new SigType(CilElementType.Object);
break;
default:
throw new NotImplementedException();
}
}
示例9: CompiledByte
public CompiledByte(OpCode op, Value a, Value b)
{
ushort[] output = compile(op,a,b);
for (int i = 0; i < output.Length; i++)
{
;
}
}
示例10: AssertOpCodeSequence
static void AssertOpCodeSequence(OpCode [] expected, MethodBody body)
{
var opcodes = body.Instructions.Select (i => i.OpCode).ToArray ();
Assert.AreEqual (expected.Length, opcodes.Length);
for (int i = 0; i < opcodes.Length; i++)
Assert.AreEqual (expected [i], opcodes [i]);
}
示例11: AddJumpBack
private void AddJumpBack(OpCode jumpOp, string jumpLabel)
{
// pop the most recently-added jump with the label
JumpPatch jump = mJumpBackPatches.Last(j => j.Label == jumpLabel);
mJumpBackPatches.Remove(jump);
mBytecode.Write(jumpOp, jump.Location);
}
示例12: Instruction
public Instruction(byte[] code, int offset, int length, OpCode oc, TokenResolver resolver)
{
this.code = code;
this.offset = offset;
this.length = length;
this.oc = oc;
this.resolver = resolver;
}
示例13: Add
public void Add(Token token, OpCode op, string stringValue, params int[] args)
{
List<int> nums = new List<int>(args);
nums.Insert(0, (int)op);
this.byteCode.Add(nums.ToArray());
this.tokens.Add(token);
this.stringArgs.Add(stringValue);
}
示例14: AddJump
private void AddJump(OpCode jumpOp, string jumpLabel)
{
// add the jump and a blank space for the destination
mBytecode.Write(jumpOp, 0);
// patch the destination later
mJumpPatches.Add(new JumpPatch(jumpLabel, mBytecode.Position - 4));
}
示例15: Instruction
public Instruction(OpCode opcode, int index, params Operand[] operands)
{
OpCode = opcode;
Operands = operands;
Index = index;
}