Esempio n. 1
0
        public static void exec_try_write_prop(StackFrame frame,OpStep step,RunTimeScope scope)
        {
            StackSlot slot = (StackSlot)((StackSlotAccessor)step.arg1).getSlot(scope,frame);

            if (slot.stackObjects.propGetSet != null)
            {
                OpAssigning._doPropAssigning(slot.stackObjects.propGetSet,frame,step,frame.player,scope,
                                             slot.stackObjects.propBindObj
                                             ,
                                             slot.getValue()
                                             ,
                                             slot
                                             );
            }
            else if (slot.stackObjects._temp_try_write_setthisitem != null)
            {
                SetThisItemSlot sslot = (SetThisItemSlot)slot.stackObjects._temp_try_write_setthisitem;
                slot.stackObjects._temp_try_write_setthisitem = null;

                OpAssigning._doSetThisItem(
                    sslot.bindObj,sslot.set_this_item,
                    slot.getValue(),
                    sslot.setindex,
                    slot,frame,step
                    );
            }
            else
            {
                //frame.endStep(step);
                frame.endStepNoError();
            }
        }
        public StackSlot(CSWC classfinder,Player player)
        {
            this.player = player;
            store       = new RunTimeValueBase[(int)RunTimeDataType._OBJECT + 1];
            index       = (int)RunTimeDataType.unknown;

            _cache_arraySlot     = new operators.OpAccess_Dot.arraySlot(null,0,classfinder);
            _cache_vectorSlot    = new operators.OpVector.vectorSLot(null,0,classfinder);
            _cache_prototypeSlot = new operators.OpAccess_Dot.prototypeSlot(null,null,null);
            _cache_setthisslot   = new SetThisItemSlot();

            //存储器设置初始值
            for (int i = 0; i < RunTimeDataType._OBJECT + 1; i++)
            {
                RunTimeDataType t = (RunTimeDataType)i;
                if (t != RunTimeDataType.unknown)
                {
                    store[i] = TypeConverter.getDefaultValue(t).getValue(null,null);
                }
            }

            store[RunTimeDataType.rt_array]    = null;
            store[RunTimeDataType.rt_string]   = null;
            store[RunTimeDataType.rt_function] = null;


            _numberValue = (rtNumber)store[RunTimeDataType.rt_number];
            _intValue    = (rtInt)store[RunTimeDataType.rt_int];
            _uintValue   = (rtUInt)store[RunTimeDataType.rt_uint];
            _stringValue = new rtString(string.Empty);

            _functionValue  = new rtFunction(-1,false);
            _functon_result = new rtFunction(-1,false);
        }
Esempio n. 3
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(D_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();
            }
        }