private static ASBinCode.rtti.Object createObject(CSWC swc,Class cls,InstanceCreator creator, out ASBinCode.rtData.rtObjectBase rtObjectBase, out ASBinCode.rtData.rtObjectBase linkrtobj, out string errinfo ) { ASBinCode.rtti.Object obj = null;// = new ASBinCode.rtti.Object(cls); rtObjectBase = null; linkrtobj = null; errinfo = null; if (cls.isLink_System) { if (creator != null) { StackSlot stackSlot = creator.objectStoreToSlot as StackSlot; if (stackSlot != null) { rtObjectBase = stackSlot.getStackCacheObject(cls); return(rtObjectBase.value); } } var func = (NativeFunctionBase)swc.class_Creator[cls]; string err; int no; ASBinCode.rtData.rtObjectBase rtObj = func.execute(null,null,cls,out err,out no) as ASBinCode.rtData.rtObjectBase; linkrtobj = rtObj; if (rtObj == null) { errinfo = cls.ToString() + " create linksystem object failed"; return(null); } else { return(rtObj.value); } } else if (cls.isCrossExtend) { var scls = cls.super; while (!scls.isLink_System) { scls = scls.super; } var cextend = scls.staticClass.linkObjCreator; var func = swc.getNativeFunction(((ClassMethodGetter)cextend.bindField).functionId); if (func == null) { errinfo = cls.ToString() + " create crossextend object failed, creator function not found"; return(null); } string err; int no; ASBinCode.rtData.rtObjectBase rtObj = func.execute(null,null,cls,out err,out no) as ASBinCode.rtData.rtObjectBase; linkrtobj = rtObj; if (rtObj == null) { errinfo = cls.ToString() + " create crossextend object failed"; return(null); } else { LinkSystemObject lo = (LinkSystemObject)rtObj.value; return(lo); } } else if ( swc.DictionaryClass != null && ClassMemberFinder.isInherits(cls,swc.DictionaryClass)) { obj = new DictionaryObject(cls); } else if (cls.dynamic) { if (cls.isUnmanaged) { obj = new HostedDynamicObject(cls); } else { obj = new DynamicObject(cls); } } else if (cls.isUnmanaged) { obj = new HostedObject(cls); } else { obj = new ASBinCode.rtti.Object(cls); } return(obj); }
public static void forin_get_enumerator(StackFrame frame, OpStep step, RunTimeScope scope) { var player = frame.player; SLOT slot = step.reg.getSlot(scope,frame); ASBinCode.rtti.HostedDynamicObject saveObj = new HostedDynamicObject(player.swc.ObjectClass); rtObject save = new rtObject(saveObj,null); slot.directSet(save); var obj = step.arg1.getValue(scope,frame); if (obj.rtType > RunTimeDataType.unknown) { rtObject rtObj = (rtObject)obj; if (ClassMemberFinder.isInherits(rtObj.value._class, player.swc.primitive_to_class_table[RunTimeDataType.rt_array])) { rtArray arr = (rtArray)rtObj.value.memberData[0].getValue(); saveObj.hosted_object = getArrayForIn(arr.innerArray); } else if (player.swc.dict_Vector_type.ContainsKey(rtObj.value._class)) { saveObj.hosted_object = getArrayForIn(((Vector_Data)((HostedObject)rtObj.value).hosted_object).innnerList); } else if (ClassMemberFinder.isImplements(rtObj.value._class,player.swc.IEnumerableInterface)) { //***调用getIEnumerator方法**** var movenext = ClassMemberFinder.find( frame.player.swc.IEnumerableInterface,"getEnumerator", frame.player.swc.IEnumerableInterface); var method = ((InterfaceMethodGetter)movenext.bindField).getMethod( rtObj); //***调用方法*** var funCaller = player.funcCallerPool.create(frame,step.token); //funCaller.releaseAfterCall = true; funCaller.SetFunction((rtFunction)method); ((rtFunction)method).Clear(); funCaller.loadDefineFromFunction(); if (!funCaller.createParaScope()) { return; } funCaller._tempSlot = frame._tempSlot1; funCaller.returnSlot = frame._tempSlot1; BlockCallBackBase cb = frame.player.blockCallBackPool.create(); cb.setCallBacker(D_getEnumerator_callbacker); cb.step = step; cb.args = frame; cb.scope = scope; funCaller.callbacker = cb; funCaller.call(); return; } else if (ClassMemberFinder.isImplements( rtObj.value._class,player.swc.IEnumeratorInterface)) { saveObj.hosted_object = rtObj; } else { IEnumerator <RunTimeValueBase> forinenum = getForinIEnumerator(player,rtObj.value,frame,step,scope); saveObj.hosted_object = forinenum; } } frame.endStep(); }