public static void push_parameter_para(StackFrame frame, ASBinCode.OpStep step, RunTimeScope scope)
        {
            int id = ((rtInt)step.arg2.getValue(frame.scope, frame)).value;
            RunTimeValueBase arg = step.arg1.getValue(frame.scope, frame);

#if DEBUG
            if (frame.typeconvertoperator != null)
            {
                throw new EngineException();
            }
#endif

            bool success;
            frame.funCaller.pushParameter_Para(arg, id, out success);


            //frame.endStep(step);
            frame.endStepNoError();
        }
        public static void push_parameter_skipcheck_stroetoheap(StackFrame frame, ASBinCode.OpStep step, RunTimeScope scope)
        {
            RunTimeValueBase arg = step.arg1.getValue(frame.scope, frame);

#if DEBUG
            if (frame.typeconvertoperator != null)
            {
                throw new EngineException();
            }
#endif

            int index = step.jumoffset;
            frame.funCaller.pushParameterToHeap(arg, index);
            frame.endStepNoError();
        }
        public static void push_parameter_skipcheck_stroetostack(StackFrame frame, ASBinCode.OpStep step, RunTimeScope scope)
        {
            RunTimeValueBase arg = step.arg1.getValue(frame.scope, frame);

#if DEBUG
            if (frame.typeconvertoperator != null)
            {
                throw new EngineException();
            }
#endif
            int _index = step.jumoffset;
            //frame.funCaller.pushParameterToStack(arg, index);
            int index = frame.baseBottomSlotIndex + frame.call_parameter_slotCount + _index;
            frame.stack[index].directSet(arg);
            frame.funCaller.pushedArgs++;

            frame.endStepNoError();
            //frame.endStep(step);
        }
        public static void create_paraScope(StackFrame frame, ASBinCode.OpStep step, RunTimeScope scope)
        {
            RunTimeValueBase rv; rtFunction toclear = null;

            if (step.arg1 is MethodGetterBase)
            {
                rv = ((MethodGetterBase)step.arg1).getMethod(frame.scope); toclear = (rtFunction)rv;
            }
            else
            {
                rv = step.arg1.getValue(frame.scope, frame);
            }

            if (rv.rtType > RunTimeDataType.unknown && ClassMemberFinder.check_isinherits(rv, RunTimeDataType._OBJECT + 2, frame.player.swc))
            {
                //***说明要调用强制类型转换***
                ASBinCode.rtti.Class cls = ((rtObjectBase)rv).value._class;
                if (frame.typeconvertoperator != null)
                {
                    frame.endStepNoError();
                    //frame.endStep(step);
                    return;
                }
                else if (frame.typeconvertoperator.targettype.instanceClass == null
                         ||
                         frame.typeconvertoperator.targettype != cls
                         )
                {
                    frame.throwError(new error.InternalError(frame.player.swc, step.token, "类型转换函数发现内部错误"
                                                             ));
                    frame.endStep(step);
                    return;
                }
            }

            if (rv.rtType == frame.player.swc.FunctionClass.getRtType())
            {
                rv = TypeConverter.ObjectImplicit_ToPrimitive((rtObjectBase)rv);
            }

            if (rv.rtType != RunTimeDataType.rt_function)
            {
                frame.throwError(step.token, 0, "value is not a function");
                frame.endStep(step);
            }
            else
            {
                ASBinCode.rtData.rtFunction function = (ASBinCode.rtData.rtFunction)rv;
                var funcCaller = frame.player.funcCallerPool.create(frame, step.token);
                funcCaller.SetFunction(function); if (toclear != null)
                {
                    toclear.Clear();
                }
                funcCaller._tempSlot = frame._tempSlot1;
                funcCaller.loadDefineFromFunction();
                if (!funcCaller.createParaScope())
                {
                    return;
                }

                frame.funCaller = funcCaller;
                frame.endStepNoError();
            }
        }
        public static void push_parameter_nativeconstpara(StackFrame frame, ASBinCode.OpStep step, RunTimeScope scope)
        {
            int id = ((rtInt)step.arg2.getValue(frame.scope, frame)).value;
            RunTimeValueBase arg = step.arg1.getValue(frame.scope, frame);

#if DEBUG
            if (frame.typeconvertoperator != null)
            {
                throw new EngineException();
            }
#endif

            var toCallFunc = frame.funCaller.toCallFunc; var player = frame.player;
            //if (toCallFunc.native_index < 0)
            //{
            //	toCallFunc.native_index = player.swc.nativefunctionNameIndex[toCallFunc.native_name];
            //}
            //var nf = (nativefuncs.NativeConstParameterFunction)player.swc.nativefunctions[toCallFunc.native_index];
            var nf = (nativefuncs.NativeConstParameterFunction)player.swc.getNativeFunction(toCallFunc);

            bool success;
            frame.funCaller.pushParameterNativeModeConstParameter(nf, arg, id, out success);

            frame.endStepNoError();
            //frame.endStep(step);
        }
Example #6
0
        public static void _do_prop_read(
            ClassPropertyGetter prop,StackFrame frame,OpStep step,Player player,RunTimeScope scope,
            ASBinCode.rtData.rtObjectBase propBindObj,Class superPropBindClass
            )
        {
            do
            {
                //***调用访问器。***

                if (prop.getter == null)
                {
                    frame.throwError(
                        step.token,0,"Illegal read of write-only property"
                        );
                    break;
                }
                //检查访问权限
                CodeBlock block = player.swc.blocks[scope.blockId];
                Class     finder;
                if (block.isoutclass)
                {
                    var c = prop._class;
                    if (c.instanceClass != null)
                    {
                        c = c.instanceClass;
                    }
                    if (c.mainClass != null)
                    {
                        c = c.mainClass;
                    }

                    if (block.define_class_id == c.classid)
                    {
                        finder = player.swc.classes[block.define_class_id];
                    }
                    else
                    {
                        finder = null;
                    }
                }
                else
                {
                    finder = player.swc.classes[block.define_class_id];
                }

                var getter = ClassMemberFinder.find(prop._class,prop.getter.name,finder);
                if (getter == null || getter.bindField != prop.getter)
                {
                    frame.throwError(
                        step.token,0,"Illegal read of write-only property"
                        );
                    break;
                }

                //***读取getter***


                RunTimeValueBase func;

                if (superPropBindClass != null)
                {
                    func = ((MethodGetterBase)getter.bindField).getSuperMethod(
                        //propslot.bindObj.objScope
                        propBindObj.objScope,
                        superPropBindClass

                        );
                }
                else
                {
                    func = ((MethodGetterBase)getter.bindField).getMethod(
                        //propslot.bindObj.objScope
                        propBindObj
                        );
                }

                //***调用访问器***

                var funCaller = player.funcCallerPool.create(frame,step.token);
                //funCaller.releaseAfterCall = true;
                funCaller.SetFunction((ASBinCode.rtData.rtFunction)func); ((ASBinCode.rtData.rtFunction)func).Clear();

                funCaller.loadDefineFromFunction();
                if (!funCaller.createParaScope())
                {
                    return;
                }

                funCaller._tempSlot  = frame._tempSlot1;
                funCaller.returnSlot = step.reg.getSlot(scope,frame);

                ((StackSlot)funCaller.returnSlot).stackObjects.propGetSet  = prop; ((StackSlot)funCaller.returnSlot).refPropChanged = true;
                ((StackSlot)funCaller.returnSlot).stackObjects.propBindObj = propBindObj;


                BlockCallBackBase cb = frame.player.blockCallBackPool.create();
                cb.setCallBacker(_getter_callbacker);
                cb.step = step;
                cb.args = frame;

                funCaller.callbacker = cb;
                funCaller.call();

                return;
            } while (false);


            frame.endStep(step);
        }
Example #7
0
        public static void exec_initfromdata(StackFrame frame, OpStep step, RunTimeScope scope)
        {
            var player = frame.player;
            RunTimeValueBase initdata = step.arg2.getValue(scope, frame);
            int classrttype           = ((rtInt)step.arg1.getValue(scope, frame)).value;

            while (true)
            {
                if (initdata.rtType == classrttype)
                {
                    step.reg.getSlot(scope, frame).directSet(initdata);
                    frame.endStep(step);
                    return;
                }
                else if (initdata.rtType == RunTimeDataType.rt_array)
                {
                    break;
                }
                else if (
                    initdata.rtType > RunTimeDataType.unknown
                    )
                {
                    var cls = ((rtObjectBase)initdata).value._class;
                    if (player.swc.dict_Vector_type.ContainsKey(cls))
                    {
                        break;
                    }
                }

                frame.throwCastException(step.token, initdata.rtType, classrttype);
                frame.endStep(step);
                return;
            }



            var _class = player.swc.getClassByRunTimeDataType(classrttype);

            //frame.instanceCreator = new InstanceCreator(player, frame, step.token, _class);
            frame.activeInstanceCreator(step.token, _class);
            frame.instanceCreator.step  = step;
            frame.instanceCreator.token = step.token;

            if (_class.constructor != null)
            {
                if (!frame.instanceCreator.prepareConstructorArgements())
                {
                    return;
                }
            }

            BlockCallBackBase cb = frame.player.blockCallBackPool.create();

            cb.args = frame;
            cb.setCallBacker(objcreated);
            cb.scope = scope;
            cb.step  = step;

            frame.instanceCreator.callbacker = cb;
            frame.instanceCreator.createInstance();

            return;
        }
        public static void create_paraScope_WithSignature(StackFrame frame, ASBinCode.OpStep step, RunTimeScope scope)
        {
            rtFunction function
                = (rtFunction)step.arg1.getValue(frame.scope, frame);

            var funcCaller = frame.player.funcCallerPool.create(frame, step.token);

            funcCaller.SetFunction(function);
            funcCaller._tempSlot  = frame._tempSlot1;
            funcCaller.toCallFunc = frame.player.swc.functions[function.functionId];
            if (!funcCaller.createParaScope())
            {
                return;
            }

            frame.funCaller = funcCaller;

            //frame.endStep(step);
            frame.endStepNoError();
        }
        public static void create_paraScope_Method_NoParameters(StackFrame frame, ASBinCode.OpStep step, RunTimeScope scope)
        {
            rtFunction function
                = (rtFunction)((MethodGetterBase)step.arg1).getMethod(frame.scope);

            var functionDefine = frame.player.swc.functions[function.functionId];


            var funcCaller = frame.player.funcCallerPool.create(frame, step.token);

            funcCaller.SetFunction(function); function.Clear();
            funcCaller.toCallFunc   = functionDefine;
            frame.funCaller         = funcCaller;
            funcCaller.CallFuncHeap = Player.emptyMembers;
            frame.endStepNoError();
        }
Example #10
0
        internal void doCall_allcheckpass()
        {
            if (toCallFunc.isYield)
            {
                if (!player.static_instance.ContainsKey(player.swc.YieldIteratorClass.staticClass.classid))
                {
                    if (!InstanceCreator.init_static_class(player.swc.YieldIteratorClass,player,token))
                    {
                        invokerFrame.endStep();

                        if (callbacker != null)
                        {
                            callbacker.noticeRunFailed();
                        }
                        release();


                        return;
                    }
                }

                ASBinCode.rtti.YieldObject yobj = new ASBinCode.rtti.YieldObject(
                    player.swc.YieldIteratorClass);


                CallFuncHeap[CallFuncHeap.Length - 2].directSet(new ASBinCode.rtData.rtInt(1));

                yobj.argements          = CallFuncHeap;
                yobj.function_bindscope = function.bindScope;
                yobj.block          = player.swc.blocks[toCallFunc.blockid];
                yobj.yield_function = toCallFunc;


                ASBinCode.rtData.rtObject rtYield = new ASBinCode.rtData.rtObject(yobj,null);
                yobj.thispointer =
                    (function.this_pointer != null ?
                     function.this_pointer : invokerFrame.scope.this_pointer);

                RunTimeScope scope = new RunTimeScope(null,
                                                      player.swc.YieldIteratorClass.blockid,null,rtYield,RunTimeScopeType.objectinstance);
                rtYield.objScope = scope;

                returnSlot.directSet(rtYield);


                if (callbacker != null)
                {
                    callbacker.call(callbacker.args);
                }
                release();

                return;
            }
            else if (!toCallFunc.isNative)
            {
                if (returnSlot is StackSlot)
                {
                    TypeConverter.setDefaultValueToStackSlot(
                        toCallFunc.signature.returnType,
                        (StackSlot)returnSlot);
                }
                else
                {
                    returnSlot.directSet(
                        TypeConverter.getDefaultValue(toCallFunc.signature.returnType).getValue(null,null));
                }
                if (!ReferenceEquals(callbacker,this))
                {
                    //***执行完成后,先清理参数***
                    BlockCallBackBase cb = player.blockCallBackPool.create();
                    cb.args            = cb.cacheObjects;
                    cb.cacheObjects[0] = callbacker;
                    cb.cacheObjects[1] = invokerFrame;

                    cb.setCallBacker(callfun_cb);
                    cb.setWhenFailed(callfun_failed);
                    cb._intArg            = onstackparametercount;
                    onstackparametercount = 0;

                    player.callBlock(
                        player.swc.blocks[toCallFunc.blockid],
                        CallFuncHeap,
                        returnSlot,
                        function.bindScope,
                        token,cb,function.this_pointer != null ? function.this_pointer : invokerFrame.scope.this_pointer,RunTimeScopeType.function);

                    release();
                }
                else
                {
                    player.callBlock(
                        player.swc.blocks[toCallFunc.blockid],
                        CallFuncHeap,
                        returnSlot,
                        function.bindScope,
                        token,callbacker,function.this_pointer != null ? function.this_pointer : invokerFrame.scope.this_pointer,RunTimeScopeType.function);
                }
            }
            else
            {
                //if (toCallFunc.native_index <0)
                //{
                //    toCallFunc.native_index = player.swc.nativefunctionNameIndex[toCallFunc.native_name];
                //}

                //var nf = player.swc.nativefunctions[toCallFunc.native_index];
                var nf = player.swc.getNativeFunction(toCallFunc);
                nf.bin = player.swc;

                if (nf.mode == NativeFunctionBase.NativeFunctionMode.normal_0)
                {
                    player._nativefuncCaller = this;

                    string errormsg;
                    int    errorno;
                    var    result = nf.execute(
                        function.this_pointer != null ? function.this_pointer : invokerFrame.scope.this_pointer,
                        CallFuncHeap,invokerFrame,
                        out errormsg,
                        out errorno
                        );
                    player._nativefuncCaller = null;
                    if (errormsg == null)
                    {
                        returnSlot.directSet(result);

                        if (callbacker != null)
                        {
                            callbacker.call(callbacker.args);
                        }

                        release();
                    }
                    else
                    {
                        invokerFrame.throwError(
                            token,0,errormsg
                            );

                        invokerFrame.endStep();

                        if (callbacker != null)
                        {
                            callbacker.noticeRunFailed();
                        }
                        release();
                    }
                }
                //else if (nf.mode == NativeFunctionBase.NativeFunctionMode.normal_1)
                //{
                //	player._nativefuncCaller = this;
                //	bool success;

                //	nf.execute2(
                //		function.this_pointer != null ? function.this_pointer : invokerFrame.scope.this_pointer,
                //		toCallFunc,
                //		CallFuncHeap,
                //		returnSlot,
                //		token,
                //		invokerFrame,
                //		out success
                //		);
                //	player._nativefuncCaller = null;
                //	if (success)
                //	{
                //		if (callbacker != null)
                //		{
                //			callbacker.call(callbacker.args);
                //		}
                //	}
                //	else
                //	{
                //		invokerFrame.endStep();
                //		if (callbacker != null)
                //		{
                //			callbacker.noticeRunFailed();
                //		}

                //	}

                //	release();


                //}
                else if (nf.mode == NativeFunctionBase.NativeFunctionMode.async_0)
                {
                    nf.executeAsync(function.this_pointer != null ? function.this_pointer : invokerFrame.scope.this_pointer,
                                    CallFuncHeap,
                                    returnSlot,
                                    callbacker,
                                    invokerFrame,
                                    token,
                                    function.bindScope
                                    );

                    if (!ReferenceEquals(callbacker,this))
                    {
                        release();
                    }
                }
                else if (nf.mode == NativeFunctionBase.NativeFunctionMode.const_parameter_0)
                {
                    bool success = false;
                    player._nativefuncCaller = this;

                    var nf3 = (nativefuncs.NativeConstParameterFunction)nf;
                    player._executeToken = nf3.getExecToken(toCallFunc.functionid);

                    nf3.execute3(
                        function.this_pointer != null ? function.this_pointer : invokerFrame.scope.this_pointer,
                        toCallFunc,
                        returnSlot,
                        token,
                        invokerFrame,
                        out success
                        );

                    player._executeToken     = nativefuncs.NativeConstParameterFunction.ExecuteToken.nulltoken;
                    player._nativefuncCaller = null;
                    ((nativefuncs.NativeConstParameterFunction)nf).clearParameter();

                    clear_para_slot(invokerFrame,onstackparametercount);
                    onstackparametercount = 0;

                    if (success)
                    {
                        var receive_err = player.clear_nativeinvokeraiseerror();
                        if (receive_err != null)
                        {
                            invokerFrame.receiveErrorFromStackFrame(receive_err);
                            if (callbacker != null)
                            {
                                callbacker.noticeRunFailed();
                            }
                        }
                        else if (callbacker != null)
                        {
                            callbacker.call(callbacker.args);
                        }
                    }
                    else
                    {
                        invokerFrame.endStep();
                        if (callbacker != null)
                        {
                            callbacker.noticeRunFailed();
                        }
                    }
                    release();
                }
            }
        }
        public static void bind(StackFrame frame, ASBinCode.OpStep step, RunTimeScope scope)
        {
            var rv = step.arg1.getValue(frame.scope, frame);

            if (rv.rtType != RunTimeDataType.rt_function)
            {
                frame.throwError(
                    step.token, 0, "value is not a function");
                frame.endStep(step);
                return;
            }
            else
            {
                ASBinCode.rtData.rtFunction function = (ASBinCode.rtData.rtFunction)rv;

                if (function.bindScope == null
                    ||
                    function.bindScope.blockId == frame.scope.blockId
                    )
                {
                    function.bind(frame.scope);
                }

                if (!function.ismethod)
                {
                    if (function.this_pointer == null)
                    {
                        var s = frame.scope;
                        if (s.this_pointer != null && s.this_pointer is rtObjectBase)
                        {
                            rtObjectBase obj = (rtObjectBase)s.this_pointer;

                            if (obj.value is Global_Object)
                            {
                                function.setThis(obj);
                            }
                            else
                            {
                                var cls = obj.value._class;
                                if (cls.staticClass == null)
                                {
                                    cls = cls.instanceClass;
                                }
                                if (cls.mainClass != null)
                                {
                                    cls = cls.mainClass;
                                }

                                var ot = frame.player.outpackage_runtimescope[cls.classid];
                                function.setThis(ot.this_pointer);
                            }
                        }
                        else
                        {
                            if (frame.player.infoOutput != null)
                            {
                                frame.player.infoOutput.Warring("当前函数没有this指针。也许不是从文档类启动,而是从包外代码启动的");
                            }
                        }
                    }
                }
                frame.endStepNoError();
            }
        }
Example #12
0
        public static void exec_AccessorBind_ConvertIdx(StackFrame frame, OpStep step, RunTimeScope scope)
        {
            RunTimeValueBase obj = step.arg1.getValue(scope, frame);

            if (rtNull.nullptr.Equals(obj))
            {
                frame.throwError(

                    step.token, 1009, "Cannot access a property or method of a null object reference."

                    );
                frame.endStep();
                return;
            }
            ASBinCode.rtti.Vector_Data vector =
                (ASBinCode.rtti.Vector_Data)((ASBinCode.rtti.HostedObject)((ASBinCode.rtData.rtObjectBase)obj).value).hosted_object;


            var idxvalue = step.arg2.getValue(scope, frame);

            double idx = double.NaN;

            if (idxvalue.rtType > RunTimeDataType.unknown)
            {
                RunTimeDataType ot;
                if (TypeConverter.Object_CanImplicit_ToPrimitive(idxvalue.rtType, frame.player.swc, out ot))
                {
                    var v = TypeConverter.ObjectImplicit_ToPrimitive((rtObjectBase)idxvalue);
                    idx = TypeConverter.ConvertToNumber(v);
                }
            }
            else if (idxvalue.rtType == RunTimeDataType.rt_string ||
                     idxvalue.rtType == RunTimeDataType.rt_int ||
                     idxvalue.rtType == RunTimeDataType.rt_number ||
                     idxvalue.rtType == RunTimeDataType.rt_uint
                     )
            {
                idx = TypeConverter.ConvertToNumber(idxvalue);
            }

            if (double.IsNaN(idx))
            {
                frame.throwError(

                    step.token, 0,
                    "索引" + idxvalue + "不能转为int"

                    );
            }
            else
            {
                int index = (int)idx;

                if (index < 0 || index > vector.innnerList.Count)
                {
                    frame.throwError(step.token, 1125,
                                     "The index " + index + " is out of range " + vector.innnerList.Count + ".");
                }

                StackSlotAccessor reg = (StackSlotAccessor)step.reg;

                if (idx == vector.innnerList.Count)
                {
                    if (vector.isFixed || !reg._isassigntarget)
                    {
                        frame.throwError(step.token,
                                         1125,
                                         "The index " + idx + " is out of range " + vector.innnerList.Count + ".");
                        frame.endStep(step);
                        return;
                    }
                    else
                    {
                        vector.innnerList.Add(TypeConverter.getDefaultValue(vector.vector_type).getValue(null, null));
                    }
                }


                StackSlot slot = (StackSlot)step.reg.getSlot(scope, frame);

                if (reg._isassigntarget || reg._hasUnaryOrShuffixOrDelete)
                {
                    slot._cache_vectorSlot.idx         = index;
                    slot._cache_vectorSlot.vector_data = vector;

                    slot.linkTo(slot._cache_vectorSlot);
                }
                else
                {
                    slot.directSet(vector.innnerList[index]);
                }
            }


            frame.endStep(step);
        }
Example #13
0
        public static void _pusharray(ASBinCode.rtti.Vector_Data o, StackFrame frame, OpStep step, RunTimeScope scope)
        {
            var arr = step.arg2.getValue(scope, frame);

            if (arr.rtType == RunTimeDataType.rt_null)
            {
                frame.throwCastException(step.token, RunTimeDataType.rt_null,
                                         step.arg1.getValue(scope, frame).rtType
                                         );
                frame.endStep(step);
            }
            else
            {
                rtArray array = (rtArray)arr;
                if (array.innerArray.Count == 0)
                {
                    frame.endStep(step);
                }
                else
                {
                    BlockCallBackBase cb = frame.player.blockCallBackPool.create();
                    cb.step = step;
                    cb.args = frame;
                    cb.setCallBacker(_allpushed);

                    pushAllElementToVector(o, array.innerArray, frame, step.token, scope, cb);
                }
            }
        }
Example #14
0
        public static void exec_pusharray(StackFrame frame, OpStep step, RunTimeScope scope)
        {
            var o = (ASBinCode.rtti.Vector_Data)((ASBinCode.rtti.HostedObject)((rtObjectBase)step.arg1.getValue(scope, frame)).value).hosted_object;

            _pusharray(o, frame, step, scope);
        }
        public static void exec(StackFrame frame, ASBinCode.OpStep step, RunTimeScope scope)
        {
#if DEBUG
            #region 函数调用检查  现基本不需要了
            //         RunTimeValueBase rv;rtFunction toclear = null;
            //if (step.arg1 is MethodGetterBase)
            //{
            //	rv = ((MethodGetterBase)step.arg1).getMethod(frame.scope); toclear = (rtFunction)rv;
            //}

            //else
            //{
            //	rv = step.arg1.getValue(frame.scope, frame);
            //}
            //         if (rv.rtType == frame.player.swc.FunctionClass.getRtType())
            //         {
            //             rv = TypeConverter.ObjectImplicit_ToPrimitive((rtObject)rv);
            //         }
            //         if (rv.rtType > RunTimeDataType.unknown && ClassMemberFinder.check_isinherits(rv, RunTimeDataType._OBJECT + 2, frame.player.swc))
            //         {
            //             //***说明要调用强制类型转换***
            //             ASBinCode.rtti.Class cls = ((rtObject)rv).value._class;
            //             if (frame.typeconvertoperator == null || frame.typeconvertoperator.targettype != cls

            //                 )
            //             {
            //                 frame.throwError(new error.InternalError(frame.player.swc, step.token, "应该是强制类型转换,内部异常"));

            //                 frame.endStep(step);
            //                 return;
            //             }
            //             else if (frame.typeconvertoperator.inputvalue == null)
            //             {
            //                 frame.throwError(step.token,0, "Argument count mismatch on class coercion.  Expected 1, got 0."
            //                     );

            //                 frame.endStep(step);
            //                 return;
            //             }
            //         }
            //         else
            //         {
            //             if (rv.rtType != RunTimeDataType.rt_function)
            //             {
            //                 frame.throwError(step.token,0, "value is not a function"
            //                     );

            //                 frame.endStep(step);
            //                 return;
            //             }

            //             ASBinCode.rtData.rtFunction function = (ASBinCode.rtData.rtFunction)rv;
            //             ASBinCode.rtti.FunctionDefine funcDefine = frame.player.swc.functions[function.functionId];


            //             if (!frame.funCaller.isFuncEquals(function))
            //             {
            //		if (toclear != null) { toclear.Clear(); }
            //                 frame.throwError(new error.InternalError(frame.player.swc, step.token, "运行时异常,调用函数不对"));
            //                 frame.endStep(step);
            //                 return;
            //             }
            //         }
            #endregion
#endif

            if (frame.typeconvertoperator == null)
            {
                var funCaller = frame.funCaller;
                funCaller.callbacker = funCaller;
                funCaller.returnSlot = step.reg.getSlot(frame.scope, frame);
                funCaller.call();

                frame.funCaller = null;
            }
            else
            {
                if (frame.typeconvertoperator.targettype.instanceClass == null)
                {
                    frame.throwError(new error.InternalError(frame.player.swc, step.token, "强制类型转换类型错误",
                                                             new ASBinCode.rtData.rtString("强制类型转换类型错误")));

                    frame.endStep(step);
                    return;
                }
                else
                {
                    BlockCallBackBase cb = frame.player.blockCallBackPool.create();
                    cb.step = step;
                    cb.args = frame;
                    cb.setCallBacker(_convert_cb);



                    OpCast.CastValue(frame.typeconvertoperator.inputvalue,
                                     frame.typeconvertoperator.targettype.instanceClass.getRtType(),
                                     frame, step.token, frame.scope, step.reg.getSlot(frame.scope, frame),
                                     cb,
                                     false);
                    frame.typeconvertoperator = null;
                }
            }
        }
        public static void create_paraScope_Method_NotNativeConstPara_AllParaOnStack(StackFrame frame, ASBinCode.OpStep step, RunTimeScope scope)
        {
            rtFunction function
                = (rtFunction)((MethodGetterBase)step.arg1).getMethod(frame.scope);

            var functionDefine = frame.player.swc.functions[function.functionId];

            if (frame.baseBottomSlotIndex + frame.call_parameter_slotCount + functionDefine.signature.onStackParameters >= Player.STACKSLOTLENGTH)
            {
                frame.throwError(new error.InternalError(frame.player.swc, step.token, "stack overflow"));
                frame.endStep();
                return;
            }

            var funcCaller = frame.player.funcCallerPool.create(frame, step.token);

            funcCaller.SetFunction(function); function.Clear();
            funcCaller.toCallFunc = functionDefine;
            frame.funCaller       = funcCaller;

            frame.call_parameter_slotCount  += functionDefine.signature.onStackParameters;
            funcCaller.onstackparametercount = functionDefine.signature.onStackParameters;
            funcCaller.CallFuncHeap          = Player.emptyMembers;

            var parameters = functionDefine.signature.parameters; int len = parameters.Count; int parast = frame.baseBottomSlotIndex + frame.call_parameter_slotCount;

            for (int i = step.jumoffset; i < len; i++)
            {
                var parameter = parameters[i];
                if (parameter.defaultValue != null)
                {
                    var dv = FunctionCaller.getDefaultParameterValue(parameter.type, parameter.defaultValue.getValue(null, null));

                    frame.stack[parast - i - 1].directSet(dv);
                    //_storeArgementToSlot(i, dv);
                }
                else if (parameter.isPara)
                {
                    frame.stack[parast - i - 1].directSet(new ASBinCode.rtData.rtArray());
                    //_storeArgementToSlot(i, new ASBinCode.rtData.rtArray());
                }
            }



            frame.endStepNoError();
        }
        public static void clear_thispointer(StackFrame frame, ASBinCode.OpStep step, RunTimeScope scope)
        {
            RunTimeValueBase rv;
            rtFunction       toclear = null;

            if (step.arg1 is MethodGetterBase)
            {
                rv      = ((ClassMethodGetter)step.arg1).getMethodForClearThis(frame.scope);
                toclear = (rtFunction)rv;
            }
            else
            {
                rv = step.arg1.getValue(frame.scope, frame);
            }

            if (rv.rtType > RunTimeDataType.unknown && ClassMemberFinder.check_isinherits(rv, RunTimeDataType._OBJECT + 2, frame.player.swc))
            {
                //***说明要调用强制类型转换***
                ASBinCode.rtti.Class cls = ((rtObjectBase)rv).value._class;

                if (cls.explicit_from != null)
                {
                    var member = (MethodGetterBase)cls.explicit_from.bindField;
                    var func   = member.getValue(((rtObjectBase)rv).objScope, null);

                    step.reg.getSlot(scope, frame).directSet(func);
                }
                else if (cls.implicit_from != null)
                {
                    var member = (MethodGetterBase)cls.implicit_from.bindField;
                    var func   = member.getValue(((rtObjectBase)rv).objScope, null);

                    step.reg.getSlot(scope, frame).directSet(func);
                }
                else
                {
                    frame.typeconvertoperator            = new typeConvertOperator();
                    frame.typeconvertoperator.targettype = cls;

                    step.reg.getSlot(scope, frame).directSet(rv);
                }

                if (toclear != null)
                {
                    toclear.Clear();
                }

                frame.endStepNoError();
                //frame.endStep(step);
                return;
            }


            if (rv.rtType != RunTimeDataType.rt_function)
            {
                frame.throwError(
                    step.token, 0, "value is not a function");
                if (toclear != null)
                {
                    toclear.Clear();
                }

                frame.endStep(step);
                return;
            }
            else
            {
                ASBinCode.rtData.rtFunction function = (ASBinCode.rtData.rtFunction)rv;

                step.reg.getSlot(scope, frame).directSet(rv);

                if (!function.ismethod)
                {
                    int          classid = ((ASBinCode.rtData.rtInt)step.arg2.getValue(scope, frame)).value;
                    RunTimeScope o;
                    if (frame.player.outpackage_runtimescope.TryGetValue(classid, out o))
                    {
                        _do_clear_thispointer(frame.player, (ASBinCode.rtData.rtFunction)step.reg.getValue(scope, frame), frame, o.this_pointer);
                    }
                }

                if (toclear != null)
                {
                    toclear.Clear();
                }

                frame.endStepNoError();
            }
        }
        public static void create_paraScope_Method(StackFrame frame, ASBinCode.OpStep step, RunTimeScope scope)
        {
            rtFunction function
                = (rtFunction)((MethodGetterBase)step.arg1).getMethod(frame.scope);

            var funcCaller = frame.player.funcCallerPool.create(frame, step.token);

            funcCaller.SetFunction(function); function.Clear();
            funcCaller._tempSlot  = frame._tempSlot1;
            funcCaller.toCallFunc = frame.player.swc.functions[function.functionId];
            if (!funcCaller.createParaScope())
            {
                return;
            }

            frame.funCaller = funcCaller;

            //frame.endStep(step);
            frame.endStepNoError();
        }
Example #19
0
        public static void exec_try_read_prop(StackFrame frame, OpStep step, RunTimeScope scope)
        {
            ASBinCode.SLOT slot = ((StackSlotAccessor)step.arg1).getSlot(scope,frame);

            if (slot.isPropGetterSetter)
            {
                ((StackSlot)slot).linkTo(null);
                _do_prop_read(

                    ((StackSlot)slot).stackObjects.propGetSet,
                    frame,step,frame.player,scope,((StackSlot)slot).stackObjects.propBindObj,((StackSlot)slot).stackObjects.superPropBindClass
                    );
            }
            else if (slot.isSetThisItem)
            {
                SetThisItemSlot sslot = (SetThisItemSlot)((StackSlot)slot).getLinkSlot();

                ((StackSlot)slot).linkTo(null);

                //***调用索引器get***
                RunTimeValueBase func;
                var rtObj  = sslot.bindObj;
                var player = frame.player;
                var v2     = sslot.setindex;
                func = ((MethodGetterBase)sslot.get_this_item.bindField).getMethod(
                    rtObj
                    );

                var funCaller = player.funcCallerPool.create(frame,step.token);
                funCaller.SetFunction((ASBinCode.rtData.rtFunction)func); ((ASBinCode.rtData.rtFunction)func).Clear();
                funCaller.loadDefineFromFunction();
                if (!funCaller.createParaScope())
                {
                    return;
                }

                //funCaller.releaseAfterCall = true;

                bool success;
                funCaller.pushParameter(v2,0,out success);
                if (!success)
                {
                    frame.endStep(step);
                    return;
                }

                funCaller._tempSlot  = frame._tempSlot1;
                funCaller.returnSlot = step.reg.getSlot(scope,frame);

                StackSlot ret = (StackSlot)funCaller.returnSlot;
                ret.stackObjects._temp_try_write_setthisitem = ret._cache_setthisslot; ret.refPropChanged = true;
                ret._cache_setthisslot.bindObj       = rtObj;
                ret._cache_setthisslot.setindex      = v2;
                ret._cache_setthisslot.set_this_item = sslot.set_this_item;

                BlockCallBackBase cb = frame.player.blockCallBackPool.create();
                cb.setCallBacker(_get_this_item_callbacker);
                cb.step = step;
                cb.args = frame;

                funCaller.callbacker = cb;
                funCaller.call();

                return;
            }
            else
            {
                SLOT regslot = step.reg.getSlot(scope,frame);

                StackSlot d = regslot as StackSlot;
                StackSlot s = slot as StackSlot;

                if (d != null && s != null && s.getLinkSlot() != null)
                {
                    d.linkTo(s.getLinkSlot());
                    s.linkTo(null);
                }
                else
                {
                    regslot.directSet(slot.getValue());
                }
                //frame.endStep(step);
                frame.endStepNoError();
            }
        }
Example #20
0
        public static void exec_AccessorBind(StackFrame frame, OpStep step, RunTimeScope scope)
        {
            RunTimeValueBase obj = step.arg1.getValue(scope, frame);

            if (rtNull.nullptr.Equals(obj))
            {
                frame.throwError(

                    step.token, 1009, "Cannot access a property or method of a null object reference."

                    );
                frame.endStep();
                return;
            }


            ASBinCode.rtti.Vector_Data vector =
                (ASBinCode.rtti.Vector_Data)((ASBinCode.rtti.HostedObject)((rtObjectBase)obj).value).hosted_object;

            int idx = TypeConverter.ConvertToInt(step.arg2.getValue(scope, frame));

            if (idx < 0 || idx > vector.innnerList.Count)
            {
                frame.throwError(step.token, 1125,
                                 "The index " + idx + " is out of range " + vector.innnerList.Count + ".");
            }

            StackSlotAccessor reg = (StackSlotAccessor)step.reg;

            if (idx == vector.innnerList.Count)
            {
                if (vector.isFixed || !reg._isassigntarget)
                {
                    frame.throwError(step.token, 1125,
                                     "The index " + idx + " is out of range " + vector.innnerList.Count + "."
                                     );
                    frame.endStep(step);
                    return;
                }
                else
                {
                    vector.innnerList.Add(TypeConverter.getDefaultValue(vector.vector_type).getValue(null, null));
                }
            }



            StackSlot slot = (StackSlot)step.reg.getSlot(scope, frame);

            if (reg._isassigntarget || reg._hasUnaryOrShuffixOrDelete)
            {
                slot._cache_vectorSlot.idx         = idx;
                slot._cache_vectorSlot.vector_data = vector;

                slot.linkTo(slot._cache_vectorSlot);
            }
            else
            {
                slot.directSet(vector.innnerList[idx]);
            }

            frame.endStep(step);
        }