public override void VisitInlineMethodInstruction(InlineMethodInstruction inlineMethodInstruction) { OverwriteInt32(_ilInfo.GetTokenFor( inlineMethodInstruction.Method.MethodHandle, inlineMethodInstruction.Method.DeclaringType.TypeHandle), inlineMethodInstruction.Offset + inlineMethodInstruction.OpCode.Size); }
public override void VisitInlineMethodInstruction(InlineMethodInstruction inlineMethodInstruction) { MethodInstructionWithReflectionEmit instruction = new MethodInstructionWithReflectionEmit( inlineMethodInstruction.OpCode, inlineMethodInstruction.Token, inlineMethodInstruction.Method); instructions.Add(instruction); }
public override void VisitInlineMethodInstruction(InlineMethodInstruction inlineMethodInstruction) { if (inlineMethodInstruction.Method.MethodHandle == _ra_getter.MethodHandle) { EmitSourceAccessCode(); } else { base.VisitInlineMethodInstruction(inlineMethodInstruction); } }
public override void VisitInlineMethodInstruction(InlineMethodInstruction inlineMethodInstruction) { MethodBase method = inlineMethodInstruction.Method; Process(inlineMethodInstruction, method); if (method == Call_Base) { inlineMethodInstruction.Method = method; for (int i = 0; i <= parameterInfos.Length; i++) { LoadReference(ilGenerator, i); } ilGenerator.Emit(OpCodes.Call, methodToOverride); // call the method non-virtually return; } else if (method == Return_Parameter) { if (returnType == typeof(void)) { ilGenerator.Emit(OpCodes.Pop); } else { if (returnType.IsValueType) { ilGenerator.Emit(OpCodes.Unbox, returnType); ilGenerator.Emit(OpCodes.Ldobj, returnType); } else { ilGenerator.Emit(OpCodes.Castclass, returnType); } StoreLocation(ilGenerator, localVariables.Count); if (this.handlingExceptions.Count > 0) { ilGenerator.Emit(OpCodes.Leave, returnLabel); } else { ilGenerator.Emit(OpCodes.Br, returnLabel); } } return; } ilGenerator.Emit(inlineMethodInstruction.OpCode, (MethodInfo)method); }
public override void VisitInlineMethodInstruction(InlineMethodInstruction inlineMethodInstruction) { base.VisitInlineMethodInstruction(inlineMethodInstruction); }
public virtual void VisitInlineMethodInstruction(InlineMethodInstruction inlineMethodInstruction) { }
public override void VisitInlineMethodInstruction(InlineMethodInstruction inlineMethodInstruction) { collector.Process(inlineMethodInstruction, formatProvider.Int32ToHex(inlineMethodInstruction.Token)); }
public static void GetAllExceptions(MethodBase method, HashSet <Type> exceptionTypes, HashSet <MethodBase> visitedMethods, Type[] localVars, Stack <Type> stack, int depth) { var ilReader = new ILReader.ILReader(method); ILInstruction[] allInstructions = ilReader.ToArray(); for (int i = 0; i < allInstructions.Length; i++) { ILInstruction instruction = allInstructions[i]; var inlineMethodInstruction = instruction as InlineMethodInstruction; if (inlineMethodInstruction != null) { InlineMethodInstruction methodInstruction = inlineMethodInstruction; if (!visitedMethods.Contains(methodInstruction.Method)) { visitedMethods.Add(methodInstruction.Method); GetAllExceptions(methodInstruction.Method, exceptionTypes, visitedMethods, localVars, stack, depth + 1); } MethodBase curMethod = methodInstruction.Method; if (curMethod is ConstructorInfo) { stack.Push(curMethod.DeclaringType); } else if (method is MethodInfo) { stack.Push(((MethodInfo)curMethod).ReturnParameter.ParameterType); } } else { var inlineFieldInstruction = instruction as InlineFieldInstruction; if (inlineFieldInstruction != null) { InlineFieldInstruction fieldInstruction = inlineFieldInstruction; stack.Push(fieldInstruction.Field.FieldType); } else if (instruction is ShortInlineBrTargetInstruction) { } else if (instruction is InlineBrTargetInstruction) { } else { switch (instruction.OpCode.Value) { // ld* case 0x06: stack.Push(localVars[0]); break; case 0x07: stack.Push(localVars[1]); break; case 0x08: stack.Push(localVars[2]); break; case 0x09: stack.Push(localVars[3]); break; case 0x11: { var index = (ushort)allInstructions[i + 1].OpCode.Value; stack.Push(localVars[index]); break; } // st* case 0x0A: localVars[0] = stack.Pop(); break; case 0x0B: localVars[1] = stack.Pop(); break; case 0x0C: localVars[2] = stack.Pop(); break; case 0x0D: localVars[3] = stack.Pop(); break; case 0x13: { var index = (ushort)allInstructions[i + 1].OpCode.Value; localVars[index] = stack.Pop(); break; } // throw case 0x7A: if (stack.Peek() == null) { break; } if (!typeof(Exception).IsAssignableFrom(stack.Peek())) { //var ops = allInstructions.Select(f => f.OpCode).ToArray(); //break; } exceptionTypes.Add(stack.Pop()); break; default: switch (instruction.OpCode.StackBehaviourPop) { case StackBehaviour.Pop0: break; case StackBehaviour.Pop1: case StackBehaviour.Popi: case StackBehaviour.Popref: case StackBehaviour.Varpop: if (stack.Count > 0) { stack.Pop(); } break; case StackBehaviour.Pop1_pop1: case StackBehaviour.Popi_pop1: case StackBehaviour.Popi_popi: case StackBehaviour.Popi_popi8: case StackBehaviour.Popi_popr4: case StackBehaviour.Popi_popr8: case StackBehaviour.Popref_pop1: case StackBehaviour.Popref_popi: stack.Pop(); stack.Pop(); break; case StackBehaviour.Popref_popi_pop1: case StackBehaviour.Popref_popi_popi: case StackBehaviour.Popref_popi_popi8: case StackBehaviour.Popref_popi_popr4: case StackBehaviour.Popref_popi_popr8: case StackBehaviour.Popref_popi_popref: stack.Pop(); stack.Pop(); stack.Pop(); break; } switch (instruction.OpCode.StackBehaviourPush) { case StackBehaviour.Push0: break; case StackBehaviour.Push1: case StackBehaviour.Pushi: case StackBehaviour.Pushi8: case StackBehaviour.Pushr4: case StackBehaviour.Pushr8: case StackBehaviour.Pushref: case StackBehaviour.Varpush: stack.Push(null); break; case StackBehaviour.Push1_push1: stack.Push(null); stack.Push(null); break; } break; } } } } }