상속: ICLS_Expression
        public ICLS_Expression Compiler_Expression_Loop_For(IList <Token> tlist, ICLS_Environment content, int pos, int posend)
        {
            int b1;
            int fs1 = pos + 1;
            int fe1 = FindCodeAny(tlist, ref fs1, out b1);
            CLS_Expression_LoopFor value = new CLS_Expression_LoopFor(pos, posend, tlist[pos].line, tlist[posend].line);

            int testbegin = fs1 + 1;

            if (b1 != 1)
            {
                return(null);
            }
            do
            {
                int fe2 = FindCodeAny(tlist, ref testbegin, out b1);


                ICLS_Expression subvalue;
                bool            succ = Compiler_Expression(tlist, content, testbegin, fe2, out subvalue);
                if (!succ)
                {
                    return(null);
                }
                if (subvalue != null)
                {
                    value.listParam.Add(subvalue);
                    testbegin = fe2 + 2;
                }
                else
                {
                    value.listParam.Add(null);
                    testbegin = fe2 + 2;
                }
            }while (testbegin <= fe1);

            if (value.listParam.Count != 3)
            {
                return(null);
            }
            ICLS_Expression subvalueblock;

            int  b2;
            int  fs2    = fe1 + 1;
            int  fecode = FindCodeAny(tlist, ref fs2, out b2);
            bool succ2  = Compiler_Expression_Block(tlist, content, fs2, fecode, out subvalueblock);

            if (succ2)
            {
                value.tokenEnd = fecode;
                value.lineEnd  = tlist[fecode].line;
                value.listParam.Add(subvalueblock);
                return(value);
            }
            return(null);
        }
예제 #2
0
        public ICLS_Expression Compiler_Expression_Loop_For(IList<Token> tlist, ICLS_Environment content, int pos, int posend)
        {
            int b1;
            int fs1 = pos + 1;
            int fe1 = FindCodeAny(tlist, ref fs1, out b1);
            CLS_Expression_LoopFor value = new CLS_Expression_LoopFor(pos, posend, tlist[pos].line, tlist[posend].line);

            int testbegin = fs1 + 1;
            if (b1 != 1)
            {
                return null;
            }
            do
            {

                int fe2 = FindCodeAny(tlist, ref testbegin, out b1);


                ICLS_Expression subvalue;
                bool succ = Compiler_Expression(tlist, content, testbegin, fe2, out subvalue);
                //if (!succ) return null;
                if (subvalue != null)
                {
                    value.listParam.Add(subvalue);
                    testbegin = fe2 + 2;
                }
                else
                {
                    value.listParam.Add(null);
                    testbegin = fe2 + 2;
                }
            }
            while (testbegin <= fe1);

            if (value.listParam.Count != 3)
            {
                return null;
            }
            ICLS_Expression subvalueblock;

            int b2;
            int fs2 = fe1 + 1;
            int fecode = FindCodeAny(tlist, ref fs2, out b2);
            bool succ2 = Compiler_Expression_Block(tlist, content, fs2, fecode, out subvalueblock);
            if (succ2)
            {
                value.tokenEnd = fecode;
                value.lineEnd = tlist[fecode].line;
                value.listParam.Add(subvalueblock);
                return value;
            }
            return null;
        }
        IEnumerator CustomCoroutine(CLS_Content content)
        {
            content.InStack(this);
            content.DepthAdd();
            CLS_Content.Value retVal = null;
            ICLS_Expression   exp    = null;

            for (int i = 0, count = listParam.Count; i < count; i++)
            {
                exp = listParam[i];
                CLS_Expression_LoopFor expLoopFor = exp as CLS_Expression_LoopFor;
                if (expLoopFor != null)
                {
                    content.InStack(expLoopFor);
                    content.DepthAdd();

                    ICLS_Expression expr_init     = expLoopFor.listParam[0];
                    ICLS_Expression expr_continue = expLoopFor.listParam[1];
                    ICLS_Expression expr_step     = expLoopFor.listParam[2];
                    ICLS_Expression expr_block    = expLoopFor.listParam[3];

#if UNITY_EDITOR
                    try
                    {
#endif
                    if (expr_init != null)
                    {
                        expr_init.ComputeValue(content);
                    }
#if UNITY_EDITOR
                }
                catch (System.Exception ex) { content.environment.logger.Log_Error(ex.Message + "\n" + content.DumpStack() + ex); }
#endif
                    for (;;)
                    {
#if UNITY_EDITOR
                        try
                        {
#endif
                        if (expr_continue != null && !(bool)expr_continue.ComputeValue(content).value)
                        {
                            break;
                        }
#if UNITY_EDITOR
                    }
                    catch (System.Exception ex) { content.environment.logger.Log_Error(ex.Message + "\n" + content.DumpStack() + ex); }
#endif
                        if (expr_block != null)
                        {
                            if (expr_block is CLS_Expression_Block)
                            {
                                content.InStack(expr_block);
                                content.DepthAdd();
                                for (int j = 0, count2 = expr_block.listParam.Count; j < count2; j++)
                                {
#if UNITY_EDITOR
                                    try
                                    {
#endif
                                    retVal = expr_block.listParam[j].ComputeValue(content);
#if UNITY_EDITOR
                                }
                                catch (System.Exception ex) { content.environment.logger.Log_Error(ex.Message + "\n" + content.DumpStack() + ex); }
#endif
                                    if (retVal != null)
                                    {
                                        if (retVal.breakBlock == 12)
                                        {
                                            CLS_Content.PoolContent(content);
                                            yield break;
                                        }
                                        else if (retVal.breakBlock == 13)
                                        {
                                            yield return(retVal.value);
                                        }
                                        else if (retVal.breakBlock > 1)
                                        {
                                            break;
                                        }
                                    }
                                }
                                content.DepthRemove();
                                content.OutStack(expr_block);
                            }
                            else
                            {
#if UNITY_EDITOR
                                try
                                {
#endif
                                retVal = expr_block.ComputeValue(content);
#if UNITY_EDITOR
                            }
                            catch (System.Exception ex) { content.environment.logger.Log_Error(ex.Message + "\n" + content.DumpStack() + ex); }
#endif
                                if (retVal != null)
                                {
                                    if (retVal.breakBlock == 12)
                                    {
                                        CLS_Content.PoolContent(content);
                                        yield break;
                                    }
                                    else if (retVal.breakBlock == 13)
                                    {
                                        yield return(retVal.value);
                                    }
                                    else if (retVal.breakBlock > 1)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
#if UNITY_EDITOR
                        try
                        {
#endif
                        if (expr_step != null)
                        {
                            expr_step.ComputeValue(content);
                        }
#if UNITY_EDITOR
                    }
                    catch (System.Exception ex) { content.environment.logger.Log_Error(ex.Message + "\n" + content.DumpStack() + ex); }
#endif
                    }

                    content.DepthRemove();
                    content.OutStack(expLoopFor);
                }
                else
                {
#if UNITY_EDITOR
                    try
                    {
#endif
                    retVal = exp.ComputeValue(content);
#if UNITY_EDITOR
                }
                catch (System.Exception ex) { content.environment.logger.Log_Error(ex.Message + "\n" + content.DumpStack() + ex); }
#endif
                    if (retVal != null)
                    {
                        if (retVal.breakBlock == 12)
                        {
                            CLS_Content.PoolContent(content);
                            yield break;
                        }
                        else if (retVal.breakBlock == 13)
                        {
                            yield return(retVal.value);
                        }
                    }
                }
            }
            CLS_Content.PoolContent(content);
        }