public override RunTimeValueBase execute(RunTimeValueBase thisObj,SLOT[] argements,object stackframe,out string errormessage,out int errorno) { errormessage = null; errorno = 0; string name = TypeConverter.ConvertToString(argements[0].getValue(),null,null); bool isEnum = TypeConverter.ConvertToBoolean(argements[1].getValue(),null,null).value; if (string.IsNullOrEmpty(name)) { return(ASBinCode.rtData.rtUndefined.undefined); } ASBinCode.rtData.rtObjectBase obj = (ASBinCode.rtData.rtObjectBase)thisObj; if (!(obj.value is ASBinCode.rtti.DynamicObject)) { return(ASBinCode.rtData.rtUndefined.undefined); } ASBinCode.rtti.DynamicObject dobj = (ASBinCode.rtti.DynamicObject)obj.value; if (dobj is ASBinCode.rtti.DictionaryObject) { return(ASBinCode.rtData.rtUndefined.undefined); } if (dobj.hasproperty(name)) { dobj.setPropertyIsEnumerable(name,isEnum); } return(ASBinCode.rtData.rtUndefined.undefined); }
public override RunTimeValueBase execute(RunTimeValueBase thisObj,SLOT[] argements,object stackframe,out string errormessage,out int errorno) { errormessage = null; errorno = 0; string name = TypeConverter.ConvertToString(argements[0].getValue(),null,null); if (String.IsNullOrEmpty(name)) { return(ASBinCode.rtData.rtBoolean.False); } //固定实例属性 — 对象类定义的非静态变量、常量或方法; //继承的固定实例属性 — 对象类继承的变量、常量或方法; //动态属性 — 对象实例化后添加到其中的属性(在其类定义之外)。要添加动态属性,必须用 dynamic 关键字声明对象的定义类。 //return new ASBinCode.rtData.rtString(TypeConverter.ConvertToString(thisObj, null, null)); ASBinCode.rtData.rtObjectBase obj = (ASBinCode.rtData.rtObjectBase)thisObj; if (ClassMemberFinder.find(obj.value._class,name,null) != null) { return(ASBinCode.rtData.rtBoolean.True); } if (obj.value is ASBinCode.rtti.DynamicObject) { ASBinCode.rtti.DynamicObject d = (ASBinCode.rtti.DynamicObject)obj.value; if (d.hasproperty(name)) { return(ASBinCode.rtData.rtBoolean.True); } else { return(ASBinCode.rtData.rtBoolean.False); } } return(ASBinCode.rtData.rtBoolean.False); }
public override RunTimeValueBase execute(RunTimeValueBase thisObj,SLOT[] argements,object stackframe,out string errormessage,out int errorno) { errormessage = null; errorno = 0; string name = TypeConverter.ConvertToString(argements[0].getValue(),null,null); if (string.IsNullOrEmpty(name)) { return(ASBinCode.rtData.rtBoolean.False); } ASBinCode.rtData.rtObjectBase obj = (ASBinCode.rtData.rtObjectBase)thisObj; if (!(obj.value is ASBinCode.rtti.DynamicObject)) { return(ASBinCode.rtData.rtBoolean.False); } ASBinCode.rtti.DynamicObject dobj = (ASBinCode.rtti.DynamicObject)obj.value; if (dobj.hasproperty(name)) { if (dobj.propertyIsEnumerable(name)) { return(ASBinCode.rtData.rtBoolean.True); } else { return(ASBinCode.rtData.rtBoolean.False); } } else { return(ASBinCode.rtData.rtBoolean.False); } }
public override RunTimeValueBase execute(RunTimeValueBase thisObj,SLOT[] argements,object stackframe,out string errormessage,out int errorno) { errormessage = null; errorno = 0; var theObj = argements[0].getValue(); if (theObj.rtType < RunTimeDataType.unknown) { return(ASBinCode.rtData.rtBoolean.False); } //***检查原型链*** ASBinCode.rtti.Object obj = ((ASBinCode.rtData.rtObjectBase)theObj).value; ASBinCode.rtti.DynamicObject _proto = null; if (obj is ASBinCode.rtti.DynamicObject) { ASBinCode.rtti.DynamicObject dobj = (ASBinCode.rtti.DynamicObject)obj; _proto = dobj._prototype_; } else { _proto = (ASBinCode.rtti.DynamicObject) ((StackFrame)stackframe).player.static_instance[obj._class.staticClass.classid].value; } var v2obj = ((ASBinCode.rtData.rtObjectBase)thisObj).value; bool found = false; while (_proto != null) { if (ReferenceEquals(_proto,v2obj)) { found = true; break; } if (_proto._class.classid == ((StackFrame)stackframe).player.swc.FunctionClass.classid) //Function { var o = (ASBinCode.rtti.DynamicObject) ((ASBinCode.rtData.rtObjectBase)_proto.memberData[1].getValue()).value; _proto = o; } else if (_proto._class.classid == 1) { _proto = null; } else { break; } } if (found) { return(ASBinCode.rtData.rtBoolean.True); } else { return(ASBinCode.rtData.rtBoolean.False); } }
private static IEnumerator <RunTimeValueBase> getForEach_IEnumerator( Player player,ASBinCode.rtti.Object obj,StackFrame frame,OpStep step,RunTimeScope scope, Dictionary <object,object> visited = null ) { if (obj is ASBinCode.rtti.DynamicObject) { ASBinCode.rtti.DynamicObject dobj = (ASBinCode.rtti.DynamicObject)obj; { var k = dobj.eachSlot(); while (k.MoveNext()) { var c = k.Current; DynamicPropertySlot ds = c as DynamicPropertySlot; if (c != null) { yield return(ds.getValue()); //new rtString(ds._propname); } } } if (obj is DictionaryObject) { DictionaryObject dictObj = (DictionaryObject)obj; var k = dictObj.eachDictSlot(); while (k.MoveNext()) { var c = k.Current; DictionarySlot ds = c as DictionarySlot; if (c != null) { yield return(ds.getValue()); //ds._key.key; } } } if (visited == null) { visited = new Dictionary <object,object>(); } //***再到原型链中查找 if (dobj._prototype_ != null) { var protoObj = dobj._prototype_; //****_prototype_的类型,只可能是Function对象或Class对象 if (protoObj._class.classid == player.swc.FunctionClass.classid) //Function { dobj = (DynamicObject)((rtObjectBase)protoObj.memberData[1].getValue()).value; if (visited.ContainsKey(dobj)) { yield break; } visited.Add(dobj,null); var res = getForEach_IEnumerator(player,dobj,frame,step,scope,visited); while (res.MoveNext()) { yield return(res.Current); } } else if (protoObj._class.classid == 1) //搜索到根Object { //***根Object有继承自Class的prototype,再没有就没有了 dobj = (DynamicObject)((rtObjectBase)protoObj.memberData[0].getValue()).value; { var k = dobj.eachSlot(); while (k.MoveNext()) { var c = k.Current; DynamicPropertySlot ds = c as DynamicPropertySlot; if (c != null) { yield return(ds.getValue()); //new rtString(ds._propname); } } } yield break; } else if (protoObj._class.staticClass == null) { dobj = (DynamicObject)((rtObjectBase)protoObj.memberData[0].getValue()).value; var res = getForEach_IEnumerator(player,dobj,frame,step,scope); while (res.MoveNext()) { yield return(res.Current); } } else { frame.throwError((new error.InternalError(frame.player.swc,step.token, "遭遇了异常的_prototype_" ))); yield break; } } } else if (obj is ASBinCode.rtti.Object) { //***处理.net IEnumerable*** System.Collections.IEnumerator enumerator = null; if (obj is LinkSystemObject) { var od = ((LinkSystemObject)obj).GetLinkData(); if (od is System.Collections.IEnumerable) { enumerator = ((System.Collections.IEnumerable)od).GetEnumerator(); } else { enumerator = od as System.Collections.IEnumerator; } } if (enumerator != null) { var e = enumerator; while (e.MoveNext()) { int slotidx = frame.baseBottomSlotIndex; if (slotidx >= Player.STACKSLOTLENGTH) { throw new ASRunTimeException("stack overflow",frame.player.stackTrace(0)); } var tempslot = frame.stack[slotidx]; try { player.linktypemapper.storeLinkObject_ToSlot(e.Current,RunTimeDataType.rt_void,frame._tempSlot2,player.swc,player); } finally { tempslot.clear(); } yield return(frame._tempSlot2.getValue()); } } else { var dobj = ((ASBinCode.rtti.DynamicObject) frame.player.static_instance[obj._class.staticClass.classid].value); dobj = (ASBinCode.rtti.DynamicObject)((rtObjectBase)dobj.memberData[0].getValue()).value; var res = getForEach_IEnumerator(player,dobj,frame,step,scope); while (res.MoveNext()) { yield return(res.Current); } } } yield break; }
private static IEnumerator <RunTimeValueBase> getForinIEnumerator( Player player,ASBinCode.rtti.Object obj,StackFrame frame,OpStep step,RunTimeScope scope, Dictionary <object,object> visited = null ) { if (obj is ASBinCode.rtti.DynamicObject) { ASBinCode.rtti.DynamicObject dobj = (ASBinCode.rtti.DynamicObject)obj; { var k = dobj.eachSlot(); while (k.MoveNext()) { var c = k.Current; DynamicPropertySlot ds = c as DynamicPropertySlot; if (c != null) { yield return(new rtString(ds._propname)); } } } if (obj is DictionaryObject) { DictionaryObject dictObj = (DictionaryObject)obj; var k = dictObj.eachDictSlot(); while (k.MoveNext()) { var c = k.Current; DictionarySlot ds = c as DictionarySlot; if (c != null) { yield return(ds._key.key); } } } if (visited == null) { visited = new Dictionary <object,object>(); } //***再到原型链中查找 if (dobj._prototype_ != null) { var protoObj = dobj._prototype_; //****_prototype_的类型,只可能是Function对象或Class对象 if (protoObj._class.classid == player.swc.FunctionClass.classid) //Function { dobj = (DynamicObject)((rtObjectBase)protoObj.memberData[1].getValue()).value; if (visited.ContainsKey(dobj)) { yield break; } visited.Add(dobj,null); var res = getForinIEnumerator(player,dobj,frame,step,scope,visited); while (res.MoveNext()) { yield return(res.Current); } } else if (protoObj._class.classid == 1) //搜索到根Object { //***根Object有继承自Class的prototype,再没有就没有了 dobj = (DynamicObject)((rtObjectBase)protoObj.memberData[0].getValue()).value; { var k = dobj.eachSlot(); while (k.MoveNext()) { var c = k.Current; DynamicPropertySlot ds = c as DynamicPropertySlot; if (c != null) { yield return(new rtString(ds._propname)); } } } yield break; } else if (protoObj._class.staticClass == null) { dobj = (DynamicObject)((rtObjectBase)protoObj.memberData[0].getValue()).value; var res = getForinIEnumerator(player,dobj,frame,step,scope); while (res.MoveNext()) { yield return(res.Current); } } else { frame.throwError((new error.InternalError(frame.player.swc,step.token, "遭遇了异常的_prototype_" ))); yield break; } } } else if (obj is ASBinCode.rtti.Object) { var dobj = ((ASBinCode.rtti.DynamicObject) frame.player.static_instance[obj._class.staticClass.classid].value); dobj = (ASBinCode.rtti.DynamicObject)((rtObjectBase)dobj.memberData[0].getValue()).value; var res = getForinIEnumerator(player,dobj,frame,step,scope); while (res.MoveNext()) { yield return(res.Current); } } yield break; }