public CodeExpression ExportCode(IMethodCompile method)
 {
     if (_hasData && _exp != null)
     {
         MathNodeNumber mn = _exp[1] as MathNodeNumber;
         if (mn == null || !mn.IsPlaceHolder)
         {
             return(_exp.ExportCode(method));
         }
     }
     return(null);
 }
 public CodeExpression ExportCode(MethodType method)
 {
     return(mathExp.ExportCode(method));
 }
        public override bool OnExportCode(ActionBranch previousAction, ActionBranch nextAction, ILimnorCodeCompiler compiler, CodeMemberMethod method, CodeStatementCollection statements)
        {
            CodeExpression c;

            if (_logicExpression == null)
            {
                c = new CodePrimitiveExpression(true);
            }
            else
            {
                _logicExpression.PrepareForCompile(this.Method);
                c = _logicExpression.ExportCode(this.Method);
            }
            CodeIterationStatement cis = new CodeIterationStatement();

            cis.TestExpression = c;
            if (_initAction != null && _initAction.Action != null)
            {
                CodeStatementCollection sts = new CodeStatementCollection();
                _initAction.Action.ExportCode(null, null, compiler, Method, method, sts, false);
                if (sts.Count > 0)
                {
                    for (int i = 0; i < sts.Count; i++)
                    {
                        if (!(sts[i] is CodeCommentStatement))
                        {
                            cis.InitStatement = sts[i];
                            break;
                        }
                    }
                }
                else
                {
                    cis.InitStatement = new CodeSnippetStatement();
                }
            }
            else
            {
                cis.InitStatement = new CodeSnippetStatement();
            }
            if (_increAction != null && _increAction.Action != null)
            {
                CodeStatementCollection sts = new CodeStatementCollection();
                _increAction.Action.ExportCode(null, null, compiler, Method, method, sts, false);
                if (sts.Count > 0)
                {
                    for (int i = 0; i < sts.Count; i++)
                    {
                        if (!(sts[i] is CodeCommentStatement))
                        {
                            cis.IncrementStatement = sts[i];
                            break;
                        }
                    }
                }
                else
                {
                    cis.IncrementStatement = new CodeSnippetStatement();
                }
            }
            else
            {
                cis.IncrementStatement = new CodeSnippetStatement();
            }
            statements.Add(cis);
            if (_iconList != null)
            {
                foreach (ComponentIcon ci in _iconList)
                {
                    ComponentIconLocal cil = ci as ComponentIconLocal;
                    if (cil != null && cil.ScopeGroupId == this.BranchId)
                    {
                        cil.LocalPointer.AddVariableDeclaration(cis.Statements);
                    }
                }
            }
            Method.SubMethod.Push(this);
            CompilerUtil.AddSubMethod(method, this);
            bool bRet = base.OnExportCode(previousAction, nextAction, compiler, method, cis.Statements);

            Method.SubMethod.Pop();
            bRet = CompilerUtil.FinishSubMethod(method, this, cis.Statements, bRet);
            return(bRet);
        }