Esempio n. 1
0
        public bool IsSameMethod(IMethodPointer method)
        {
            CustomMethodPointer cp = method as CustomMethodPointer;

            if (cp != null)
            {
                return(cp.WholeId == this.WholeId);
            }
            return(false);
        }
Esempio n. 2
0
        public object Clone()
        {
            CustomMethodPointer cp = new CustomMethodPointer(_method, _holder);

            return(cp);
        }
        public void Compile(ActionBranch currentAction, ActionBranch nextAction, ILimnorCodeCompiler compiler, IMethodCompile methodToCompile, CodeMemberMethod method, CodeStatementCollection statements, CodeExpressionCollection parameters, IObjectPointer returnReceiver, bool debug)
        {
            if (_method == null)
            {
                return;
            }
            IObjectPointer op = _method.VariablePointer;

            if (op == null)
            {
                return;
            }
            ClassPointer        cp  = op as ClassPointer;
            CustomMethodPointer cmp = null;
            MethodClass         mc  = null;

            if (cp != null)
            {
                mc = cp.GetCustomMethodById(_method.MethodId);
                if (mc != null)
                {
                    cmp = new CustomMethodPointer(mc, _holder);
                    cmp.SetParameterExpressions(_parameterExpressions);
                    cmp.Compile(currentAction, nextAction, compiler, methodToCompile, method, statements, parameters, returnReceiver, debug);
                    return;
                }
            }
            CodeExpression cmi = null;

            if (_method != null)
            {
                CodeMethodReferenceExpression mref = (CodeMethodReferenceExpression)_method.GetReferenceCode(methodToCompile, statements, false);
                CodeMethodInvokeExpression    cmim = new CodeMethodInvokeExpression();
                cmim.Method = mref;
                cmim.Parameters.AddRange(parameters);
                cmi = cmim;
            }
            bool useOutput = false;

            if (!NoReturn && nextAction != null && nextAction.UseInput)
            {
                CodeVariableDeclarationStatement output = new CodeVariableDeclarationStatement(
                    currentAction.OutputType.TypeString, currentAction.OutputCodeName, cmi);
                statements.Add(output);
                cmi       = new CodeVariableReferenceExpression(currentAction.OutputCodeName);
                useOutput = true;
            }
            if (_method.HasReturn && returnReceiver != null)
            {
                CodeExpression cr = returnReceiver.GetReferenceCode(methodToCompile, statements, true);
                if (_method.ReturnType != null)
                {
                    Type          target;
                    IClassWrapper wrapper = returnReceiver as IClassWrapper;
                    if (wrapper != null)
                    {
                        target = wrapper.WrappedType;
                    }
                    else
                    {
                        target = returnReceiver.ObjectType;
                    }
                    Type dt;
                    if (useOutput)
                    {
                        dt = currentAction.OutputType.BaseClassType;
                    }
                    else
                    {
                        dt = _method.ReturnType.BaseClassType;
                    }
                    CompilerUtil.CreateAssignment(cr, target, cmi, dt, statements, true);
                }
                else
                {
                    CodeAssignStatement cas = new CodeAssignStatement(cr, cmi);
                    statements.Add(cas);
                }
            }
            else
            {
                if (!useOutput)
                {
                    CodeExpressionStatement ces = new CodeExpressionStatement(cmi);
                    statements.Add(ces);
                }
            }
        }