private bool make_outpackage_scope(Class cls,IBlockCallBack cb) { ASBinCode.CodeBlock codeblock = player.swc.blocks[cls.outscopeblockid]; HeapSlot[] globaldata = player.genHeapFromCodeBlock(codeblock); Global_Object global = Global_Object.formCodeBlock(codeblock,globaldata,player.swc.classes[0]); ASBinCode.rtData.rtObject globalObj = new ASBinCode.rtData.rtObject(global,null); ASBinCode.RunTimeScope rtscope = player.callBlock( codeblock,globaldata,null, null, //player.static_instance[cls.staticClass.classid].objScope, step.token, cb, globalObj, RunTimeScopeType.outpackagemember ); if (rtscope == null) { invokerFrame.endStep(step); return(false); } globalObj.objScope = rtscope; player.outpackage_runtimescope.Add(cls.classid,rtscope); { var slot = new DynamicPropertySlot(globalObj,true,player.swc.FunctionClass.getRtType()); slot.directSet(player.static_instance[cls.staticClass.classid]); global.createproperty(cls.name,slot); } for (int i = 0; i < player.swc.classes.Count; i++) { if (player.swc.classes[i].mainClass == cls) { if (init_static_class(player.swc.classes[i])) { var slot = new DynamicPropertySlot(globalObj,true,player.swc.FunctionClass.getRtType()); slot.directSet(player.static_instance[player.swc.classes[i].staticClass.classid]); global.createproperty(player.swc.classes[i].name,slot); } else { //***出错了 invokerFrame.endStep(step); return(false); } } } return(true); }
public FrameInfo(ASBinCode.CodeBlock block, int codeLinePtr, ASBinCode.RunTimeScope scope, //ASBinCode.RunTimeValueBase scope_thispointer, int offset, StackSlot[] stack ) { this.codeLinePtr = codeLinePtr; this.block = block; //this.scope = scope; //this.scope_thispointer = scope_thispointer; this.offset = offset; this.stack = stack; }
public void buildInterfaceMembers(ASTool.AS3.AS3ClassInterfaceBase as3interface, Builder builder) { List <ASTool.AS3.IAS3Stmt> classstmts = as3interface.StamentsStack.Peek(); var cls = builder.buildingclasses[as3interface]; ASBinCode.CodeBlock block = new ASBinCode.CodeBlock(cls.blockid, cls.name, cls.classid, false); block.scope = new ASBinCode.scopes.ObjectInstanceScope(cls); CompileEnv env = new CompileEnv(block, false); builder._classbuildingEnv.Add(cls, env); for (int i = 0; i < classstmts.Count; i++) { buildInterfaceMember(env, classstmts[i], cls, builder); } //copyInheritsFromImplements(cls, env); }
private static ASBinCode.rtData.rtObjectBase makeObj( Player player, SourceToken token, ASBinCode.rtti.Class cls, BlockCallBackBase callbacker,InstanceCreator creator,out ASBinCode.RunTimeScope objScope) { ASBinCode.rtData.rtObjectBase result; ASBinCode.rtData.rtObjectBase lr; string err; ASBinCode.rtti.Object obj = createObject(player.swc,cls,creator,out result,out lr,out err); if (obj == null) { objScope = null; if (callbacker != null) { callbacker.noticeRunFailed(); } player.throwWhenMakeObjFailed(new ASRunTimeException(err,player.stackTrace(0))); return(null); } if (result == null) { if (lr == null) { result = new ASBinCode.rtData.rtObject(obj,null); } else { result = lr; } if (cls.fields.Count > 0) { obj.memberData = new ObjectMemberSlot[cls.fields.Count]; for (int i = 0; i < obj.memberData.Length; i++) { obj.memberData[i] = new ObjectMemberSlot(result,player.swc.FunctionClass.getRtType(),cls.fields[i].valueType,player.swc); if (cls.fields[i].defaultValue == null) { obj.memberData[i].directSet(TypeConverter.getDefaultValue(cls.fields[i].valueType).getValue(null,null)); } ((ObjectMemberSlot)obj.memberData[i]).isConstMember = cls.fields[i].isConst; } } else { obj.memberData = blankFields; } ASBinCode.CodeBlock codeblock = player.swc.blocks[cls.blockid]; objScope = player.callBlock(codeblock, (ObjectMemberSlot[])obj.memberData,null, null ,token,callbacker , result,RunTimeScopeType.objectinstance ); result.objScope = objScope; if (objScope == null) { if (callbacker != null) { callbacker.noticeRunFailed(); } return(null); } //***把父类的初始化函数推到栈上去*** var ss = cls.super; while (ss != null) { var scope = player.callBlock(player.swc.blocks[ss.blockid], (ObjectMemberSlot[])obj.memberData, null,null,token,null,result,RunTimeScopeType.objectinstance ); ss = ss.super; if (scope == null) { if (callbacker != null) { callbacker.noticeRunFailed(); } return(null); } } } else { objScope = result.objScope; player.CallBlankBlock(callbacker); } if (callbacker != null) { //callbacker.obj = obj; //callbacker.rtObject = result; //callbacker.objScope = objScope; callbacker.cacheObjects[0] = obj; callbacker.cacheObjects[1] = result; callbacker.cacheObjects[2] = objScope; } return(result); }