private void exec_step3(ASBinCode.rtData.rtObjectBase rtobject)
        {
            if (constructor == null)
            {
                objectResult = rtobject;
                //objectResult.directSet(rtobject);
                if (callbacker != null)
                {
                    callbacker.call(this);
                    callbacker = null;
                }
            }
            else
            {
                HeapSlot _temp = tempSlot; _temp.directSet(ASBinCode.rtData.rtUndefined.undefined);
                _function_constructor.returnSlot = _temp;
                //_function_constructor.function = (ASBinCode.rtData.rtFunction)TypeConverter.ObjectImplicit_ToPrimitive(constructor).Clone();
                //_function_constructor.function.setThis(rtobject);
                _function_constructor.SetFunction((ASBinCode.rtData.rtFunction)TypeConverter.ObjectImplicit_ToPrimitive(constructor),rtobject);

                BlockCallBackBase cb = player.blockCallBackPool.create();
                cb.args            = cb.cacheObjects; //new object[] { rtobject , _temp };
                cb.cacheObjects[0] = rtobject;
                cb.cacheObjects[1] = _temp;

                cb.setCallBacker(_finalStep);

                _function_constructor.callbacker = cb;
                _function_constructor.call();
                _function_constructor = null;
            }
        }
 private InstanceCreator(StackFrame invokerFrame)//, SourceToken token, Class _class)
 {
     this.invokerFrame = invokerFrame;
     //this.token = token;
     //this._class = _class;
     tempSlot = new HeapSlot();
 }
        public TournamentMergeSortMovieGen(int width, int height, string name, byte[] data)
        {
            _width     = width;
            _height    = height;
            _name      = name;
            _itemCount = data.Length;
            _data      = data;
            _mergeTemp = new byte[data.Length];
            _font      = new Font("Dave", 24);
            _fontSmall = new Font("Dave", 18);
            _fontTiny  = new Font("Dave", 9);

            _estComplex = (int)(Math.Log2(_itemCount) * _itemCount);

            _steps = 0;
            _heap  = new HeapSlot[7];
            for (int i = 0; i < 7; i++)
            {
                _heap[i] = new HeapSlot {
                    Locked = false, Occupied = false, Value = (byte)(0)
                };
            }

            _iterator = TournamentSort().GetEnumerator();
        }
        private void exec_step2(
            ASBinCode.rtti.Object obj,
            RunTimeScope objScope,ASBinCode.rtData.rtObjectBase _object)
        {
            //***添加Object的动态对象****
            if (
                //(obj._class.classid == 0)
                obj is DynamicObject &&
                obj._class.staticClass != null)
            {
                DynamicObject dobj = (DynamicObject)obj;

                if (constructor == null)
                {
                    dobj.createproperty("constructor",new DynamicPropertySlot(_object,false,player.swc.FunctionClass.getRtType()));
                    dobj["constructor"].directSet(player.static_instance[obj._class.staticClass.classid]);
                    dobj._prototype_ = (DynamicObject)player.static_instance[_class.staticClass.classid].value;
                }
                else
                {
                    dobj._prototype_ = (DynamicObject)constructor.value;
                }
            }

            ClassMember ctor = obj._class.constructor;

            //if (obj._class.isCrossExtend)
            //{
            //	//***创建Adapter***
            //	var scls = obj._class.super;
            //	while (!scls.isLink_System)
            //	{
            //		scls = scls.super;
            //	}

            //	ctor = scls.crossExtendAdapterCreator;

            //	var nf = player.swc.getNativeFunction(((MethodGetterBase)ctor.bindField).functionId);
            //	if (!(nf is ICrossExtendAdapterCreator))
            //	{
            //		invokerFrame.throwAneException(token, "adapter不是ICrossExtendAdapterCreator");
            //		callbacker.noticeRunFailed();
            //		noticeWhenCreateAneFailed();
            //		invokerFrame.endStep();
            //		return;

            //	}

            //	constructorCaller.toCallFunc =  player.swc.functions[((MethodGetterBase)ctor.bindField).functionId];

            //}


            //调用构造函数
            if (ctor != null)
            {
                ASBinCode.rtData.rtFunction function =
                    (ASBinCode.rtData.rtFunction)((MethodGetterBase)ctor.bindField).getConstructor(objScope);


                HeapSlot _temp = tempSlot;
                constructorCaller.returnSlot = _temp;
                constructorCaller.SetFunction(function); function.Clear();


                //afterCallConstructor callbacker = new afterCallConstructor();
                var callbacker = player.blockCallBackPool.create();
                callbacker.args = this;
                //callbacker.obj = obj;
                //callbacker.objScope = objScope;
                //callbacker.rtObject = _object;
                callbacker.cacheObjects[0] = _object;
                callbacker.setWhenFailed(creatorFailed);
                callbacker.setCallBacker(afterCallConstructorCallbacker);


                constructorCaller.callbacker = callbacker;

                toNoticeFailed2 = callbacker;
                constructorCaller.call();
                toNoticeFailed2 = null;

                constructorCaller = null;
            }
            else
            {
                exec_step3(_object);
            }
        }
 static int Map(HeapSlot hs) => hs.Occupied ? hs.Value : int.MaxValue;
Esempio n. 6
0
 public YieldObject(ASBinCode.rtti.Class _class) : base(_class)
 {
     returnSlot = new HeapSlot();
 }