Changeset 76 in dev for BasicCompiler32/Compile_ProcOp.cpp
- Timestamp:
- Mar 21, 2007, 9:26:56 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler32/Compile_ProcOp.cpp
r75 r76 26 26 } 27 27 28 extern BOOL bCompilingGlobal; 29 BOOL bBackCompilingGlobal; 30 bBackCompilingGlobal=bCompilingGlobal; 31 bCompilingGlobal=1; 28 UserProc *pBackUserProc; 29 pBackUserProc = &UserProc::CompilingUserProc(); 30 UserProc::CompileStartForGlobalArea(); 32 31 33 32 int BackCp; … … 49 48 GetGlobalDataForDll(); 50 49 51 bCompilingGlobal=bBackCompilingGlobal;50 UserProc::CompileStartForUserProc( pBackUserProc ); 52 51 cp=BackCp; 53 52 … … 58 57 //静的ローカルオブジェクトのコンストラクタ呼び出し 59 58 60 extern int MaxGlobalVarNum; 61 extern VARIABLE *GlobalVar; 62 int i; 63 for(i=0;i<MaxGlobalVarNum;i++){ 64 if(_memicmp(GlobalVar[i].name,"Static%",7)==0){ 59 foreach( Variable *pVar, globalVars ){ 60 if(memicmp(pVar->GetName().c_str(),"Static%",7)==0){ 65 61 //コンストラクタ呼び出し 66 if( GlobalVar[i].type==DEF_OBJECT){62 if( pVar->IsObject() ){ 67 63 68 64 //エラー用 69 cp=GlobalVar[i].source_code_address; 70 71 Type TypeInfo; 72 TypeInfo.type=GlobalVar[i].type; 73 TypeInfo.u.lpIndex=GlobalVar[i].u.index; 65 cp=pVar->source_code_address; 66 74 67 CallConstructor( 75 GlobalVar[i].name,76 GlobalVar[i].SubScripts,77 TypeInfo,78 GlobalVar[i].ConstractParameter);68 pVar->GetName().c_str(), 69 pVar->GetSubScriptsPtr(), 70 *pVar, 71 pVar->paramStrForConstructor.c_str()); 79 72 } 80 73 } … … 86 79 else if(lstrcmp(name,"_System_Call_Destructor_of_GlobalObject")==0){ 87 80 88 extern BOOL bCompilingGlobal; 89 BOOL bBackCompilingGlobal; 90 bBackCompilingGlobal=bCompilingGlobal; 91 bCompilingGlobal=1; 81 UserProc *pBackUserProc; 82 pBackUserProc = &UserProc::CompilingUserProc(); 83 UserProc::CompileStartForGlobalArea(); 92 84 93 85 obj_LexScopes.CallDestructorsOfScopeEnd(); 94 86 95 bCompilingGlobal=bBackCompilingGlobal;87 UserProc::CompileStartForUserProc( pBackUserProc ); 96 88 97 89 … … 219 211 extern UserProc **ppSubHash; 220 212 extern BOOL bDebugCompile; 221 int i3,i4, VarSize,LocalVarSchedule,EspOffsetSchedule,BufferSize,BaseOffset;213 int i3,i4,LocalVarSchedule,EspOffsetSchedule,BaseOffset; 222 214 char temporary[VN_SIZE]; 223 215 224 BufferSize=128;225 226 216 if( pUserProc->IsUsing() == false || pUserProc->IsCompiled() ) return; 217 218 if( pUserProc->localVars.size() ){ 219 SetError(); 220 return; 221 } 227 222 228 223 pUserProc->CompleteCompile(); … … 235 230 if(memcmp(pUserProc->GetName().c_str(),"_DebugSys_",10)==0){ 236 231 if(!bDebugCompile){ 237 pUserProc->pVar=(VARIABLE *)HeapAlloc(hHeap,0,1);238 pUserProc->VarNum=0;239 232 return; 240 233 } … … 246 239 247 240 if(pUserProc->IsSystem()){ 248 extern int MaxLocalVarNum;249 241 extern int AllLocalVarSize; 250 MaxLocalVarNum=0;251 242 AllLocalVarSize=0; 252 243 … … 254 245 255 246 pUserProc->endOpAddress=obp; 256 pUserProc->pVar=(VARIABLE *)HeapAlloc(hHeap,0,1);257 pUserProc->VarNum=0;258 247 return; 259 248 } … … 266 255 267 256 //ローカル変数に関する情報 268 extern VARIABLE *LocalVar;269 extern int MaxLocalVarNum;270 257 extern int AllLocalVarSize; 271 LocalVar=(VARIABLE *)HeapAlloc(hHeap,0,1);272 MaxLocalVarNum=0;273 258 AllLocalVarSize=0; 274 259 … … 283 268 Parameter ¶m = *pUserProc->RealParams()[i3]; 284 269 285 //変数データを追加 286 LocalVar=(VARIABLE *)HeapReAlloc(hHeap,0,LocalVar,(MaxLocalVarNum+1)*sizeof(VARIABLE)); 287 288 lstrcpy( LocalVar[MaxLocalVarNum].name,param.GetVarName().c_str() ); 289 290 // TODO: パラメータのConst定義の指定が未完成 291 LocalVar[MaxLocalVarNum].bConst=false; 292 293 LocalVar[MaxLocalVarNum].bArray=param.IsArray()?TRUE:FALSE; 294 memcpy(LocalVar[MaxLocalVarNum].SubScripts,param.GetSubScriptsPtr(),MAX_ARRAYDIM*sizeof(int)); 295 296 LocalVar[MaxLocalVarNum].type=param.GetBasicType(); 297 if(LocalVar[MaxLocalVarNum].type==DEF_OBJECT 298 ||LocalVar[MaxLocalVarNum].type==DEF_STRUCT){ 299 if(pUserProc->IsExport()) 300 SetError(24,NULL,cp); 301 } 302 303 LocalVar[MaxLocalVarNum].u.index=param.GetIndex(); 304 270 Variable *pVar = new Variable( param.GetVarName(), param, false, param.IsRef() ); 271 272 if( param.IsArray() ){ 273 pVar->SetArray( param.GetSubScriptsPtr() ); 274 } 275 276 int varSize; 305 277 if( param.IsRef() == false && param.IsStruct() ){ 306 278 //構造体のByValパラメータ 307 LocalVar[MaxLocalVarNum].fRef=REF_PARAMETER | OBJECT_PARAMETER;308 VarSize=PTR_SIZE;279 pVar->ThisIsParameter(); 280 varSize=PTR_SIZE; 309 281 } 310 282 else{ 311 if( param.IsRef() == false && param.IsArray() == false ){ 312 LocalVar[MaxLocalVarNum].fRef=0; 313 VarSize=GetTypeSize(LocalVar[MaxLocalVarNum].type,LocalVar[MaxLocalVarNum].u.index); 314 if(VarSize%PTR_SIZE) VarSize+=PTR_SIZE-(VarSize%PTR_SIZE); 283 if( param.IsArray() == false ){ 284 varSize = pVar->GetMemorySize(); 315 285 } 316 286 else{ 317 LocalVar[MaxLocalVarNum].fRef=REF_PARAMETER; 318 VarSize=PTR_SIZE; 319 } 320 } 321 AllLocalVarSize+=VarSize; 322 LocalVar[MaxLocalVarNum].offset=AllLocalVarSize; 287 varSize=PTR_SIZE; 288 } 289 } 290 AllLocalVarSize+=varSize; 291 pVar->offset=AllLocalVarSize; 323 292 324 293 //レキシカルスコープ情報 325 LocalVar[MaxLocalVarNum].ScopeLevel=obj_LexScopes.GetNowLevel();326 LocalVar[MaxLocalVarNum].ScopeStartAddress=obj_LexScopes.GetStartAddress();327 LocalVar[MaxLocalVarNum].bLiving=TRUE;328 329 MaxLocalVarNum++;294 pVar->ScopeLevel=obj_LexScopes.GetNowLevel(); 295 pVar->ScopeStartAddress=obj_LexScopes.GetStartAddress(); 296 pVar->bLiving=TRUE; 297 298 pUserProc->localVars.push_back( pVar ); 330 299 } 331 300 … … 346 315 347 316 //コンパイル中の関数 348 extern UserProc *pCompilingUserProc; 349 pCompilingUserProc=pUserProc; 317 UserProc::CompileStartForUserProc( pUserProc ); 350 318 351 319 … … 507 475 } 508 476 509 510 477 //実体クラスを持つメンバのコンストラクタ(引数有りを除く)を呼び出す 511 478 for(i3=0;i3<pobj_CompilingClass->iMemberNum;i3++){ 512 479 CMember *pMember = pobj_CompilingClass->ppobj_Member[i3]; 513 if(pMember-> TypeInfo.type==DEF_OBJECT){480 if(pMember->IsObject()){ 514 481 // オブジェクトメンバを発見したとき 515 482 … … 517 484 pMember->name, 518 485 1, ESC_NEW, 519 pMember-> TypeInfo.u.pobj_Class->name );486 pMember->GetClass().name ); 520 487 OpcodeCalc( temporary ); 521 488 } 522 489 } 523 524 490 525 491 //仮想関数テーブルを初期化 … … 686 652 //戻り値をeax、edxに設定 687 653 RELATIVE_VAR RelativeVar; 688 LONG_PTR lpIndex;689 654 690 655 const char *temp = pUserProc->GetName().c_str(); … … 692 657 temp="_System_ReturnValue"; 693 658 } 694 GetVarOffsetReadWrite(temp,& i3,&RelativeVar,&lpIndex);659 GetVarOffsetReadWrite(temp,&RelativeVar,Type()); 695 660 696 661 i3=pUserProc->ReturnType().GetBasicType(); … … 773 738 } 774 739 HeapDefaultFree(pLocalVarAddrSchedule); 775 for(i3=0;i3<MaxLocalVarNum;i3++){ 776 LocalVar[i3].offset=AllLocalVarSize-LocalVar[i3].offset;//後にデバッグで利用する 740 foreach( Variable *pVar, pUserProc->localVars ){ 741 //後にデバッグで利用する 742 pVar->offset = AllLocalVarSize - pVar->offset; 777 743 } 778 744 … … 828 794 } 829 795 796 830 797 pUserProc->endOpAddress=obp; 831 pUserProc->pVar=LocalVar;832 pUserProc->VarNum=MaxLocalVarNum;833 798 834 799
Note:
See TracChangeset
for help on using the changeset viewer.