public override IEnumerable GetValues() { yield return TokenString("Name", row.NameString); yield return Value("Flags", row.Flags.ToString()); yield return Value("ImplFlags", row.ImplFlags.ToString()); yield return Value("ParamList", row.ParamList); yield return Value("Rva", row.Rva.ToString()); MethodSignature signature = new MethodSignature(Metadata, row.SignatureBlob); yield return Value("Signature", signature.ToString()); if (row.Rva != 0) { var code = MetadataModule.GetInstructionStream((long)row.Rva); var codeReader = new EndianAwareBinaryReader(code, Endianness.Little); var header = new MethodHeader(codeReader); if (header.LocalVarSigTok.RID != 0) { yield return Value("LocalVarSigTok", header.LocalVarSigTok.ToString()); StandAloneSigRow standAlongSigRow = Metadata.ReadStandAloneSigRow(header.LocalVarSigTok); var local = new LocalVariableSignature(Metadata, standAlongSigRow.SignatureBlob); yield return Value("Method Header", local.ToString()); } } }
/// <summary> /// Initializes a new instance of the <see cref="LocalVariableSignature"/> class. /// </summary> /// <param name="provider">The provider.</param> /// <param name="token">The token.</param> /// <param name="genericArguments">The generic arguments.</param> public LocalVariableSignature(LocalVariableSignature signature, SigType[] genericArguments) : base(signature.Token) { locals = new VariableSignature[signature.locals.Length]; for (int i = 0; i < signature.locals.Length; i++) locals[i] = new VariableSignature(signature.locals[i], genericArguments); }
/// <summary> /// Performs stage specific processing on the compiler context. /// </summary> void IMethodCompilerStage.Run() { if (plugSystem != null) { RuntimeMethod plugMethod = plugSystem.GetPlugMethod(this.methodCompiler.Method); if (plugMethod != null) { SymbolOperand plugSymbol = SymbolOperand.FromMethod(plugMethod); Context ctx = new Context(instructionSet); ctx.AppendInstruction(IR.IRInstruction.Jmp, null, plugSymbol); ctx.Label = -1; basicBlocks.CreateBlock(BasicBlock.PrologueLabel, ctx.Index); return; } } using (Stream code = methodCompiler.GetInstructionStream()) { using (codeReader = new EndianAwareBinaryReader(code, true)) { MethodHeader header = ReadMethodHeader(codeReader); if (header.LocalsSignature.RID != 0) { StandAloneSigRow row = methodCompiler.Method.Module.MetadataModule.Metadata.ReadStandAloneSigRow(header.LocalsSignature); LocalVariableSignature localsSignature; if (methodCompiler.Method.DeclaringType is CilGenericType) { localsSignature = new LocalVariableSignature(methodCompiler.Method.Module.MetadataModule.Metadata, row.SignatureBlobIdx, (methodCompiler.Method.DeclaringType as CilGenericType).GenericArguments); } else { localsSignature = new LocalVariableSignature(methodCompiler.Method.Module.MetadataModule.Metadata, row.SignatureBlobIdx); } var declaringType = this.methodCompiler.Method.DeclaringType; var locals = localsSignature.Locals; for (var i = 0; i < locals.Length; ++i) { var local = locals[i]; if (local.Type is GenericInstSigType && declaringType is CilGenericType) { var genericInstSigType = local.Type as GenericInstSigType; var genericArguments = methodCompiler.AssemblyCompiler.GenericTypePatcher.CloseGenericArguments((declaringType as CilGenericType).GenericArguments, genericInstSigType.GenericArguments); local = new VariableSignature(locals[i], genericArguments); } } methodCompiler.SetLocalVariableSignature(localsSignature); } /* Decode the instructions */ Decode(methodCompiler, header); } } }
/// <summary> /// Sets the signature of local variables in the method. /// </summary> /// <param name="localVariableSignature">The local variable signature of the _method.</param> public void SetLocalVariableSignature(LocalVariableSignature localVariableSignature) { if (localVariableSignature == null) throw new ArgumentNullException(@"localVariableSignature"); localsSig = localVariableSignature; EvaluateLocalVariables(); }
/// <summary> /// Sets the signature of local variables in the method. /// </summary> /// <param name="localVariableSignature">The local variable signature of the _method.</param> public void SetLocalVariableSignature(LocalVariableSignature localVariableSignature) { if (localVariableSignature == null) throw new ArgumentNullException(@"localVariableSignature"); localsSig = localVariableSignature; locals = new Operand[localsSig.Locals.Length]; nextStackSlot = locals.Length + 1; }