public override void ExportJavaScriptCode(ActionBranch currentAction, ActionBranch nextAction, StringCollection jsCode, StringCollection methodToCompile, JsMethodCompiler data)
        {
            IMathExpression mathExp = MathExp;

            if (mathExp != null)
            {
                string ce = mathExp.ReturnJavaScriptCodeExpression(methodToCompile);
                if (!string.IsNullOrEmpty(ce))
                {
                    string target = null;
                    string output = null;
                    if (nextAction != null)
                    {
                        if (nextAction.UseInput)
                        {
                            methodToCompile.Add("var ");
                            methodToCompile.Add(currentAction.OutputCodeName);
                            methodToCompile.Add("=");
                            methodToCompile.Add(ce);
                            methodToCompile.Add(";\r\n");
                            output = currentAction.OutputCodeName;
                        }
                    }
                    IVariable v = mathExp.OutputVariable;
                    if (v != null)
                    {
                        string ceCondition = null;
                        if (Condition != null)
                        {
                            ceCondition = Condition.CreateJavaScriptCode(methodToCompile);
                        }
                        target = v.ExportJavaScriptCode(methodToCompile);
                        string jsLine;
                        if (output != null)
                        {
                            jsLine = string.Format(System.Globalization.CultureInfo.InvariantCulture,
                                                   "{0}={1};\r\n", target, currentAction.OutputCodeName);
                        }
                        else
                        {
                            jsLine = string.Format(System.Globalization.CultureInfo.InvariantCulture,
                                                   "{0}={1};\r\n", target, ce);
                        }
                        if (string.IsNullOrEmpty(ceCondition))
                        {
                            methodToCompile.Add(jsLine);
                        }
                        else
                        {
                            methodToCompile.Add("if(");
                            methodToCompile.Add(ceCondition);
                            methodToCompile.Add(")\r\n{\r\n");
                            methodToCompile.Add(jsLine);
                            methodToCompile.Add("\r\n}\r\n");
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public override bool OnExportPhpScriptCode(ActionBranch previousAction, ActionBranch nextAction, StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data)
        {
            if (IsCompiled)
            {
                return(false);
            }
            //preventing of compiling it twice
            IsCompiled = true;
            bool         isGotoPoint = this.IsGotoPoint;
            ActionBranch nt          = nextAction;

            if (_jumpToId != 0)
            {
                //next action is the one it jumps to
                nt = _jumpToActionBranch;
            }
            JsMethodSegment  ms0 = null;
            StringCollection sts = methodCode;

            if (isGotoPoint)
            {
                //two or more branches in the same thread linked to this branch
                //since goto-label must be in the method scope, not sub-scope, this branch code must be
                //in the method scope
                ms0 = data.GetGotoBranch(this.FirstActionId);
                if (ms0 == null)
                {
                    sts = new StringCollection();
                    ms0 = new JsMethodSegment(sts);
                    data.AddGotoBranch(this.FirstActionId, ms0);
                }
                else
                {
                    throw new DesignerException("Action list as goto branch {0} compiled twice", this.FirstActionId);
                }
                //use goto statement to jump to this branch is the responsibility of the branches jumping to it.
            }
            bool b0 = base.OnExportPhpScriptCode(previousAction, nt, jsCode, sts, data);

            if (ms0 != null)
            {
                ms0.Completed = b0;
            }
            if (b0)
            {
                return(true);
            }
            else
            {
                //not all sub-branches of this branch completed.
                //check jumping
                if (_jumpToId != 0)
                {
                    bool bRet = false;
                    //same thread: use goto or fall through; otherwise use waiting point
                    if (_jumpToActionBranch.StartingBranchId == this.StartingBranchId)
                    {
                        //a goto branch, use goto
                        if (_jumpToActionBranch.IsGotoPoint)
                        {
                            sts.Add(Indentation.GetIndent());
                            sts.Add("goto ");
                            sts.Add(ActionBranch.IdToLabel(_jumpToId));
                            sts.Add(";\r\n");
                            bRet = true;
                        }
                        if (!_jumpToActionBranch.IsCompiled)
                        {
                            if (_jumpToActionBranch.IsGotoPoint)
                            {
                                Indentation.IndentIncrease();
                            }
                            bool b = _jumpToActionBranch.ExportPhpScriptCode(this, null, jsCode, sts, data);
                            if (_jumpToActionBranch.IsGotoPoint)
                            {
                                Indentation.IndentDecrease();
                            }
                            if (!_jumpToActionBranch.IsGotoPoint)
                            {
                                bRet = b;
                            }
                        }
                    }
                    return(bRet);
                }
                else
                {
                    //not completed
                    return(false);
                }
            }
        }
 public override void ExportPhpScriptCode(ActionBranch currentAction, ActionBranch nextAction, StringCollection jsCode, StringCollection methodToCompile, JsMethodCompiler data)
 {
     CreatePhpScript(methodToCompile);
 }
        public override bool OnExportPhpScriptCode(ActionBranch previousAction, ActionBranch nextAction, StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data)
        {
            bool bRet;

            if (_actionData == null)
            {
                _actionData = (ActionSubMethod)this.Method.GetActionInstance(_actId.ActionId);
            }
            SubMethodInfoPointer smi = _actionData.ActionMethod as SubMethodInfoPointer;
            SubMethodInfo        mi  = smi.MethodInformation as SubMethodInfo;

            if (mi == null)
            {
                return(false);
            }
            if (mi.IsForeach)
            {
                ParameterClassSubMethod p  = mi.GetParameterType(0, smi, this);
                StringBuilder           sb = new StringBuilder();
                string         s1          = smi.Owner.CodeName;
                IObjectPointer op          = smi.Owner;
                sb.Append(s1);
                while (!(op is ILocalvariable) && op.Owner != null && op.Owner.Owner != null)
                {
                    if (string.CompareOrdinal(s1, op.Owner.CodeName) != 0)
                    {
                        s1 = op.Owner.CodeName;
                        sb.Insert(0, "->");
                        sb.Insert(0, s1);
                    }
                    op = op.Owner;
                }
                if (op is ILocalvariable || op.Owner is ILocalvariable)
                {
                }
                else
                {
                    sb.Insert(0, "$this->");
                }
                s1 = sb.ToString();
                string indents = Indentation.GetIndent();
                string s0      = string.Format(System.Globalization.CultureInfo.InvariantCulture,
                                               "\r\n{2}foreach ({0} as {1}) {{\r\n", s1, p.CodeName, indents);
                methodCode.Add(s0);
                //
                Method.SubMethod.Push(this);
                data.AddSubMethod(this);
                Indentation.IndentIncrease();
                bRet = base.OnExportPhpScriptCode(previousAction, nextAction, jsCode, methodCode, data);
                Indentation.IndentDecrease();
                Method.SubMethod.Pop();
                //
                methodCode.Add(indents);
                methodCode.Add("}\r\n");
            }
            else
            {
                string         indents = Indentation.GetIndent();
                StringBuilder  sb      = new StringBuilder();
                string         s1      = smi.Owner.CodeName;
                IObjectPointer op      = smi.Owner;
                sb.Append(s1);
                while (!(op is ILocalvariable) && op.Owner != null && op.Owner.Owner != null)
                {
                    if (string.CompareOrdinal(s1, op.Owner.CodeName) != 0)
                    {
                        s1 = op.Owner.CodeName;
                        sb.Insert(0, "->");
                        sb.Insert(0, s1);
                    }
                    op = op.Owner;
                }
                if (op is ILocalvariable)
                {
                }
                else
                {
                    sb.Insert(0, "$this->");
                }
                s1 = sb.ToString();

                ParameterClassSubMethod p = mi.GetParameterType(1, smi, this);
                p.ParameterID = _actionData.ParameterValues[1].ParameterID;
                string v  = p.CodeName;
                string s0 = string.Format(System.Globalization.CultureInfo.InvariantCulture,
                                          "\r\n{3}foreach ({0} as {1} => {2} ) {{\r\n", s1, mi.GetIndexCodePHP(smi, this.BranchId), v, indents);
                methodCode.Add(s0);
                Method.SubMethod.Push(this);
                data.AddSubMethod(this);
                //
                Indentation.IndentIncrease();
                bRet = base.OnExportPhpScriptCode(previousAction, nextAction, jsCode, methodCode, data);
                Method.SubMethod.Pop();
                //
                Indentation.IndentDecrease();
                methodCode.Add(indents);
                methodCode.Add("}\r\n");
            }

            return(bRet);
        }
 public void ExportPhpScriptCode(ActionBranch currentAction, ActionBranch nextAction, StringCollection jsCode, StringCollection methodToCompile, JsMethodCompiler data)
 {
 }
        public override bool OnExportPhpScriptCode(ActionBranch previousAction, ActionBranch nextAction, StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data)
        {
            BranchList _list = this.ActionList;

            if (_list != null)
            {
                //link both actions
                if (nextAction != null)
                {
                    if (!string.IsNullOrEmpty(OutputCodeName) && OutputType != null && !OutputType.IsVoid)
                    {
                        nextAction.InputName = OutputCodeName;
                        nextAction.InputType = OutputType;
                        nextAction.SetInputName(OutputCodeName, OutputType);
                    }
                }
                return(_list.ExportPhpScriptCode(jsCode, methodCode, data));
            }
            return(false);
        }
Beispiel #7
0
        public void ExportClientServerCode(ILimnorCodeCompiler compiler, CodeMemberMethod method, CodeStatementCollection statements,
                                           StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data)
        {
            MathNode.Trace("BranchList.ExportJavaScriptCode. Method {0}, action blocks {1}================", _method.Name, this.Count);
            //create code threads
            List <ActionBranch> independentThreads;

            if (_independentThreads == null)
            {
                independentThreads = FindoutActionThreads(true);
            }
            else
            {
                independentThreads = _independentThreads;
            }
            IsMultiThreads = (independentThreads.Count > 1);
            //the case of Count == 0 (empty method) is handled by MethodClass.ExportCode
            if (independentThreads.Count > 0)
            {
                int k0 = 0;                // main thread index
                this.ActionThreads.Clear();
                foreach (ActionBranch a in independentThreads)
                {
                    _threads.Add(a.BranchId, a);
                }
                for (int k = 0; k < independentThreads.Count; k++)
                {
                    if (independentThreads[k].IsMainThread)
                    {
                        k0 = k;
                        break;
                    }
                }
                if (k0 == 0)
                {
                    independentThreads[0].IsMainThread = true;
                }
                this.MainThreadId = independentThreads[k0].BranchId;
                List <UInt32> usedBranches = new List <uint>();
                for (int k = 0; k < independentThreads.Count; k++)
                {
                    independentThreads[k].IsMainThread = (k == k0);
                    independentThreads[k].SetIsMainThreadForSubBranches(usedBranches);
                }
                //client/server does not support threading, process all threads one by one
                for (int k = 0; k < independentThreads.Count; k++)
                {
                    independentThreads[k].ExportClientServerCode(null, null, compiler, method, statements, jsCode, methodCode, data);
                }
            }
        }
Beispiel #8
0
 public void ExportPhpScriptCode(ActionBranch currentAction, ActionBranch nextAction, StringCollection jsCode, StringCollection methodToCompile, JsMethodCompiler data)
 {
     if (IsValid)
     {
         string ceCondition = null;
         if (_condition != null)
         {
             ceCondition = _condition.CreatePhpScriptCode(methodToCompile);
         }
         StringCollection sts = methodToCompile;
         if (!string.IsNullOrEmpty(ceCondition))
         {
             sts.Add("if(");
             sts.Add(ceCondition);
             sts.Add(")\r\n{\r\n");
         }
         string right;
         if (_valType.ValueType == EnumValueType.ConstantValue)
         {
             right = _val.CreatePhpScript(sts);
         }
         else
         {
             right = _val.CreatePhpScript(sts);
         }
         string left = _var.GetPhpScriptReferenceCode(sts);
         sts.Add(left);
         sts.Add("=");
         sts.Add(right);
         sts.Add(";\r\n");
         if (!string.IsNullOrEmpty(ceCondition))
         {
             sts.Add("\r\n}\r\n");
         }
     }
 }
Beispiel #9
0
        public bool ExportJavaScriptCode(StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data)
        {
            bool bRet = false;

            MathNode.Trace("BranchList.ExportJavaScriptCode. Method {0}, action blocks {1}================", _method.Name, this.Count);
            //create code threads
            List <ActionBranch> independentThreads;

            if (_independentThreads == null)
            {
                independentThreads = FindoutActionThreads(true);
            }
            else
            {
                independentThreads = _independentThreads;
            }
            IsMultiThreads = (independentThreads.Count > 1);
            //the case of Count == 0 (empty method) is handled by MethodClass.ExportCode
            if (independentThreads.Count > 0)
            {
                int k0 = 0;                // main thread index
                this.ActionThreads.Clear();
                foreach (ActionBranch a in independentThreads)
                {
                    _threads.Add(a.BranchId, a);
                }
                for (int k = 0; k < independentThreads.Count; k++)
                {
                    if (independentThreads[k].IsMainThread)
                    {
                        k0 = k;
                        break;
                    }
                }
                if (k0 == 0)
                {
                    independentThreads[0].IsMainThread = true;
                }
                this.MainThreadId = independentThreads[k0].BranchId;
                List <UInt32> usedBranches = new List <uint>();
                for (int k = 0; k < independentThreads.Count; k++)
                {
                    independentThreads[k].IsMainThread = (k == k0);
                    independentThreads[k].SetIsMainThreadForSubBranches(usedBranches);
                }
                //javascript does not support threading
                for (int k = 0; k < independentThreads.Count; k++)
                {
                    if (k != k0)
                    {
                        ActionBranch ab = independentThreads[k];
                        ab.IsMainThread = false;
                        ////method contents: a single thread
                        ab.ExportJavaScriptCode(null, null, jsCode, methodCode, data);
                    }
                }
                //main thread code
                bRet = independentThreads[k0].ExportJavaScriptCode(null, null, jsCode, methodCode, data);
                //
                if (_method == null)
                {
                    MathNode.LogError("method is null");
                }
            }
            MathNode.Trace("End of BranchList.ExportJavaScriptCode. Method {0}================", _method.Name);
            return(bRet);
        }
Beispiel #10
0
        public bool ExportPhpScriptCode(StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data)
        {
            bool bRet = false;

            MathNode.Trace("BranchList.ExportPhpScriptCode. Method {0}, action blocks {1}================", _method.Name, this.Count);
            //create code threads
            List <ActionBranch> independentThreads;

            if (_independentThreads == null)
            {
                independentThreads = FindoutActionThreads(true);
            }
            else
            {
                independentThreads = _independentThreads;
            }
            IsMultiThreads = (independentThreads.Count > 1);
            //the case of Count == 0 (empty method) is handled by MethodClass.ExportCode
            if (independentThreads.Count > 0)
            {
                int k0 = 0;                // main thread index
                this.ActionThreads.Clear();
                foreach (ActionBranch a in independentThreads)
                {
                    _threads.Add(a.BranchId, a);
                }
                for (int k = 0; k < independentThreads.Count; k++)
                {
                    if (independentThreads[k].IsMainThread)
                    {
                        k0 = k;
                        break;
                    }
                }
                if (k0 == 0)
                {
                    independentThreads[0].IsMainThread = true;
                }
                this.MainThreadId = independentThreads[k0].BranchId;
                List <UInt32> usedBranches = new List <uint>();
                for (int k = 0; k < independentThreads.Count; k++)
                {
                    independentThreads[k].IsMainThread = (k == k0);
                    independentThreads[k].SetIsMainThreadForSubBranches(usedBranches);
                }
                //javascript does not support threading
                for (int k = 0; k < independentThreads.Count; k++)
                {
                    if (k != k0)
                    {
                        ActionBranch ab = independentThreads[k];
                        ab.IsMainThread = false;
                        ////method contents: a single thread
                        ab.ExportPhpScriptCode(null, null, jsCode, methodCode, data);
                    }
                }
                //main thread code
                bRet = independentThreads[k0].ExportPhpScriptCode(null, null, jsCode, methodCode, data);
                //
                if (_method == null)
                {
                    MathNode.LogError("method is null");
                }
                else                 //
                {
                    if (_method.ReturnValue != null)
                    {
                        if (!typeof(void).Equals(_method.ReturnValue.ObjectType))
                        {
                            //check whether all branches ends with a method return statement
                            if (!independentThreads[k0].AllBranchesEndWithMethodReturnStatement())
                            {
                                methodCode.Add("return ");
                                methodCode.Add(ValueTypeUtil.GetDefaultPhpScriptValueByType(_method.ReturnValue.ObjectType));
                                methodCode.Add(";\r\n");
                            }
                        }
                    }
                }
            }
            MathNode.Trace("End of BranchList.ExportPhpScriptCode. Method {0}================", _method.Name);
            return(bRet);
        }
Beispiel #11
0
 public override void OnExportClientServerCode(ActionBranch previousAction, ActionBranch nextAction, ILimnorCodeCompiler compiler, CodeMemberMethod method, CodeStatementCollection statements,
                                               StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data)
 {
     if (_actionList != null)
     {
         int last = _actionList.Count - 1;
         for (int k = 0; k < _actionList.Count; k++)
         {
             if (_actionList[k].Action != null)
             {
                 ActionBranch nt = null;
                 if (k == last)
                 {
                     nt = nextAction;
                     if (nt != null && nt.UseInput)
                     {
                         nt.InputName = this.OutputCodeName;
                         nt.InputType = this.OutputType;
                         nt.SetInputName(OutputCodeName, OutputType);
                     }
                 }
                 _actionList[k].Action.ExportJavaScriptCode(this, nt, jsCode, methodCode, data);
             }
         }
     }
 }
Beispiel #12
0
        public override bool OnExportPhpScriptCode(ActionBranch previousAction, ActionBranch nextAction, StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data)
        {
            bool bRet = false;

            if (_actionList != null)
            {
                int last = _actionList.Count - 1;
                for (int k = 0; k < _actionList.Count; k++)
                {
                    if (_actionList[k].Action != null)
                    {
                        bRet = _actionList[k].Action.IsMethodReturn;
                        ActionBranch nt = null;
                        if (k == last)
                        {
                            nt = nextAction;
                            if (nt != null && nt.UseInput)
                            {
                                nt.InputName = this.OutputCodeName;
                                nt.InputType = this.OutputType;
                                nt.SetInputName(OutputCodeName, OutputType);
                            }
                        }
                        _actionList[k].Action.ExportPhpScriptCode(this, nt, jsCode, methodCode, data);
                    }
                }
            }
            return(bRet);
        }
Beispiel #13
0
 /// <summary>
 /// javascript does not use cast
 /// </summary>
 /// <param name="previousAction"></param>
 /// <param name="nextAction"></param>
 /// <param name="jsCode"></param>
 /// <param name="methodCode"></param>
 /// <param name="data"></param>
 /// <returns></returns>
 public override bool OnExportJavaScriptCode(ActionBranch previousAction, ActionBranch nextAction, StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data)
 {
     //this action is not available in javascript
     return(false);
 }
Beispiel #14
0
 public void ExportPhpScriptCode(ActionBranch currentAction, ActionBranch nextAction, StringCollection jsCode, StringCollection methodToCompile, JsMethodCompiler data)
 {
     throw new DesignerException("ExportPhpScriptCode should not be called because ActionSubMethod can only be for AB_SubMethodAction");
 }
Beispiel #15
0
        public override bool OnExportPhpScriptCode(ActionBranch previousAction, ActionBranch nextAction, StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data)
        {
            bool bRet = false;

            if (_list != null)
            {
                ActionBranch p = previousAction;
                ActionBranch n;
                _list.ResetBeforeCompile();
                for (int i = 0, j = 1; i < _list.Count; i++, j++)                //ActionBranch a in _list)
                {
                    if (j < _list.Count)
                    {
                        n = _list[j];
                    }
                    else
                    {
                        n = nextAction;
                    }
                    if (!_list[i].IsCompiled)
                    {
                        bRet = _list[i].ExportPhpScriptCode(p, n, jsCode, methodCode, data);
                    }
                    p = _list[i];
                }
            }
            return(bRet);
        }
        public override bool OnExportPhpScriptCode(ActionBranch previousAction, ActionBranch nextAction, StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data)
        {
            string indexName = RepeatIndex.CodeName;

            methodCode.Add(Indentation.GetIndent());
            methodCode.Add("for(");
            methodCode.Add(indexName);
            methodCode.Add("=0;");
            methodCode.Add(indexName);
            methodCode.Add("<");
            methodCode.Add(RepeatCount.CreateJavaScript(methodCode));
            methodCode.Add(";");
            methodCode.Add(indexName);
            methodCode.Add("++) {\r\n");
            Indentation.IndentIncrease();
            string           indents = Indentation.GetIndent();
            StringCollection sc      = new StringCollection();

            if (_iconList != null)
            {
                foreach (ComponentIcon ci in _iconList)
                {
                    ComponentIconLocal cil = ci as ComponentIconLocal;
                    if (cil != null && cil.ScopeGroupId == this.BranchId)
                    {
                        sc.Add(indents);
                        sc.Add("$");
                        sc.Add(cil.LocalPointer.CodeName);
                        sc.Add("=");
                        sc.Add(ValueTypeUtil.GetDefaultPhpScriptValueByType(cil.LocalPointer.BaseClassType));
                        sc.Add(";\r\n");
                    }
                }
            }
            SetWithinLoop();
            Method.SubMethod.Push(this);
            data.AddSubMethod(this);
            bool bRet = base.OnExportPhpScriptCode(previousAction, nextAction, jsCode, sc, data);

            Method.SubMethod.Pop();
            //
            for (int i = 0; i < sc.Count; i++)
            {
                methodCode.Add(sc[i]);
            }
            Indentation.IndentDecrease();
            methodCode.Add(Indentation.GetIndent());
            methodCode.Add("}\r\n");
            return(bRet);
        }
Beispiel #17
0
 public override bool OnExportPhpScriptCode(ActionBranch previousAction, ActionBranch nextAction, StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data)
 {
     if (_decisionTable != null && _decisionTable.ConditionCount > 0)
     {
         for (int i = 0; i < _decisionTable.ConditionCount; i++)
         {
             _decisionTable[i].Condition.PrepareForCompile(this.Method);
             string c = _decisionTable[i].Condition.CreatePhpScript(methodCode);
             if (i == 0)
             {
                 methodCode.Add("if(");
             }
             else
             {
                 methodCode.Add("else if(");
             }
             if (string.IsNullOrEmpty(c))
             {
                 methodCode.Add("true");
             }
             else
             {
                 methodCode.Add(c);
             }
             methodCode.Add(")\r\n{\r\n");
             if (_decisionTable[i].Actions != null)
             {
                 for (int k = 0; k < _decisionTable[i].Actions.Count; k++)
                 {
                     verifyActionObj(k, i);
                     _decisionTable[i].Actions[k].Action.ExportPhpScriptCode(this, nextAction, jsCode, methodCode, data);
                 }
             }
             methodCode.Add("\r\n}\r\n");
         }
     }
     return(false);
 }
 protected override void createJavascriptFunction(StringCollection jsCode, StringCollection methodcode, JsMethodCompiler jmc, bool bRet)
 {
 }
Beispiel #19
0
 public abstract void ExportJavaScriptCode(ActionBranch currentAction, ActionBranch nextAction, StringCollection jsCode, StringCollection methodToCompile, JsMethodCompiler data);
 public override void OnExportClientServerCode(ActionBranch previousAction, ActionBranch nextAction, ILimnorCodeCompiler compiler, CodeMemberMethod method, CodeStatementCollection statements,
                                               StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data)
 {
 }
        public override bool OnExportPhpScriptCode(ActionBranch previousAction, ActionBranch nextAction, StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data)
        {
            string c;

            if (_logicExpression == null)
            {
                c = "true";
            }
            else
            {
                _logicExpression.PrepareForCompile(this.Method);
                c = _logicExpression.CreatePhpScript(methodCode);
            }
            methodCode.Add(Indentation.GetIndent());
            string initCodeStr  = null;
            string increCodeStr = null;

            if (_initAction != null && _initAction.Action != null)
            {
                StringCollection initCode = new StringCollection();
                _initAction.Action.ExportPhpScriptCode(null, null, methodCode, initCode, data);
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < initCode.Count; i++)
                {
                    sb.Append(initCode[i]);
                }
                initCodeStr = sb.ToString().Replace("\r\n", "");
            }
            if (_increAction != null && _increAction.Action != null)
            {
                StringCollection increCode = new StringCollection();
                _increAction.Action.ExportPhpScriptCode(null, null, methodCode, increCode, data);
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < increCode.Count; i++)
                {
                    sb.Append(increCode[i]);
                }
                increCodeStr = sb.ToString().Replace("\r\n", "");
            }
            if (string.IsNullOrEmpty(initCodeStr))
            {
                initCodeStr = ";";
            }
            if (!string.IsNullOrEmpty(increCodeStr))
            {
                increCodeStr = increCodeStr.Trim();
                while (increCodeStr.EndsWith(";", StringComparison.Ordinal))
                {
                    increCodeStr = increCodeStr.Substring(0, increCodeStr.Length - 1);
                    increCodeStr = increCodeStr.Trim();
                }
            }
            methodCode.Add("for(");
            methodCode.Add(initCodeStr);
            methodCode.Add(c);
            methodCode.Add(";");
            methodCode.Add(increCodeStr);
            methodCode.Add(") {\r\n");
            Indentation.IndentIncrease();
            string           indents = Indentation.GetIndent();
            StringCollection sc      = new StringCollection();

            if (_iconList != null)
            {
                foreach (ComponentIcon ci in _iconList)
                {
                    ComponentIconLocal cil = ci as ComponentIconLocal;
                    if (cil != null && cil.ScopeGroupId == this.BranchId)
                    {
                        sc.Add(indents);
                        sc.Add("$");
                        sc.Add(cil.LocalPointer.CodeName);
                        sc.Add("=");
                        sc.Add(ValueTypeUtil.GetDefaultPhpScriptValueByType(cil.LocalPointer.BaseClassType));
                        sc.Add(";\r\n");
                    }
                }
            }
            Method.SubMethod.Push(this);
            data.AddSubMethod(this);
            bool bRet = base.OnExportPhpScriptCode(previousAction, nextAction, jsCode, sc, data);

            Method.SubMethod.Pop();
            //
            for (int i = 0; i < sc.Count; i++)
            {
                methodCode.Add(sc[i]);
            }
            Indentation.IndentDecrease();
            methodCode.Add(Indentation.GetIndent());
            methodCode.Add("}\r\n");
            return(bRet);
        }
 public override void ExportJavaScriptCode(ActionBranch currentAction, ActionBranch nextAction, StringCollection jsCode, StringCollection methodToCompile, JsMethodCompiler data)
 {
     CreateJavaScript(methodToCompile, data.FormSubmissions, nextAction == null ? null : nextAction.InputName, "\t");
 }
        public override bool OnExportPhpScriptCode(ActionBranch currentAction, ActionBranch nextAction, StringCollection jsCode, StringCollection methodToCompile, JsMethodCompiler data)
        {
            ClassPointer list = data.ActionEventList;

            if (list != null && _actId != null)
            {
                _actionData = _actId.LoadActionInstance(this.ActionsHolder);
            }
            if (_actionData != null)
            {
                //link both actions
                if (nextAction != null)
                {
                    if (!string.IsNullOrEmpty(OutputCodeName) && OutputType != null && !OutputType.IsVoid)
                    {
                        nextAction.InputName = OutputCodeName;
                        nextAction.InputType = OutputType;
                        nextAction.SetInputName(OutputCodeName, OutputType);
                    }
                }
                if (_actionData.ActionMethod != null && _actionData.ActionMethod.IsValid)
                {
                    _actionData.ExportPhpScriptCode(this, nextAction, jsCode, methodToCompile, data);
                }
                if (_actionData.IsMethodReturn)
                {
                    return(true);
                }
                return(this.IsMethodReturn);
            }
            return(false);
        }
 public override void ExportClientServerCode(ActionBranch currentAction, ActionBranch nextAction, ILimnorCodeCompiler compiler, IMethodCompile methodToCompile, CodeMemberMethod method, CodeStatementCollection statements, bool debug,
                                             StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data)
 {
 }
        public override bool OnExportJavaScriptCode(ActionBranch previousAction, ActionBranch nextAction, StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data)
        {
            bool bRet;

            if (_actionData == null)
            {
                _actionData = (ActionSubMethod)this.Method.GetActionInstance(_actId.ActionId);                // (ActionSubMethod)compiler.ActionEventList.GetAction(_actId);
            }
            if (_actionData == null)
            {
                return(false);
            }
            SubMethodInfoPointer smi = _actionData.ActionMethod as SubMethodInfoPointer;
            SubMethodInfo        mi  = smi.MethodInformation as SubMethodInfo;

            if (mi == null)
            {
                return(false);
            }
            if (mi.IsForeach)
            {
                ParameterClassSubMethod p  = mi.GetParameterType(0, smi, this);
                StringBuilder           sb = new StringBuilder();
                string         s1          = smi.Owner.CodeName;
                IObjectPointer op          = smi.Owner;
                sb.Append(s1);
                while (!(op is ILocalvariable) && op.Owner != null && op.Owner.Owner != null)
                {
                    if (!s1.StartsWith(op.Owner.CodeName, StringComparison.Ordinal))
                    {
                        s1 = op.Owner.CodeName;
                        sb.Insert(0, ".");
                        sb.Insert(0, s1);
                    }
                    op = op.Owner;
                }
                s1 = sb.ToString();
                string indents = Indentation.GetIndent();
                string a       = string.Format(CultureInfo.InvariantCulture,
                                               "a{0}", Guid.NewGuid().GetHashCode().ToString("x", CultureInfo.InvariantCulture));
                string idx = string.Format(CultureInfo.InvariantCulture,
                                           "i{0}", Guid.NewGuid().GetHashCode().ToString("x", CultureInfo.InvariantCulture));
                string s0 = string.Format(System.Globalization.CultureInfo.InvariantCulture,
                                          "{4}var {3} = {1};\r\n{4}if({3}) for(var {0}=0;{0}<{3}.length;{0}++) {{\r\n{4}var {2}={3}[{0}]; \r\n", idx, s1, p.CodeName, a, indents);
                methodCode.Add(s0);
                Method.SubMethod.Push(this);
                data.AddSubMethod(this);
                Indentation.IndentIncrease();
                bRet = base.OnExportJavaScriptCode(previousAction, nextAction, jsCode, methodCode, data);
                Indentation.IndentDecrease();
                Method.SubMethod.Pop();
                //
                methodCode.Add(indents);
                methodCode.Add("}\r\n");
            }
            else
            {
                string indents = Indentation.GetIndent();
                methodCode.Add(indents);
                methodCode.Add("for(var ");
                methodCode.Add(mi.GetInitStatementJS(smi, jsCode, methodCode, data, this.BranchId));
                methodCode.Add(mi.GetTestExpressionJS(smi, jsCode, methodCode, data, this.BranchId));
                methodCode.Add(mi.GetIncrementalStatementJS(smi, jsCode, methodCode, data, this.BranchId));
                methodCode.Add(") {\r\n");
                Method.SubMethod.Push(this);
                data.AddSubMethod(this);
                Indentation.IndentIncrease();
                if (_iconList != null)
                {
                    foreach (ComponentIcon ci in _iconList)
                    {
                        ComponentIconLocal cil = ci as ComponentIconLocal;
                        if (cil != null && cil.ScopeGroupId == this.BranchId)
                        {
                            methodCode.Add(Indentation.GetIndent());
                            methodCode.Add("var ");
                            methodCode.Add(cil.LocalPointer.CodeName);
                            methodCode.Add("=");
                            methodCode.Add(ValueTypeUtil.GetDefaultJavaScriptValueByType(cil.LocalPointer.BaseClassType));
                            methodCode.Add(";\r\n");
                        }
                    }
                }
                bRet = base.OnExportJavaScriptCode(previousAction, nextAction, jsCode, methodCode, data);
                Method.SubMethod.Pop();
                //
                Indentation.IndentDecrease();
                methodCode.Add(indents);
                methodCode.Add("}\r\n");
            }

            return(bRet);
        }