示例#1
0
        public CQ_Content.Value ComputeValue(CQ_Content content)
        {
            content.InStack(this);
            List <string> depth__;

            content.Record(out depth__);
            try
            {
                ICQ_Expression expr = listParam[0];
                if (expr is CQ_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)
                {
                    CQ_Expression_Define def = listParam[i] as CQ_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 CQ_Value ComputeValue(CQ_Content content)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif
            int oldDepthCount = content.Record();
            try {
                ICQ_Expression expr = _expressions[0];
                if (expr is CQ_Expression_Block)
                {
                    expr.ComputeValue(content);
                }
                else
                {
                    content.DepthAdd();
                    expr.ComputeValue(content);
                    content.DepthRemove();
                }
            }
            catch (Exception err) {
                bool bParse = false;
                int  i      = 1;
                while (i < _expressions.Count)
                {
                    CQ_Expression_Define def = _expressions[i] as CQ_Expression_Define;
                    if (err.GetType() == (Type)def.value_type || err.GetType().IsSubclassOf((Type)def.value_type))
                    {
                        content.DepthAdd();
                        CQ_Value errVal = new CQ_Value();
                        errVal.SetObject(def.value_type, err);
                        content.DefineAndSet(def.value_name, def.value_type, errVal);

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

#if CQUARK_DEBUG
            content.OutStack(this);
#endif
            return(CQ_Value.Null);
        }