Пример #1
0
        public static OperatorFunctions LoadOperatorFunctions(BinaryReader reader, CSWCSerizlizer serizlizer, IDictionary <int, object> serizlized, int key)
        {
            OperatorFunctions operatorFunctions = new OperatorFunctions(); serizlized.Add(key, operatorFunctions);

            for (int i = 0; i < operatorFunctions.operFunctions.Length; i++)
            {
                var dict  = operatorFunctions.operFunctions[i];
                int count = reader.ReadInt32();
                for (int j = 0; j < count; j++)
                {
                    RunTimeDataType v1 = reader.ReadInt32();
                    RunTimeDataType v2 = reader.ReadInt32();

                    OperatorFunctionKey operatorFunctionKey = new OperatorFunctionKey(v1, v2);

                    rtti.FunctionDefine define   = serizlizer.DeserializeObject <rtti.FunctionDefine>(reader, rtti.FunctionDefine.LoadFunctionDefine);
                    rtData.rtFunction   function = serizlizer.DeserializeObject <rtData.rtFunction>(reader, RunTimeValueBase.LoadRunTimeValueBase);

                    DefineAndFunc defineAndFunc = new DefineAndFunc();
                    defineAndFunc.define = define;
                    defineAndFunc.func   = function;

                    dict.Add(operatorFunctionKey, defineAndFunc);
                }
            }

            return(operatorFunctions);
        }
        public bool prepareConstructorArgements()
        {
            int classid = _class.classid;


            ASBinCode.rtti.FunctionDefine    funcDefine = player.swc.functions[player.swc.classes[classid].constructor_functionid];
            ASBinCode.rtti.FunctionSignature signature  = funcDefine.signature;

            constructorCaller            = player.funcCallerPool.create(invokerFrame,token);
            constructorCaller.toCallFunc = funcDefine;
            constructorCaller._tempSlot  = invokerFrame._tempSlot1;
            if (!constructorCaller.createParaScope())
            {
                return(false);
            }

            //constructorCaller.releaseAfterCall = true;

            if (constructor != null)
            {
                _function_constructor            = player.funcCallerPool.create(invokerFrame,token);
                _function_constructor._tempSlot  = invokerFrame._tempSlot1;
                _function_constructor.toCallFunc =
                    player.swc.functions[((ASBinCode.rtData.rtFunction)
                                          TypeConverter.ObjectImplicit_ToPrimitive(constructor)).functionId];

                if (!_function_constructor.createParaScope())
                {
                    return(false);
                }

                //_function_constructor.releaseAfterCall = true;
            }
            return(true);
        }
 public System.Reflection.MethodInfo GetMethodInfo(ASBinCode.rtti.FunctionDefine functionDefine,ASBinCode.CSWC swc,ASRuntime.Player player)
 {
     if (method == null)
     {
         method = typeof(RefOutStore).GetMethod("GetValue",new Type[] { typeof(System.String) });;
     }
     return(method);
 }
 public System.Reflection.MethodInfo GetMethodInfo(ASBinCode.rtti.FunctionDefine functionDefine,ASBinCode.CSWC swc,ASRuntime.Player player)
 {
     if (method == null)
     {
         method = typeof(System.ICloneable).GetMethod("Clone",Type.EmptyTypes);;
     }
     return(method);
 }
 public virtual void execute2(RunTimeValueBase thisObj,
                              rtti.FunctionDefine functionDefine,
                              SLOT[] argements,
                              SLOT returnSlot,
                              SourceToken token,
                              object stackframe,
                              out bool success)
 {
     throw new NotImplementedException();
 }
Пример #6
0
 /// <summary>
 /// 检查是否充分
 /// </summary>
 public bool Check(out rtti.FunctionDefine function)
 {
     for (int i = 0; i <= (int)OverrideableOperator.Inequality; i++)
     {
         foreach (var key in operFunctions[i].Keys)
         {
             if (i == (int)OverrideableOperator.Equality)
             {
                 var dict = operFunctions[(int)OverrideableOperator.Inequality];
                 if (!dict.ContainsKey(key))
                 {
                     function = operFunctions[i][key].define;
                     return(false);
                 }
             }
             else if (i == (int)OverrideableOperator.Inequality)
             {
                 var dict = operFunctions[(int)OverrideableOperator.Equality];
                 if (!dict.ContainsKey(key))
                 {
                     function = operFunctions[i][key].define;
                     return(false);
                 }
             }
             else
             {
                 //***查找其他操作符定义***
                 for (int j = 0; j < (int)OverrideableOperator.Inequality; j++)
                 {
                     var dict = operFunctions[j];
                     if (!dict.ContainsKey(key))
                     {
                         function = operFunctions[i][key].define;
                         return(false);
                     }
                 }
             }
         }
     }
     function = null;
     return(true);
 }
Пример #7
0
        public void AddOperatorFunction(OverrideableOperator operCode, rtti.FunctionDefine function)
        {
            var dict = operFunctions[(int)operCode];

            if (function.signature.parameters.Count == 2)
            {
                OperatorFunctionKey key = new OperatorFunctionKey(
                    function.signature.parameters[0].type,
                    function.signature.parameters[1].type
                    );
                dict.Add(key, new DefineAndFunc()
                {
                    define = function, func = null
                });
            }
            else if (operCode == OverrideableOperator.op_explicit)
            {
                OperatorFunctionKey key = new OperatorFunctionKey(
                    function.signature.parameters[0].type,
                    function.signature.returnType
                    );
                dict.Add(key, new DefineAndFunc()
                {
                    define = function, func = null
                });
            }
            else
            {
                OperatorFunctionKey key = new OperatorFunctionKey(
                    function.signature.parameters[0].type,
                    RunTimeDataType.unknown
                    );
                dict.Add(key, new DefineAndFunc()
                {
                    define = function, func = null
                });
            }
        }
        /// <summary>
        /// 检查是否充分
        /// </summary>
        public bool Check(out rtti.FunctionDefine function)
        {
            for (int i = 0; i <= (int)OverrideableOperator.Inequality; i++)
            {
                foreach (var key in operFunctions[i].Keys)
                {
                    if (i == (int)OverrideableOperator.Equality)
                    {
                        var dict = operFunctions[(int)OverrideableOperator.Inequality];
                        if (!dict.ContainsKey(key))
                        {
                            function = operFunctions[i][key].define;
                            return(false);
                        }
                    }
                    else if (i == (int)OverrideableOperator.Inequality)
                    {
                        var dict = operFunctions[(int)OverrideableOperator.Equality];
                        if (!dict.ContainsKey(key))
                        {
                            function = operFunctions[i][key].define;
                            return(false);
                        }
                    }
                    else if (i == (int)OverrideableOperator.GreatherThan)
                    {
                        var dict = operFunctions[(int)OverrideableOperator.LessThan];
                        if (!dict.ContainsKey(key))
                        {
                            function = operFunctions[i][key].define;
                            return(false);
                        }
                    }
                    else if (i == (int)OverrideableOperator.LessThan)
                    {
                        var dict = operFunctions[(int)OverrideableOperator.GreatherThan];
                        if (!dict.ContainsKey(key))
                        {
                            function = operFunctions[i][key].define;
                            return(false);
                        }
                    }
                    else if (i == (int)OverrideableOperator.GreatherThanOrEqual)
                    {
                        var dict = operFunctions[(int)OverrideableOperator.LessThanOrEqual];
                        if (!dict.ContainsKey(key))
                        {
                            function = operFunctions[i][key].define;
                            return(false);
                        }
                    }
                    else if (i == (int)OverrideableOperator.LessThanOrEqual)
                    {
                        var dict = operFunctions[(int)OverrideableOperator.GreatherThanOrEqual];
                        if (!dict.ContainsKey(key))
                        {
                            function = operFunctions[i][key].define;
                            return(false);
                        }
                    }
                    //else
                    //{
                    //    //***查找其他操作符定义***
                    //    for (int j = 0; j < (int)OverrideableOperator.Inequality; j++)
                    //    {

                    //        var dict = operFunctions[j];
                    //        if (!dict.ContainsKey(key))
                    //        {
                    //            function = operFunctions[i][key].define;
                    //            return false;
                    //        }

                    //    }
                    //}
                }
            }
            function = null;
            return(true);
        }