示例#1
0
        private void CallMethodData(MethodBase methodInfo, MethodData methodData, OperationKind operationKind,
                                    CrRuntimeLibrary crRuntime)
        {
            if (HandleRuntimeHelpersMethod(methodInfo))
            {
                methodData.ExtractNeededValuesFromStack(_evaluator);
                AddOperation(OperationKind.CallRuntime, methodData);
                return;
            }
            if (methodInfo.IsConstructor && methodInfo.DeclaringType == typeof(object))
            {
                return;
            }
            methodData.ExtractNeededValuesFromStack(_evaluator);

            if (!methodData.Info.IsStatic && methodData.Parameters.Count > 0)
            {
                methodData.Info = ClassHierarchyAnalysis.GetBestVirtualMatch(methodData.Info,
                                                                             methodData.Parameters[0].ComputedType().ClrType);
            }
            var declaringType = methodData.Info.DeclaringType;

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

            if (!methodData.IsVoid)
            {
                var vreg = SetNewVReg();
                vreg.FixedType    = new TypeDescription(methodInfo.GetReturnType());
                methodData.Result = vreg;
            }
            methodData.FixedType = new TypeDescription(methodInfo.GetReturnType());
            AddOperation(operationKind, methodData);
        }
        public void Call(object operand, EvaluatorStack evaluator)
        {
            var methodInfo = (MethodBase)operand;
            var methodData = new MethodData(methodInfo);


            methodData.ExtractNeededValuesFromStack(evaluator);
            if (!methodData.IsVoid)
            {
                var vreg = SetNewVReg(evaluator);
                vreg.FixedType    = methodInfo.GetReturnType();
                methodData.Result = vreg;
            }
            methodData.FixedType = methodInfo.GetReturnType();
            AddOperation(SimpleOperations.LocalOperation.Kinds.Call, methodData);
        }