public string getStackTrace() { if (errorValue != null) { string errinfo = string.Empty; if (errorValue.rtType > RunTimeDataType.unknown && swc.ErrorClass != null) { if (ClassMemberFinder.check_isinherits(errorValue, swc.ErrorClass.getRtType(), swc)) { errinfo = ((rtObjectBase)errorValue).value.memberData[3].getValue().ToString(); } } else if (callStack != null) { StringBuilder sb = new StringBuilder(); var toget = new List <ASRuntime.FrameInfo>(callStack); toget.Reverse(); foreach (var item in toget) { if (item.block.instructions.Length == 0) { continue; } if (item.codeLinePtr < item.block.instructions.Length) { sb.Append("\tat "); sb.Append(item.block.name); sb.Append(" ["); sb.Append(item.block.instructions[item.codeLinePtr].token.sourceFile); sb.Append(" "); sb.Append(item.block.instructions[item.codeLinePtr].token.line + 1); sb.Append(" ptr:"); sb.Append(item.block.instructions[item.codeLinePtr].token.ptr + 1); sb.Append("]"); sb.AppendLine(); } else { sb.Append("\tat "); sb.AppendLine(item.block.name); } } errinfo = sb.ToString(); } return("\t" + errinfo); } else { return(string.Empty); } }
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); } }
public string getErrorInfo() { if (errorValue != null && swc != null) { string errinfo = errorValue.ToString(); if (errorValue.rtType > RunTimeDataType.unknown && swc.ErrorClass != null) { if (ClassMemberFinder.check_isinherits(errorValue, swc.ErrorClass.getRtType(), swc)) { errinfo = ((rtObjectBase)errorValue).value.memberData[1].getValue().ToString() + " #" + ((rtObjectBase)errorValue).value.memberData[2].getValue().ToString() + " " + ((rtObjectBase)errorValue).value.memberData[0].getValue().ToString(); } } return("[故障] " + "信息=" + errinfo); } else { return(message); } }
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 create_paraScope(StackFrame frame, ASBinCode.OpStep step, RunTimeScope scope) { 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 > RunTimeDataType.unknown && ClassMemberFinder.check_isinherits(rv, RunTimeDataType._OBJECT + 2, frame.player.swc)) { //***说明要调用强制类型转换*** ASBinCode.rtti.Class cls = ((rtObjectBase)rv).value._class; if (frame.typeconvertoperator != null) { frame.endStepNoError(); //frame.endStep(step); return; } else if (frame.typeconvertoperator.targettype.instanceClass == null || frame.typeconvertoperator.targettype != cls ) { frame.throwError(new error.InternalError(frame.player.swc, step.token, "类型转换函数发现内部错误" )); frame.endStep(step); return; } } if (rv.rtType == frame.player.swc.FunctionClass.getRtType()) { rv = TypeConverter.ObjectImplicit_ToPrimitive((rtObjectBase)rv); } if (rv.rtType != RunTimeDataType.rt_function) { frame.throwError(step.token, 0, "value is not a function"); frame.endStep(step); } else { ASBinCode.rtData.rtFunction function = (ASBinCode.rtData.rtFunction)rv; var funcCaller = frame.player.funcCallerPool.create(frame, step.token); funcCaller.SetFunction(function); if (toclear != null) { toclear.Clear(); } funcCaller._tempSlot = frame._tempSlot1; funcCaller.loadDefineFromFunction(); if (!funcCaller.createParaScope()) { return; } frame.funCaller = funcCaller; frame.endStepNoError(); } }
public static void clear_thispointer(StackFrame frame, ASBinCode.OpStep step, RunTimeScope scope) { RunTimeValueBase rv; rtFunction toclear = null; if (step.arg1 is MethodGetterBase) { rv = ((ClassMethodGetter)step.arg1).getMethodForClearThis(frame.scope); toclear = (rtFunction)rv; } else { rv = step.arg1.getValue(frame.scope, frame); } if (rv.rtType > RunTimeDataType.unknown && ClassMemberFinder.check_isinherits(rv, RunTimeDataType._OBJECT + 2, frame.player.swc)) { //***说明要调用强制类型转换*** ASBinCode.rtti.Class cls = ((rtObjectBase)rv).value._class; if (cls.explicit_from != null) { var member = (MethodGetterBase)cls.explicit_from.bindField; var func = member.getValue(((rtObjectBase)rv).objScope, null); step.reg.getSlot(scope, frame).directSet(func); } else if (cls.implicit_from != null) { var member = (MethodGetterBase)cls.implicit_from.bindField; var func = member.getValue(((rtObjectBase)rv).objScope, null); step.reg.getSlot(scope, frame).directSet(func); } else { frame.typeconvertoperator = new typeConvertOperator(); frame.typeconvertoperator.targettype = cls; step.reg.getSlot(scope, frame).directSet(rv); } if (toclear != null) { toclear.Clear(); } frame.endStepNoError(); //frame.endStep(step); return; } if (rv.rtType != RunTimeDataType.rt_function) { frame.throwError( step.token, 0, "value is not a function"); if (toclear != null) { toclear.Clear(); } frame.endStep(step); return; } else { ASBinCode.rtData.rtFunction function = (ASBinCode.rtData.rtFunction)rv; step.reg.getSlot(scope, frame).directSet(rv); if (!function.ismethod) { int classid = ((ASBinCode.rtData.rtInt)step.arg2.getValue(scope, frame)).value; RunTimeScope o; if (frame.player.outpackage_runtimescope.TryGetValue(classid, out o)) { _do_clear_thispointer(frame.player, (ASBinCode.rtData.rtFunction)step.reg.getValue(scope, frame), frame, o.this_pointer); } } if (toclear != null) { toclear.Clear(); } frame.endStepNoError(); } }
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); } }