public static void execBitOR(StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope) { ASBinCode.RunTimeValueBase v1 = step.arg1.getValue(scope, frame); ASBinCode.RunTimeValueBase v2 = step.arg2.getValue(scope, frame); var f = frame.player.swc.operatorOverrides.getOperatorFunction(OverrideableOperator.bitOr, v1.rtType, v2.rtType); if (f != null) { FunctionCaller fc = frame.player.funcCallerPool.create(frame, step.token); fc.SetFunction(f); fc.loadDefineFromFunction(); if (!fc.createParaScope()) { return; } //fc.releaseAfterCall = true; bool success; fc.pushParameter(v1, 0, out success); fc.pushParameter(v2, 1, out success); fc.returnSlot = step.reg.getSlot(scope, frame); fc.callbacker = fc; fc.call(); } else { OpCast.InvokeTwoValueOf(v1, v2, frame, step.token, scope, frame._tempSlot1, frame._tempSlot2, step, _BitOR_ValueOf_CallBacker); } }
private static void _execAdd_InvokeToString_CallBacker( ASBinCode.RunTimeValueBase v1, ASBinCode.RunTimeValueBase v2, StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope) { ASBinCode.RunTimeDataType v1type = v1.rtType; ASBinCode.RunTimeDataType v2type = v2.rtType; if (v1type == ASBinCode.RunTimeDataType.rt_void) { v1type = ASBinCode.RunTimeDataType.rt_number; } if (v2type == ASBinCode.RunTimeDataType.rt_void) { v2type = ASBinCode.RunTimeDataType.rt_number; } ASBinCode.RunTimeDataType finalType = TypeConverter.getImplicitOpType( v1type, v2type, ASBinCode.OpCode.add, frame.player.swc ); if (finalType == ASBinCode.RunTimeDataType.rt_number) { step.reg.getSlot(scope, frame).setValue( TypeConverter.ConvertToNumber(v1) + TypeConverter.ConvertToNumber(v2) ); frame.endStepNoError(); return; } else if (finalType == ASBinCode.RunTimeDataType.rt_string) { BlockCallBackBase cb = frame.player.blockCallBackPool.create(); cb.setCallBacker(D_Cast_TwoString_Callbacker); cb.args = frame; cb.scope = scope; cb.step = step; OpCast.CastTwoValue(v1, v2, finalType, frame, step.token, scope, frame._tempSlot1, frame._tempSlot2, cb ); return; } else if (finalType == ASBinCode.RunTimeDataType.rt_void) { step.reg.getSlot(scope, frame).setValue(ASBinCode.rtData.rtUndefined.undefined); } else { frame.throwOpException(step.token, ASBinCode.OpCode.add); } frame.endStep(step); }
private static void _execSuffixInc_ValueOf_Callbacker(ASBinCode.RunTimeValueBase v1, ASBinCode.RunTimeValueBase v2, StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope) { if (v1.rtType > ASBinCode.RunTimeDataType.unknown) { OpCast.InvokeTwoToString(v1, ASBinCode.rtData.rtNull.nullptr, frame, step.token, scope, frame._tempSlot1, frame._tempSlot2, step, _execSuffixInc_toString_Callbacker); } else { double n = TypeConverter.ConvertToNumber(v1); step.reg.getSlot(scope, frame).setValue(n); ASBinCode.rtData.rtNumber num = new ASBinCode.rtData.rtNumber(++n); StackSlotAccessor register = step.arg1 as StackSlotAccessor; if (register != null) { bool issuccess; ((StackSlot)register.getSlotForAssign(scope, frame)).assign(num, out issuccess); if (!issuccess) { frame.throwError(step.token, 0, "操作失败"); } } else { ((ASBinCode.LeftValueBase)step.arg1).getSlot(scope, frame).directSet(num); } frame.endStep(step); } }
private static void _convertCB(BlockCallBackBase sender, object args) { object[] a = (object[])sender.args; if (sender.isSuccess) { ASBinCode.rtti.Vector_Data vd = (ASBinCode.rtti.Vector_Data)a[0]; var v = ((StackFrame)a[5])._tempSlot1.getValue().Clone(); //必须Clone var list = (List <RunTimeValueBase>)a[1]; vd.innnerList.Add((RunTimeValueBase)v); sender._intArg = sender._intArg + 1; if (sender._intArg >= list.Count) { IBlockCallBack cb = (IBlockCallBack)a[4]; cb.call(cb.args); } else { OpCast.CastValue(list[sender._intArg], vd.vector_type, (StackFrame)a[5], (SourceToken)a[2], (RunTimeScope)a[3], ((StackFrame)a[5])._tempSlot1, sender, false); } } }
public static void execBitXOR(StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope) { ASBinCode.RunTimeValueBase v1 = step.arg1.getValue(scope, frame); ASBinCode.RunTimeValueBase v2 = step.arg2.getValue(scope, frame); OpCast.InvokeTwoValueOf(v1, v2, frame, step.token, scope, frame._tempSlot1, frame._tempSlot2, step, _BitXOR_ValueOf_Callbacker); }
public static void execAdd(StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope) { ASBinCode.RunTimeValueBase v1 = step.arg1.getValue(scope, frame); ASBinCode.RunTimeValueBase v2 = step.arg2.getValue(scope, frame); var f = frame.player.swc.operatorOverrides.getOperatorFunction(OverrideableOperator.addition, v1.rtType, v2.rtType); if (f != null) { FunctionCaller fc = frame.player.funcCallerPool.create(frame, step.token); fc.SetFunction(f); fc.loadDefineFromFunction(); if (!fc.createParaScope()) { return; } //fc.releaseAfterCall = true; bool success; fc.pushParameter(v1, 0, out success); fc.pushParameter(v2, 1, out success); fc.returnSlot = step.reg.getSlot(scope, frame); fc.callbacker = fc; fc.call(); } else if ( (v1.rtType > ASBinCode.RunTimeDataType.unknown && v2.rtType > ASBinCode.RunTimeDataType.unknown) || v1.rtType == ASBinCode.RunTimeDataType.rt_int || v1.rtType == ASBinCode.RunTimeDataType.rt_uint || v1.rtType == ASBinCode.RunTimeDataType.rt_number || v2.rtType == ASBinCode.RunTimeDataType.rt_int || v2.rtType == ASBinCode.RunTimeDataType.rt_uint || v2.rtType == ASBinCode.RunTimeDataType.rt_number ) { OpCast.InvokeTwoValueOf(v1, v2, frame, step.token, scope, frame._tempSlot1, frame._tempSlot2, step, _execAdd_CallBacker); } else //toString { OpCast.InvokeTwoToString(v1, v2, frame, step.token, scope, frame._tempSlot1, frame._tempSlot2, step, _execAdd_InvokeToString_CallBacker); } }
private static void _execIncrement_ValueOf_Callbacker(ASBinCode.RunTimeValueBase v1, ASBinCode.RunTimeValueBase v2, StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope ) { if (v1.rtType > ASBinCode.RunTimeDataType.unknown) { OpCast.InvokeTwoToString(v1, ASBinCode.rtData.rtNull.nullptr, frame, step.token, scope, frame._tempSlot1, frame._tempSlot2, step, _execIncrement_ToString_Callbacker); } else { double n = TypeConverter.ConvertToNumber(v1); ASBinCode.rtData.rtNumber num = new ASBinCode.rtData.rtNumber(++n); ((ASBinCode.LeftValueBase)step.reg).getSlot(scope, frame).directSet(num); frame.endStep(step); } }
private static void _execNeg_ValueOf_Callbacker(ASBinCode.RunTimeValueBase v1, ASBinCode.RunTimeValueBase v2, StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope ) { if (v1.rtType > ASBinCode.RunTimeDataType.unknown) { OpCast.InvokeTwoToString(v1, ASBinCode.rtData.rtNull.nullptr, frame, step.token, scope, frame._tempSlot1, frame._tempSlot2, step, _execNeg_ToString_Callbacker); } else { step.reg.getSlot(scope, frame).setValue( -TypeConverter.ConvertToNumber(v1) ); //frame.endStep(step); frame.endStepNoError(); } }
public static void execNeg(StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope) { ASBinCode.RunTimeValueBase v = step.arg1.getValue(scope, frame); if (v.rtType != ASBinCode.RunTimeDataType.rt_number) { var f = frame.player.swc.operatorOverrides.getOperatorFunction(OverrideableOperator.Unary_negation, v.rtType, RunTimeDataType.unknown); if (f != null) { FunctionCaller fc = frame.player.funcCallerPool.create(frame, step.token); //fc.releaseAfterCall = true; fc.SetFunction(f); fc.loadDefineFromFunction(); if (!fc.createParaScope()) { return; } bool success; fc.pushParameter(v, 0, out success); fc.returnSlot = step.reg.getSlot(scope, frame); fc.callbacker = fc; fc.call(); return; } else { OpCast.InvokeTwoValueOf(v, ASBinCode.rtData.rtNull.nullptr, frame, step.token, scope, frame._tempSlot1, frame._tempSlot2, step, _execNeg_ValueOf_Callbacker); } } else { step.reg.getSlot(scope, frame).setValue(-((ASBinCode.rtData.rtNumber)v).value);//new ASBinCode.rtData.rtNumber( -((ASBinCode.rtData.rtNumber)v).value)); //frame.endStep(step); frame.endStepNoError(); } }
public static void pushAllElementToVector(ASBinCode.rtti.Vector_Data vd, List <RunTimeValueBase> datalist, StackFrame frame, SourceToken token, RunTimeScope scope, IBlockCallBack callbacker ) { BlockCallBackBase convertCb = frame.player.blockCallBackPool.create(); convertCb._intArg = 0; convertCb.setCallBacker(_convertCB); object[] args = convertCb.cacheObjects; //new object[6]; args[0] = vd; args[1] = datalist; args[2] = token; args[3] = scope; args[4] = callbacker; args[5] = frame; convertCb.args = args; OpCast.CastValue(datalist[convertCb._intArg], vd.vector_type, frame, token, scope, frame._tempSlot1, convertCb, false); }
public static void execUnaryPlus(StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope) { ASBinCode.RunTimeValueBase v = step.arg1.getValue(scope, frame); var f = frame.player.swc.operatorOverrides.getOperatorFunction(OverrideableOperator.Unary_plus, v.rtType, RunTimeDataType.unknown); if (f != null) { FunctionCaller fc = frame.player.funcCallerPool.create(frame, step.token); //fc.releaseAfterCall = true; fc.SetFunction(f); fc.loadDefineFromFunction(); if (!fc.createParaScope()) { return; } bool success; fc.pushParameter(v, 0, out success); fc.returnSlot = step.reg.getSlot(scope, frame); fc.callbacker = fc; fc.call(); return; } else { BlockCallBackBase cb = frame.player.blockCallBackPool.create(); cb.scope = scope; cb.step = step; cb.args = frame; cb.setCallBacker(_tonumber_cb); OpCast.CastValue(v, RunTimeDataType.rt_number, frame, step.token, scope, frame._tempSlot1, cb, false); } }
private static void _execAdd_CallBacker( ASBinCode.RunTimeValueBase v1, ASBinCode.RunTimeValueBase v2, StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope) { ASBinCode.RunTimeDataType v1type = v1.rtType; ASBinCode.RunTimeDataType v2type = v2.rtType; if (v1type == ASBinCode.RunTimeDataType.rt_void) { v1type = ASBinCode.RunTimeDataType.rt_number; } if (v2type == ASBinCode.RunTimeDataType.rt_void) { v2type = ASBinCode.RunTimeDataType.rt_number; } if (v1type > ASBinCode.RunTimeDataType.unknown || v2type > ASBinCode.RunTimeDataType.unknown) { //***调用toString()*** OpCast.InvokeTwoToString(v1, v2, frame, step.token, scope, frame._tempSlot1, frame._tempSlot2, step, _execAdd_InvokeToString_CallBacker); } //else if (v1type > ASBinCode.RunTimeDataType.unknown) //{ // OpCast.InvokeTwoToString(v1, v2, frame, step.token, scope, // frame._tempSlot1, frame._tempSlot2, step, _execAdd_InvokeToString_CallBacker); //} //else if (v2type > ASBinCode.RunTimeDataType.unknown) //{ //} else { _execAdd_InvokeToString_CallBacker(v1, v2, frame, step, scope); } }
public override void executeAsync(RunTimeValueBase thisObj,SLOT[] argements,SLOT resultSlot, object callbacker, object stackframe, SourceToken token,RunTimeScope scope) { //base.executeAsync(thisObj, argements, resultSlot, callbacker, stackframe, token, scope); var thisArg = argements[0].getValue(); rtFunction func = (rtFunction)((rtObjectBase)thisObj).value.memberData[0].getValue(); rtFunction toApply = (rtFunction)func; //.Clone(); if (!func.ismethod) //方法无法更改this { if (!(thisArg is rtObjectBase)) { var player = ((StackFrame)stackframe).player; var objtype = thisArg.rtType; if (objtype < RunTimeDataType.unknown && player.swc.primitive_to_class_table[objtype] != null ) { FunctionCaller toInsertStack = ((StackFrame)stackframe).player.funcCallerPool.create((StackFrame)(stackframe),token); toInsertStack.callbacker = (IBlockCallBack)callbacker; toInsertStack.SetFunction(toApply); toInsertStack._tempSlot = ((StackFrame)stackframe)._tempSlot1; toInsertStack.returnSlot = resultSlot; toInsertStack.tag = argements; stackCallers.Push(toInsertStack); //***转换为对象*** OpCast.Primitive_to_Object(thisArg,(StackFrame)stackframe,token,scope, ((StackFrame)stackframe)._tempSlot1, null,_primitive_toObj); return; } else { var fd = player.swc.functions[toApply.functionId]; var block = player.swc.blocks[fd.blockid]; //if (block.isoutclass )将this复位 { var oc = player.outpackage_runtimescope[block.define_class_id]; toApply.setThis(oc.this_pointer); } //else //{ // caller.function.setThis(null); //} } } else { toApply.setThis((rtObjectBase)thisArg); } } FunctionCaller caller = ((StackFrame)stackframe).player.funcCallerPool.create((StackFrame)(stackframe),token); caller.callbacker = (IBlockCallBack)callbacker; caller.SetFunction(toApply); caller._tempSlot = ((StackFrame)stackframe)._tempSlot1; caller.returnSlot = resultSlot; caller.loadDefineFromFunction(); if (!caller.createParaScope()) { return; } if (argements[1].getValue().rtType == RunTimeDataType.rt_array) { rtArray argArray = (rtArray)argements[1].getValue(); for (int i = 0; i < argArray.innerArray.Count; i++) { bool success; caller.pushParameter(argArray.innerArray[i],i,out success); } } caller.call(); }
public static void execBitNot(StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope) { ASBinCode.RunTimeValueBase v1 = step.arg1.getValue(scope, frame); OpCast.InvokeTwoValueOf(v1, ASBinCode.rtData.rtNull.nullptr, frame, step.token, scope, frame._tempSlot1, frame._tempSlot2, step, _BitNot_ValueOf_Callbacker); }
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); }
private void check_para(BlockCallBackBase checkparacb) { while (check_para_id < pushedArgs) { var parameter = toCallFunc.signature.parameters; RunTimeValueBase argement = getToCheckParameter(check_para_id); var argtype = argement.rtType; var targettype = parameter[check_para_id].type; if (argtype != targettype && targettype != RunTimeDataType.rt_void && !(argtype == RunTimeDataType.rt_null && targettype > RunTimeDataType.unknown) && !(argtype > RunTimeDataType.unknown && targettype > RunTimeDataType.unknown && ( ClassMemberFinder.check_isinherits(argement,targettype,player.swc) || ClassMemberFinder.check_isImplements(argement,targettype,player.swc) ) ) ) { BlockCallBackBase cb = player.blockCallBackPool.create(); cb.args = argement; cb._intArg = check_para_id; cb.setCallBacker(check_para_callbacker); cb.setWhenFailed(check_para_failed); check_para_id++; OpCast.CastValue(argement,parameter[ cb._intArg].type, invokerFrame,token,invokerFrame.scope,_tempSlot,cb,false); return; } else { check_para_id++; } } if (pushedArgs < toCallFunc.signature.parameters.Count && !toCallFunc.IsAnonymous) //匿名函数能跳过参数检查 { for (int i = pushedArgs; i < toCallFunc.signature.parameters.Count; i++) { if (toCallFunc.signature.parameters[pushedArgs].defaultValue == null && !toCallFunc.signature.parameters[pushedArgs].isPara ) { invokerFrame.throwArgementException( token, string.Format( "Argument count mismatch on Function/{0}. Expected {1}, got {2}.", player.swc.blocks[toCallFunc.blockid].name,toCallFunc.signature.parameters.Count,pushedArgs ) ); clear_para_slot(invokerFrame,onstackparametercount); onstackparametercount = 0; //***中断本帧本次代码执行进入try catch阶段 invokerFrame.endStep(); if (callbacker != null) { callbacker.noticeRunFailed(); } release(); return; } } } if (!check_return_objtypeisclasscreated()) { return; } if (checkparacb != null) { checkparacb.noticeEnd(); } //***全部参数检查通过*** doCall_allcheckpass(); }
public static void execIncrement(StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope) { var v = step.arg1.getValue(scope, frame); StackSlotAccessor register = step.arg1 as StackSlotAccessor; if (register != null) { ((StackSlot)register.getSlotForAssign(scope, frame)).linkTo(null); } switch (v.rtType) { case ASBinCode.RunTimeDataType.rt_int: { ASBinCode.rtData.rtInt iv = (ASBinCode.rtData.rtInt)v; iv.value++; ((LeftValueBase)step.arg1).getSlot(scope, frame).directSet(iv); step.reg.getSlot(scope, frame).setValue(iv.value); } break; case ASBinCode.RunTimeDataType.rt_uint: { ASBinCode.rtData.rtUInt iv = (ASBinCode.rtData.rtUInt)v; iv.value++; ((LeftValueBase)step.arg1).getSlot(scope, frame).directSet(iv); step.reg.getSlot(scope, frame).setValue(iv.value); } break; case ASBinCode.RunTimeDataType.rt_number: { ASBinCode.rtData.rtNumber iv = (ASBinCode.rtData.rtNumber)v; iv.value++; ((LeftValueBase)step.arg1).getSlot(scope, frame).directSet(iv); step.reg.getSlot(scope, frame).setValue(iv.value); } break; case ASBinCode.RunTimeDataType.rt_string: { double n = TypeConverter.ConvertToNumber(v); if (string.IsNullOrEmpty(((ASBinCode.rtData.rtString)v).value)) { n = 0; } ASBinCode.rtData.rtNumber num = new ASBinCode.rtData.rtNumber(++n); step.reg.getSlot(scope, frame).directSet(num); } break; case ASBinCode.RunTimeDataType.rt_boolean: case ASBinCode.RunTimeDataType.rt_void: case ASBinCode.RunTimeDataType.rt_null: { double n = TypeConverter.ConvertToNumber(v); ASBinCode.rtData.rtNumber num = new ASBinCode.rtData.rtNumber(++n); ((ASBinCode.LeftValueBase)step.reg).getSlot(scope, frame).directSet(num); } break; case ASBinCode.RunTimeDataType.unknown: default: { OpCast.InvokeTwoValueOf(v, ASBinCode.rtData.rtNull.nullptr, frame, step.token, scope, frame._tempSlot1, frame._tempSlot2, step, _execIncrement_ValueOf_Callbacker); return; } } //frame.endStep(step); frame.endStepNoError(); }
public static void exec(StackFrame frame, ASBinCode.OpStep step, RunTimeScope scope) { #if DEBUG #region 函数调用检查 现基本不需要了 // RunTimeValueBase rv;rtFunction toclear = null; //if (step.arg1 is MethodGetterBase) //{ // rv = ((MethodGetterBase)step.arg1).getMethod(frame.scope); toclear = (rtFunction)rv; //} //else //{ // rv = step.arg1.getValue(frame.scope, frame); //} // if (rv.rtType == frame.player.swc.FunctionClass.getRtType()) // { // rv = TypeConverter.ObjectImplicit_ToPrimitive((rtObject)rv); // } // if (rv.rtType > RunTimeDataType.unknown && ClassMemberFinder.check_isinherits(rv, RunTimeDataType._OBJECT + 2, frame.player.swc)) // { // //***说明要调用强制类型转换*** // ASBinCode.rtti.Class cls = ((rtObject)rv).value._class; // if (frame.typeconvertoperator == null || frame.typeconvertoperator.targettype != cls // ) // { // frame.throwError(new error.InternalError(frame.player.swc, step.token, "应该是强制类型转换,内部异常")); // frame.endStep(step); // return; // } // else if (frame.typeconvertoperator.inputvalue == null) // { // frame.throwError(step.token,0, "Argument count mismatch on class coercion. Expected 1, got 0." // ); // frame.endStep(step); // return; // } // } // else // { // if (rv.rtType != RunTimeDataType.rt_function) // { // frame.throwError(step.token,0, "value is not a function" // ); // frame.endStep(step); // return; // } // ASBinCode.rtData.rtFunction function = (ASBinCode.rtData.rtFunction)rv; // ASBinCode.rtti.FunctionDefine funcDefine = frame.player.swc.functions[function.functionId]; // if (!frame.funCaller.isFuncEquals(function)) // { // if (toclear != null) { toclear.Clear(); } // frame.throwError(new error.InternalError(frame.player.swc, step.token, "运行时异常,调用函数不对")); // frame.endStep(step); // return; // } // } #endregion #endif if (frame.typeconvertoperator == null) { var funCaller = frame.funCaller; funCaller.callbacker = funCaller; funCaller.returnSlot = step.reg.getSlot(frame.scope, frame); funCaller.call(); frame.funCaller = null; } else { if (frame.typeconvertoperator.targettype.instanceClass == null) { frame.throwError(new error.InternalError(frame.player.swc, step.token, "强制类型转换类型错误", new ASBinCode.rtData.rtString("强制类型转换类型错误"))); frame.endStep(step); return; } else { BlockCallBackBase cb = frame.player.blockCallBackPool.create(); cb.step = step; cb.args = frame; cb.setCallBacker(_convert_cb); OpCast.CastValue(frame.typeconvertoperator.inputvalue, frame.typeconvertoperator.targettype.instanceClass.getRtType(), frame, step.token, frame.scope, step.reg.getSlot(frame.scope, frame), cb, false); frame.typeconvertoperator = null; } } }
public static void execAssigning(StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope) { ASBinCode.SLOT slot = step.reg.getSlotForAssign(scope,frame); ASBinCode.RunTimeValueBase v = step.arg1.getValue(scope,frame); bool success; var lt = slot.assign(v,out success); if (!success) //(!slot.directSet(v)) { if (!(slot is StackSlot)) //直接赋值时 { //ext = "Illegal assignment to function " + ((MethodGetterBase)step.reg).name + "."; } else { StackSlot oslot = (StackSlot)slot; //if (oslot.linktarget != null) { //slot = oslot.linktarget; slot = lt; } if (step.arg1 is IMemReg) { //将其暂存到临时槽内 frame._tempSlot2.directSet(v); v = frame._tempSlot2.getValue(); } if (slot is SetThisItemSlot) { _doSetThisItem(((SetThisItemSlot)slot).bindObj,v,((SetThisItemSlot)slot).setindex,oslot,frame,step); return; } if (slot is ClassPropertyGetter.PropertySlot) { ClassPropertyGetter.PropertySlot propslot = (ASBinCode.ClassPropertyGetter.PropertySlot)slot; //***调用访问器。*** ASBinCode.ClassPropertyGetter prop = oslot.stackObjects.propGetSet; //propslot.property; _doPropAssigning(prop,frame,step,frame.player,scope, //propslot.bindObj oslot.stackObjects.propBindObj ,v, oslot ); return; } if (slot is OpVector.vectorSLot) //Vector类型不匹配 { BlockCallBackBase cb = frame.player.blockCallBackPool.create(); cb.scope = scope; cb.step = step; cb.args = frame; cb.setCallBacker(_vectorConvertCallBacker); cb.cacheObjects[0] = slot; //***调用强制类型转换*** OpCast.CastValue(v,((OpVector.vectorSLot)slot).vector_data.vector_type, frame,step.token,scope,frame._tempSlot1,cb,false); return; } if (slot is ObjectMemberSlot && !((ObjectMemberSlot)slot).isConstMember) { BlockCallBackBase cb = frame.player.blockCallBackPool.create(); cb.scope = scope; cb.step = step; cb.args = frame; cb.setCallBacker(_objectmemberslotConvertCallbacker); cb.cacheObjects[0] = slot; //***调用强制类型转换*** OpCast.CastValue(v,((ObjectMemberSlot)slot).slottype, frame,step.token,scope,frame._tempSlot1,cb,false); return; } } string ext = String.Empty; if (slot is MethodGetterBase.MethodSlot) { ext = "Cannot assign to a method "; // + ((ASBinCode.ClassMethodGetter.MethodSlot)slot).method; } else if (slot is ObjectMemberSlot) { ext = "Illegal write to read-only property "; //+ ((ObjectMemberSlot)slot).obj.value._class.name //+" on ppp.PPC." } else if (slot is ClassPropertyGetter.PropertySlot) { ext = "Illegal write to read-only property "; } else if (slot is OpAccess_Dot.prototypeSlot) { ext = "Cannot create property " + ((OpAccess_Dot.prototypeSlot)slot)._protoname + " on " + ((OpAccess_Dot.prototypeSlot)slot)._protoRootObj.value._class.name; } frame.throwError( step.token,0,ext ); frame.endStep(step); } else { frame.endStepNoError(); } }