Ejemplo n.º 1
0
        public void noticeRunFailed()
        {
            if (!hasnoticed)
            {
                hasnoticed = true;

                if (args is object[])
                {
                    object[] a = (object[])args;
                    for (int i = 0; i < a.Length; i++)
                    {
                        if (a[i] is IBlockCallBack)
                        {
                            ((IBlockCallBack)a[i]).noticeRunFailed();
                        }
                    }
                }
                else if (args is IBlockCallBack)
                {
                    ((IBlockCallBack)args).noticeRunFailed();
                }
                else if (args is ASBinCode.rtti.YieldObject)
                {
                    ASBinCode.rtti.YieldObject yobj = (ASBinCode.rtti.YieldObject)args;
                    if (yobj._callbacker != null)
                    {
                        ((IBlockCallBack)yobj._callbacker).noticeRunFailed();
                        yobj._callbacker = null;
                    }
                }

                if (whenFailed != null)
                {
                    whenFailed(this, args);
                }

                release();
            }
        }
Ejemplo n.º 2
0
        internal void doCall_allcheckpass()
        {
            if (toCallFunc.isYield)
            {
                if (!player.static_instance.ContainsKey(player.swc.YieldIteratorClass.staticClass.classid))
                {
                    if (!InstanceCreator.init_static_class(player.swc.YieldIteratorClass,player,token))
                    {
                        invokerFrame.endStep();

                        if (callbacker != null)
                        {
                            callbacker.noticeRunFailed();
                        }
                        release();


                        return;
                    }
                }

                ASBinCode.rtti.YieldObject yobj = new ASBinCode.rtti.YieldObject(
                    player.swc.YieldIteratorClass);


                CallFuncHeap[CallFuncHeap.Length - 2].directSet(new ASBinCode.rtData.rtInt(1));

                yobj.argements          = CallFuncHeap;
                yobj.function_bindscope = function.bindScope;
                yobj.block          = player.swc.blocks[toCallFunc.blockid];
                yobj.yield_function = toCallFunc;


                ASBinCode.rtData.rtObject rtYield = new ASBinCode.rtData.rtObject(yobj,null);
                yobj.thispointer =
                    (function.this_pointer != null ?
                     function.this_pointer : invokerFrame.scope.this_pointer);

                RunTimeScope scope = new RunTimeScope(null,
                                                      player.swc.YieldIteratorClass.blockid,null,rtYield,RunTimeScopeType.objectinstance);
                rtYield.objScope = scope;

                returnSlot.directSet(rtYield);


                if (callbacker != null)
                {
                    callbacker.call(callbacker.args);
                }
                release();

                return;
            }
            else if (!toCallFunc.isNative)
            {
                if (returnSlot is StackSlot)
                {
                    TypeConverter.setDefaultValueToStackSlot(
                        toCallFunc.signature.returnType,
                        (StackSlot)returnSlot);
                }
                else
                {
                    returnSlot.directSet(
                        TypeConverter.getDefaultValue(toCallFunc.signature.returnType).getValue(null,null));
                }
                if (!ReferenceEquals(callbacker,this))
                {
                    //***执行完成后,先清理参数***
                    BlockCallBackBase cb = player.blockCallBackPool.create();
                    cb.args            = cb.cacheObjects;
                    cb.cacheObjects[0] = callbacker;
                    cb.cacheObjects[1] = invokerFrame;

                    cb.setCallBacker(callfun_cb);
                    cb.setWhenFailed(callfun_failed);
                    cb._intArg            = onstackparametercount;
                    onstackparametercount = 0;

                    player.callBlock(
                        player.swc.blocks[toCallFunc.blockid],
                        CallFuncHeap,
                        returnSlot,
                        function.bindScope,
                        token,cb,function.this_pointer != null ? function.this_pointer : invokerFrame.scope.this_pointer,RunTimeScopeType.function);

                    release();
                }
                else
                {
                    player.callBlock(
                        player.swc.blocks[toCallFunc.blockid],
                        CallFuncHeap,
                        returnSlot,
                        function.bindScope,
                        token,callbacker,function.this_pointer != null ? function.this_pointer : invokerFrame.scope.this_pointer,RunTimeScopeType.function);
                }
            }
            else
            {
                //if (toCallFunc.native_index <0)
                //{
                //    toCallFunc.native_index = player.swc.nativefunctionNameIndex[toCallFunc.native_name];
                //}

                //var nf = player.swc.nativefunctions[toCallFunc.native_index];
                var nf = player.swc.getNativeFunction(toCallFunc);
                nf.bin = player.swc;

                if (nf.mode == NativeFunctionBase.NativeFunctionMode.normal_0)
                {
                    player._nativefuncCaller = this;

                    string errormsg;
                    int    errorno;
                    var    result = nf.execute(
                        function.this_pointer != null ? function.this_pointer : invokerFrame.scope.this_pointer,
                        CallFuncHeap,invokerFrame,
                        out errormsg,
                        out errorno
                        );
                    player._nativefuncCaller = null;
                    if (errormsg == null)
                    {
                        returnSlot.directSet(result);

                        if (callbacker != null)
                        {
                            callbacker.call(callbacker.args);
                        }

                        release();
                    }
                    else
                    {
                        invokerFrame.throwError(
                            token,0,errormsg
                            );

                        invokerFrame.endStep();

                        if (callbacker != null)
                        {
                            callbacker.noticeRunFailed();
                        }
                        release();
                    }
                }
                //else if (nf.mode == NativeFunctionBase.NativeFunctionMode.normal_1)
                //{
                //	player._nativefuncCaller = this;
                //	bool success;

                //	nf.execute2(
                //		function.this_pointer != null ? function.this_pointer : invokerFrame.scope.this_pointer,
                //		toCallFunc,
                //		CallFuncHeap,
                //		returnSlot,
                //		token,
                //		invokerFrame,
                //		out success
                //		);
                //	player._nativefuncCaller = null;
                //	if (success)
                //	{
                //		if (callbacker != null)
                //		{
                //			callbacker.call(callbacker.args);
                //		}
                //	}
                //	else
                //	{
                //		invokerFrame.endStep();
                //		if (callbacker != null)
                //		{
                //			callbacker.noticeRunFailed();
                //		}

                //	}

                //	release();


                //}
                else if (nf.mode == NativeFunctionBase.NativeFunctionMode.async_0)
                {
                    nf.executeAsync(function.this_pointer != null ? function.this_pointer : invokerFrame.scope.this_pointer,
                                    CallFuncHeap,
                                    returnSlot,
                                    callbacker,
                                    invokerFrame,
                                    token,
                                    function.bindScope
                                    );

                    if (!ReferenceEquals(callbacker,this))
                    {
                        release();
                    }
                }
                else if (nf.mode == NativeFunctionBase.NativeFunctionMode.const_parameter_0)
                {
                    bool success = false;
                    player._nativefuncCaller = this;

                    var nf3 = (nativefuncs.NativeConstParameterFunction)nf;
                    player._executeToken = nf3.getExecToken(toCallFunc.functionid);

                    nf3.execute3(
                        function.this_pointer != null ? function.this_pointer : invokerFrame.scope.this_pointer,
                        toCallFunc,
                        returnSlot,
                        token,
                        invokerFrame,
                        out success
                        );

                    player._executeToken     = nativefuncs.NativeConstParameterFunction.ExecuteToken.nulltoken;
                    player._nativefuncCaller = null;
                    ((nativefuncs.NativeConstParameterFunction)nf).clearParameter();

                    clear_para_slot(invokerFrame,onstackparametercount);
                    onstackparametercount = 0;

                    if (success)
                    {
                        var receive_err = player.clear_nativeinvokeraiseerror();
                        if (receive_err != null)
                        {
                            invokerFrame.receiveErrorFromStackFrame(receive_err);
                            if (callbacker != null)
                            {
                                callbacker.noticeRunFailed();
                            }
                        }
                        else if (callbacker != null)
                        {
                            callbacker.call(callbacker.args);
                        }
                    }
                    else
                    {
                        invokerFrame.endStep();
                        if (callbacker != null)
                        {
                            callbacker.noticeRunFailed();
                        }
                    }
                    release();
                }
            }
        }