public override SLOT assign(RunTimeValueBase value,out bool success) { if (slottype != value.rtType && slottype != RunTimeDataType.rt_void && ! ( //***检查子类关系**** (slottype > RunTimeDataType.unknown && value.rtType > RunTimeDataType.unknown && ( ClassMemberFinder.check_isinherits(value,slottype,classfinder) || ClassMemberFinder.check_isImplements(value,slottype,classfinder) ) ) || ( slottype > RunTimeDataType.unknown && value.rtType == RunTimeDataType.rt_null ) || ( slottype == RunTimeDataType.rt_array && value.rtType == RunTimeDataType.rt_null ) || ( slottype == RunTimeDataType.rt_function && value.rtType == RunTimeDataType.rt_null ) || ( slottype == RunTimeDataType.rt_string && value.rtType == RunTimeDataType.rt_null ) ) ) { //return false; success = false; return(this); } else { success = directSet(value); return(this); } }
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 override SLOT assign(RunTimeValueBase value,out bool success) { if (vector_data.vector_type != value.rtType && ! ( //***检查子类关系**** (vector_data.vector_type > RunTimeDataType.unknown && value.rtType > RunTimeDataType.unknown && ( ClassMemberFinder.check_isinherits(value,vector_data.vector_type,classfinder) || ClassMemberFinder.check_isImplements(value,vector_data.vector_type,classfinder) ) ) || ( vector_data.vector_type > RunTimeDataType.unknown && value.rtType == RunTimeDataType.rt_null ) || ( vector_data.vector_type == RunTimeDataType.rt_array && value.rtType == RunTimeDataType.rt_null ) || ( vector_data.vector_type == RunTimeDataType.rt_function && value.rtType == RunTimeDataType.rt_null ) || ( vector_data.vector_type == RunTimeDataType.rt_string && value.rtType == RunTimeDataType.rt_null ) ) ) { //return false; success = false; return(this); } else { switch (value.rtType) { case RunTimeDataType.rt_int: { ((rtInt)vector_data.innnerList[idx]).value = ((rtInt)value).value; success = true; return(this); } case RunTimeDataType.rt_uint: { ((rtUInt)vector_data.innnerList[idx]).value = ((rtUInt)value).value; success = true; return(this); } case RunTimeDataType.rt_number: { ((rtNumber)vector_data.innnerList[idx]).value = ((rtNumber)value).value; success = true; return(this); } case RunTimeDataType.rt_string: { ((rtString)vector_data.innnerList[idx]).value = ((rtString)value).value; success = true; return(this); } case RunTimeDataType.rt_function: { ((rtFunction)vector_data.innnerList[idx]).CopyFrom((rtFunction)value); success = true; return(this); } default: break; } if (value.rtType > RunTimeDataType.unknown) { var vd = vector_data.innnerList[idx]; if (vd != null) { var cls = classfinder.getClassByRunTimeDataType(value.rtType); if (cls.isLink_System) { ASBinCode.rtti.LinkSystemObject link = (ASBinCode.rtti.LinkSystemObject)((rtObjectBase)vd).value; if (cls.isStruct) { link.CopyStructData((ASBinCode.rtti.LinkSystemObject)((rtObjectBase)value).value); } else { ((rtObjectBase)vd).value = ((rtObjectBase)value).value; } success = true; return(this); } } } vector_data.innnerList[idx] = (RunTimeValueBase)value.Clone(); //对容器的直接赋值,需要Clone //return true; success = true; return(this); } }
public override SLOT assign(RunTimeValueBase value,out bool success) { if (vector_data.vector_type != value.rtType && ! ( //***检查子类关系**** (vector_data.vector_type > RunTimeDataType.unknown && value.rtType > RunTimeDataType.unknown && ( ClassMemberFinder.check_isinherits(value,vector_data.vector_type,classfinder) || ClassMemberFinder.check_isImplements(value,vector_data.vector_type,classfinder) ) ) || ( vector_data.vector_type > RunTimeDataType.unknown && value.rtType == RunTimeDataType.rt_null ) || ( vector_data.vector_type == RunTimeDataType.rt_array && value.rtType == RunTimeDataType.rt_null ) || ( vector_data.vector_type == RunTimeDataType.rt_function && value.rtType == RunTimeDataType.rt_null ) || ( vector_data.vector_type == RunTimeDataType.rt_string && value.rtType == RunTimeDataType.rt_null ) ) ) { //return false; success = false; return(this); } else { switch (value.rtType) { case RunTimeDataType.rt_int: { ((rtInt)vector_data.innnerList[idx]).value = ((rtInt)value).value; success = true; return(this); } case RunTimeDataType.rt_uint: { ((rtUInt)vector_data.innnerList[idx]).value = ((rtUInt)value).value; success = true; return(this); } case RunTimeDataType.rt_number: { ((rtNumber)vector_data.innnerList[idx]).value = ((rtNumber)value).value; success = true; return(this); } case RunTimeDataType.rt_string: { ((rtString)vector_data.innnerList[idx]).value = ((rtString)value).value; success = true; return(this); } case RunTimeDataType.rt_function: { ((rtFunction)vector_data.innnerList[idx]).CopyFrom((rtFunction)value); success = true; return(this); } default: break; } vector_data.innnerList[idx] = (RunTimeValueBase)value.Clone(); //对容器的直接赋值,需要Clone //return true; success = true; return(this); } }