private bool check_return_objtypeisclasscreated() { if (toCallFunc.signature.returnType > RunTimeDataType.unknown) { if (!InstanceCreator.init_static_class(player.swc.getClassByRunTimeDataType(toCallFunc.signature.returnType),player,token)) { //***中断本帧本次代码执行进入try catch阶段 invokerFrame.endStep(); if (callbacker != null) { callbacker.noticeRunFailed(); } release(); return(false); } else { return(true); } } else { return(true); } }
//abstract class baseinstancecallbacker : IBlockCallBack //{ // public object args // { // get // ; // set // ; // } // public ASBinCode.rtti.Object obj { get; set; } // public ASBinCode.IRunTimeScope objScope { get; set; } // public ASBinCode.rtData.rtObject rtObject { get; set; } // public abstract void call(object args); //} //class afterCreateStaticInstance : baseinstancecallbacker //{ // public override void call(object args) // { // object[] a = (object[])args; // exec_step0( // (Player)a[0], // (StackFrame)a[1], // (ASBinCode.OpStep)a[2], // (ASBinCode.rtti.Class)a[3], // (ASBinCode.IRunTimeScope)a[4] // ); // } //} //class afterCreateOutScope : baseinstancecallbacker //{ // public override void call(object args) // { // object[] a = (object[])args; // exec_step1( // (Player)a[0], // (StackFrame)a[1], // (ASBinCode.OpStep)a[2], // (ASBinCode.rtti.Class)a[3], // (ASBinCode.IRunTimeScope)a[4] // ); // } //} //class afterCreateInstanceData : baseinstancecallbacker //{ // public override void call(object args) // { // object[] a = (object[])args; // exec_step2( // (Player)a[0], // (StackFrame)a[1], // (ASBinCode.OpStep)a[2], // obj,objScope, // (ASBinCode.IRunTimeScope)a[4], // rtObject // ); // } //} //class afterCallConstructor : baseinstancecallbacker //{ // public override void call(object args) // { // object[] a = (object[])args; // exec_step3( // (ASBinCode.OpStep)a[0], // obj,objScope, // (ASBinCode.IRunTimeScope)a[1], // (StackFrame)a[2] // ); // } //} public static void init_static(StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope) { var player = frame.player; int classid = ((ASBinCode.rtData.rtInt)step.arg1.getValue(scope, frame)).value; ASBinCode.rtti.Class as3class = player.swc.classes[classid]; //init_static_class(player, frame, as3class,step.token, scope); if (InstanceCreator.init_static_class(as3class, player, step.token)) { //frame.endStep(step); frame.endStepNoError(); } //InstanceCreator ic = new InstanceCreator(player, frame, step.token, as3class); //if (ic.init_static_class(as3class)) //{ // frame.endStep(step); //} }
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(); } } }