public override Type TestType(Type type)
        {
            if (_testType == null)
            {
                _testType = (ASBinCode.rtData.rtFunction)player.getMethod(bindAS3Object, "testType");
            }
            if (_testTypeFunctionId == -1)
            {
                var c = typeclass.getBaseLinkSystemClass();
                _testTypeFunctionId = ((ClassMethodGetter)c.classMembers.FindByName("testType").bindField).functionId;
            }


            if (_testType != null &&
                (player == null || (player != null && NativeConstParameterFunction.checkToken(
                                        new NativeConstParameterFunction.ExecuteToken(
                                            player.ExecuteToken.tokenid, _testTypeFunctionId
                                            )
                                        ))
                )
                )
            {
                return(base.TestType(type));
            }
            else
            {
                var b = player.InvokeFunction(_testType, 1, type, null, null, null, null, null);

                return((Type)b);
            }
        }
Пример #2
0
 public void SetFunction(ASBinCode.rtData.rtFunction rtFunction, RunTimeValueBase thisobj)
 {
     function.CopyFrom(rtFunction);
     if (thisobj != null)
     {
         function.setThis(thisobj);
     }
 }
Пример #3
0
        private FunctionCaller(Player player,StackFrame invokerFrame,SourceToken token)
        {
            this.player       = player;
            this.invokerFrame = invokerFrame;
            this.token        = token;

            check_para_id = 0;
            pushedArgs    = 0;
            hasReleased   = false;

            function = new ASBinCode.rtData.rtFunction(-1,false);
        }
Пример #4
0
        internal Iterator(ASBinCode.RunTimeValueBase v, Player player)
        {
            this.player = player;

            if (v.rtType > ASBinCode.RunTimeDataType.unknown)
            {
                var cls = player.swc.getClassByRunTimeDataType(v.rtType);
                if (cls.isLink_System)
                {
                    var lobj = ((ASBinCode.rtti.LinkSystemObject)((ASBinCode.rtData.rtObjectBase)v).value).GetLinkData();

                    if (lobj is System.Collections.IEnumerator)
                    {
                        innerenumerator = (System.Collections.IEnumerator)lobj;
                    }
                    else if (lobj is System.Collections.IEnumerable)
                    {
                        innerenumerator = ((System.Collections.IEnumerable)lobj).GetEnumerator();
                    }
                    else
                    {
                        throw new InvalidCastException("不能将" + v.ToString() + "包装为Iterator");
                    }
                }
                else if (ASRuntime.TypeConverter.testImplicitConvert(v.rtType, player.swc.IEnumeratorInterface.getRtType(), player.swc))
                {
                    as3ienumerator = (ASBinCode.rtData.rtObjectBase)v;
                    get_current    = player.getMethod(as3ienumerator, "@current_get");
                    movenext       = player.getMethod(as3ienumerator, "moveNext");
                    reset          = player.getMethod(as3ienumerator, "reset");
                }
                else if (ASRuntime.TypeConverter.testImplicitConvert(v.rtType, player.swc.IEnumerableInterface.getRtType(), player.swc))
                {
                    var getenumerator = player.getMethod((ASBinCode.rtData.rtObjectBase)v, "getEnumerator");
                    as3ienumerator = (ASBinCode.rtData.rtObjectBase)player.InvokeFunction(getenumerator, 0, null, null, null, null, null, null);
                    get_current    = player.getMethod(as3ienumerator, "@current_get");
                    movenext       = player.getMethod(as3ienumerator, "moveNext");
                    reset          = player.getMethod(as3ienumerator, "reset");
                }
                else
                {
                    throw new InvalidCastException("不能将" + v.ToString() + "包装为Iterator");
                }
            }
            else
            {
                throw new InvalidCastException("不能将" + v.ToString() + "包装为Iterator");
            }
        }
Пример #5
0
        public override bool directSet(RunTimeValueBase value)
        {
            if (isConstMember)
            {
                if (!flaghasset)
                {
                    flaghasset = true;
                }
                else
                {
                    return(false);
                }
            }

            base.directSet(value);
            if (value.rtType == RunTimeDataType.rt_function)
            {
                ASBinCode.rtData.rtFunction function = (ASBinCode.rtData.rtFunction)getValue();

                if (function.this_pointer == null || !function.ismethod)
                {
                    function.setThis(obj);
                }
            }
            else if (obj.objScope != null && value.rtType == FunctionClassRtType)
            {
                ASBinCode.rtData.rtFunction function = (ASBinCode.rtData.rtFunction)
                                                       TypeConverter.ObjectImplicit_ToPrimitive((ASBinCode.rtData.rtObjectBase)value);

                if (function.this_pointer == null || !function.ismethod)
                {
                    function.setThis(obj);
                }
            }

            return(true);
        }
Пример #6
0
 public bool isFuncEquals(ASBinCode.rtData.rtFunction function)
 {
     return(this.function.Equals(function));
 }
Пример #7
0
 public void SetFunction(ASBinCode.rtData.rtFunction rtFunction)
 {
     function.CopyFrom(rtFunction);
 }
        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);
            }
        }
        public static void prepareConstructorClassArgements(StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope)
        {
            var rv = step.arg1.getValue(scope, frame);

            if (rv.rtType > RunTimeDataType.unknown)
            {
                var player = frame.player;
                var _class = getClass(player, frame, step, scope);
                if (_class != null && !_class.no_constructor)
                {
                    //frame.instanceCreator = new InstanceCreator(player, frame, step.token, _class);
                    frame.activeInstanceCreator(step.token, _class);
                    if (_class.constructor != null)
                    {
                        if (!frame.instanceCreator.prepareConstructorArgements())
                        {
                            return;
                        }
                    }
                    //if (_class.constructor != null)
                    //{
                    //    ASBinCode.rtti.FunctionDefine funcDefine = player.swc.functions[_class.constructor_functionid];
                    //    ASBinCode.rtti.FunctionSignature signature = funcDefine.signature;

                    //    frame.funCaller = new FunctionCaller(player, frame, step.token);
                    //    frame.funCaller.toCallFunc = funcDefine;
                    //    frame.funCaller.createParaScope();

                    //}
                }
                else if (_class.isInterface)
                {
                    frame.throwError(step.token, 0, _class.name + " Interfaces cannot be instantiated with the new operator.");
                }
                else
                {
                    frame.throwError(step.token, 0, _class.name + " is not a constructor");
                }
            }
            else
            {
                if (rv.rtType == RunTimeDataType.rt_function)
                {
                    ASBinCode.rtData.rtFunction func = (ASBinCode.rtData.rtFunction)rv;
                    if (func.ismethod)
                    {
                        frame.throwError(step.token, 0,
                                         "Method cannot be used as a constructor."
                                         );
                    }
                    else
                    {
                        //***创建一个Object对象,创建完毕之后,使用此函数执行初始化。将此对象作为此函数的this指针执行一次。
                        OpCast.Primitive_to_Object((ASBinCode.rtData.rtFunction)rv,
                                                   frame, step.token, scope, frame._tempSlot1, step, _func_ToObj
                                                   );

                        return;
                    }
                }
                else
                {
                    frame.throwCastException(step.token, rv.rtType, RunTimeDataType.rt_function);

                    //new error.InternalError( step.token,"原始类型转对象未实现",new ASBinCode.rtData.rtString("原始类型转对象未实现") ));
                }
            }
            frame.endStep(step);
        }