public void Init(CLRSharp.ICLRSharp_Environment env) { if (bInited) { return; } if (bodyNative.HasVariables) { typelistForLoc = new MethodParamList(env, bodyNative.Variables); } for (int i = 0; i < bodyNative.Instructions.Count; i++) { var code = bodyNative.Instructions[i]; OpCode c = new OpCode(); c.code = (CodeEx)(int)code.OpCode.Code; c.addr = code.Offset; if (code.SequencePoint != null) { if (debugDoc == null) { debugDoc = new Dictionary <string, int>(); } if (debugDoc.ContainsKey(code.SequencePoint.Document.Url) == false) { debugDoc.Add(code.SequencePoint.Document.Url, code.SequencePoint.StartLine); } c.debugline = code.SequencePoint.StartLine; } this.opCodes.Add(c); addr[c.addr] = i;; } var context = ThreadContext.activeContext; for (int i = 0; i < bodyNative.Instructions.Count; i++) { OpCode c = opCodes[i]; var code = bodyNative.Instructions[i]; c.InitToken(context, this, code.Operand); } bInited = true; }
public ILMethod(ILType type, Mono.Cecil.MethodDefinition method, ILogger logger = null) { this.method = method; if (method != null) { returntype = method.ReturnType.FullName; if (method.HasParameters) { hasParam = true; foreach (var p in method.Parameters) { string paramtype = p.ParameterType.FullName; try { var _type = p.ParameterType.Resolve(); foreach (var i in _type.Interfaces) { if (i.InterfaceType.Name == "IApiInterface") { paramtype = "IInteropInterface"; } } } catch { } this.paramtypes.Add(new NeoParam(p.Name, paramtype)); } } if (method.HasBody) { var bodyNative = method.Body; if (bodyNative.HasVariables) { foreach (var v in bodyNative.Variables) { var indexname = v.VariableType.Name + ":" + v.Index; this.body_Variables.Add(new NeoParam(indexname, v.VariableType.FullName)); } } for (int i = 0; i < bodyNative.Instructions.Count; i++) { var code = bodyNative.Instructions[i]; OpCode c = new OpCode { code = (CodeEx)(int)code.OpCode.Code, addr = code.Offset }; var sp = method.DebugInformation.GetSequencePoint(code); if (sp != null) { c.debugcode = sp.Document.Url; c.debugline = sp.StartLine; } c.InitToken(code.Operand); this.body_Codes.Add(c.addr, c); } } } }