예제 #1
0
        public static void exec_set_dynamic_prop(StackFrame frame, OpStep step, RunTimeScope scope)
        {
            ASBinCode.rtData.rtObjectBase obj  = (ASBinCode.rtData.rtObjectBase)step.reg.getValue(scope, frame);
            ASBinCode.rtti.DynamicObject  dobj = (ASBinCode.rtti.DynamicObject)obj.value;

            DynamicPropertySlot heapslot = new DynamicPropertySlot(obj, true, frame.player.swc.FunctionClass.getRtType());

            heapslot._propname = ((ASBinCode.rtData.rtString)step.arg1.getValue(scope, frame)).value;

            if (step.arg2 is MethodGetterBase)
            {
                var sf = ((MethodGetterBase)step.arg2).getMethod(scope);
                heapslot.directSet(sf); ((rtFunction)sf).Clear();
            }
            else
            {
                heapslot.directSet(step.arg2.getValue(scope, frame));
            }

            //dobj.createOrReplaceproperty(heapslot._propname,heapslot);
            if (dobj.hasproperty(heapslot._propname))
            {
                dobj.deleteProperty(heapslot._propname);
            }
            dobj.createproperty(heapslot._propname, heapslot);
            //直接初始化,可枚举
            heapslot.propertyIsEnumerable = true;
            //frame.endStep(step);
            frame.endStepNoError();
        }
        private rtFunction(int id, bool ismethod, int objid) : base(RunTimeDataType.rt_function)
        {
            _functionid    = id; _bindScope = null;
            this._ismethod = ismethod;
            _objid         = objid;

            //需要保证所有函数对象一致,因此会被拷贝传下去
            wapperContainer = new WapperContainer();

            objHandle = null;
        }
        public void CopyFrom(rtFunction right)
        {
            _objid        = right._objid;
            _functionid   = right._functionid;
            _bindScope    = right._bindScope;
            _ismethod     = right._ismethod;
            _this_pointer = right._this_pointer;

            objHandle       = right.objHandle;
            wapperContainer = right.wapperContainer;
        }
예제 #4
0
        //public virtual rtObject getSrcObject()
        //{
        //	return this;
        //}

        public sealed override bool Equals(object obj)
        {
            rtObjectBase o = obj as rtObjectBase;

            if (o == null)
            {
                return(false);
            }

            return(value.Equals(o.value));
        }
        public void Clear()
        {
            //_objid = -1;
            //_functionid = -1;
            //_ismethod = false; //值类型无需清理

            wapperContainer = null;

            _bindScope    = null;
            _this_pointer = null;
            objHandle     = null;
        }
예제 #6
0
        public sealed override SLOT getSlot(RunTimeScope scope,ASRuntime.StackFrame frame)
        {
            while (scope.scopeType != RunTimeScopeType.objectinstance)
            {
                scope = scope.parent;
                if (scope == null)
                {
                    return(null);
                }
            }

#if DEBUG
            //***检查类的继承关系***
            rtData.rtObjectBase obj = (rtData.rtObjectBase)scope.this_pointer;
            var cls = obj.value._class;

            while (cls.blockid != refblockid)
            {
                cls = cls.super;
            }
#endif

            return(scope.memberData[indexOfMembers]);
        }
예제 #7
0
 public DynamicPropertySlot(ASBinCode.rtData.rtObjectBase obj, bool _canDelete, RunTimeDataType functionClassRtType) : base(obj, functionClassRtType, RunTimeDataType.rt_void, null)
 {
     this._canDelete      = _canDelete;
     propertyIsEnumerable = false;
 }