public CLS_Content.Value Call(CLS_Content content, IList<CLS_Content.Value> param)
 {
     CLS_Content.Value v = new CLS_Content.Value();
     List<object> objs = new List<object>();
     //var _params =   dele.Method.GetParameters();
     for (int i = 0; i < this.defvalues.Count; i++)
     {
         if (i >= param.Count)
         {
             objs.Add(defvalues[i]);
         }
         else
         {
             if (this.paramtype[i] == (Type)param[i].type)
             {
                 objs.Add(param[i].value);
             }
             else
             {
                 object conv = content.environment.GetType(param[i].type).ConvertTo(content, param[i].value, paramtype[i]);
                 objs.Add(conv);
             }
         }
     }
     v.type = this.returntype;
     v.value = dele.DynamicInvoke(objs.ToArray());
     return v;
 }
Пример #2
0
 public override CLS_Content.Value New(CLS_Content content, BetterList<CLS_Content.Value> _params)
 {
     CLS_Content.Value val = new CLS_Content.Value();
     val.type = typeof(UnityEngine.Random);
     val.value = new UnityEngine.Random();
     return val;
 }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            CLS_Content.Value rv = new CLS_Content.Value();
            rv.breakBlock = 10;
            if (listParam.Count > 0&&listParam[0]!=null)
            {
                var v = listParam[0].ComputeValue(content);
                {
                    rv.type = v.type;
                    rv.value = v.value;
                }
            }
            else
            {
                rv.type = typeof(void);
            }
            content.OutStack(this);
            return rv;

            //for 逻辑
            //做数学计算
            //从上下文取值
            //_value = null;
        }
 public CLS_Content.Value ComputeValue(CLS_Content content)
 {
     CLS_Content.Value value = new CLS_Content.Value();
     value.type = typeof(DeleLambda);
     value.value = new DeleLambda(content, this.listParam[0].listParam, this.listParam[1]);
     return value;
 }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            var parent = listParam[0].ComputeValue(content);
            if (parent == null)
            {
                throw new Exception("调用空对象的方法:" + listParam[0].ToString() + ":" + ToString());
            }
            var type = content.environment.GetType(parent.type);
            //string membername=null;


            var getvalue = type.function.MemberValueGet(content, parent.value, membername);

            CLS_Content.Value vright = CLS_Content.Value.One;
            if (listParam.Count > 1)
            {
                vright = listParam[1].ComputeValue(content);
            }
            CLS_Content.Value vout =new CLS_Content.Value();
            var mtype = content.environment.GetType(getvalue.type);
            vout.value = mtype.Math2Value(content, mathop, getvalue.value, vright, out vout.type);

            type.function.MemberValueSet(content, parent.value, membername, vout.value);
            //CLS_Content.Value v = new CLS_Content.Value();

            content.OutStack(this);
            return vout;
            //做数学计算
            //从上下文取值
            //_value = null;
            //return null;

        }
Пример #6
0
 public override CLS_Content.Value New(CLS_Content content, BetterList<CLS_Content.Value> _params)
 {
     CLS_Content.Value val = new CLS_Content.Value();
     val.type = typeof(Time);
     val.value = new Time();
     return val;
 }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            CLS_Content.Value rv = new CLS_Content.Value();


            {
                var v = listParam[0].ComputeValue(content);
                {
                    rv.type = v.type;
                    rv.value = v.value;
                }
                Exception err = v.value as Exception;
                if (err != null)
                {
                    throw err;
                }
                else
                {
                    throw new Exception(v.ToString());
                }
            }

            content.OutStack(this);
            return rv;

            //for 逻辑
            //做数学计算
            //从上下文取值
            //_value = null;
        }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);

            int arraySize = listParam[0] == null ? (listParam.Count - 1) : (int)listParam[0].ComputeValue(content).value;
            if (arraySize == 0)
                throw new Exception("不能创建0长度数组");

            int initValCount = listParam.Count - 1;
            object[] initVals = new object[initValCount];
            for (int i = 1; i < listParam.Count; i++)
            {
                initVals[i - 1] = listParam[i].ComputeValue(content).value;
            }

            CLS_Content.Value vcount = new CLS_Content.Value();
            vcount.type = typeof(int);
            vcount.value = arraySize;
            BetterList<CLS_Content.Value> _params = CLS_Content.NewParamList();
            _params.Add(vcount);
            CLS_Content.Value newVal = type.function.New(content, _params);

            for (int i = 0; i < initValCount; i++)
            {
                type.function.IndexSet(content, newVal.value, i, initVals[i]);
            }

            CLS_Content.PoolParamList(_params);
            content.OutStack(this);
            return newVal;
        }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            CLS_Content.Value result = new CLS_Content.Value();
            result.type = typeof(bool);

            bool bleft = (bool)listParam[0].ComputeValue(content).value;

            if (mathop == '&')
            {
                if (!bleft)
                {
                    result.value = false;
                }
                else
                {
                    result.value = bleft && (bool)listParam[1].ComputeValue(content).value;
                }
            }
            else if (mathop == '|')
            {
                if (bleft)
                {
                    result.value = true;
                }
                else
                {
                    result.value = bleft || (bool)listParam[1].ComputeValue(content).value;
                }
            }

            content.OutStack(this);
            return result;
        }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            List<object> list = new List<object>();
            int count = listParam[0] == null ? (listParam.Count - 1) : (int)listParam[0].ComputeValue(content).value;
            if (count == 0)
                throw new Exception("不能创建0长度数组");
            CLS_Content.Value vcount = new CLS_Content.Value();
            vcount.type = typeof(int);
            vcount.value = count;
            for (int i = 1; i < listParam.Count; i++)
            {
                //if (listParam[i] != null)
                {
                    list.Add(listParam[i].ComputeValue(content).value);
                }
            }
            List<CLS_Content.Value> p = new List<CLS_Content.Value>();
            p.Add(vcount);
            var outvalue = type.function.New(content, p);
            for (int i = 0; i < list.Count; i++)
            {
                type.function.IndexSet(content, outvalue.value, i, list[i]);
            }
            content.OutStack(this);
            return outvalue;

        }
 public override CLS_Content.Value New(CLS_Content content, BetterList<CLS_Content.Value> _params)
 {
     CLS_Content.Value val = new CLS_Content.Value();
     val.type = typeof(SphereCollider);
     val.value = new SphereCollider();
     return val;
 }
 public CLS_Content.Value ComputeValue(CLS_Content content)
 {
     content.InStack(this);
     CLS_Content.Value rv = new CLS_Content.Value();
     rv.breakBlock = 2;
     //跳出逻辑
     content.OutStack(this);
     return rv;
 }
 public CLS_Content.Value ComputeValue(CLS_Content content)
 {
     content.InStack(this);
     CLS_Content.Value left = listParam[0].ComputeValue(content);
     CLS_Content.Value right = listParam[1].ComputeValue(content);
     CLS_Content.Value result = new CLS_Content.Value();
     result.value = content.environment.GetType(left.type).Math2Value(content, mathop, left.value, right, out result.type);
     content.OutStack(this);
     return result;
 }
 public CLS_Content.Value ComputeValue(CLS_Content content)
 {
     content.InStack(this);
     CLS_Content.Value right = listParam[0].ComputeValue(content);
     ICLS_Type type = content.environment.GetType(right.type);
     CLS_Content.Value value = new CLS_Content.Value();
     value.type = targettype;
     value.value = type.ConvertTo(content, right.value, targettype);
     content.OutStack(this);
     return value;
 }
Пример #15
0
 public override CSLE.CLS_Content.Value StaticValueGet(CSLE.CLS_Content environment, string valuename)
 {
     if (valuename == "one")
     {
         CSLE.CLS_Content.Value v = new CSLE.CLS_Content.Value();
         v.value = Vector3.one;
         v.type  = typeof(Vector3);
         return(v);
     }
     return(base.StaticValueGet(environment, valuename));
 }
Пример #16
0
        public override CLS_Content.Value MemberCall(CLS_Content content, object object_this, string function, BetterList<CLS_Content.Value> _params, bool isBaseCall = false)
        {
            if (function == "ClosestPointOnBounds")
            {
                CLS_Content.Value val = new CLS_Content.Value();
                val.type = typeof(Vector3);
                val.value = ((Collider)object_this).ClosestPointOnBounds(((Vector3)_params[0].value));
                return val;
            }

            return base.MemberCall(content, object_this, function, _params, isBaseCall);
        }
Пример #17
0
        public override CSLE.CLS_Content.Value MemberValueGet(CSLE.CLS_Content environment, object object_this, string valuename)
        {
            if (valuename == "transform")
            {
                CSLE.CLS_Content.Value v = new CSLE.CLS_Content.Value();
                v.value = ((GameObject)object_this).transform;
                v.type  = typeof(Transform);

                return(v);
            }
            return(base.MemberValueGet(environment, object_this, valuename));
        }
        public Delegate CreateDelegate(ICLS_Environment env, DeleFunction delefunc)
        {
            DeleFunction _func = delefunc;
            Delegate     _dele = delefunc.cacheFunction(this._type, null);

            if (_dele != null)
            {
                return(_dele);
            }
            NonVoidDelegate dele = delegate(T param0, T1 param1, T2 param2)
            {
                var func = _func.calltype.functions[_func.function];
                if (func.expr_runtime != null)
                {
                    CLS_Content content = new CLS_Content(env, true);
                    try
                    {
                        content.DepthAdd();
                        content.CallThis = _func.callthis;
                        content.CallType = _func.calltype;
                        content.function = _func.function;

                        content.DefineAndSet(func._paramnames[0], func._paramtypes[0].type, param0);
                        content.DefineAndSet(func._paramnames[1], func._paramtypes[1].type, param1);
                        content.DefineAndSet(func._paramnames[2], func._paramtypes[2].type, param2);

                        CLS_Content.Value retValue = func.expr_runtime.ComputeValue(content);
                        content.DepthRemove();

                        return((ReturnType)retValue.value);
                    }
                    catch (Exception err)
                    {
                        string errinfo = "Dump Call in:";
                        if (_func.calltype != null)
                        {
                            errinfo += _func.calltype.Name + "::";
                        }
                        if (_func.function != null)
                        {
                            errinfo += _func.function;
                        }
                        errinfo += "\n";
                        env.logger.Log(errinfo + content.Dump());
                        throw err;
                    }
                }
                return(default(ReturnType));
            };

            _dele = Delegate.CreateDelegate(this.type, dele.Target, dele.Method);
            return(delefunc.cacheFunction(this._type, _dele));
        }
Пример #19
0
 public bool MathLogic(CLS_Content env, logictoken code, object left, CLS_Content.Value right)
 {
     if (code == logictoken.equal)
     {
         return(null == right.value);
     }
     else if (code == logictoken.not_equal)
     {
         return(null != right.value);
     }
     throw new NotImplementedException();
 }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            //List<CLS_Content.Value> list = new List<CLS_Content.Value>();
            CLS_Content.Value value = new CLS_Content.Value();
            value.type = typeof(DeleLambda);
            value.value = new DeleLambda(content,(this.listParam[0] as CLS_Expression_Block).listParam,this.listParam[1]);
            //创建一个匿名方法
            content.OutStack(this);
            return value;

        }
Пример #21
0
        public override object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype)
        {
            bool   math2ValueSuccess = false;
            object value             = NumericTypeUtils.Math2Value <char>(code, left, right, out returntype, out math2ValueSuccess);

            if (math2ValueSuccess)
            {
                return(value);
            }

            return(base.Math2Value(env, code, left, right, out returntype));
        }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            List <CLS_Content.Value> list = new List <CLS_Content.Value>();

            CLS_Content.Value value = new CLS_Content.Value();
            value.type  = typeof(DeleLambda);
            value.value = new DeleLambda(content, (this.listParam[0] as CLS_Expression_Block).listParam, this.listParam[1]);
            //创建一个匿名方法
            content.OutStack(this);
            return(value);
        }
Пример #23
0
        public virtual CLS_Content.Value IndexGet(CLS_Content environment, object object_this, object key)
        {
            //var m = type.GetMembers();
            if (indexGetCache == null)
            {
                indexGetCache = type.GetMethod("get_Item");
                if (indexGetCache != null)
                {
                    indexGetCacheType = indexGetCache.ReturnType;
                }
                //    CLS_Content.Value v = new CLS_Content.Value();
                //    v.type = targetop.ReturnType;
                //    v.value = targetop.Invoke(object_this, new object[] { key });
                //    return v;
                //}
                if (indexGetCache == null)
                {
                    indexGetCache = type.GetMethod("GetValue", new Type[] { typeof(int) });
                    if (indexGetCache != null)
                    {
                        indexGetCacheType = type.GetElementType();
                    }
                }
                if (indexGetCache != null)
                {
                    CLS_Content.Value v = new CLS_Content.Value();
                    v.type  = indexGetCacheType;
                    v.value = indexGetCache.Invoke(object_this, new object[] { key });
                    return(v);
                }
                //{
                //    targetop = type.GetMethod("GetValue", new Type[] { typeof(int) });
                //    if (targetop != null)
                //    {
                //        //targetop = type.GetMethod("Get");

                //        CLS_Content.Value v = new CLS_Content.Value();
                //        v.type = type.GetElementType();
                //        v.value = targetop.Invoke(object_this, new object[] { key });
                //        return v;
                //    }
                //}
            }
            else
            {
                CLS_Content.Value v = new CLS_Content.Value();
                v.type  = indexGetCacheType;
                v.value = indexGetCache.Invoke(object_this, new object[] { key });
                return(v);
            }
            throw new NotImplementedException();
        }
Пример #24
0
        public virtual bool MathLogic(CLS_Content env, logictoken code, object left, CLS_Content.Value right)
        {
            System.Reflection.MethodInfo call = null;

            //var m = _type.GetMethods();
            if (code == logictoken.more)//[2] = {Boolean op_GreaterThan(CLScriptExt.Vector3, CLScriptExt.Vector3)}
            {
                call = _type.GetMethod("op_GreaterThan");
            }
            else if (code == logictoken.less)//[4] = {Boolean op_LessThan(CLScriptExt.Vector3, CLScriptExt.Vector3)}
            {
                call = _type.GetMethod("op_LessThan");
            }
            else if (code == logictoken.more_equal)//[3] = {Boolean op_GreaterThanOrEqual(CLScriptExt.Vector3, CLScriptExt.Vector3)}
            {
                call = _type.GetMethod("op_GreaterThanOrEqual");
            }
            else if (code == logictoken.less_equal)//[5] = {Boolean op_LessThanOrEqual(CLScriptExt.Vector3, CLScriptExt.Vector3)}
            {
                call = _type.GetMethod("op_LessThanOrEqual");
            }
            else if (code == logictoken.equal)//[6] = {Boolean op_Equality(CLScriptExt.Vector3, CLScriptExt.Vector3)}
            {
                if (left == null || right.type == null)
                {
                    return(left == right.value);
                }



                call = _type.GetMethod("op_Equality");
                if (call == null)
                {
                    return(left.Equals(right.value));
                }
            }
            else if (code == logictoken.not_equal)//[7] = {Boolean op_Inequality(CLScriptExt.Vector3, CLScriptExt.Vector3)}
            {
                if (left == null || right.type == null)
                {
                    return(left != right.value);
                }
                call = _type.GetMethod("op_Inequality");
                if (call == null)
                {
                    return(!left.Equals(right.value));
                }
            }
            var obj = call.Invoke(null, new object[] { left, right.value });

            return((bool)obj);
        }
Пример #25
0
        public CLS_Content.Value MemberValueGet(CLS_Content environment, object object_this, string valuename)
        {
            SInstance sin = object_this as SInstance;

            if (sin.member.ContainsKey(valuename))
            {
                CLS_Content.Value v = new CLS_Content.Value();
                v.type  = sin.member[valuename].type;
                v.value = sin.member[valuename].value;
                return(v);
            }
            throw new NotImplementedException();
        }
Пример #26
0
        public CLS_Content.Value StaticValueGet(CLS_Content content, string valuename)
        {
            NewStatic(content.environment);

            if (this.staticMemberInstance.ContainsKey(valuename))
            {
                CLS_Content.Value v = new CLS_Content.Value();
                v.type  = this.staticMemberInstance[valuename].type;
                v.value = this.staticMemberInstance[valuename].value;
                return(v);
            }
            throw new NotImplementedException();
        }
Пример #27
0
        public virtual CLS_Content.Value StaticValueGet(CLS_Content environment, string valuename)
        {
            var targetf = type.GetField(valuename);

            if (targetf != null)
            {
                CLS_Content.Value v = new CLS_Content.Value();
                v.value = targetf.GetValue(null);
                v.type  = targetf.FieldType;
                return(v);
            }
            else
            {
                var methodf = type.GetMethod("get_" + valuename);
                if (methodf != null)
                {
                    CLS_Content.Value v = new CLS_Content.Value();
                    v.value = methodf.Invoke(null, null);
                    v.type  = methodf.ReturnType;
                    return(v);
                }
                //var targetf = type.GetField(valuename);
                //if (targetf != null)
                //{
                //    CLS_Content.Value v = new CLS_Content.Value();
                //    v.value = targetf.GetValue(null);
                //    v.type = targetf.FieldType;
                //    return v;
                //}
                else
                {
                    var targete = type.GetEvent(valuename);
                    if (targete != null)
                    {
                        CLS_Content.Value v = new CLS_Content.Value();

                        v.value = new DeleEvent(null, targete);
                        v.type  = targete.EventHandlerType;
                        return(v);
                    }
                }
            }
            if (type.BaseType != null)
            {
                return(environment.environment.GetType(type.BaseType).function.StaticValueGet(environment, valuename));
            }


            throw new NotImplementedException();
        }
        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);
        }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);

            var       right = listParam[0].ComputeValue(content);
            ICLS_Type type  = content.environment.GetType(right.type);

            CLS_Content.Value value = new CLS_Content.Value();
            value.type  = typeof(bool);
            value.value = type.ConvertTo(content, right.value, targettype) != null;

            content.OutStack(this);
            return(value);
        }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            CLS_Content.Value result = new CLS_Content.Value();


            //if(mathop=="<"||mathop=="<="||mathop==">"||mathop==">="||mathop=="=="||mathop=="!=")
            {
                result.type = typeof(bool);
                var left = listParam[0].ComputeValue(content);
                var right = listParam[1].ComputeValue(content);
                if(left.type==null||right.type==null)
                {
                    if (mathop == logictoken.equal)
                    {
                        result.value = left.value == right.value;
                    }
                    if(mathop== logictoken.not_equal)
                    {
                        result.value = left.value != right.value;
                    }
                }
                else if ((Type)left.type == typeof(bool) && (Type)right.type == typeof(bool))
                {
                    if (mathop == logictoken.equal)
                    {
                        result.value = (bool)left.value == (bool)right.value;
                        //return result;
                    }
                    else if (mathop == logictoken.not_equal)
                    {
                        result.value = (bool)left.value != (bool)right.value;
                        //return result;
                    }
                    else
                    {
                        throw new Exception("bool 不支持此运算符");
                    }
                }
                else
                {

                    result.value = content.environment.GetType(left.type).MathLogic(content, mathop, left.value, right);

                }
            }
            content.OutStack(this);

            return result;
        }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            BetterList <CLS_Content.Value> _params = CLS_Content.NewParamList();

            for (int i = 0, count = listParam.Count; i < count; i++)
            {
                _params.Add(listParam[i].ComputeValue(content));
            }
            CLS_Content.Value value = type.function.New(content, _params);
            CLS_Content.PoolParamList(_params);
            content.OutStack(this);
            return(value);
        }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            BetterList <CLS_Content.Value> _params = CLS_Content.NewParamList();

            for (int i = 0, count = listParam.Count; i < count; i++)
            {
                _params.Add(listParam[i].ComputeValue(content));
            }
            CLS_Content.Value retVal = content.environment.GetFunction(funcname).Call(content, _params);
            CLS_Content.PoolParamList(_params);
            content.OutStack(this);
            return(retVal);
        }
Пример #33
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);
            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);
        }
Пример #35
0
        public virtual CLS_Content.Value New(CLS_Content content, BetterList <CLS_Content.Value> _params)
        {
            Type[]            pts = CLS_Content.ParamTypesArray[_params.size];
            object[]          ps  = CLS_Content.ParamObjsArray[_params.size];
            CLS_Content.Value tempValue;
            for (int i = 0; i < _params.size; i++)
            {
                tempValue = _params[i];
                if (tempValue.type == null)
                {
                    pts[i] = typeof(object);
                }
                else if ((SType)tempValue.type != null)
                {
                    pts[i] = typeof(SInstance);
                }
                else if ((Type)tempValue.type != null)
                {
                    pts[i] = tempValue.type;
                }
                else
                {
                    pts[i] = typeof(object);
                }
                ps[i] = tempValue.value;
            }

            CacheMethod cache;

            if (!s_cacheMethod.TryGetValue(content.CallExpression, out cache))
            {
                cache             = new CacheMethod();
                cache.constructor = this.type.GetConstructor(pts);
                s_cacheMethod[content.CallExpression] = cache;
            }

            CLS_Content.Value retVal = new CLS_Content.Value();
            if (cache.constructor != null)
            {
                retVal.value = cache.constructor.Invoke(ps);
                retVal.type  = this.type;
            }
            else
            {
                retVal.value = Activator.CreateInstance(this.type);
                retVal.type  = this.type;
            }
            return(retVal);
        }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            CLS_Content.Value result = null;


            {
                result = new CLS_Content.Value();
                var left  = listParam[0].ComputeValue(content);
                var right = listParam[1].ComputeValue(content);
                result.value = content.environment.GetType(left.type).Math2Value(content, mathop, left.value, right, out result.type);
            }
            content.OutStack(this);
            return(result);
        }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);

            CLS_Content.Value oriVal = listParam[0].ComputeValue(content);

            CLS_Content.Value retVal = new CLS_Content.Value();

            ICLS_Type type = content.environment.GetType(oriVal.type);
            retVal.value = type.Math2Value(content, '~', oriVal.value, CLS_Content.Value.One, out retVal.type);

            content.OutStack(this);

            return retVal;
        }
Пример #38
0
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            CLS_Content.Value v   = listParam[0].ComputeValue(content);
            Exception         err = v.value as Exception;

            if (err != null)
            {
                throw err;
            }
            else
            {
                throw new Exception(v.ToString());
            }
        }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);

            CLS_Content.Value r = listParam[0].ComputeValue(content);


            CLS_Content.Value r2 = new CLS_Content.Value();
            r2.type = r.type;
            r2.breakBlock = r.breakBlock;
            r2.value = !(bool)r.value;
            content.OutStack(this);

            return r2;
        }
Пример #40
0
        public virtual CLS_Content.Value IndexGet(CLS_Content environment, object object_this, object key)
        {
            //var m =type.GetMembers();
            var targetop = type.GetMethod("get_Item");

            if (targetop == null)
            {
                targetop = type.GetMethod("Get");
            }

            CLS_Content.Value v = new CLS_Content.Value();
            v.type  = targetop.ReturnType;
            v.value = targetop.Invoke(object_this, new object[] { key });
            return(v);
        }
Пример #41
0
 public CLS_Content.Value ComputeValue(CLS_Content content)
 {
     CLS_Content.Value srcVal = listParam[0].ComputeValue(content);
     // 不能直接修改srcVal
     CLS_Content.Value val = new CLS_Content.Value();
     val.type = srcVal.type;
     val.value = srcVal.value;
     val.breakBlock = srcVal.breakBlock;
     val.breakBlock += 10;
     #if UNITY_EDITOR
     if (val.value is System.Collections.IEnumerator)
         throw new Exception("Dont support yield return IEnumerator, please use StartCoroutine(IEnumerator) instead: " + content.DumpStack());
     #endif
     return val;
 }
Пример #42
0
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);

            CLS_Content.Value r = listParam[0].ComputeValue(content);


            CLS_Content.Value r2 = new CLS_Content.Value();
            r2.type       = r.type;
            r2.breakBlock = r.breakBlock;
            r2.value      = !(bool)r.value;
            content.OutStack(this);

            return(r2);
        }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            CLS_Content.Value result = new CLS_Content.Value();


            //if(mathop=="<"||mathop=="<="||mathop==">"||mathop==">="||mathop=="=="||mathop=="!=")
            {
                result.type = typeof(bool);
                var left  = listParam[0].ComputeValue(content);
                var right = listParam[1].ComputeValue(content);
                if (left.type == null || right.type == null)
                {
                    if (mathop == logictoken.equal)
                    {
                        result.value = left.value == right.value;
                    }
                    if (mathop == logictoken.not_equal)
                    {
                        result.value = left.value != right.value;
                    }
                }
                else if ((Type)left.type == typeof(bool) && (Type)right.type == typeof(bool))
                {
                    if (mathop == logictoken.equal)
                    {
                        result.value = (bool)left.value == (bool)right.value;
                        //return result;
                    }
                    else if (mathop == logictoken.not_equal)
                    {
                        result.value = (bool)left.value != (bool)right.value;
                        //return result;
                    }
                    else
                    {
                        throw new Exception("bool 不支持此运算符");
                    }
                }
                else
                {
                    result.value = content.environment.GetType(left.type).MathLogic(content, mathop, left.value, right);
                }
            }
            content.OutStack(this);

            return(result);
        }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            CLS_Content.Value parent = listParam[0].ComputeValue(content);
            ICLS_Type         type   = content.environment.GetType(parent.type);
            BetterList <CLS_Content.Value> _params = CLS_Content.NewParamList();

            for (int i = 1, count = listParam.Count; i < count; i++)
            {
                _params.Add(listParam[i].ComputeValue(content));
            }
            CLS_Content.Value value = type.function.MemberCall(content, parent.value, functionName, _params, parent.breakBlock == 255);
            CLS_Content.PoolParamList(_params);
            content.OutStack(this);
            return(value);
        }
Пример #45
0
        public virtual CLS_Content.Value New(CLS_Content environment, IList<CLS_Content.Value> _params)
        {

            List<Type> types = new List<Type>();
            List<object> objparams = new List<object>();
            foreach (var p in _params)
            {
                types.Add(p.type);
                objparams.Add(p.value);
            }
            CLS_Content.Value value = new CLS_Content.Value();
            value.type = type;
            var con = this.type.GetConstructor(types.ToArray());
            value.value = con.Invoke(objparams.ToArray());
            return value;
        }
Пример #46
0
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);

            CLS_Content.Value left = content.Get(value_name);
            ICLS_Type         type = content.environment.GetType(left.type);
            CLType            returntype;

            left.value = type.Math2Value(content, mathop, left.value, CLS_Content.Value.One, out returntype);
            //left.value = type.ConvertTo(content, left.value, v.type);
            //content.Set(value_name, left.value);

            content.OutStack(this);

            return(content.Get(value_name));
        }
Пример #47
0
 public object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype)
 {
     returntype = typeof(string);
     if (code == '+')
     {
         if (right.value == null)
         {
             return((string)left + "null");
         }
         else
         {
             return((string)left + right.value.ToString());
         }
     }
     throw new NotImplementedException();
 }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);

            CLS_Content.Value oriVal = listParam[0].ComputeValue(content);

            CLS_Content.Value retVal = new CLS_Content.Value();

            retVal.type       = oriVal.type;
            retVal.breakBlock = oriVal.breakBlock;
            retVal.value      = !(bool)oriVal.value;

            content.OutStack(this);

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

            CLS_Content.Value oriVal = listParam[0].ComputeValue(content);

            CLS_Content.Value retVal = new CLS_Content.Value();

            ICLS_Type type = content.environment.GetType(oriVal.type);

            retVal.value = type.Math2Value(content, '*', oriVal.value, CLS_Content.Value.OneMinus, out retVal.type);

            content.OutStack(this);

            return(retVal);
        }
Пример #50
0
 public CLS_Content.Value ComputeValue(CLS_Content content)
 {
     content.InStack(this);
     CLS_Content.Value value = listParam[0].ComputeValue(content);
     CLS_Content.Value result;
     if ((bool)value.value)
     {
         result = listParam[1].ComputeValue(content);
     }
     else
     {
         result = listParam[2].ComputeValue(content);
     }
     content.OutStack(this);
     return(result);
 }
Пример #51
0
        public virtual CLS_Content.Value MemberCall(CLS_Content environment, object object_this, string func, IList <CLS_Content.Value> _params)
        {
            List <Type>   types    = new List <Type>();
            List <object> _oparams = new List <object>();

            foreach (var p in _params)
            {
                {
                    _oparams.Add(p.value);
                }
                if ((SType)p.type != null)
                {
                    types.Add(typeof(object));
                }
                else
                {
                    types.Add(p.type);
                }
            }

            var targetop = type.GetMethod(func, types.ToArray());

            CLS_Content.Value v = new CLS_Content.Value();
            if (targetop == null)
            {
                if (func[func.Length - 1] == '>')//这是一个临时的模板函数调用
                {
                    string[] sf    = func.Split(new char[] { '<', ',', '>' }, StringSplitOptions.RemoveEmptyEntries);
                    string   tfunc = sf[0];

                    Type[] gtypes = new Type[sf.Length - 1];

                    for (int i = 1; i < sf.Length; i++)
                    {
                        gtypes[i - 1] = environment.environment.GetTypeByKeyword(sf[i]).type;
                    }
                    targetop = FindTMethod(type, tfunc, _params, gtypes);
                }
                else
                {
                    throw new Exception("函数不存在function:" + type.ToString() + "." + func);
                }
            }
            v.value = targetop.Invoke(object_this, _oparams.ToArray());
            v.type  = targetop.ReturnType;
            return(v);
        }
 public CLS_Content.Value ComputeValue(CLS_Content content)
 {
     content.InStack(this);
     CLS_Content.Value rv;
     if (listParam.Count > 0 && listParam[0] != null)
     {
         rv = listParam[0].ComputeValue(content);
     }
     else
     {
         rv = new CLS_Content.Value();
         rv.type = typeof(void);
     }
     rv.breakBlock = 3;
     content.OutStack(this);
     return rv;
 }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);

            var right = listParam[0].ComputeValue(content);
            ICLS_Type type = content.environment.GetType(right.type);
            CLS_Content.Value value = new CLS_Content.Value();
            value.type = typeof(bool);
            value.value = type.ConvertTo(content, right.value, targettype) != null;

            //操作变量之
            //做数学计算
            //从上下文取值
            //_value = null;
            content.OutStack(this);

            return value;
        }
Пример #54
0
        public virtual CLS_Content.Value StaticValueGet(CLS_Content environment, string valuename)
        {
            var targetf = type.GetField(valuename);
            if (targetf != null)
            {
                CLS_Content.Value v = new CLS_Content.Value();
                v.value = targetf.GetValue(null);
                v.type = targetf.FieldType;
                return v;
            }
            else
            {
                var methodf = type.GetMethod("get_" + valuename);
                if (methodf != null)
                {
                    CLS_Content.Value v = new CLS_Content.Value();
                    v.value = methodf.Invoke(null, null);
                    v.type = methodf.ReturnType;
                    return v;
                }
                //var targetf = type.GetField(valuename);
                //if (targetf != null)
                //{
                //    CLS_Content.Value v = new CLS_Content.Value();
                //    v.value = targetf.GetValue(null);
                //    v.type = targetf.FieldType;
                //    return v;
                //}
                else
                {
                    var targete = type.GetEvent(valuename);
                    if (targete != null)
                    {
                        CLS_Content.Value v = new CLS_Content.Value();

                        v.value = new DeleEvent(null, targete);
                        v.type = targete.EventHandlerType;
                        return v;
                    }
                }
            }

            return null;
        }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            CLS_Content.Value result = new CLS_Content.Value();

            //if (mathop == "&&" || mathop == "||")
            {
                bool bleft = false;
                bool bright = false;
                if (listParam[0] is ICLS_Value)
                {
                    bleft = (bool)((listParam[0] as ICLS_Value).value);
                }
                else
                {
                    bleft = (bool)listParam[0].ComputeValue(content).value;
                }

                if (listParam[1] is ICLS_Value)
                {
                    bright = (bool)((listParam[1] as ICLS_Value).value);
                }
                else
                {
                    bright = (bool)listParam[1].ComputeValue(content).value;
                }
                result.type = typeof(bool);


                if (mathop == '&')
                {

                    result.value = (bool)(bleft && bright);
                }
                else if (mathop == '|')
                {
                    result.value = (bool)(bleft || bright);
                }
            }
            content.OutStack(this);
            return result;

        }
Пример #56
0
        public override CLS_Content.Value MemberCall(CLS_Content content, object object_this, string function, BetterList<CLS_Content.Value> _params, bool isBaseCall = false)
        {
            if (function == "Equals")
            {
                CLS_Content.Value val = new CLS_Content.Value();
                val.type = typeof(bool);
                val.value = ((Time)object_this).Equals(_params[0].value);
                return val;
            }
            else if (function == "ToString")
            {
                CLS_Content.Value val = new CLS_Content.Value();
                val.type = typeof(string);
                val.value = ((Time)object_this).ToString();
                return val;
            }

            return base.MemberCall(content, object_this, function, _params, isBaseCall);
        }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);

            CLS_Content.Value getvalue = type.function.StaticValueGet(content, staticmembername);

            CLS_Content.Value vright = CLS_Content.Value.One;
            if (listParam.Count > 0)
            {
                vright = listParam[0].ComputeValue(content);
            }

            CLS_Content.Value vout = new CLS_Content.Value();
            vout.value = content.environment.GetType(getvalue.type).Math2Value(content, mathop, getvalue.value, vright, out vout.type);

            type.function.StaticValueSet(content, staticmembername, vout.value);

            content.OutStack(this);
            return vout;
        }
Пример #58
0
        public virtual CLS_Content.Value StaticCall(CLS_Content environment, string function, IList<CLS_Content.Value> _params)
        {

            List<object> _oparams = new List<object>();
            List<Type> types = new List<Type>();
            foreach (var p in _params)
            {
                _oparams.Add(p.value);
                types.Add(p.type);
            }
            var targetop = type.GetMethod(function, types.ToArray());
            if (targetop == null && type.BaseType != null)//加上父类型静态函数查找,典型的现象是 GameObject.Destory
            {
                targetop = type.BaseType.GetMethod(function, types.ToArray());
            }
            CLS_Content.Value v = new CLS_Content.Value();
            v.value = targetop.Invoke(null, _oparams.ToArray());
            v.type = targetop.ReturnType;
            return v;


        }
Пример #59
0
        public override CSLE.CLS_Content.Value StaticCall(CSLE.CLS_Content environment, string function, IList<CSLE.CLS_Content.Value> _params)
        {
            switch(function)
            {
                case "Destory":
                    GameObject.Destroy(_params[0].value as UnityEngine.Object);
                    return CSLE.CLS_Content.Value.Void;
                case "DestroyImmediate":
                    GameObject.DestroyImmediate(_params[0].value as UnityEngine.Object);
                    return CSLE.CLS_Content.Value.Void;
                case "Find":
                    {
                        CSLE.CLS_Content.Value v =new CSLE.CLS_Content.Value();
                        v.value=GameObject.Find(_params[0].value as string);
                        v.type = typeof(GameObject);
                        return v;
                    }
            }

            
            return base.StaticCall(environment, function, _params);
        }
Пример #60
0
        public override CLS_Content.Value MemberCall(CLS_Content content, object object_this, string function, BetterList<CLS_Content.Value> _params, bool isBaseCall = false)
        {
            CLS_Content.Value retVal = null;

            Mathf newVal = (Mathf)object_this;
            if (function == "Equals")
            {
                retVal = new CLS_Content.Value();
                retVal.type = typeof(bool);
                retVal.value = newVal.Equals(_params[0].value);
            }
            else if (function == "ToString")
            {
                retVal = new CLS_Content.Value();
                retVal.type = typeof(string);
                retVal.value = newVal.ToString();
            }
            else
                return base.MemberCall(content, object_this, function, _params, isBaseCall);
            ICLS_Expression expLeft = content.CallExpression.listParam[0];
            CLS_Expression_GetValue expGetValue = expLeft as CLS_Expression_GetValue;
            if (expGetValue != null)
            {
                content.Set(expGetValue.value_name, newVal);
                return retVal;
            }
            CLS_Expression_MemberFind expMemberFind = expLeft as CLS_Expression_MemberFind;
            if (expMemberFind != null)
            {
                expGetValue = expMemberFind.listParam[0] as CLS_Expression_GetValue;
                CLS_Content.Value val = content.Get(expGetValue.value_name);
                content.environment.GetType(val.type).function.MemberValueSet(content, val.value, expMemberFind.membername, newVal);
                return retVal;
            }

            return base.MemberCall(content, object_this, function, _params, isBaseCall);
        }