static InstructionPushPopInfo?GetInstructionPops(InstructionVM instr) { var code = instr.Code; if (code == Code.Pop || code == Code.Nop) { return(null); } int pushes, pops; instr.CalculateStackUsage(out pushes, out pops); if (pops < 0) { return(null); } if (pushes == 1 && (code == Code.Call || code == Code.Callvirt || code == Code.Calli)) { return(new InstructionPushPopInfo(pops, GetMethodSig(instr.InstructionOperandVM.Other).GetRetType())); } if (pushes == 1 && code == Code.Newobj) { var ctor = instr.InstructionOperandVM.Other as IMethod; return(new InstructionPushPopInfo(pops, ctor == null ? null : ctor.DeclaringType.ToTypeSig())); } if (pushes != 0) { return(null); } return(new InstructionPushPopInfo(pops)); }
static void WriteShort(this ITextOutput output, InstructionVM instr) { output.Write(instr.Index.ToString(), TextTokenType.Number); output.WriteSpace(); output.Write('(', TextTokenType.Operator); output.Write(string.Format("{0:X4}", instr.Offset), TextTokenType.Number); output.Write(')', TextTokenType.Operator); }
static void WriteShort(this ITextColorWriter output, InstructionVM instr) { output.Write(BoxedTextColor.Number, instr.Index.ToString()); output.WriteSpace(); output.Write(BoxedTextColor.Punctuation, "("); output.Write(BoxedTextColor.Number, string.Format("{0:X4}", instr.Offset)); output.Write(BoxedTextColor.Punctuation, ")"); }
static void WriteShort(this ISyntaxHighlightOutput output, InstructionVM instr) { output.Write(instr.Index.ToString(), TextTokenKind.Number); output.WriteSpace(); output.Write("(", TextTokenKind.Operator); output.Write(string.Format("{0:X4}", instr.Offset), TextTokenKind.Number); output.Write(")", TextTokenKind.Operator); }
static void WriteLong(this ITextOutput output, InstructionVM instr) { output.WriteShort(instr); output.WriteSpace(); output.Write(instr.Code.ToOpCode().Name, TextTokenType.OpCode); output.WriteSpace(); Write(output, instr.InstructionOperandVM); }
static void WriteShort(this ITextColorWriter output, InstructionVM instr) { output.Write(BoxedTextColor.Number, instr.Index.ToString()); output.WriteSpace(); output.Write(BoxedTextColor.Punctuation, "("); output.Write(BoxedTextColor.Label, instr.Offset.ToString("X4")); output.Write(BoxedTextColor.Punctuation, ")"); }
static void WriteLong(this ITextColorWriter output, InstructionVM instr) { output.WriteShort(instr); output.WriteSpace(); output.Write(BoxedTextColor.OpCode, instr.Code.ToOpCode().Name); output.WriteSpace(); Write(output, instr.InstructionOperandVM); }
public InstructionVM Import(ModuleDef ownerModule) { var instr = new InstructionVM(); instr.Code = Code; instr.InstructionOperandVM.ImportFrom(ownerModule, InstructionOperandVM); instr.Offset = offset; return(instr); }
static InstructionVM RemoveNullInstance(InstructionVM vm) { Debug.Assert(vm != null); if (vm == null || vm == InstructionVM.Null) { return(null); } return(vm); }
public ExceptionHandlerOptions(Dictionary<object, object> ops, ExceptionHandler eh) { this.TryStart = (InstructionVM)BodyUtils.TryGetVM(ops, eh.TryStart); this.TryEnd = (InstructionVM)BodyUtils.TryGetVM(ops, eh.TryEnd); this.FilterStart = (InstructionVM)BodyUtils.TryGetVM(ops, eh.FilterStart); this.HandlerStart = (InstructionVM)BodyUtils.TryGetVM(ops, eh.HandlerStart); this.HandlerEnd = (InstructionVM)BodyUtils.TryGetVM(ops, eh.HandlerEnd); this.CatchType = eh.CatchType; this.HandlerType = eh.HandlerType; }
public ExceptionHandlerOptions(Dictionary <object, object> ops, ExceptionHandler eh) { this.TryStart = (InstructionVM)BodyUtils.TryGetVM(ops, eh.TryStart); this.TryEnd = (InstructionVM)BodyUtils.TryGetVM(ops, eh.TryEnd); this.FilterStart = (InstructionVM)BodyUtils.TryGetVM(ops, eh.FilterStart); this.HandlerStart = (InstructionVM)BodyUtils.TryGetVM(ops, eh.HandlerStart); this.HandlerEnd = (InstructionVM)BodyUtils.TryGetVM(ops, eh.HandlerEnd); this.CatchType = eh.CatchType; this.HandlerType = eh.HandlerType; }
public object Clone() { var inst = new InstructionVM(ownerModule); inst.Code = this.Code; inst.InstructionOperandVM.InitializeFrom(this.InstructionOperandVM); inst.SequencePoint = this.SequencePoint; return(inst); }
public IIndexedItem Clone() { var instr = new InstructionVM(); instr.Code = Code; instr.InstructionOperandVM.InitializeFrom(InstructionOperandVM); instr.SequencePoint = SequencePoint; instr.Offset = offset; return(instr); }
public static object ToOperandVM(Dictionary <object, object> ops, object operand) { if (operand is IList <Instruction> targets) { var newTargets = new InstructionVM[targets.Count]; for (int i = 0; i < newTargets.Length; i++) { newTargets[i] = (InstructionVM)TryGetVM(ops, (object)targets[i] ?? InstructionVM.Null); } return(newTargets); } return(TryGetVM(ops, operand)); }
public void ImportFrom(ModuleDef ownerModule, InstructionOperandVM other) { this.InstructionOperandType = other.InstructionOperandType; switch (other.InstructionOperandType) { case MethodBody.InstructionOperandType.None: break; case MethodBody.InstructionOperandType.SByte: SByte.StringValue = other.SByte.StringValue; break; case MethodBody.InstructionOperandType.Byte: Byte.StringValue = other.Byte.StringValue; break; case MethodBody.InstructionOperandType.Int32: Int32.StringValue = other.Int32.StringValue; break; case MethodBody.InstructionOperandType.Int64: Int64.StringValue = other.Int64.StringValue; break; case MethodBody.InstructionOperandType.Single: Single.StringValue = other.Single.StringValue; break; case MethodBody.InstructionOperandType.Double: Double.StringValue = other.Double.StringValue; break; case MethodBody.InstructionOperandType.String: String.StringValue = other.String.StringValue; break; case MethodBody.InstructionOperandType.Field: Other = Import(ownerModule, other.Other); break; case MethodBody.InstructionOperandType.Method: Other = Import(ownerModule, other.Other); break; case MethodBody.InstructionOperandType.Token: Other = Import(ownerModule, other.Other); break; case MethodBody.InstructionOperandType.Type: Other = Import(ownerModule, other.Other); break; case MethodBody.InstructionOperandType.MethodSig: Other = Import(ownerModule, other.Other); break; case MethodBody.InstructionOperandType.BranchTarget: OperandListItem = InstructionVM.Null; break; case MethodBody.InstructionOperandType.SwitchTargets: Other = new InstructionVM[0]; break; case MethodBody.InstructionOperandType.Local: OperandListItem = LocalVM.Null; break; case MethodBody.InstructionOperandType.Parameter: OperandListItem = BodyUtils.NullParameter; break; default: throw new InvalidOperationException(); } }
public SwitchInstructionVM(InstructionVM instr) => InstructionVM = instr;
public SwitchInstructionVM(InstructionVM instr) { this.instr = instr; }
static InstructionVM RemoveNullInstance(InstructionVM vm) { Debug.Assert(vm != null); if (vm == null || vm == InstructionVM.Null) return null; return vm; }
public IIndexedItem Clone() { var instr = new InstructionVM(); instr.Code = Code; instr.InstructionOperandVM.InitializeFrom(InstructionOperandVM); instr.SequencePoint = SequencePoint; instr.Offset = offset; return instr; }
public SwitchInstructionVM(InstructionVM instr) { InstructionVM = instr; }
public InstructionVM Import(ModuleDef ownerModule) { var instr = new InstructionVM(); instr.Code = Code; instr.InstructionOperandVM.ImportFrom(ownerModule, InstructionOperandVM); instr.Offset = offset; return instr; }
public object Clone() { var inst = new InstructionVM(ownerModule); inst.Code = this.Code; inst.InstructionOperandVM.InitializeFrom(this.InstructionOperandVM); inst.SequencePoint = this.SequencePoint; return inst; }