public static ClassPropertyGetter LoadClassPropertyGetter(BinaryReader reader,CSWCSerizlizer serizlizer,IDictionary <int,object> serizlized,int key)
        {
            int    indexofMember = reader.ReadInt32();
            string _name         = reader.ReadString();

            ClassPropertyGetter cpg = new ClassPropertyGetter(_name,null,indexofMember);

            serizlized.Add(key,cpg);

            rtti.Class _class = serizlizer.DeserializeObject <rtti.Class>(reader,rtti.Class.LoadClass);
            cpg._class = _class;


            cpg.getter = serizlizer.DeserializeObject <MethodGetterBase>(reader,ISWCSerializableLoader.LoadIMember);
            cpg.setter = serizlizer.DeserializeObject <MethodGetterBase>(reader,ISWCSerializableLoader.LoadIMember);

            return(cpg);
        }
        public static ISWCSerializable LoadIMember(BinaryReader reader, CSWCSerizlizer serizlizer, IDictionary <int, object> serizlized, int key)
        {
            int membertype = reader.ReadInt32();

            if (membertype == 0)
            {
                return(ClassMethodGetter.LoadClassMethodGetter(reader, serizlizer, serizlized, key));
            }
            else if (membertype == 1)
            {
                return(InterfaceMethodGetter.LoadInterfaceMethodGetter(reader, serizlizer, serizlized, key));
            }
            else if (membertype == 2)
            {
                return(ClassPropertyGetter.LoadClassPropertyGetter(reader, serizlizer, serizlized, key));
            }
            else if (membertype == 3)
            {
                return(Variable.LoadVariable(reader, serizlizer, serizlized, key));
            }
            else if (membertype == 4)
            {
                return(Field.LoadField(reader, serizlizer, serizlized, key));
            }
            else if (membertype == 5)
            {
                return(StackSlotAccessor.LoadRegister(reader, serizlizer, serizlized, key));
            }
            else if (membertype == 6)
            {
                return(rtData.RightValue.LoadRightValue(reader, serizlizer, serizlized, key));
            }
            else if (membertype == 7)
            {
                return(StaticClassDataGetter.LoadStaticClassDataGetter(reader, serizlizer, serizlized, key));
            }
            else if (membertype == 8)
            {
                return(ThisPointer.LoadThisPointer(reader, serizlizer, serizlized, key));
            }
            else if (membertype == 9)
            {
                return(SuperPointer.LoadSuperPointer(reader, serizlizer, serizlized, key));
            }
            else if (membertype == 10)
            {
                return(MemRegister_Number.LoadRegister(reader, serizlizer, serizlized, key));
            }
            else if (membertype == 11)
            {
                return(MemRegister_Boolean.LoadRegister(reader, serizlizer, serizlized, key));
            }
            else if (membertype == 12)
            {
                return(MemRegister_Int.LoadRegister(reader, serizlizer, serizlized, key));
            }
            else if (membertype == 13)
            {
                return(MemRegister_UInt.LoadRegister(reader, serizlizer, serizlized, key));
            }
            //else if (membertype == 14)
            //{
            //	return MemRegister_Object.LoadRegister(reader, serizlizer, serizlized, key);
            //}
            else
            {
                throw new IOException("格式异常");
            }
        }
Exemplo n.º 3
0
        public static void execAssigning(StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope)
        {
            ASBinCode.SLOT slot = step.reg.getSlotForAssign(scope,frame);

            ASBinCode.RunTimeValueBase v = step.arg1.getValue(scope,frame);
            bool success;

            var lt = slot.assign(v,out success);


            if (!success)                 //(!slot.directSet(v))
            {
                if (!(slot is StackSlot)) //直接赋值时
                {
                    //ext = "Illegal assignment to function " + ((MethodGetterBase)step.reg).name + ".";
                }
                else
                {
                    StackSlot oslot = (StackSlot)slot;
                    //if (oslot.linktarget != null)
                    {
                        //slot = oslot.linktarget;
                        slot = lt;
                    }

                    if (step.arg1 is IMemReg)
                    {
                        //将其暂存到临时槽内
                        frame._tempSlot2.directSet(v);
                        v = frame._tempSlot2.getValue();
                    }

                    if (slot is SetThisItemSlot)
                    {
                        _doSetThisItem(((SetThisItemSlot)slot).bindObj,v,((SetThisItemSlot)slot).setindex,oslot,frame,step);

                        return;
                    }

                    if (slot is ClassPropertyGetter.PropertySlot)
                    {
                        ClassPropertyGetter.PropertySlot propslot =
                            (ASBinCode.ClassPropertyGetter.PropertySlot)slot;
                        //***调用访问器。***
                        ASBinCode.ClassPropertyGetter prop = oslot.stackObjects.propGetSet;                         //propslot.property;

                        _doPropAssigning(prop,frame,step,frame.player,scope,
                                         //propslot.bindObj
                                         oslot.stackObjects.propBindObj
                                         ,v,
                                         oslot
                                         );
                        return;
                    }

                    if (slot is OpVector.vectorSLot)                        //Vector类型不匹配
                    {
                        BlockCallBackBase cb = frame.player.blockCallBackPool.create();
                        cb.scope = scope;
                        cb.step  = step;
                        cb.args  = frame;
                        cb.setCallBacker(_vectorConvertCallBacker);
                        cb.cacheObjects[0] = slot;

                        //***调用强制类型转换***
                        OpCast.CastValue(v,((OpVector.vectorSLot)slot).vector_data.vector_type,
                                         frame,step.token,scope,frame._tempSlot1,cb,false);

                        return;
                    }

                    if (slot is ObjectMemberSlot && !((ObjectMemberSlot)slot).isConstMember)
                    {
                        BlockCallBackBase cb = frame.player.blockCallBackPool.create();
                        cb.scope = scope;
                        cb.step  = step;
                        cb.args  = frame;
                        cb.setCallBacker(_objectmemberslotConvertCallbacker);
                        cb.cacheObjects[0] = slot;

                        //***调用强制类型转换***
                        OpCast.CastValue(v,((ObjectMemberSlot)slot).slottype,
                                         frame,step.token,scope,frame._tempSlot1,cb,false);

                        return;
                    }
                }
                string ext = String.Empty;

                if (slot is MethodGetterBase.MethodSlot)
                {
                    ext = "Cannot assign to a method ";                    // + ((ASBinCode.ClassMethodGetter.MethodSlot)slot).method;
                }
                else if (slot is ObjectMemberSlot)
                {
                    ext = "Illegal write to read-only property ";
                    //+ ((ObjectMemberSlot)slot).obj.value._class.name
                    //+" on ppp.PPC."
                }
                else if (slot is ClassPropertyGetter.PropertySlot)
                {
                    ext = "Illegal write to read-only property ";
                }
                else if (slot is OpAccess_Dot.prototypeSlot)
                {
                    ext = "Cannot create property "
                          + ((OpAccess_Dot.prototypeSlot)slot)._protoname +
                          " on " + ((OpAccess_Dot.prototypeSlot)slot)._protoRootObj.value._class.name;
                }

                frame.throwError(
                    step.token,0,ext
                    );
                frame.endStep(step);
            }
            else
            {
                frame.endStepNoError();
            }
        }