public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            content.DepthAdd();
            ICLS_Expression expr_while = listParam[1] as ICLS_Expression;
            ICLS_Expression expr_block = listParam[0] as ICLS_Expression;

            CLS_Content.Value vrt = null;
            do
            {
                if (expr_block != null)
                {
                    if (expr_block is CLS_Expression_Block)
                    {
                        var v = expr_block.ComputeValue(content);
                        if (v != null)
                        {
                            if (v.breakBlock > 2)
                            {
                                vrt = v;
                            }
                            if (v.breakBlock > 1)
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        content.DepthAdd();
                        var v = expr_block.ComputeValue(content);
                        if (v != null)
                        {
                            if (v.breakBlock > 2)
                            {
                                vrt = v;
                            }
                            if (v.breakBlock > 1)
                            {
                                break;
                            }
                        }
                        content.DepthRemove();
                    }
                    //if (v.breakBlock == 1) continue;
                    //if (v.breakBlock == 2) break;
                    //if (v.breakBlock == 10) return v;
                }
            } while ((bool)expr_while.ComputeValue(content).value);
            content.DepthRemove();
            content.OutStack(this);
            return(vrt);
            //for 逻辑
            //做数学计算
            //从上下文取值
            //_value = null;
        }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            List <string> depth__;

            content.Record(out depth__);
            try
            {
                ICLS_Expression expr = listParam[0];
                if (expr is CLS_Expression_Block)
                {
                    expr.ComputeValue(content);
                }
                else
                {
                    content.DepthAdd();
                    expr.ComputeValue(content);
                    content.DepthRemove();
                }
            }
            catch (Exception err)
            {
                bool bParse = false;
                int  i      = 1;
                while (i < listParam.Count)
                {
                    CLS_Expression_Define def = listParam[i] as CLS_Expression_Define;
                    if (err.GetType() == (Type)def.value_type || err.GetType().IsSubclassOf((Type)def.value_type))
                    {
                        content.DepthAdd();
                        content.DefineAndSet(def.value_name, def.value_type, err);

                        listParam[i + 1].ComputeValue(content);
                        content.DepthRemove();
                        bParse = true;
                        break;
                    }
                    i += 2;
                }
                if (!bParse)
                {
                    throw err;
                }
            }
            content.Restore(depth__, this);
            //while((bool)expr_continue.value);

            //for 逻辑
            //做数学计算
            //从上下文取值
            //_value = null;
            content.OutStack(this);
            return(null);
        }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            content.DepthAdd();
            ICLS_Expression expr_init = listParam[0] as ICLS_Expression;

            if (expr_init != null)
            {
                expr_init.ComputeValue(content);
            }

            ICLS_Expression expr_continue = listParam[1] as ICLS_Expression;
            ICLS_Expression expr_step     = listParam[2] as ICLS_Expression;

            ICLS_Expression expr_block = listParam[3] as ICLS_Expression;

            for (; (bool)expr_continue.ComputeValue(content).value; expr_step.ComputeValue(content))
            {
                if (expr_block != null)
                {
                    if (expr_block is CLS_Expression_Block)
                    {
                        var v = expr_block.ComputeValue(content);
                        if (v != null && v.breakBlock > 1)
                        {
                            break;
                        }
                        ;
                    }
                    else
                    {
                        content.DepthAdd();
                        var v = expr_block.ComputeValue(content);
                        if (v != null && v.breakBlock > 1)
                        {
                            break;
                        }
                        ;
                        content.DepthRemove();
                    }
                    //if (v.breakBlock == 1) continue;
                    //if (v.breakBlock == 2) break;
                    //if (v.breakBlock == 10) return v;
                }
            }
            content.DepthRemove();
            content.OutStack(this);
            return(null);
            //for 逻辑
            //做数学计算
            //从上下文取值
            //_value = null;
        }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            ICLS_Expression expr_if = listParam[0];
            bool            bif     = (bool)expr_if.ComputeValue(content).value;
            //if (expr_init != null) expr_init.ComputeValue(content);
            ICLS_Expression expr_go1 = listParam[1];
            ICLS_Expression expr_go2 = null;

            if (listParam.Count > 2)
            {
                expr_go2 = listParam[2];
            }
            CLS_Content.Value value = null;
            if (bif && expr_go1 != null)
            {
                if (expr_go1 is CLS_Expression_Block)
                {
                    value = expr_go1.ComputeValue(content);
                }
                else
                {
                    content.DepthAdd();
                    value = expr_go1.ComputeValue(content);
                    content.DepthRemove();
                }
            }
            else if (!bif && expr_go2 != null)
            {
                if (expr_go2 is CLS_Expression_Block)
                {
                    value = expr_go2.ComputeValue(content);
                }
                else
                {
                    content.DepthAdd();
                    value = expr_go2.ComputeValue(content);
                    content.DepthRemove();
                }
            }

            //while((bool)expr_continue.value);

            //for 逻辑
            //做数学计算
            //从上下文取值
            //_value = null;
            content.OutStack(this);
            return(value);
        }
Example #5
0
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            content.DepthAdd();

            CLS_Content.Value vrt = null;

            ICLS_Expression expr_while = listParam[0];
            ICLS_Expression expr_block = listParam[1];

            while ((bool)expr_while.ComputeValue(content).value)
            {
                if (expr_block != null)
                {
                    CLS_Content.Value v = expr_block.ComputeValue(content);
                    if (v != null)
                    {
                        if (v.breakBlock > 2)
                        {
                            vrt = v;
                        }
                        if (v.breakBlock > 1)
                        {
                            break;
                        }
                    }
                }
            }
            content.DepthRemove();
            content.OutStack(this);
            return(vrt);
        }
Example #6
0
 public CLS_Content.Value Execute(ICLS_Expression expr, CLS_Content content = null)
 {
     if (content == null)
     {
         content = CreateContent();
     }
     return(expr.ComputeValue(content));
 }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);

            CLS_Content.Value value = null;
            if ((bool)listParam[0].ComputeValue(content).value)
            {
                ICLS_Expression expr_block = listParam[1];
                if (expr_block != null)
                {
                    if (expr_block is CLS_Expression_Block)
                    {
                        value = expr_block.ComputeValue(content);
                    }
                    else
                    {
                        content.DepthAdd();
                        value = expr_block.ComputeValue(content);
                        content.DepthRemove();
                    }
                }
            }
            else if (listParam.Count > 2)
            {
                ICLS_Expression expr_elseif = listParam[2];
                if (expr_elseif != null)
                {
                    if (expr_elseif is CLS_Expression_Block)
                    {
                        value = expr_elseif.ComputeValue(content);
                    }
                    else
                    {
                        content.DepthAdd();
                        value = expr_elseif.ComputeValue(content);
                        content.DepthRemove();
                    }
                }
            }

            content.OutStack(this);
            return(value);
        }
Example #8
0
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            content.DepthAdd();
            CLS_Expression_Define define = listParam[0] as CLS_Expression_Define;

            if (define == null)
            {
            }
            define.ComputeValue(content);

            System.Collections.IEnumerable emu = listParam[1].ComputeValue(content).value as System.Collections.IEnumerable;

            ICLS_Expression expr_block = listParam[2] as ICLS_Expression;

            var it = emu.GetEnumerator();

            while (it.MoveNext())
            {
                content.Set(define.value_name, it.Current);

                if (expr_block != null)
                {
                    var v = expr_block.ComputeValue(content);
                    if (v != null && v.breakBlock > 1)
                    {
                        break;
                    }
                    ;
                }
            }
            //ICLS_Expression expr_continue = listParam[1] as ICLS_Expression;
            //ICLS_Expression expr_step = listParam[2] as ICLS_Expression;

            //ICLS_Expression expr_block = listParam[3] as ICLS_Expression;

            //for (;(bool)expr_continue.ComputeValue(content).value; expr_step.ComputeValue(content))
            //{
            //    if(expr_block!=null)
            //    {
            //        var v = expr_block.ComputeValue(content);
            //        if (v != null && v.breakBlock > 1) break; ;
            //        //if (v.breakBlock == 1) continue;
            //        //if (v.breakBlock == 2) break;
            //        //if (v.breakBlock == 10) return v;
            //    }
            //}
            content.DepthRemove();
            content.OutStack(this);
            return(null);
            //for 逻辑
            //做数学计算
            //从上下文取值
            //_value = null;
        }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            content.DepthAdd();

            CLS_Content.Value vrt = null;

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

            if (expr_init != null)
            {
                expr_init.ComputeValue(content);
            }

            for (;;)
            {
                if (expr_continue != null && !(bool)expr_continue.ComputeValue(content).value)
                {
                    break;
                }

                if (expr_block != null)
                {
                    CLS_Content.Value v = expr_block.ComputeValue(content);
                    if (v != null)
                    {
                        if (v.breakBlock > 2)
                        {
                            vrt = v;
                        }
                        if (v.breakBlock > 1)
                        {
                            break;
                        }
                    }
                }

                if (expr_step != null)
                {
                    expr_step.ComputeValue(content);
                }
            }
            content.DepthRemove();
            content.OutStack(this);
            return(vrt);
        }
Example #10
0
        ICLS_Expression OptimizeSingle(ICLS_Expression expr, CLS_Content content)
        {
            if (expr is CLS_Expression_Math2Value || expr is CLS_Expression_Math2ValueAndOr || expr is CLS_Expression_Math2ValueLogic)
            {
                if (expr.listParam[0] is ICLS_Value &&
                    expr.listParam[1] is ICLS_Value)
                {
                    CLS_Content.Value result = expr.ComputeValue(content);
                    if ((Type)result.type == typeof(bool))
                    {
                        CLS_Value_Value <bool> value = new CLS_Value_Value <bool>();
                        value.value_value = (bool)result.value;
                        value.tokenBegin  = expr.listParam[0].tokenBegin;
                        value.tokenEnd    = expr.listParam[1].tokenEnd;
                        value.lineBegin   = expr.listParam[0].lineBegin;
                        value.lineEnd     = expr.listParam[1].lineEnd;
                        return(value);
                    }
                    else
                    {
                        ICLS_Type  v     = content.environment.GetType(result.type);
                        ICLS_Value value = v.MakeValue(result.value);
                        value.tokenBegin = expr.listParam[0].tokenBegin;
                        value.tokenEnd   = expr.listParam[1].tokenEnd;
                        value.lineBegin  = expr.listParam[0].lineBegin;
                        value.lineEnd    = expr.listParam[1].lineEnd;
                        return(value);
                    }
                }
            }
            if (expr is CLS_Expression_Math3Value)
            {
                CLS_Content.Value result = expr.listParam[0].ComputeValue(content);
                if ((Type)result.type == typeof(bool))
                {
                    bool bv = (bool)result.value;
                    if (bv)
                    {
                        return(expr.listParam[1]);
                    }
                    else
                    {
                        return(expr.listParam[2]);
                    }
                }
            }

            return(expr);
        }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);

            ICLS_Expression leftExp = listParam[0];

            CLS_Content.Value left  = leftExp.ComputeValue(content);
            CLS_Content.Value right = listParam[1].ComputeValue(content);
            ICLS_Type         type  = content.environment.GetType(left.type);

            CLType returntype;

            left.value = type.Math2Value(content, mathop, left.value, right, out returntype);
            //left.value = type.ConvertTo(content, left.value, left.type);

            if (leftExp is CLS_Expression_MemberFind)
            {
                CLS_Expression_MemberFind f = leftExp as CLS_Expression_MemberFind;

                CLS_Content.Value parent = f.listParam[0].ComputeValue(content);
                ICLS_Type         ptype  = content.environment.GetType(parent.type);
                ptype.function.MemberValueSet(content, parent.value, f.membername, left.value);
            }
            else if (leftExp is CLS_Expression_StaticFind)
            {
                CLS_Expression_StaticFind f = leftExp as CLS_Expression_StaticFind;
                f.type.function.StaticValueSet(content, f.staticmembername, left.value);
            }
            else if (leftExp is CLS_Expression_IndexFind)
            {
                CLS_Expression_IndexFind f = leftExp as CLS_Expression_IndexFind;

                CLS_Content.Value parent = f.listParam[0].ComputeValue(content);
                CLS_Content.Value key    = f.listParam[1].ComputeValue(content);
                ICLS_Type         ptype  = content.environment.GetType(parent.type);
                ptype.function.IndexSet(content, parent.value, key.value, left.value);
            }

            content.OutStack(this);

            return(null);
        }
Example #12
0
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            content.DepthAdd();

            CLS_Content.Value vrt = null;

            CLS_Expression_Define define = listParam[0] as CLS_Expression_Define;

            define.ComputeValue(content);

            IEnumerator it = (listParam[1].ComputeValue(content).value as IEnumerable).GetEnumerator();

            ICLS_Expression expr_block = listParam[2];

            while (it.MoveNext())
            {
                content.Set(define.value_name, it.Current);

                if (expr_block != null)
                {
                    CLS_Content.Value v = expr_block.ComputeValue(content);
                    if (v != null)
                    {
                        if (v.breakBlock > 2)
                        {
                            vrt = v;
                        }
                        if (v.breakBlock > 1)
                        {
                            break;
                        }
                    }
                }
            }
            content.DepthRemove();
            content.OutStack(this);
            return(vrt);
        }
Example #13
0
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            content.DepthAdd();
            CLS_Content.Value value = null;
            foreach (ICLS_Expression i in listParam)
            {
                ICLS_Expression e = i  as ICLS_Expression;
                if (e != null)
                {
                    value = e.ComputeValue(content);
                }


                if (value != null && value.breakBlock != 0)
                {
                    break;
                }
            }
            content.DepthRemove();
            content.OutStack(this);
            return(value);
        }
        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);
        }
Example #15
0
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            content.DepthAdd();
            ICLS_Expression expr_init = listParam[0] as ICLS_Expression;

            if (expr_init != null)
            {
                expr_init.ComputeValue(content);                   //expr1
            }
            ICLS_Expression expr_continue = listParam[1] as ICLS_Expression;
            ICLS_Expression expr_step     = listParam[2] as ICLS_Expression;

            ICLS_Expression expr_block = listParam[3] as ICLS_Expression;

            CLS_Content.Value vrt = null;
            for (; ;)
            {
                if (expr_continue != null && !(bool)expr_continue.ComputeValue(content).value)
                {
                    break;                                                                           //expr2
                }
                if (expr_block != null)
                {
                    if (expr_block is CLS_Expression_Block)
                    {
                        var v = expr_block.ComputeValue(content);
                        if (v != null)
                        {
                            if (v.breakBlock > 2)
                            {
                                vrt = v;
                            }
                            if (v.breakBlock > 1)
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        content.DepthAdd();
                        bool bbreak = false;
                        var  v      = expr_block.ComputeValue(content);
                        if (v != null)
                        {
                            if (v.breakBlock > 2)
                            {
                                vrt = v;
                            }
                            if (v.breakBlock > 1)
                            {
                                bbreak = true;
                            }
                        }
                        content.DepthRemove();
                        if (bbreak)
                        {
                            break;
                        }
                    }
                    //if (v.breakBlock == 1) continue;
                    //if (v.breakBlock == 2) break;
                    //if (v.breakBlock == 10) return v;
                }

                if (expr_step != null)
                {
                    expr_step.ComputeValue(content);//expr3
                }
            }
            content.DepthRemove();
            content.OutStack(this);
            return(vrt);
            //for 逻辑
            //做数学计算
            //从上下文取值
            //_value = null;
        }
Example #16
0
 public CLS_Content.Value Execute(ICLS_Expression expr, CLS_Content content = null)
 {
     if (content == null) content = CreateContent();
     return expr.ComputeValue(content);
 }
Example #17
0
        public CLS_Content.Value Expr_Execute(ICLS_Expression expr)
        {
            CLS_Content content = CreateContent();

            return(expr.ComputeValue(content));
        }
Example #18
0
        ICLS_Expression OptimizeSingle(ICLS_Expression expr, CLS_Content content)
        {

            if (expr is CLS_Expression_Math2Value || expr is CLS_Expression_Math2ValueAndOr || expr is CLS_Expression_Math2ValueLogic)
            {

                if (expr.listParam[0] is ICLS_Value &&
                expr.listParam[1] is ICLS_Value)
                {
                    CLS_Content.Value result = expr.ComputeValue(content);
                    if ((Type)result.type == typeof(bool))
                    {
                        CLS_Value_Value<bool> value = new CLS_Value_Value<bool>();
                        value.value_value = (bool)result.value;
                        value.tokenBegin = expr.listParam[0].tokenBegin;
                        value.tokenEnd = expr.listParam[1].tokenEnd;
                        value.lineBegin = expr.listParam[0].lineBegin;
                        value.lineEnd = expr.listParam[1].lineEnd;
                        return value;
                    }
                    else
                    {
                        ICLS_Type v = content.environment.GetType(result.type);
                        ICLS_Value value = v.MakeValue(result.value);
                        value.tokenBegin = expr.listParam[0].tokenBegin;
                        value.tokenEnd = expr.listParam[1].tokenEnd;
                        value.lineBegin = expr.listParam[0].lineBegin;
                        value.lineEnd = expr.listParam[1].lineEnd;
                        return value;
                    }


                }
            }
            if (expr is CLS_Expression_Math3Value)
            {
                CLS_Content.Value result = expr.listParam[0].ComputeValue(content);
                if ((Type)result.type == typeof(bool))
                {
                    bool bv = (bool)result.value;
                    if (bv)
                        return expr.listParam[1];
                    else
                        return expr.listParam[2];
                }
            }

            return expr;
        }
Example #19
0
 public CLS_Content.Value Expr_Execute(ICLS_Expression expr)
 {
     CLS_Content content = CreateContent();
     return expr.ComputeValue(content);
 }