public Delegate CreateDelegate(ICLS_Environment env, DeleFunction delefunc)
        {
            DeleFunction _func = delefunc;
            Delegate     _dele = delefunc.cacheFunction(null);

            if (_dele != null)
            {
                return(_dele);
            }
            NonVoidDelegate dele = delegate(T param) {
                var func = _func.calltype.functions[_func.function];
                if (func.expr_runtime != null)
                {
                    CLS_Content content = new CLS_Content(env);

                    content.DepthAdd();
                    content.CallThis = _func.callthis;
                    content.CallType = _func.calltype;
                    content.function = _func.function;

                    content.DefineAndSet(func._paramnames[0], func._paramtypes[0].type, param);
                    CLS_Content.Value retValue = func.expr_runtime.ComputeValue(content);
                    content.DepthRemove();

                    return((ReturnType)retValue.value);
                }
                return(default(ReturnType));
            };

            _dele = Delegate.CreateDelegate(this.type, dele.Target, dele.Method);
            return(delefunc.cacheFunction(_dele));
        }
        public Delegate CreateDelegate(ICLS_Environment env, DeleLambda lambda)
        {
            var pnames = lambda.paramNames;
            var expr   = lambda.expr_func;

            NonVoidDelegate dele = delegate(T param) {
                if (expr != null)
                {
                    CLS_Content content = lambda.content.Clone();

                    content.DepthAdd();

                    content.DefineAndSet(pnames[0], typeof(T), param);
                    CLS_Content.Value retValue = expr.ComputeValue(content);

                    content.DepthRemove();

                    return((ReturnType)retValue.value);
                }
                return(default(ReturnType));
            };

            Delegate d = dele as Delegate;

            return(Delegate.CreateDelegate(this.type, d.Target, d.Method));
        }
Ejemplo n.º 3
0
 public override CLS_Content.Value IndexGet(CLS_Content content, object object_this, object key)
 {
     return(new CLS_Content.Value()
     {
         type = typeof(TValue), value = ((Dictionary <TKey, TValue>)object_this)[(TKey)key]
     });
 }
Ejemplo n.º 4
0
        public virtual object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype)
        {
            returntype = type;
            System.Reflection.MethodInfo call = null;
            var m = ((Type)type).GetMembers();

            if (code == '+')
            {
                call = _type.GetMethod("op_Addition", new Type[] { this.type, right.type });
            }
            else if (code == '-')//base = {CLScriptExt.Vector3 op_Subtraction(CLScriptExt.Vector3, CLScriptExt.Vector3)}
            {
                call = _type.GetMethod("op_Subtraction", new Type[] { this.type, right.type });
            }
            else if (code == '*')//[2] = {CLScriptExt.Vector3 op_Multiply(CLScriptExt.Vector3, CLScriptExt.Vector3)}
            {
                call = _type.GetMethod("op_Multiply", new Type[] { this.type, right.type });
            }
            else if (code == '/')//[3] = {CLScriptExt.Vector3 op_Division(CLScriptExt.Vector3, CLScriptExt.Vector3)}
            {
                call = _type.GetMethod("op_Division", new Type[] { this.type, right.type });
            }
            else if (code == '%')//[4] = {CLScriptExt.Vector3 op_Modulus(CLScriptExt.Vector3, CLScriptExt.Vector3)}
            {
                call = _type.GetMethod("op_Modulus", new Type[] { this.type, right.type });
            }


            var obj = call.Invoke(null, new object[] { left, right.value });

            //function.StaticCall(env,"op_Addtion",new List<ICL>{})
            return(obj);
        }
Ejemplo n.º 5
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)
            {
                CLS_Content.Value v = new CLS_Content.Value();
                v.type  = targetop.ReturnType;
                v.value = targetop.Invoke(object_this, new object[] { key });
                return(v);
            }

            if (targetop == null)
            {
                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);
                }
            }
            throw new NotImplementedException();
        }
Ejemplo n.º 6
0
 public virtual void IndexSet(CLS_Content environment, object object_this, object key, object value)
 {
     if (indexSetCache == null)
     {
         indexSetCache         = type.GetMethod("set_Item");
         indexSetCachekeyfirst = true;
         if (indexSetCache == null)
         {
             indexSetCache         = type.GetMethod("SetValue", new Type[] { typeof(object), typeof(int) });
             indexSetCachekeyfirst = false;
         }
     }
     //else
     if (indexSetCachekeyfirst)
     {
         indexSetCache.Invoke(object_this, new object[] { key, value });
     }
     else
     {
         indexSetCache.Invoke(object_this, new object[] { value, key });
     }
     //var m = type.GetMethods();
     //var targetop = type.GetMethod("set_Item");
     //if (targetop == null)
     //{
     //    //targetop = type.GetMethod("Set");
     //    targetop = type.GetMethod("SetValue", new Type[] { typeof(object), typeof(int) });
     //    targetop.Invoke(object_this, new object[] { value, key });
     //    return;
     //}
     //targetop.Invoke(object_this, new object[] { key, value });
 }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            content.DepthAdd();

            CLS_Content.Value vrt = null;

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

            do
            {
                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;
                    }
                }
            } while ((bool)expr_while.ComputeValue(content).value);

            content.DepthRemove();
            content.OutStack(this);
            return vrt;
        }
Ejemplo n.º 8
0
 public override object ConvertTo(CLS_Content env, object src, CLType targetType)
 {
     Type t = targetType;
     if (t == typeof(double))
         return (double)(long)(src);
     if (t == typeof(float))
         return (float)(long)(src);
     if (t == typeof(long))
         return src;
     if (t == typeof(ulong))
         return (ulong)(long)(src);
     if (t == typeof(int))
         return (int)(long)(src);
     if (t == typeof(uint))
         return (uint)(long)(src);
     if (t == typeof(short))
         return (short)(long)(src);
     if (t == typeof(ushort))
         return (ushort)(long)(src);
     if (t == typeof(sbyte))
         return (sbyte)(long)(src);
     if (t == typeof(byte))
         return (byte)(long)(src);
     if (t == typeof(char))
         return (char)(long)(src);
     if (t == typeof(int?))
         return (int?)(long)(src);
     if (t == typeof(uint?))
         return (uint?)(long)(src);
     return base.ConvertTo(env, src, targetType);
 }
Ejemplo n.º 9
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(0, 0, 200, 50), "Eval use String"))
        {
            Script.ClearValue();
            string callExpr = "ScriptClass1 sc =new ScriptClass1();\n" +
                              "sc.defHP1=200;\n" +
                              "sc.defHP2=300;\n" +
                              "return sc.GetHP();";
            object i = Script.Execute(callExpr);
            result = "result=" + i;
        }

        if (GUI.Button(new Rect(200, 0, 200, 50), "Eval use Code"))
        {
            Script.ClearValue();
            CSLE.CLS_Content content = new CSLE.CLS_Content(Script.env);
            //得到脚本类型
            var typeOfScript = Script.env.GetTypeByKeyword("ScriptClass1");
            //调用脚本类构造创造一个实例
            var thisOfScript = typeOfScript.function.New(content, null).value;
            //调用脚本类成员变量赋值
            //Debug.LogWarning(thisOfScript+","+ typeOfScript+","+ typeOfScript.function);
            typeOfScript.function.MemberValueSet(content, thisOfScript, "defHP1", 200);
            typeOfScript.function.MemberValueSet(content, thisOfScript, "defHP2", 300);
            //调用脚本类成员函数
            var    returnvalue = typeOfScript.function.MemberCall(content, thisOfScript, "GetHP", null);
            object i           = returnvalue.value;
            result = "result=" + i;
        }

        GUI.Label(new Rect(0, 50, 200, 50), result);
    }
        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 key = listParam[1].ComputeValue(content);
            var type = content.environment.GetType(parent.type);

            var value = type.function.IndexGet(content, parent.value, key.value);
            content.OutStack(this);

            //IndexGet返回的值类型是 System.Object.
            //在这里需要将类型明确化.
            //value.type = value.value.GetType();

            return value;
            //return type.function.MemberValueGet(content.environment, parent.value, membername);
            //做数学计算
            //从上下文取值
            //_value = null;
            //return 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 Delegate CreateDelegate(ICLS_Environment env, DeleFunction delefunc)
        {
            CLS_Content  content = new CLS_Content(env);
            DeleFunction _func   = delefunc;
            Action <T>   dele    = (T param0) =>
            {
                content.DepthAdd();
                content.CallThis = _func.callthis;
                content.CallType = _func.calltype;
                content.function = _func.function;
                var func = _func.calltype.functions[_func.function];

                content.DefineAndSet(func._paramnames[0], func._paramtypes[0].type, param0);

                func.expr_runtime.ComputeValue(content);
                content.DepthRemove();
            };
            Delegate d = dele as Delegate;

            if ((Type)this.type != typeof(Action <T>))
            {
                return(Delegate.CreateDelegate(this.type, d.Target, d.Method));
            }
            else
            {
                return(dele);
            }
        }
Ejemplo n.º 13
0
        public override object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype)
        {
            returntype = null;

            Delegate rightDele = null;
            if (right.value is DeleFunction)
                rightDele = CreateDelegate(env.environment, right.value as DeleFunction);
            else if (right.value is DeleLambda)
                rightDele = CreateDelegate(env.environment, right.value as DeleLambda);
            else if (right.value is Delegate)
                rightDele = right.value as Delegate;

            if (rightDele != null)
            {
                Delegate leftDele = left as Delegate;
                if (left == null)
                    return rightDele;

                if (code == '+')
                    return Delegate.Combine(leftDele, rightDele);
                if (code == '-')
                    return Delegate.Remove(leftDele, rightDele);
            }

            throw new NotSupportedException("" + right.value);
        }
Ejemplo n.º 14
0
        public virtual object ConvertTo(CLS_Content env, object src, CLType targetType)
        {
            //type.get

            if (_type.IsEnum)
            {

                if ((Type)targetType == typeof(int))
                    return System.Convert.ToInt32(src);
                else if ((Type)targetType == typeof(uint))
                    return System.Convert.ToUInt32(src);
                else if ((Type)targetType == typeof(short))
                    return System.Convert.ToInt16(src);
                else if ((Type)targetType == typeof(ushort))
                    return System.Convert.ToUInt16(src);
                else
                {
                    return System.Convert.ToInt32(src);
                }
            }
            var ms = _type.GetMethods();
            foreach (var m in ms)
            {
                if ((m.Name == "op_Implicit" || m.Name == "op_Explicit") && m.ReturnType == (Type)targetType)
                {
                    return m.Invoke(null, new object[] { src });
                }
            }

            return src;
        }
        public override object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype)
        {
            returntype = null;

            if (left is DeleEvent)
            {
                DeleEvent info     = left as DeleEvent;
                Delegate  calldele = null;
                if (right.value is DeleFunction)
                {
                    calldele = CreateDelegate(env.environment, right.value as DeleFunction);
                }
                else if (right.value is DeleLambda)
                {
                    calldele = CreateDelegate(env.environment, right.value as DeleLambda);
                }
                else if (right.value is Delegate)
                {
                    calldele = right.value as Delegate;
                }

                if (code == '+')
                {
                    info._event.AddEventHandler(info.source, calldele);
                    return(null);
                }
                else if (code == '-')
                {
                    info._event.AddEventHandler(info.source, calldele);
                    return(null);
                }
            }
            else if (left is Delegate)
            {
                Delegate info     = left as Delegate;
                Delegate calldele = null;
                if (right.value is DeleFunction)
                {
                    calldele = CreateDelegate(env.environment, right.value as DeleFunction);
                }
                else if (right.value is DeleLambda)
                {
                    calldele = CreateDelegate(env.environment, right.value as DeleLambda);
                }
                else if (right.value is Delegate)
                {
                    calldele = right.value as Delegate;
                }
                if (code == '+')
                {
                    Delegate.Combine(info, calldele);
                    return(null);
                }
                else if (code == '-')
                {
                    Delegate.Remove(info, calldele);
                }
            }
            return(new NotSupportedException());
        }
Ejemplo n.º 16
0
 public override CLS_Content.Value IndexGet(CLS_Content content, object object_this, object key)
 {
     return(new CLS_Content.Value()
     {
         type = typeof(T), value = ((T[])object_this)[Convert.ToInt32(key)]
     });
 }
Ejemplo n.º 17
0
        public virtual void MemberValueSet(CLS_Content content, object object_this, string valuename, object value)
        {
            //先操作File
            var targetf = type.GetField(valuename);

            if (targetf != null)
            {
                if (value != null && value.GetType() != targetf.FieldType)
                {
                    value = content.environment.GetType(value.GetType()).ConvertTo(content, value, targetf.FieldType);
                }
                targetf.SetValue(object_this, value);
                return;
            }
            else
            {
                var methodf = type.GetMethod("set_" + valuename);
                if (methodf != null)
                {
                    var ptype = methodf.GetParameters()[0].ParameterType;
                    if (value != null && value.GetType() != ptype)
                    {
                        value = content.environment.GetType(value.GetType()).ConvertTo(content, value, ptype);
                    }
                    methodf.Invoke(object_this, new object[] { value });

                    return;
                }
            }



            throw new NotImplementedException();
        }
Ejemplo n.º 18
0
        public ScreenController(string name, IGameForModel game, IScreenForModel screen)
        {
            this.game   = game;
            this.screen = screen;


            IScriptModel script = game.GetModel("script") as IScriptModel;

            env = script.getScriptEnv();
            var type = env.GetTypeByKeywordQuiet(name) as CSLE.CLS_Type_Class;

            content    = new CSLE.CLS_Content(env);
            scriptThis = type.function.New(content, null).value as CSLE.SInstance;
            scriptThis.member["game"]         = new CSLE.CLS_Content.Value();
            scriptThis.member["game"].value   = game;
            scriptThis.member["game"].type    = typeof(IGameForModel);
            scriptThis.member["screen"]       = new CSLE.CLS_Content.Value();
            scriptThis.member["screen"].value = screen;
            scriptThis.member["screen"].type  = typeof(IScreenForModel);


            var typeasync = env.GetTypeByKeywordQuiet("IScreenControllerAsync") as CSLE.CLS_Type_Class;

            try
            {
                havetypeasync = (type.ConvertTo(content, scriptThis, typeasync.type) != null);
            }
            catch
            {
                havetypeasync = false;
            }
            Debug.Log(havetypeasync);
        }
 public CLS_Content.Value ComputeValue(CLS_Content content)
 {
     content.InStack(this);
     var parent = listParam[0].ComputeValue(content);
     var typefunction = content.environment.GetType(parent.type).function;
     if(parent.type is object)
     {
         SInstance s = parent.value as SInstance;
         if(s!=null)
         {
             typefunction = s.type;
         }
     }
     List<CLS_Content.Value> _params = new List<CLS_Content.Value>();
     for (int i = 1; i < listParam.Count; i++)
     {
         _params.Add(listParam[i].ComputeValue(content));
     }
     CLS_Content.Value value = null;
     if (cache == null||cache.cachefail)
     {
         cache = new MethodCache();
         value = typefunction.MemberCall(content, parent.value, functionName, _params,cache);
     }
     else
     {
         value = typefunction.MemberCallCache(content, parent.value, _params, cache);
     }
     content.OutStack(this);
     return value;
     //做数学计算
     //从上下文取值
     //_value = null;
     //return null;
 }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            //var parent = listParam[0].ComputeValue(content);
            //var type = content.environment.GetType(parent.type);
            List <CLS_Content.Value> _params = new List <CLS_Content.Value>();

            for (int i = 0; i < listParam.Count; i++)
            {
                _params.Add(listParam[i].ComputeValue(content));
            }
            CLS_Content.Value value = null;
            if (cache == null || cache.cachefail)
            {
                cache = new MethodCache();
                value = type.function.StaticCall(content, functionName, _params, cache);
            }
            else
            {
                value = type.function.StaticCallCache(content, _params, cache);
            }

            content.OutStack(this);
            return(value);
            //做数学计算
            //从上下文取值
            //_value = null;
            //return null;
        }
        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);
            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;
        }
Ejemplo n.º 23
0
        public object ConvertTo(CLS_Content env, object src, CLType targetType)
        {
            ICLS_Type_Dele dele = env.environment.GetType(targetType) as ICLS_Type_Dele;

            return(dele.CreateDelegate(env.environment, src as DeleLambda));
            //throw new NotImplementedException();
        }
Ejemplo n.º 24
0
 public bool MathLogic(CLS_Content env, logictoken code, object left, CLS_Content.Value right)
 {
     if (code == logictoken.equal)//[6] = {Boolean op_Equality(CLScriptExt.Vector3, CLScriptExt.Vector3)}
     {
         if (left == null || right.type == null)
         {
             return(left == right.value);
         }
         else
         {
             return(left == 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);
         }
         else
         {
             return(left != right.value);
         }
     }
     throw new NotImplementedException();
 }
 public CLS_Content.Value ComputeValue(CLS_Content content)
 {
     content.InStack(this);
     //var parent = listParam[0].ComputeValue(content);
     //var type = content.environment.GetType(parent.type);
     List<CLS_Content.Value> _params = new List<CLS_Content.Value>();
     for (int i = 0; i < listParam.Count; i++)
     {
         _params.Add(listParam[i].ComputeValue(content));
     }
     CLS_Content.Value value = null;
     if (cache == null || cache.cachefail)
     {
         cache = new MethodCache();
         value = type.function.StaticCall(content, functionName, _params, cache);
     }
     else
     {
         value = type.function.StaticCallCache(content, _params, cache);
     }
     
     content.OutStack(this);
     return value;
     //做数学计算
     //从上下文取值
     //_value = null;
     //return null;
 }
        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 key  = listParam[1].ComputeValue(content);
            var type = content.environment.GetType(parent.type);

            var value = type.function.IndexGet(content, parent.value, key.value);

            content.OutStack(this);

            //IndexGet返回的值类型是 System.Object.
            //在这里需要将类型明确化.
            //value.type = value.value.GetType();

            return(value);
            //return type.function.MemberValueGet(content.environment, parent.value, membername);
            //做数学计算
            //从上下文取值
            //_value = null;
            //return null;
        }
Ejemplo n.º 27
0
 public override CLS_Content.Value New(CLS_Content content, BetterList <CLS_Content.Value> _params)
 {
     CLS_Content.Value retVal = new CLS_Content.Value();
     retVal.value = new T[Convert.ToInt32(_params[0].value)];
     retVal.type  = type;
     return(retVal);
 }
Ejemplo n.º 28
0
        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);
        }
Ejemplo n.º 29
0
    void OnGUI()
    {


        if (GUI.Button(new Rect(0, 0, 200, 50), "Eval use String"))
        {
            Script.ClearValue();
            string callExpr ="ScriptClass1 sc =new ScriptClass1();\n"+
                            "sc.defHP1=200;\n"+
                            "sc.defHP2=300;\n"+
                            "return sc.GetHP();";
            object i = Script.Execute(callExpr);
            result = "result=" + i;
        }

        if (GUI.Button(new Rect(200, 0, 200, 50), "Eval use Code"))
        {
            Script.ClearValue();
            CSLE.CLS_Content content = new CSLE.CLS_Content(Script.env);
            //得到脚本类型
            var typeOfScript = Script.env.GetTypeByKeyword("ScriptClass1");
            //调用脚本类构造创造一个实例
            var thisOfScript = typeOfScript.function.New(content, null).value;
            //调用脚本类成员变量赋值
            //Debug.LogWarning(thisOfScript+","+ typeOfScript+","+ typeOfScript.function);
            typeOfScript.function.MemberValueSet(content, thisOfScript, "defHP1", 200);
            typeOfScript.function.MemberValueSet(content, thisOfScript, "defHP2", 300);
            //调用脚本类成员函数
            var returnvalue = typeOfScript.function.MemberCall(content, thisOfScript, "GetHP", null);
            object i = returnvalue.value;
            result = "result=" + i;
        }

        GUI.Label(new Rect(0, 50, 200, 50), result);
    }
        public Delegate CreateDelegate(ICLS_Environment env, DeleLambda lambda)
        {
            CLS_Content content = lambda.content.Clone();
            var         pnames  = lambda.paramNames;
            var         expr    = lambda.expr_func;
            Action <T>  dele    = (T param0) =>
            {
                content.DepthAdd();


                content.DefineAndSet(pnames[0], typeof(T), param0);

                expr.ComputeValue(content);

                content.DepthRemove();
            };
            Delegate d = dele as Delegate;

            if ((Type)this.type != typeof(Action <T>))
            {
                return(Delegate.CreateDelegate(this.type, d.Target, d.Method));
            }
            else
            {
                return(dele);
            }
        }
        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 CLS_Content.Value ComputeValue(CLS_Content content)
 {
     content.InStack(this);
     CLS_Content.Value value = type.function.StaticValueGet(content, staticmembername);
     content.OutStack(this);
     return value;
 }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);

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

                        {
                            object val = v.value;
                            if (content.values.ContainsKey(value_name))
                            {
                                CLType value_type = content.values[value_name].type;

                                val = v.value;
                                if ((Type)value_type != typeof(CLS_Type_Var.var) && value_type != v.type)
                                {
                                    val = content.environment.GetType(v.type).ConvertTo(content, v.value, value_type);
                                }
                            }
                    content.Set(value_name, val);
                    }
            }
            content.OutStack(this);
            return null;
        }
Ejemplo n.º 34
0
        public object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype)
        {
            returntype = typeof(float);
            if ((Type)right.type == typeof(int))
            {
                if (code == '+')
                    return (float)left + (float)(int)right.value;
                else if (code == '-')
                    return (float)left - (float)(int)right.value;
                else if (code == '*')
                    return (float)left * (float)(int)right.value;
                else if (code == '/')
                    return (float)left / (float)(int)right.value;
                else if (code == '%')
                    return (float)left % (float)(int)right.value;
            }
            else if ((Type)right.type == typeof(uint))
            {
                if (code == '+')
                    return (float)left + (float)(uint)right.value;
                else if (code == '-')
                    return (float)left - (float)(uint)right.value;
                else if (code == '*')
                    return (float)left * (float)(uint)right.value;
                else if (code == '/')
                    return (float)left / (float)(uint)right.value;
                else if (code == '%')
                    return (float)left % (float)(uint)right.value;
            }
            else if ((Type)right.type == typeof(double))
            {
                returntype = typeof(double);

                if (code == '+')
                    return (double)(float)left + (double)right.value;
                else if (code == '-')
                    return (double)(float)left - (double)right.value;
                else if (code == '*')
                    return (double)(float)left * (double)right.value;
                else if (code == '/')
                    return (double)(float)left / (double)right.value;
                else if (code == '%')
                    return (double)(float)left % (double)right.value;
            }
            else if ((Type)right.type == typeof(float))
            {
                returntype = typeof(float);
                if (code == '+')
                    return (float)left + (float)right.value;
                else if (code == '-')
                    return (float)left - (float)right.value;
                else if (code == '*')
                    return (float)left * (float)right.value;
                else if (code == '/')
                    return (float)left / (float)right.value;
                else if (code == '%')
                    return (float)left % (float)right.value;
            }
            throw new NotImplementedException();
        }
Ejemplo n.º 35
0
        public override object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype)
        {
            returntype = typeof(double);
            if ((Type)right.type == typeof(int))
            {
                if (code == '+')
                    return (double)left + (double)(int)right.value;
                else if (code == '-')
                    return (double)left - (double)(int)right.value;
                else if (code == '*')
                    return (double)left * (double)(int)right.value;
                else if (code == '/')
                    return (double)left / (double)(int)right.value;
                else if (code == '%')
                    return (double)left % (double)(int)right.value;
            }
            else if ((Type)right.type == typeof(uint))
            {
                if (code == '+')
                    return (double)left + (double)(uint)right.value;
                else if (code == '-')
                    return (double)left - (double)(uint)right.value;
                else if (code == '*')
                    return (double)left * (double)(uint)right.value;
                else if (code == '/')
                    return (double)left / (double)(uint)right.value;
                else if (code == '%')
                    return (double)left % (double)(uint)right.value;
            }
            else if ((Type)right.type == typeof(double))
            {
                returntype = typeof(double);

                if (code == '+')
                    return (double)left + (double)right.value;
                else if (code == '-')
                    return (double)left - (double)right.value;
                else if (code == '*')
                    return (double)left * (double)right.value;
                else if (code == '/')
                    return (double)left / (double)right.value;
                else if (code == '%')
                    return (double)left % (double)right.value;
            }
            else if ((Type)right.type == typeof(float))
            {
                returntype = typeof(double);
                if (code == '+')
                    return (double)left + (double)(float)right.value;
                else if (code == '-')
                    return (double)left - (double)(float)right.value;
                else if (code == '*')
                    return (double)left * (double)(float)right.value;
                else if (code == '/')
                    return (double)left / (double)(float)right.value;
                else if (code == '%')
                    return (double)left % (double)(float)right.value;
            }
            return base.Math2Value(env, code, left, right, out returntype);
        }
        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;
        }
Ejemplo n.º 37
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;
 }
Ejemplo n.º 38
0
        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());
            }
            ICLS_TypeFunction typefunction = content.environment.GetType(parent.type).function;

            if (parent.type is object)
            {
                SInstance s = parent.value as SInstance;
                if (s != null)
                {
                    typefunction = s.type;
                }
            }
            //var type = content.environment.GetType(parent.type);
            var value = typefunction.MemberValueGet(content, parent.value, membername);

            content.OutStack(this);
            return(value);
            //做数学计算
            //从上下文取值
            //_value = null;
            //return null;
        }
        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;
        }
        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());
            }
            ICLS_TypeFunction typefunction = content.environment.GetType(parent.type).function;
            if(parent.type is object)
            {
                SInstance s =parent.value as SInstance;
                if(s!=null)
                {
                    typefunction = s.type;
                }
            }
            //var type = content.environment.GetType(parent.type);
            var value=typefunction.MemberValueGet(content, parent.value, membername);
            content.OutStack(this);
            return value;
            //做数学计算
            //从上下文取值
            //_value = null;
            //return null;

        }
Ejemplo n.º 41
0
 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;
 }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);


            var left = listParam[0].ComputeValue(content);
            var right = listParam[1].ComputeValue(content);
            ICLS_Type type = content.environment.GetType(left.type);
            //if (mathop == "+=")

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

                //content.Set(value_name, value);
            }

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

            return null;
        }
Ejemplo n.º 43
0
    public override object Math2Value(CLS_Content content, char code, object left, CLS_Content.Value right, out CLType returntype)
    {
        if (code == '+')
        {
            if (right.value is Vector3)
            {
                returntype = typeof(Vector3);
                return ((Vector3)left) + ((Vector3)right.value);
            }
        }
        if (code == '-')
        {
            returntype = typeof(Vector3);
            return ((Vector3)left) - ((Vector3)right.value);
        }
        if (code == '*')
        {
            returntype = typeof(Vector3);
            return ((Vector3)left) * Convert.ToSingle(right.value);
        }
        if (code == '/')
        {
            returntype = typeof(Vector3);
            return ((Vector3)left) / Convert.ToSingle(right.value);
        }

        return base.Math2Value(content, code, left, right, out returntype);
    }
        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;

        }
 public CLS_Content.Value ComputeValue(CLS_Content content)
 {
     content.InStack(this);
     var parent = listParam[0].ComputeValue(content);
     var value = listParam[1].ComputeValue(content);
     object setv=value.value;
     //if(value.type!=parent.type)
     //{
     //    var vtype = content.environment.GetType(value.type);
     //    setv = vtype.ConvertTo(content.environment, setv, parent.type);
     //}
     var typefunction = content.environment.GetType(parent.type).function;
     if(parent.type is object)
     {
         SInstance s = parent.value as SInstance;
         if(s!=null)
         {
             typefunction = s.type;
         }
     }
     typefunction.MemberValueSet(content, parent.value, membername, setv);
     //做数学计算
     //从上下文取值
     //_value = null;
     content.OutStack(this);
     return null;
 }
Ejemplo n.º 46
0
        public void MemberValueSet(CLS_Content content, object object_this, string valuename, object value)
        {
            SInstance sin = object_this as SInstance;

            if (sin.member.ContainsKey(valuename))
            {
                if (value != null && value.GetType() != (Type)this.members[valuename].type.type)
                {
                    if (value is SInstance)
                    {
                        value = content.environment.GetType((value as SInstance).type).ConvertTo(content, value, this.members[valuename].type.type);
                    }
                    else if (value is DeleEvent)
                    {
                    }
                    else
                    {
                        value = content.environment.GetType(value.GetType()).ConvertTo(content, value, this.members[valuename].type.type);
                    }
                }
                sin.member[valuename].value = value;
                return;
            }
            throw new NotImplementedException();
        }
Ejemplo n.º 47
0
 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);

            if (_listParam != null && _listParam.Count > 0)
            {

                CLS_Content.Value v = _listParam[0].ComputeValue(content);
                object val = v.value;
                if ((Type)value_type == typeof(CLS_Type_Var.var))
                {
                    if(v.type!=null)
                        value_type = v.type;
                    
                }
                else if (v.type != value_type)
                {
                    val = content.environment.GetType(v.type).ConvertTo(content, v.value, value_type);
                   
                }

                content.DefineAndSet(value_name, value_type, val);
            }
            else
            {
                content.Define(value_name, value_type);
            }
            //设置环境变量为
            content.OutStack(this);

            return null;
        }
        public Delegate CreateDelegate(ICLS_Environment env, DeleFunction delefunc)
        {
            CLS_Content content = new CLS_Content(env);
            DeleFunction _func = delefunc;
            Action dele = () =>
            {

                content.DepthAdd();
                content.CallThis = _func.callthis;
                content.CallType = _func.calltype;
                content.function = _func.function;
                var func = _func.calltype.functions[_func.function];

                //content.DefineAndSet(function._paramnames[0], function._paramtypes[0].type, param0);

                func.expr_runtime.ComputeValue(content);
                content.DepthRemove();
            };
            Delegate d = dele as Delegate;
            if ((Type)this.type != typeof(Action))
            {
                return Delegate.CreateDelegate(this.type, d.Target, d.Method);
            }
            else
            {
                return dele;
            }
        }
 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;
 }
Ejemplo n.º 51
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;
 }
Ejemplo n.º 52
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);
                if ((SType)p.type != null)
                {
                    types.Add(typeof(object));
                }
                else
                {
                    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());
            //}
            if (targetop == null)
            {
                if (function[function.Length - 1] == '>')//这是一个临时的模板函数调用
                {
                    string[] sf     = function.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
                {
                    Type ptype = type.BaseType;
                    while (ptype != null)
                    {
                        targetop = ptype.GetMethod(function, types.ToArray());
                        if (targetop != null)
                        {
                            break;
                        }
                        ptype = ptype.BaseType;
                    }
                }
            }
            if (targetop == null)
            {
                throw new Exception("函数不存在function:" + type.ToString() + "." + function);
            }
            CLS_Content.Value v = new CLS_Content.Value();
            v.value = targetop.Invoke(null, _oparams.ToArray());
            v.type  = targetop.ReturnType;
            return(v);
        }
Ejemplo n.º 53
0
        public virtual object ConvertTo(CLS_Content env, object src, CLType targetType)
        {
            if (this._type == (Type)targetType)
            {
                return(src);
            }

            //type.get

            if (_type.IsEnum)
            {
                if ((Type)targetType == typeof(int))
                {
                    return(System.Convert.ToInt32(src));
                }
                else if ((Type)targetType == typeof(uint))
                {
                    return(System.Convert.ToUInt32(src));
                }
                else if ((Type)targetType == typeof(short))
                {
                    return(System.Convert.ToInt16(src));
                }
                else if ((Type)targetType == typeof(ushort))
                {
                    return(System.Convert.ToUInt16(src));
                }
                else
                {
                    return(System.Convert.ToInt32(src));
                }
            }
            var ms = _type.GetMethods();

            foreach (var m in ms)
            {
                if ((m.Name == "op_Implicit" || m.Name == "op_Explicit") && m.ReturnType == (Type)targetType)
                {
                    return(m.Invoke(null, new object[] { src }));
                }
            }
            if ((Type)targetType != null)
            {
                if (((Type)targetType).IsAssignableFrom(_type))
                {
                    return(src);
                }
                if (src != null && ((Type)targetType).IsInstanceOfType(src))
                {
                    return(src);
                }
            }
            else
            {
                return(src);
            }

            return(null);
        }
Ejemplo n.º 54
0
        public Delegate CreateDelegate(ICLS_Environment env, DeleFunction delefunc)
        {
            DeleFunction _func = delefunc;
            Delegate     _dele = delefunc.cacheFunction(this._type, null);

            if (_dele != null)
            {
                return(_dele);
            }
            Action <T, T1, T2> dele = (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);

                        func.expr_runtime.ComputeValue(content);
                        content.DepthRemove();
                    }
                    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;
                    }
                }
            };
            Delegate d = dele as Delegate;

            if ((Type)this.type != typeof(Action))
            {
                _dele = Delegate.CreateDelegate(this.type, d.Target, d.Method);
            }
            else
            {
                _dele = dele;
            }
            return(delefunc.cacheFunction(this._type, _dele));
        }
Ejemplo n.º 55
0
        public CLS_Content.Value StaticCall(CLS_Content contentParent, string function, IList <CLS_Content.Value> _params)
        {
            NewStatic(contentParent.environment);
            if (this.functions.ContainsKey(function))
            {
                if (this.functions[function].bStatic == true)
                {
                    CLS_Content content = new CLS_Content(contentParent.environment, true);

                    contentParent.InStack(content);//把这个上下文推给上层的上下文,这样如果崩溃是可以一层层找到原因的
                    content.CallType = this;
                    content.CallThis = null;
                    content.function = function;
                    // int i = 0;
                    for (int i = 0; i < functions[function]._paramtypes.Count; i++)
                    //foreach (var p in this.functions[function]._params)
                    {
                        content.DefineAndSet(functions[function]._paramnames[i], functions[function]._paramtypes[i].type, _params[i].value);
                        //i++;
                    }
                    //var value = this.functions[function].expr_runtime.ComputeValue(content);
                    CLS_Content.Value value = null;
                    if (this.functions[function].expr_runtime != null)
                    {
                        value = this.functions[function].expr_runtime.ComputeValue(content);
                    }
                    else
                    {
                    }
                    contentParent.OutStack(content);
                    return(value);
                }
            }
            else if (this.members.ContainsKey(function))
            {
                if (this.members[function].bStatic == true)
                {
                    Delegate dele = this.staticMemberInstance[function].value as Delegate;
                    if (dele != null)
                    {
                        CLS_Content.Value value = new CLS_Content.Value();
                        value.type = null;
                        object[] objs = new object[_params.Count];
                        for (int i = 0; i < _params.Count; i++)
                        {
                            objs[i] = _params[i].value;
                        }
                        value.value = dele.DynamicInvoke(objs);
                        if (value.value != null)
                        {
                            value.type = value.value.GetType();
                        }

                        return(value);
                    }
                }
            }
            throw new NotImplementedException();
        }
        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;
            SType.Function    fun;

            if (content.CallType != null && content.CallType.functions.TryGetValue(funcname, out fun))
            {
                if (fun.bStatic)
                {
                    retVal = content.CallType.StaticCall(content, funcname, _params);
                }
                else
                {
                    retVal = content.CallType.MemberCall(content, content.CallThis, funcname, _params);
                }
            }
            else
            {
                retVal = content.Get(funcname);
                Delegate sysDele = retVal.value as Delegate;
                if (sysDele != null)
                {
                    object[] args = CLS_Content.ParamObjsArray[_params.size];
                    for (int i = 0; i < _params.size; i++)
                    {
                        args[i] = _params[i].value;
                    }
                    retVal       = new CLS_Content.Value();
                    retVal.value = sysDele.DynamicInvoke(args);
                    if (retVal.value != null)
                    {
                        retVal.type = retVal.value.GetType();
                    }
                }
                else
                {
                    DeleFunction csleDele = retVal.value as DeleFunction;
                    if (csleDele.callthis != null)
                    {
                        retVal = csleDele.calltype.MemberCall(content, csleDele.callthis, csleDele.function, _params);
                    }
                    else
                    {
                        retVal = csleDele.calltype.StaticCall(content, csleDele.function, _params);
                    }
                }
            }
            CLS_Content.PoolParamList(_params);
            content.OutStack(this);
            return(retVal);
        }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            var value = type.function.StaticValueGet(content, staticmembername);

            content.OutStack(this);
            return(value);
        }
Ejemplo n.º 58
0
 public CLS_Content.Value Expr_Execute(ICLS_Expression expr, CLS_Content content = null)
 {
     if (content == null)
     {
         content = CreateContent();
     }
     return(expr.ComputeValue(content));
 }
Ejemplo n.º 59
0
 public CLS_Content.Value ComputeValue(CLS_Content content)
 {
     content.InStack(this);
     CLS_Content.Value value = listParam[0].ComputeValue(content);
     type.function.StaticValueSet(content, staticmembername, value.value);
     content.OutStack(this);
     return(null);
 }
Ejemplo n.º 60
0
        public override object ConvertTo(CLS_Content env, object src, CLType targetType)
        {
            Type t = targetType;

            if (t == typeof(double))
            {
                return((double)(long)(src));
            }
            if (t == typeof(float))
            {
                return((float)(long)(src));
            }
            if (t == typeof(long))
            {
                return(src);
            }
            if (t == typeof(ulong))
            {
                return((ulong)(long)(src));
            }
            if (t == typeof(int))
            {
                return((int)(long)(src));
            }
            if (t == typeof(uint))
            {
                return((uint)(long)(src));
            }
            if (t == typeof(short))
            {
                return((short)(long)(src));
            }
            if (t == typeof(ushort))
            {
                return((ushort)(long)(src));
            }
            if (t == typeof(sbyte))
            {
                return((sbyte)(long)(src));
            }
            if (t == typeof(byte))
            {
                return((byte)(long)(src));
            }
            if (t == typeof(char))
            {
                return((char)(long)(src));
            }
            if (t == typeof(int?))
            {
                return((int?)(long)(src));
            }
            if (t == typeof(uint?))
            {
                return((uint?)(long)(src));
            }
            return(base.ConvertTo(env, src, targetType));
        }