Changeset 34 in dev for BasicCompiler_Common/Object.cpp
- Timestamp:
- Jan 14, 2007, 6:11:23 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler_Common/Object.cpp
r31 r34 183 183 } 184 184 } 185 186 187 void CallDestrouctorsOfScope(void){188 extern BOOL bCompilingGlobal;189 VARIABLE *pVar;190 int num;191 if(bCompilingGlobal){192 //グローバルオブジェクトの解放処理193 extern VARIABLE *GlobalVar;194 extern int MaxGlobalVarNum;195 pVar=GlobalVar;196 num=MaxGlobalVarNum;197 }198 else{199 //ローカルオブジェクトの解放処理200 extern VARIABLE *LocalVar;201 extern int MaxLocalVarNum;202 pVar=LocalVar;203 num=MaxLocalVarNum;204 }205 206 207 int i3,i4,i5;208 int indexSystemGC=-1;209 for(i3=0;i3<num;i3++){210 211 if(bCompilingGlobal&&obj_LexScopes.GetNowLevel()==0){212 if(lstrcmp(pVar[i3].name,"_System_GC")==0){213 indexSystemGC=i3;214 continue;215 }216 }217 218 //同一レベルのレキシカルスコープのみを検知219 if(!pVar[i3].bLiving) continue;220 if(pVar[i3].ScopeLevel!=obj_LexScopes.GetNowLevel()) continue;221 222 if(pVar[i3].type==DEF_OBJECT&&pVar[i3].fRef&OBJECT_PARAMETER){223 //実態オブジェクトのパラメータを持つとき224 225 //デストラクタを呼び出す226 i5=pVar[i3].u.pobj_c->DestructorMemberSubIndex;227 if(i5!=-1)228 Opcode_CallProc("",pVar[i3].u.pobj_c->ppobj_Method[i5]->psi,0,pVar[i3].name,DEF_OBJECT);229 230 //メモリを解放する231 232 #ifdef _AMD64_233 //x64ビットコード234 235 //mov rcx,qword ptr[rsp+offset]236 op_mov_RM(sizeof(_int64),REG_RCX,REG_RSP,237 -pVar[i3].offset,238 MOD_BASE_DISP32);239 obp-=sizeof(long);240 AddLocalVarAddrSchedule();241 obp+=sizeof(long);242 #else243 //x86コード244 245 //mov ecx,dword ptr[ebp+offset]246 op_mov_RM(sizeof(long),REG_ECX,REG_EBP,-pVar[i3].offset,MOD_BASE_DISP32);247 obp-=sizeof(long);248 AddLocalVarAddrSchedule();249 obp+=sizeof(long);250 251 //push ecx252 op_push(REG_ECX);253 #endif254 255 //call free256 extern SUBINFO *pSub_free;257 op_call(pSub_free);258 259 260 if(bCompilingGlobal){261 //ここには来ないハズ262 SetError(300,NULL,cp);263 }264 }265 else if(pVar[i3].type==DEF_OBJECT&&pVar[i3].fRef==0){266 //デストラクタの呼び出し267 i5=pVar[i3].u.pobj_c->DestructorMemberSubIndex;268 if(i5!=-1){269 int ss[MAX_ARRAYDIM];270 memset(ss,0,MAX_ARRAYDIM*sizeof(int));271 if(pVar[i3].SubScripts[0]!=-1){272 while(1){273 for(i4=0;;i4++){274 if(pVar[i3].SubScripts[i4]==-1) break;275 276 if(ss[i4]>pVar[i3].SubScripts[i4]){277 ss[i4]=0;278 ss[i4+1]++;279 }280 else break;281 }282 if(pVar[i3].SubScripts[i4]==-1) break;283 char temporary[VN_SIZE];284 sprintf(temporary,"%s[%d",pVar[i3].name,ss[0]);285 for(i4=1;;i4++){286 if(pVar[i3].SubScripts[i4]==-1) break;287 288 sprintf(temporary+lstrlen(temporary),",%d",ss[i4]);289 }290 lstrcat(temporary,"]");291 Opcode_CallProc("",pVar[i3].u.pobj_c->ppobj_Method[i5]->psi,0,temporary,DEF_OBJECT);292 293 ss[0]++;294 295 296 //ネイティブコードバッファの再確保297 extern int obp_AllocSize;298 if(obp_AllocSize<obp+8192){299 obp_AllocSize+=8192;300 OpBuffer=(char *)HeapReAlloc(hHeap,0,OpBuffer,obp_AllocSize); //matea301 }302 }303 }304 else{305 Opcode_CallProc("",pVar[i3].u.pobj_c->ppobj_Method[i5]->psi,0,pVar[i3].name,DEF_OBJECT);306 }307 }308 }309 }310 311 if(indexSystemGC!=-1){312 //_System_GCオブジェクトのデストラクタの呼び出し処理313 i3=pVar[indexSystemGC].u.pobj_c->DestructorMemberSubIndex;314 if(i3!=-1){315 Opcode_CallProc("",pVar[indexSystemGC].u.pobj_c->ppobj_Method[i3]->psi,0,pVar[indexSystemGC].name,DEF_OBJECT);316 }317 }318 }319
Note:
See TracChangeset
for help on using the changeset viewer.