internal MethodEx(MethodBase method, ILMethodDecoder decoder) { this.method = method; ArrayList list = new ArrayList(); locals = new LocalVariables(decoder.GetLocalVarTypes()); while (!decoder.EndOfCode()) { list.Add(new Instruction(decoder)); } body = new Instruction [list.Count]; list.CopyTo(body); int[] offsetsMap = new int [decoder.CodeSize]; for (int i = 0; i < body.Length; i++) { offsetsMap[body[i].startOffset] = i; } foreach (Instruction instr in body) { instr.FixOffset(offsetsMap); } ehClauses = new EHClausesArray(decoder.GetEHDecoder(), offsetsMap); verified = Verifier.Check(this); }
internal MethodEx(MethodBase method, ILMethodDecoder decoder) { this.method = method; ArrayList list = new ArrayList(); locals = new LocalVariables(decoder.GetLocalVarTypes()); while (! decoder.EndOfCode()) list.Add(new Instruction(decoder)); body = new Instruction [list.Count]; list.CopyTo(body); int[] offsetsMap = new int [decoder.CodeSize]; for (int i = 0; i < body.Length; i++) offsetsMap[body[i].startOffset] = i; foreach (Instruction instr in body) instr.FixOffset(offsetsMap); ehClauses = new EHClausesArray(decoder.GetEHDecoder(),offsetsMap); verified = Verifier.Check(this); }
internal Instruction(ILMethodDecoder decoder) { stack = null; startOffset = decoder.GetOffset(); int code = decoder.ReadCode(); Info info = instructions[code]; if (info.code == InstructionCode.TAIL) { hasTail = true; code = decoder.ReadCode(); info = instructions[code]; } else hasTail = false; hasUnaligned = false; hasVolatile = false; unalignedParam = 0; while (info.code == InstructionCode.VOLATILE || info.code == InstructionCode.UNALIGNED) { if (info.code == InstructionCode.VOLATILE) hasVolatile = true; else { hasUnaligned = true; unalignedParam = (Int32)(decoder.ReadUint8()); } code = decoder.ReadCode(); info = instructions[code]; } instructionCode = info.code; ovfFlag = info.ovf; unFlag = info.un; typeSuffix = info.typeSuffix; name = info.name; paramIsOffset = false; switch (info.pType) { case ParamType.pNone: if (info.apType >= AdditionalParamType.apU0 && info.apType <= AdditionalParamType.apU3) param = (Int32)(info.apType-AdditionalParamType.apU0); if (info.apType >= AdditionalParamType.apIM1 && info.apType <= AdditionalParamType.apI8) param = (Int32)(info.apType-AdditionalParamType.apIM1-1); break; case ParamType.pInt8: param = (Int32)(decoder.ReadInt8()); if (info.apType == AdditionalParamType.apOfs) paramIsOffset = true; break; case ParamType.pInt32: param = decoder.ReadInt32(); if (info.apType == AdditionalParamType.apOfs) paramIsOffset = true; break; case ParamType.pInt64: param = decoder.ReadInt64(); break; case ParamType.pUint8: param = (Int32)(decoder.ReadUint8()); break; case ParamType.pUint16: param = (Int32)(decoder.ReadUint16()); break; case ParamType.pFloat32: param = (double)(decoder.ReadFloat32()); break; case ParamType.pFloat64: param = decoder.ReadFloat64(); break; case ParamType.pToken: param = decoder.ReadToken(); break; case ParamType.pSwitch: param = decoder.ReadSwitch(); paramIsOffset = true; break; } afterEndOffset = decoder.GetOffset(); }