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 _pusharray(ASBinCode.rtti.Vector_Data o, StackFrame frame, OpStep step, RunTimeScope scope) { var arr = step.arg2.getValue(scope, frame); if (arr.rtType == RunTimeDataType.rt_null) { frame.throwCastException(step.token, RunTimeDataType.rt_null, step.arg1.getValue(scope, frame).rtType ); frame.endStep(step); } else { rtArray array = (rtArray)arr; if (array.innerArray.Count == 0) { frame.endStep(step); } else { BlockCallBackBase cb = frame.player.blockCallBackPool.create(); cb.step = step; cb.args = frame; cb.setCallBacker(_allpushed); pushAllElementToVector(o, array.innerArray, frame, step.token, scope, cb); } } }
public static void _pushVector(ASBinCode.rtti.Vector_Data o, StackFrame frame, OpStep step, RunTimeScope scope) { var arr = step.arg2.getValue(scope, frame); if (arr.rtType == RunTimeDataType.rt_null) { frame.throwCastException(step.token, RunTimeDataType.rt_null, step.arg1.getValue(scope, frame).rtType ); frame.endStep(step); } else { ASBinCode.rtti.Vector_Data array = (ASBinCode.rtti.Vector_Data)((ASBinCode.rtti.HostedObject)((rtObjectBase)step.arg2.getValue(scope, frame)).value).hosted_object; if (array.innnerList.Count == 0) { frame.endStep(step); } else { BlockCallBackBase cb = frame.player.blockCallBackPool.create(); cb.step = step; cb.args = frame; cb.setCallBacker(D_allpushed); pushAllElementToVector(o, array.innnerList, frame, step.token, scope, cb); } } }
public static void exec_GetValue(StackFrame frame, OpStep step, RunTimeScope scope) { ASBinCode.rtti.Vector_Data vector = (ASBinCode.rtti.Vector_Data)((ASBinCode.rtti.HostedObject)((rtObjectBase)step.arg1.getValue(scope, frame)).value).hosted_object; int idx = TypeConverter.ConvertToInt(step.arg2.getValue(scope, frame)); if (idx < 0 || idx >= vector.innnerList.Count) { frame.throwError(step.token, 1125, "The index " + idx + " is out of range " + vector.innnerList.Count + "."); frame.endStep(step); } else { step.reg.getSlot(scope, frame).directSet(vector.innnerList[idx]); 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 exec_AccessorBind_ConvertIdx(StackFrame frame, OpStep step, RunTimeScope scope) { RunTimeValueBase obj = step.arg1.getValue(scope, frame); if (rtNull.nullptr.Equals(obj)) { frame.throwError( step.token, 1009, "Cannot access a property or method of a null object reference." ); frame.endStep(); return; } ASBinCode.rtti.Vector_Data vector = (ASBinCode.rtti.Vector_Data)((ASBinCode.rtti.HostedObject)((ASBinCode.rtData.rtObjectBase)obj).value).hosted_object; var idxvalue = step.arg2.getValue(scope, frame); double idx = double.NaN; if (idxvalue.rtType > RunTimeDataType.unknown) { RunTimeDataType ot; if (TypeConverter.Object_CanImplicit_ToPrimitive(idxvalue.rtType, frame.player.swc, out ot)) { var v = TypeConverter.ObjectImplicit_ToPrimitive((rtObjectBase)idxvalue); idx = TypeConverter.ConvertToNumber(v); } } else if (idxvalue.rtType == RunTimeDataType.rt_string || idxvalue.rtType == RunTimeDataType.rt_int || idxvalue.rtType == RunTimeDataType.rt_number || idxvalue.rtType == RunTimeDataType.rt_uint ) { idx = TypeConverter.ConvertToNumber(idxvalue); } if (double.IsNaN(idx)) { frame.throwError( step.token, 0, "索引" + idxvalue + "不能转为int" ); } else { int index = (int)idx; if (index < 0 || index > vector.innnerList.Count) { frame.throwError(step.token, 1125, "The index " + index + " is out of range " + vector.innnerList.Count + "."); } StackSlotAccessor reg = (StackSlotAccessor)step.reg; if (idx == vector.innnerList.Count) { if (vector.isFixed || !reg._isassigntarget) { frame.throwError(step.token, 1125, "The index " + idx + " is out of range " + vector.innnerList.Count + "."); frame.endStep(step); return; } else { vector.innnerList.Add(TypeConverter.getDefaultValue(vector.vector_type).getValue(null, null)); } } StackSlot slot = (StackSlot)step.reg.getSlot(scope, frame); if (reg._isassigntarget || reg._hasUnaryOrShuffixOrDelete) { slot._cache_vectorSlot.idx = index; slot._cache_vectorSlot.vector_data = vector; slot.linkTo(slot._cache_vectorSlot); } else { slot.directSet(vector.innnerList[index]); } } frame.endStep(step); }
//public sealed override bool isPropGetterSetter //{ // get // { // return false; // } //} public sealed override void clear() { vector_data = null; idx = 0; }
public vectorSLot(ASBinCode.rtti.Vector_Data vector_data,int idx,IClassFinder classfinder) { this.vector_data = vector_data; this.idx = idx; this.classfinder = classfinder; }
public static void exec_AccessorBind(StackFrame frame, OpStep step, RunTimeScope scope) { RunTimeValueBase obj = step.arg1.getValue(scope, frame); if (rtNull.nullptr.Equals(obj)) { frame.throwError( step.token, 1009, "Cannot access a property or method of a null object reference." ); frame.endStep(); return; } ASBinCode.rtti.Vector_Data vector = (ASBinCode.rtti.Vector_Data)((ASBinCode.rtti.HostedObject)((rtObjectBase)obj).value).hosted_object; int idx = TypeConverter.ConvertToInt(step.arg2.getValue(scope, frame)); if (idx < 0 || idx > vector.innnerList.Count) { frame.throwError(step.token, 1125, "The index " + idx + " is out of range " + vector.innnerList.Count + "."); } StackSlotAccessor reg = (StackSlotAccessor)step.reg; if (idx == vector.innnerList.Count) { if (vector.isFixed || !reg._isassigntarget) { frame.throwError(step.token, 1125, "The index " + idx + " is out of range " + vector.innnerList.Count + "." ); frame.endStep(step); return; } else { vector.innnerList.Add(TypeConverter.getDefaultValue(vector.vector_type).getValue(null, null)); } } StackSlot slot = (StackSlot)step.reg.getSlot(scope, frame); if (reg._isassigntarget || reg._hasUnaryOrShuffixOrDelete) { slot._cache_vectorSlot.idx = idx; slot._cache_vectorSlot.vector_data = vector; slot.linkTo(slot._cache_vectorSlot); } else { slot.directSet(vector.innnerList[idx]); } frame.endStep(step); }