예제 #1
0
        public void CallVirtual(MethodBase operand)
        {
            var methodInfo = operand;

            var interpreter = new CilMethodInterpreter(methodInfo);

            var methodData = new CallMethodVirtual(interpreter);

            CallMethodDataVirtual(methodInfo, methodData);
        }
예제 #2
0
        private void CallMethodDataVirtual(MethodBase methodInfo, CallMethodVirtual callMethodStatic)
        {
            if (HandleRuntimeHelpersMethod(methodInfo))
            {
                callMethodStatic.ExtractNeededValuesFromStack(_evaluator);
                AddOperation(callMethodStatic);
                return;
            }
            if (methodInfo.IsConstructor && methodInfo.DeclaringType == typeof(object))
            {
                return;
            }
            callMethodStatic.ExtractNeededValuesFromStack(_evaluator);


            if (!callMethodStatic.Info.IsStatic && callMethodStatic.Parameters.Count > 0)
            {
                //GetBestVirtualMatch not required as the appropriate method is called in CppHandleCalls and VirtualMethod
                //TODO: GetBestVirtualMatch does not work  with base class constructors
                // if(!methodInfo.IsConstructor && CallMethodStatic.Parameters[0].ComputedType().ClrType.DeclaringType!=methodInfo.DeclaringType)
                //  CallMethodStatic.Info = ClassHierarchyAnalysis.GetBestVirtualMatch(CallMethodStatic.Info,
                //      CallMethodStatic.Parameters[0].ComputedType().ClrType);
            }
            var declaringType = callMethodStatic.Info.DeclaringType;

            if (declaringType.IsSubclassOf(typeof(Delegate)))
            {
                var signature = declaringType.GetMethod("Invoke");
                DelegateManager.RegisterType(declaringType, signature);
            }

            if (!callMethodStatic.IsVoid)
            {
                var vreg = SetNewVReg();
                vreg.FixedType          = new TypeDescription(methodInfo.GetReturnType());
                callMethodStatic.Result = vreg;
            }
            if (callMethodStatic.Result != null)
            {
                callMethodStatic.Result.FixedType = new TypeDescription(methodInfo.GetReturnType());
            }
            AddOperation(callMethodStatic);
        }