Changeset 75 in dev for BasicCompiler64/Compile_Var.cpp
- Timestamp:
- Mar 20, 2007, 4:36:16 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler64/Compile_Var.cpp
r73 r75 3 3 4 4 //変数 5 V ARIABLE *GlobalVar;5 Variables globalVars; 6 6 int MaxGlobalVarNum; 7 7 int AllGlobalVarSize; 8 8 int AllInitGlobalVarSize; 9 VARIABLE *LocalVar; 9 10 10 int MaxLocalVarNum; 11 11 int AllLocalVarSize; 12 12 13 13 14 void SetRelativeOffset(int *pType,LONG_PTR lpIndex,RELATIVE_VAR *pRelativeVar,char *lpPtrOffset){ 15 int i2; 16 17 14 void SetRelativeOffset( Type &resultType, RELATIVE_VAR *pRelativeVar,const char *lpPtrOffset){ 18 15 ///////////////////////////////////////////// 19 16 // 先頭ポインタをr12に取得してメモリへ退避 … … 31 28 32 29 int reg=REG_NON; 33 i2=NumOpe(®,lpPtrOffset,0,0,0); 34 if(!IsWholeNumberType(i2)) SetError(46,NULL,cp); 35 ExtendTypeTo64(i2,reg); 30 Type type; 31 NumOpe( ®, lpPtrOffset, Type(), type ); 32 if( !type.IsWhole() ){ 33 SetError(46,NULL,cp); 34 } 35 ExtendTypeTo64(type.GetBasicType(),reg); 36 36 37 37 if(reg==REG_R14){ … … 40 40 } 41 41 42 if( PTR_LEVEL(*pType)){43 *pType = PTR_LEVEL_DOWN( *pType);44 45 i 2=GetTypeSize(*pType,lpIndex);46 if( i2>=2){42 if( resultType.PtrLevel() ){ 43 resultType.PtrLevelDown(); 44 45 int typeSize = resultType.GetSize(); 46 if(typeSize>=2){ 47 47 //imul reg,i2 48 op_imul_RV(sizeof(_int64),reg, i2);48 op_imul_RV(sizeof(_int64),reg,typeSize); 49 49 } 50 50 } … … 80 80 } 81 81 } 82 BOOL GetArrayOffset(int *SubScripts,char *array,int type,LONG_PTR lpIndex){82 bool GetArrayOffset(const int *SubScripts,char *array, const Type &type){ 83 83 extern HANDLE hHeap; 84 int i,i2,i3,i4 ,TypeSize;84 int i,i2,i3,i4; 85 85 char temporary[VN_SIZE],*pParm[MAX_PARMS]; 86 86 … … 101 101 if(SubScripts[i3]==-1){ 102 102 for(i3--;i3>=0;i3--) HeapDefaultFree(pParm[i3]); 103 return 0;103 return false; 104 104 } 105 105 … … 114 114 if(SubScripts[i3]!=-1){ 115 115 for(i3--;i3>=0;i3--) HeapDefaultFree(pParm[i3]); 116 return 0;116 return false; 117 117 } 118 118 break; … … 136 136 137 137 int reg=REG_NON; 138 T YPEINFO TypeInfo;138 Type type; 139 139 BOOL bUseHeap; 140 TypeInfo.type=NumOpe(®,pParm[i],DEF_LONG,-1,&TypeInfo.u.lpIndex,&bUseHeap);141 if( TypeInfo.type==DEF_OBJECT){140 NumOpe( ®, pParm[i], Type( DEF_LONG ), type, &bUseHeap ); 141 if( type.IsObject() ){ 142 142 //キャスト演算子のオーバーロードに対応する 143 143 CallCastOperatorProc(reg, 144 TypeInfo.type,TypeInfo.u.lpIndex, 145 bUseHeap,DEF_LONG,-1); 146 TypeInfo.type=DEF_LONG; 147 } 148 149 if(!IsWholeNumberType(TypeInfo.type)) SetError(46,NULL,cp); 150 ExtendTypeTo64(TypeInfo.type,reg); 144 type, 145 bUseHeap, Type(DEF_LONG) ); 146 type.SetBasicType( DEF_LONG ); 147 } 148 149 if( !type.IsWhole() ){ 150 SetError(46,NULL,cp); 151 } 152 ExtendTypeTo64( type.GetBasicType(), reg ); 151 153 152 154 if(reg==REG_R14){ … … 168 170 HeapDefaultFree(pParm[i]); 169 171 } 170 171 TypeSize=GetTypeSize(type,lpIndex);172 172 173 173 //imul r12,TypeSize … … 175 175 OpBuffer[obp++]=(char)0x69; 176 176 OpBuffer[obp++]=(char)0xE4; 177 *((long *)(OpBuffer+obp))= TypeSize;177 *((long *)(OpBuffer+obp))=type.GetSize(); 178 178 obp+=sizeof(long); 179 179 … … 186 186 OpBuffer[obp++]=(char)0xDC; 187 187 188 return 1;188 return true; 189 189 } 190 BOOL GetMemberOffset(bool isErrorEnabled, bool isWriteAccess, CClass *pobj_c, char *member, int *pType, RELATIVE_VAR *pRelativeVar, LONG_PTR *plpNestIndex, BOOL bPrivateAccess){190 bool _member_offset(bool isErrorEnabled, bool isWriteAccess, const CClass &objClass, const char *member, RELATIVE_VAR *pRelativeVar, Type &resultType, BOOL bPrivateAccess){ 191 191 int i; 192 192 … … 202 202 CClass::RefType refType; 203 203 lstrcpy(VarName,member); 204 if(!GetVarFormatString(VarName,array,lpPtrOffset,NestMember,refType)) return 0;204 if(!GetVarFormatString(VarName,array,lpPtrOffset,NestMember,refType)) return false; 205 205 206 206 … … 209 209 //////////////////////////// 210 210 211 int offset = pobj_c->GetMemberOffset( VarName, &i );212 if(i== pobj_c->iMemberNum){211 int offset = objClass.GetMemberOffset( VarName, &i ); 212 if(i==objClass.iMemberNum){ 213 213 if(isErrorEnabled) SetError(103,VarName,cp); 214 return 0;215 } 216 217 CMember *pMember= pobj_c->ppobj_Member[i];214 return false; 215 } 216 217 CMember *pMember=objClass.ppobj_Member[i]; 218 218 219 219 220 220 //アクセシビリティをチェック 221 if( pobj_c==pobj_CompilingClass){221 if(&objClass==pobj_CompilingClass){ 222 222 //同一クラスオブジェクトの場合はプライベートアクセスを容認する 223 223 if(pMember->dwAccess==ACCESS_NON){ 224 224 if(isErrorEnabled) SetError(107,VarName,cp); 225 return 0;225 return false; 226 226 } 227 227 } … … 230 230 pMember->dwAccess==ACCESS_NON){ 231 231 if(isErrorEnabled) SetError(107,VarName,cp); 232 return 0;232 return false; 233 233 } 234 234 else if(bPrivateAccess==0&&pMember->dwAccess==ACCESS_PROTECTED){ 235 235 if(isErrorEnabled) SetError(108,VarName,cp); 236 return 0;236 return false; 237 237 } 238 238 } … … 242 242 if( pMember->IsConst() && //定数メンバである 243 243 isWriteAccess && //書き込みアクセスを要求されている 244 pobj_c->IsCompilingConstructor() == false //コンストラクタ コンパイル中を除く244 objClass.IsCompilingConstructor() == false //コンストラクタ コンパイル中を除く 245 245 ){ 246 246 //Const定義の変数に書き込みアクセスをしようとした場合 … … 248 248 } 249 249 250 *pType=pMember->TypeInfo.type; 251 *plpNestIndex=pMember->TypeInfo.u.lpIndex; 250 resultType = *pMember; 252 251 253 252 //ポインタ変数の場合 254 if( IsPtrType(*pType)){253 if( resultType.IsPointer() ){ 255 254 if(pMember->SubScripts[0]==-1){ 256 255 lstrcpy(lpPtrOffset,array); … … 261 260 if(lpPtrOffset[0]){ 262 261 if(isErrorEnabled) SetError(16,member,cp); 263 return 0;262 return false; 264 263 } 265 264 } … … 276 275 if(array[0]){ 277 276 //配列オフセット 278 if(!GetArrayOffset(pMember->SubScripts,array,*p Type,pMember->TypeInfo.u.lpIndex)){277 if(!GetArrayOffset(pMember->SubScripts,array,*pMember)){ 279 278 if(isErrorEnabled) SetError(14,member,cp); 280 279 } 281 280 } 282 281 else if(pMember->SubScripts[0]!=-1){ 283 *pType|=FLAG_PTR;282 resultType.SetBasicType( resultType.GetBasicType() | FLAG_PTR ); 284 283 } 285 284 … … 287 286 //入れ子構造の場合 288 287 289 if( *pType==DEF_OBJECT || *pType==DEF_STRUCT){288 if( resultType.IsObject() || resultType.IsStruct() ){ 290 289 if( refType != CClass::Dot ){ 291 290 if(isErrorEnabled) SetError(104,member,cp); 292 return 0;293 } 294 295 if( *pType==DEF_OBJECT){291 return false; 292 } 293 294 if( resultType.IsObject() ){ 296 295 // 参照内容へのポインタを抽出 297 296 SetRelativeOffset( *pRelativeVar ); 298 297 } 299 298 } 300 else if( *pType==DEF_PTR_OBJECT||*pType==DEF_PTR_STRUCT){299 else if( resultType.IsObjectPtr() || resultType.IsStructPtr() ){ 301 300 //構造体ポインタ型メンバ変数 302 301 303 302 if(lpPtrOffset[0]){ 304 303 //pObj[n].member 305 if( ( *pType==DEF_PTR_OBJECT||*pType==DEF_PTR_STRUCT )&& refType != CClass::Dot ){ 306 if(isErrorEnabled) SetError(104,member,cp); 307 return 0; 304 if( ( resultType.IsObjectPtr() || resultType.IsStructPtr() ) 305 && refType != CClass::Dot ){ 306 if(isErrorEnabled) SetError(104,member,cp); 307 return false; 308 308 } 309 309 310 310 //直接参照に切り替え 311 SetRelativeOffset( pType,*plpNestIndex,pRelativeVar,lpPtrOffset);311 SetRelativeOffset(resultType,pRelativeVar,lpPtrOffset); 312 312 pRelativeVar->dwKind=VAR_DIRECTMEM; 313 313 … … 316 316 else{ 317 317 //pObj->member 318 if( ( *pType==DEF_PTR_OBJECT||*pType==DEF_PTR_STRUCT )&& refType != CClass::Pointer ){ 319 if(isErrorEnabled) SetError(104,member,cp); 320 return 0; 318 if( (resultType.IsObjectPtr() || resultType.IsStructPtr() ) 319 && refType != CClass::Pointer ){ 320 if(isErrorEnabled) SetError(104,member,cp); 321 return false; 321 322 } 322 323 … … 324 325 } 325 326 } 326 else if(*pType==MAKE_PTR_TYPE(DEF_OBJECT,2) || *pType==MAKE_PTR_TYPE(DEF_STRUCT,2)){ 327 else if( resultType.GetBasicType() == MAKE_PTR_TYPE(DEF_OBJECT,2) 328 || resultType.GetBasicType() == MAKE_PTR_TYPE(DEF_STRUCT,2)){ 327 329 //構造体ポインタのポインタ型メンバ変数 328 330 … … 331 333 if( refType != CClass::Pointer ){ 332 334 if(isErrorEnabled) SetError(104,member,cp); 333 return 0;335 return false; 334 336 } 335 337 336 338 //直接参照に切り替え 337 SetRelativeOffset( pType,*plpNestIndex,pRelativeVar,lpPtrOffset);339 SetRelativeOffset(resultType,pRelativeVar,lpPtrOffset); 338 340 pRelativeVar->dwKind=VAR_DIRECTMEM; 339 341 … … 345 347 else{ 346 348 if(isErrorEnabled) SetError(104,member,cp); 347 return 0;348 } 349 } 350 351 if(! GetMemberOffset(349 return false; 350 } 351 } 352 353 if(!_member_offset( 352 354 isErrorEnabled, 353 355 isWriteAccess, 354 pMember-> TypeInfo.u.pobj_Class,356 pMember->GetClass(), 355 357 NestMember, 356 pType,357 358 pRelativeVar, 358 plpNestIndex,359 0)) return 0;359 resultType, 360 0)) return false; 360 361 } 361 362 362 363 if(lpPtrOffset[0]){ 363 SetRelativeOffset( pType,*plpNestIndex,pRelativeVar,lpPtrOffset);364 SetRelativeOffset(resultType,pRelativeVar,lpPtrOffset); 364 365 pRelativeVar->dwKind=VAR_DIRECTMEM; 365 366 } 366 367 367 return 1;368 return true; 368 369 } 369 370 void GetWithName(char *buffer){ … … 380 381 //自身のオブジェクトのThisポインタをregにコピー 381 382 382 extern VARIABLE *LocalVar;383 383 RELATIVE_VAR RelativeVar; 384 384 RelativeVar.dwKind=VAR_LOCAL; … … 388 388 SetReg_WholeVariable(DEF_PTR_VOID,&RelativeVar,reg); 389 389 } 390 BOOL GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpIndex,int *pss){ 391 extern BOOL bCompilingGlobal; 390 bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType,int *pss){ 392 391 int i; 393 LONG_PTR lpIndex;394 392 char variable[VN_SIZE],member[VN_SIZE],VarName[VN_SIZE],array[VN_SIZE],lpPtrOffset[VN_SIZE]; 395 393 … … 406 404 407 405 void *pInfo; 408 int idProc=GetProc(VarName, &pInfo);406 int idProc=GetProc(VarName,(void **)&pInfo); 409 407 410 408 if(idProc){ 411 409 pRelativeVar->dwKind=VAR_DIRECTMEM; 410 411 Type type; 412 412 413 413 ////////////////////////////////////////////////////// … … 420 420 //////////////// 421 421 422 *pType=CallProc(idProc,pInfo,VarName,array,&lpIndex);422 CallProc(idProc,pInfo,VarName,array,type); 423 423 424 424 //戻り値をr11にコピー … … 430 430 }//////////////////////////////////////////// 431 431 432 LONG_PTR lp2; 433 if(!GetMemberOffset( 432 if(!_member_offset( 434 433 isErrorEnabled, 435 434 isWriteAccess, 436 (CClass *)lpIndex, 437 member,pType,pRelativeVar,&lp2,0)) return 0; 438 if(plpIndex) *plpIndex=lp2; 439 440 return 1; 435 type.GetClass(), 436 member,pRelativeVar,resultType,0)) return false; 437 438 return true; 441 439 } 442 440 } … … 447 445 GetVarFormatString(VarName,array,lpPtrOffset,member,refType); 448 446 449 int *pSubScripts;447 const int *pSubScripts; 450 448 bool bConst = false; 451 449 452 450 453 if( bCompilingGlobal==0){451 if( UserProc::IsLocalAreaCompiling() ){ 454 452 ////////////////// 455 453 // ローカル変数 456 454 ////////////////// 457 455 458 for(i=MaxLocalVarNum-1;i>=0;i--){ //レキシカルスコープを考慮してバックサーチ 459 if( LocalVar[i].bLiving //現在のスコープで有効なもの 460 && LocalVar[i].ScopeLevel <= obj_LexScopes.GetNowLevel() //現在のスコープレベルを超さないもの(Returnによる解放処理中を考慮) 461 ){ 462 if(lstrcmp(VarName,LocalVar[i].name)==0) break; 463 } 464 } 465 if(i>=0){ 456 const Variable *pVar = UserProc::CompilingUserProc().localVars.BackSearch( VarName ); 457 if( pVar ){ 466 458 //ポインタ変数の場合 467 if( IsPtrType(LocalVar[i].type)){468 if( LocalVar[i].SubScripts[0]==-1){459 if( pVar->IsPointer() ){ 460 if( !pVar->IsArray() ){ 469 461 lstrcpy(lpPtrOffset,array); 470 462 array[0]=0; … … 475 467 SetError(16,variable,cp); 476 468 pRelativeVar->dwKind=NON_VAR; 477 return 0;469 return false; 478 470 } 479 471 } 480 472 481 pRelativeVar->offset=- LocalVar[i].offset;473 pRelativeVar->offset=-pVar->offset; 482 474 pRelativeVar->bOffsetOffset=0; 483 if( LocalVar[i].fRef){475 if( pVar->IsRef() ){ 484 476 // 参照型 485 477 pRelativeVar->dwKind = VAR_REFLOCAL; 486 478 } 487 479 else pRelativeVar->dwKind=VAR_LOCAL; 488 *pType=LocalVar[i].type; 489 lpIndex=LocalVar[i].u.index; 490 if(plpIndex) *plpIndex=lpIndex; 491 pSubScripts=LocalVar[i].SubScripts; 492 bConst = LocalVar[i].bConst; 480 resultType = *pVar; 481 pSubScripts=pVar->GetSubScriptsPtr(); 482 bConst = pVar->IsConst(); 493 483 494 484 goto ok; … … 506 496 SetThisPtrToReg(REG_R11); 507 497 508 *pType=DEF_OBJECT;509 498 pRelativeVar->dwKind=VAR_DIRECTMEM; 510 499 511 if(plpIndex) *plpIndex=(LONG_PTR)pobj_CompilingClass;512 return 1;500 resultType.SetType( DEF_OBJECT, pobj_CompilingClass ); 501 return true; 513 502 } 514 503 … … 542 531 543 532 pRelativeVar->dwKind=VAR_DIRECTMEM; 544 if(! GetMemberOffset(533 if(!_member_offset( 545 534 isErrorEnabled, 546 535 isWriteAccess, 547 pobj_CompilingClass,536 *pobj_CompilingClass, 548 537 variable, 549 pType,550 538 pRelativeVar, 551 &lpIndex,1)) return 0; 552 if(plpIndex) *plpIndex=lpIndex; 553 return 1; 539 resultType,1)) return false; 540 return true; 554 541 } 555 542 556 543 NonClassMember: 557 544 558 ////////////////////////// 559 // 静的ローカル変数 560 // ※"Static.Object.Method.Variable" 561 ////////////////////////// 562 563 char temporary[VN_SIZE]; 564 extern SubInfo *pCompilingSubInfo; 565 if(pCompilingSubInfo){ 566 GetNowStaticVarFullName(VarName,temporary); 567 568 for(i=0;i<MaxGlobalVarNum;i++){ 569 if(lstrcmp(temporary,GlobalVar[i].name)==0) break; 570 } 571 if(i!=MaxGlobalVarNum){ 545 { 546 const Variable *pVar; 547 548 ////////////////////////// 549 // 静的ローカル変数 550 // ※"Static.Object.Method.Variable" 551 ////////////////////////// 552 553 char temporary[VN_SIZE]; 554 if( UserProc::IsLocalAreaCompiling() ){ 555 GetNowStaticVarFullName(VarName,temporary); 556 557 pVar = globalVars.Find( temporary ); 558 if( pVar ){ 559 goto GlobalOk; 560 } 561 } 562 563 564 ////////////////////////// 565 // クラスの静的メンバ 566 ////////////////////////// 567 568 if(member[0]){ 569 lstrcpy(temporary,member); 570 571 char tempMember[VN_SIZE]; 572 char tempArray[VN_SIZE]; 573 { 574 CClass::RefType refType; 575 GetVarFormatString(temporary,tempArray,lpPtrOffset,tempMember, refType ); 576 } 577 578 char temp2[VN_SIZE]; 579 sprintf(temp2,"%s.%s",VarName,temporary); 580 pVar = globalVars.Find( temp2 ); 581 if( pVar ){ 582 lstrcpy(member,tempMember); 583 lstrcpy(array,tempArray); 584 goto GlobalOk; 585 } 586 } 587 588 if(pobj_CompilingClass){ 589 //自身のクラスから静的メンバを参照する場合 590 char temp2[VN_SIZE]; 591 sprintf(temp2,"%s.%s",pobj_CompilingClass->name,VarName); 592 pVar = globalVars.Find( temp2 ); 593 if( pVar ){ 594 goto GlobalOk; 595 } 596 } 597 598 ///////////////////// 599 // グローバル変数 600 ///////////////////// 601 602 pVar = globalVars.BackSearch( VarName ); 603 if( pVar ){ 572 604 goto GlobalOk; 573 605 } 574 } 575 576 577 ////////////////////////// 578 // クラスの静的メンバ 579 ////////////////////////// 580 581 if(member[0]){ 582 lstrcpy(temporary,member); 583 584 char tempMember[VN_SIZE]; 585 char tempArray[VN_SIZE]; 586 { 587 CClass::RefType refType; 588 GetVarFormatString(temporary,tempArray,lpPtrOffset,tempMember, refType ); 589 } 590 591 char temp2[VN_SIZE]; 592 sprintf(temp2,"%s.%s",VarName,temporary); 593 for(i=0;i<MaxGlobalVarNum;i++){ 594 if(lstrcmp(temp2,GlobalVar[i].name)==0) break; 595 } 596 597 if(i!=MaxGlobalVarNum){ 598 lstrcpy(member,tempMember); 599 lstrcpy(array,tempArray); 600 goto GlobalOk; 601 } 602 } 603 604 if(pobj_CompilingClass){ 605 //自身のクラスから静的メンバを参照する場合 606 char temp2[VN_SIZE]; 607 sprintf(temp2,"%s.%s",pobj_CompilingClass->name,VarName); 608 for(i=0;i<MaxGlobalVarNum;i++){ 609 if(lstrcmp(temp2,GlobalVar[i].name)==0) break; 610 } 611 612 if(i!=MaxGlobalVarNum){ 613 goto GlobalOk; 614 } 615 } 616 617 ///////////////////// 618 // グローバル変数 619 ///////////////////// 620 621 for(i=MaxGlobalVarNum-1;i>=0;i--){ //レキシカルスコープを考慮してバックサーチ 622 if( GlobalVar[i].bLiving //現在のスコープで有効なもの 623 && GlobalVar[i].ScopeLevel <= obj_LexScopes.GetNowLevel() //現在のスコープレベルを超さないもの(Returnによる解放処理中を考慮) 624 ){ 625 if(lstrcmp(VarName,GlobalVar[i].name)==0) break; 626 } 627 } 628 if(i>=0){ 629 goto GlobalOk; 630 } 631 632 if(isErrorEnabled) SetError(3,variable,cp); 633 pRelativeVar->dwKind=NON_VAR; 634 return 0; 606 607 if(isErrorEnabled) SetError(3,variable,cp); 608 pRelativeVar->dwKind=NON_VAR; 609 return false; 635 610 636 611 637 612 638 613 GlobalOk: 639 //ポインタ変数の場合 640 if(IsPtrType(GlobalVar[i].type)){ 641 if(GlobalVar[i].SubScripts[0]==-1){ 642 lstrcpy(lpPtrOffset,array); 643 array[0]=0; 644 } 645 } 646 else{ 647 if(lpPtrOffset[0]){ 648 SetError(16,variable,cp); 649 pRelativeVar->dwKind=NON_VAR; 650 return 0; 651 } 652 } 653 654 pRelativeVar->offset=GlobalVar[i].offset; 655 pRelativeVar->bOffsetOffset=0; 656 if(GlobalVar[i].fRef){ 657 // 参照型 658 pRelativeVar->dwKind = VAR_REFGLOBAL; 659 } 660 else pRelativeVar->dwKind=VAR_GLOBAL; 661 *pType=GlobalVar[i].type; 662 lpIndex=GlobalVar[i].u.index; 663 if(plpIndex) *plpIndex=lpIndex; 664 pSubScripts=GlobalVar[i].SubScripts; 665 bConst = GlobalVar[i].bConst; 614 //ポインタ変数の場合 615 if( pVar->IsPointer() ){ 616 if( !pVar->IsArray() ){ 617 lstrcpy(lpPtrOffset,array); 618 array[0]=0; 619 } 620 } 621 else{ 622 if(lpPtrOffset[0]){ 623 SetError(16,variable,cp); 624 pRelativeVar->dwKind=NON_VAR; 625 return false; 626 } 627 } 628 629 pRelativeVar->offset=pVar->offset; 630 pRelativeVar->bOffsetOffset=0; 631 if( pVar->IsRef() ){ 632 // 参照型 633 pRelativeVar->dwKind = VAR_REFGLOBAL; 634 } 635 else pRelativeVar->dwKind=VAR_GLOBAL; 636 resultType = *pVar; 637 pSubScripts=pVar->GetSubScriptsPtr(); 638 bConst = pVar->IsConst(); 639 } 666 640 667 641 … … 671 645 if( bConst && isWriteAccess ){ 672 646 //Const定義の変数に書き込みアクセスをしようとした場合 673 if( *pType == DEF_OBJECT){647 if( resultType.IsObject() ){ 674 648 //オブジェクト定数 675 649 SetError(130, VarName, cp ); … … 683 657 if(array[0]==0&&pSubScripts[0]!=-1){ 684 658 //配列の先頭ポインタを示す場合 685 *pType|=FLAG_PTR;659 resultType.SetBasicType( resultType.GetBasicType() | FLAG_PTR ); 686 660 if(pss) memcpy(pss,pSubScripts,MAX_ARRAYDIM); 687 return 1;661 return true; 688 662 } 689 663 … … 696 670 } 697 671 if(array[0]){ 698 if(!GetArrayOffset(pSubScripts,array, *pType,lpIndex)){672 if(!GetArrayOffset(pSubScripts,array,resultType)){ 699 673 SetError(14,variable,cp); 700 674 pRelativeVar->dwKind=NON_VAR; 701 return 0;675 return false; 702 676 } 703 677 } 704 678 if(member[0]){ 705 if( *pType==DEF_OBJECT || *pType==DEF_STRUCT){679 if( resultType.IsObject() || resultType.IsStruct() ){ 706 680 //実態オブジェクトのメンバを参照(obj.member) 707 681 if( refType != CClass::Dot ){ 708 682 SetError(104,VarName,cp); 709 683 pRelativeVar->dwKind=NON_VAR; 710 return 0;711 } 712 713 if( *pType==DEF_OBJECT){684 return false; 685 } 686 687 if( resultType.IsObject() ){ 714 688 // 参照内容へのポインタを抽出 715 689 SetRelativeOffset( *pRelativeVar ); 716 690 } 717 691 } 718 else if( *pType==DEF_PTR_OBJECT || *pType==DEF_PTR_STRUCT){692 else if( resultType.IsObjectPtr() || resultType.IsStructPtr() ){ 719 693 //ポインタオブジェクトが示すメンバを参照 720 694 if(lpPtrOffset[0]){ … … 723 697 SetError(104,VarName,cp); 724 698 pRelativeVar->dwKind=NON_VAR; 725 return 0;699 return false; 726 700 } 727 SetRelativeOffset( pType,lpIndex,pRelativeVar,lpPtrOffset);701 SetRelativeOffset(resultType,pRelativeVar,lpPtrOffset); 728 702 pRelativeVar->dwKind=VAR_DIRECTMEM; 729 703 } … … 733 707 SetError(104,VarName,cp); 734 708 pRelativeVar->dwKind=NON_VAR; 735 return 0;709 return false; 736 710 } 737 711 … … 743 717 } 744 718 } 745 else if( *pType==MAKE_PTR_TYPE(DEF_OBJECT,2) || *pType==MAKE_PTR_TYPE(DEF_STRUCT,2)){719 else if( resultType.GetBasicType()==MAKE_PTR_TYPE(DEF_OBJECT,2) || resultType.GetBasicType()==MAKE_PTR_TYPE(DEF_STRUCT,2)){ 746 720 //ポインタオブジェクトが示すメンバを参照 747 721 if(lpPtrOffset[0]){ … … 750 724 SetError(104,VarName,cp); 751 725 pRelativeVar->dwKind=NON_VAR; 752 return 0;726 return false; 753 727 } 754 728 755 SetRelativeOffset( pType,lpIndex,pRelativeVar,lpPtrOffset);729 SetRelativeOffset(resultType,pRelativeVar,lpPtrOffset); 756 730 pRelativeVar->dwKind=VAR_DIRECTMEM; 757 731 … … 765 739 SetError(104,VarName,cp); 766 740 pRelativeVar->dwKind=NON_VAR; 767 return 0;741 return false; 768 742 } 769 743 } … … 771 745 SetError(102,VarName,cp); 772 746 pRelativeVar->dwKind=NON_VAR; 773 return 0; 774 } 775 776 LONG_PTR lp2; 777 if(!GetMemberOffset( 747 return false; 748 } 749 750 if(!_member_offset( 778 751 isErrorEnabled, 779 752 isWriteAccess, 780 (CClass *)lpIndex, 781 member,pType,pRelativeVar,&lp2,0)) return 0; 782 if(plpIndex) *plpIndex=lp2; 783 784 return 1; 753 resultType.GetClass(), 754 member,pRelativeVar,resultType,0)) return false; 755 756 return true; 785 757 } 786 758 787 759 if(lpPtrOffset[0]){ 788 SetRelativeOffset( pType,lpIndex,pRelativeVar,lpPtrOffset);760 SetRelativeOffset(resultType,pRelativeVar,lpPtrOffset); 789 761 pRelativeVar->dwKind=VAR_DIRECTMEM; 790 762 } 791 763 792 return 1;764 return true; 793 765 } 794 766 795 BOOL SetInitGlobalData(int offset,int type,LONG_PTR lpIndex,int *SubScripts,char *InitBuf){767 bool SetInitGlobalData(int offset,const Type &type,const int *SubScripts,char *InitBuf){ 796 768 extern BYTE *initGlobalBuf; 797 int i,i2,i3 ,TypeSize;769 int i,i2,i3; 798 770 char temporary[VN_SIZE]; 799 771 … … 802 774 InitBuf[lstrlen(InitBuf)-1]=0; 803 775 804 TypeSize=GetTypeSize(type,lpIndex);776 int typeSize = type.GetSize(); 805 777 806 778 if(SubScripts[0]!=-1){ 807 TypeSize*=JumpSubScripts(SubScripts+1);779 typeSize*=JumpSubScripts(SubScripts+1); 808 780 i=0; 809 781 i2=0; … … 815 787 i=GetOneParameter(InitBuf,i,temporary); 816 788 if(!SetInitGlobalData( 817 offset+i2* TypeSize,789 offset+i2*typeSize, 818 790 type, 819 lpIndex,820 791 SubScripts+1, 821 temporary)) return 0;792 temporary)) return false; 822 793 i2++; 823 794 if(InitBuf[i]=='\0') break; 824 795 } 825 return -1; 826 } 827 828 if(type==DEF_STRUCT){ 829 CClass *pobj_c; 830 pobj_c=(CClass *)lpIndex; 831 832 for(i=0,i2=0;i2<pobj_c->iMemberNum;i2++){ 796 return true; 797 } 798 799 if(type.IsStruct()){ 800 const CClass &objClass = type.GetClass(); 801 802 for(i=0,i2=0;i2<objClass.iMemberNum;i2++){ 833 803 i=GetOneParameter(InitBuf,i,temporary); 834 804 835 i3= pobj_c->GetMemberOffset( pobj_c->ppobj_Member[i2]->name, NULL );805 i3=objClass.GetMemberOffset( objClass.ppobj_Member[i2]->name, NULL ); 836 806 837 807 if(!SetInitGlobalData(offset+i3, 838 pobj_c->ppobj_Member[i2]->TypeInfo.type, 839 pobj_c->ppobj_Member[i2]->TypeInfo.u.lpIndex, 840 pobj_c->ppobj_Member[i2]->SubScripts, 841 temporary)) return 0; 808 *objClass.ppobj_Member[i2], 809 objClass.ppobj_Member[i2]->SubScripts, 810 temporary)) return false; 842 811 843 812 if(InitBuf[i]=='\0') break; 844 813 } 845 if(i2+1!= pobj_c->iMemberNum){814 if(i2+1!=objClass.iMemberNum){ 846 815 SetError(41,0,cp); 847 return 0;848 } 849 return 1;816 return false; 817 } 818 return true; 850 819 } 851 820 852 821 SetError(41,0,cp); 853 return 0;822 return false; 854 823 } 855 824 … … 859 828 /////////////////////////////////////// 860 829 861 if( type == DEF_OBJECT || type == DEF_STRUCT){830 if( type.IsObject() || type.IsStruct() ){ 862 831 //オブジェクトまたは構造体の場合はありえない 863 832 SetError(300,NULL,cp); 864 return 0;833 return false; 865 834 } 866 835 867 836 if(SubScripts[0]!=-1){ 868 837 SetError(41,0,cp); 869 return 0;838 return false; 870 839 } 871 840 872 841 double dbl; 873 842 _int64 i64data; 874 int CalcType; 875 LONG_PTR lpCalcIndex; 876 877 CalcType=StaticCalculation(false, InitBuf,type,&i64data,&lpCalcIndex); 878 if(!CalcType){ 843 Type calcType; 844 845 if( !StaticCalculation(false, InitBuf,type.GetBasicType(),&i64data,calcType) ){ 879 846 //動的データだった場合 880 return 0;881 } 882 if( IsRealNumberType(CalcType)){847 return false; 848 } 849 if( calcType.IsReal() ){ 883 850 memcpy(&dbl,&i64data,sizeof(double)); 884 851 i64data=(_int64)dbl; … … 889 856 CheckDifferentType( 890 857 type, 891 lpIndex, 892 CalcType, 893 lpCalcIndex, 858 calcType, 894 859 0,0); 895 860 896 if( type==DEF_DOUBLE)861 if( type.IsDouble() ){ 897 862 *(double *)(initGlobalBuf+offset)=(double)dbl; 898 else if(type==DEF_SINGLE) 899 *(float *)(initGlobalBuf+offset)=(float)dbl; 900 else if(type==DEF_INT64||type==DEF_QWORD||IsPtrType(type)){ 901 if(type==typeOfPtrChar&&lpCalcIndex==LITERAL_STRING){ 863 } 864 else if( type.IsSingle() ){ 865 *(float *)(initGlobalBuf+offset)=(float)dbl; 866 } 867 else if( type.Is64() || type.IsPointer() ){ 868 if(type.GetBasicType()==typeOfPtrChar && type.GetIndex()==LITERAL_STRING){ 902 869 //文字列定数のとき 903 870 … … 923 890 } 924 891 } 925 else if( type==DEF_LONG||type==DEF_DWORD)892 else if( type.IsDWord() || type.IsLong() ){ 926 893 *(DWORD *)(initGlobalBuf+offset)=(DWORD)i64data; 927 else if(type==DEF_INTEGER||type==DEF_WORD || (isUnicode&&type==DEF_CHAR)) 894 } 895 else if( type.IsWord() || type.IsInteger() ){ 928 896 *(WORD *)(initGlobalBuf+offset)=(WORD)i64data; 929 else if(type==DEF_SBYTE||type==DEF_BYTE||type==DEF_BOOLEAN || (isUnicode==false&&type==DEF_CHAR)) 897 } 898 else if( type.IsSByte() || type.IsByte() || type.IsBoolean() ){ 930 899 *(BYTE *)(initGlobalBuf+offset)=(BYTE)i64data; 931 932 return 1; 900 } 901 902 return true; 933 903 } 934 BOOL InitLocalVar(int offset,int type,LONG_PTR lpIndex,int *SubScripts,char *InitBuf){935 int i,i2,i3 ,TypeSize;904 bool InitLocalVar(int offset,const Type &type,const int *SubScripts,char *InitBuf){ 905 int i,i2,i3; 936 906 char temporary[VN_SIZE]; 937 907 … … 940 910 InitBuf[lstrlen(InitBuf)-1]=0; 941 911 942 TypeSize=GetTypeSize(type,lpIndex);912 int typeSize = type.GetSize(); 943 913 944 914 if(SubScripts[0]!=-1){ 945 TypeSize*=JumpSubScripts(SubScripts+1);915 typeSize*=JumpSubScripts(SubScripts+1); 946 916 i=0; 947 917 i2=0; … … 949 919 if(SubScripts[0]<i2){ 950 920 SetError(41,0,cp); 951 return 0;921 return false; 952 922 } 953 923 i=GetOneParameter(InitBuf,i,temporary); 954 924 if(!InitLocalVar( 955 offset+i2* TypeSize,925 offset+i2*typeSize, 956 926 type, 957 lpIndex,958 927 SubScripts+1, 959 temporary)) return 0;928 temporary)) return false; 960 929 i2++; 961 930 if(InitBuf[i]=='\0') break; 962 931 } 963 return -1; 964 } 965 966 if(type==DEF_STRUCT){ 967 CClass *pobj_c; 968 pobj_c=(CClass *)lpIndex; 969 970 for(i=0,i2=0;i2<pobj_c->iMemberNum;i2++){ 932 return true; 933 } 934 935 if(type.IsStruct()){ 936 const CClass &objClass = type.GetClass(); 937 938 for(i=0,i2=0;i2<objClass.iMemberNum;i2++){ 971 939 i=GetOneParameter(InitBuf,i,temporary); 972 940 973 i3= pobj_c->GetMemberOffset( pobj_c->ppobj_Member[i2]->name, NULL );941 i3=objClass.GetMemberOffset( objClass.ppobj_Member[i2]->name, NULL ); 974 942 975 943 if(!InitLocalVar(offset+i3, 976 pobj_c->ppobj_Member[i2]->TypeInfo.type, 977 pobj_c->ppobj_Member[i2]->TypeInfo.u.lpIndex, 978 pobj_c->ppobj_Member[i2]->SubScripts, 979 temporary)) return 0; 944 *objClass.ppobj_Member[i2], 945 objClass.ppobj_Member[i2]->SubScripts, 946 temporary)) return false; 980 947 981 948 if(InitBuf[i]=='\0') break; 982 949 } 983 if(i2+1!= pobj_c->iMemberNum){950 if(i2+1!=objClass.iMemberNum){ 984 951 SetError(41,0,cp); 985 952 return 0; 986 953 } 987 return 1;954 return true; 988 955 } 989 956 990 957 SetError(41,0,cp); 991 return 0;958 return false; 992 959 } 993 960 … … 999 966 if(SubScripts[0]!=-1){ 1000 967 SetError(41,0,cp); 1001 return 0;968 return false; 1002 969 } 1003 970 1004 971 double dbl; 1005 972 _int64 i64data; 1006 int CalcType; 1007 LONG_PTR lpCalcIndex; 1008 CalcType=StaticCalculation(false, InitBuf,type,&i64data,&lpCalcIndex); 1009 if(!CalcType){ 973 Type calcType; 974 975 if( !StaticCalculation(false, InitBuf,type.GetBasicType(),&i64data,calcType) ){ 1010 976 //動的データだった場合 1011 return 0;1012 } 1013 if( IsRealNumberType(CalcType)){977 return false; 978 } 979 if( calcType.IsReal() ){ 1014 980 memcpy(&dbl,&i64data,sizeof(double)); 1015 981 i64data=(_int64)dbl; … … 1020 986 CheckDifferentType( 1021 987 type, 1022 lpIndex, 1023 CalcType, 1024 lpCalcIndex, 988 calcType, 1025 989 0,0); 1026 990 1027 if( type==DEF_DOUBLE){991 if( type.IsDouble() ){ 1028 992 memcpy(&i64data,&dbl,sizeof(double)); 1029 993 … … 1037 1001 obp+=sizeof(long); 1038 1002 } 1039 else if( type==DEF_SINGLE){1003 else if( type.IsSingle() ){ 1040 1004 float flt; 1041 1005 flt=(float)dbl; … … 1047 1011 obp+=sizeof(long)+sizeof(long); 1048 1012 } 1049 else if( type==DEF_INT64||type==DEF_QWORD||IsPtrType(type)){1050 if(type ==typeOfPtrChar&&lpCalcIndex==LITERAL_STRING){1013 else if( type.Is64() || type.IsPointer() ){ 1014 if(type.GetBasicType()==typeOfPtrChar && type.GetIndex()==LITERAL_STRING){ 1051 1015 //文字列定数のとき 1052 1016 … … 1088 1052 } 1089 1053 } 1090 else if( type==DEF_LONG||type==DEF_DWORD){1054 else if( type.IsDWord() || type.IsLong() ){ 1091 1055 //mov dword ptr[rsp+offset],value 1092 1056 op_mov_MV(sizeof(long),REG_RSP,offset,USE_OFFSET,(int)i64data); … … 1095 1059 obp+=sizeof(long)+sizeof(long); 1096 1060 } 1097 else if( type==DEF_INTEGER||type==DEF_WORD || (isUnicode&&type==DEF_CHAR)){1061 else if( type.IsWord() || type.IsInteger() ){ 1098 1062 //mov word ptr[rsp+offset],value 1099 1063 op_mov_MV(sizeof(short),REG_RSP,offset,USE_OFFSET,(int)i64data); … … 1102 1066 obp+=sizeof(long)+sizeof(short); 1103 1067 } 1104 else if( type==DEF_SBYTE||type==DEF_BYTE||type==DEF_BOOLEAN || (isUnicode==false&&type==DEF_CHAR)){1068 else if( type.IsSByte() || type.IsByte() || type.IsBoolean() ){ 1105 1069 //mov byte ptr[rsp+offset],value 1106 1070 op_mov_MV(sizeof(char),REG_RSP,offset,USE_OFFSET,(int)i64data); … … 1109 1073 obp+=sizeof(long)+sizeof(char); 1110 1074 } 1111 return 1;1075 return true; 1112 1076 } 1113 1077 1114 void dim(bool isRef, char *VarName,int *SubScripts,TYPEINFO &TypeInfo,int TypeSize,char *InitBuf,char *ConstractParameter,DWORD dwFlags){ 1115 extern BOOL bCompilingGlobal; 1116 if(bCompilingGlobal){ 1078 void dim(bool isRef, char *VarName,int *SubScripts,Type &type,char *InitBuf,char *ConstractParameter,DWORD dwFlags){ 1079 if( UserProc::IsGlobalAreaCompiling() ){ 1117 1080 ///////////////////////// 1118 1081 // グローバル変数 1119 1082 ///////////////////////// 1120 1083 1121 AddGlobalVariable(isRef,VarName,SubScripts, &TypeInfo,TypeSize,InitBuf,ConstractParameter,dwFlags);1084 AddGlobalVariable(isRef,VarName,SubScripts,type,InitBuf,ConstractParameter,dwFlags); 1122 1085 } 1123 1086 else{ … … 1126 1089 ///////////////// 1127 1090 1128 int i2,i3; 1129 1130 for(i2=0;i2<MaxLocalVarNum;i2++){ 1131 if(LocalVar[i2].bLiving&&obj_LexScopes.GetNowLevel()==LocalVar[i2].ScopeLevel){ 1132 if(lstrcmp(LocalVar[i2].name,VarName)==0){ 1133 //2重定義のエラー 1134 SetError(15,VarName,cp); 1135 return; 1136 } 1137 } 1138 } 1139 1140 LocalVar=(VARIABLE *)HeapReAlloc(hHeap,0,LocalVar,(MaxLocalVarNum+1)*sizeof(VARIABLE)); 1141 VARIABLE *pVar = &LocalVar[MaxLocalVarNum]; 1142 MaxLocalVarNum++; 1143 1144 if( isRef ){ 1145 //参照型 1146 pVar->fRef = REF_VARIABLE; 1147 TypeSize = PTR_SIZE; 1148 } 1149 else pVar->fRef=0; 1150 1151 for(i2=1,i3=0;i3<255;i3++){ 1152 //配列要素数 1153 pVar->SubScripts[i3]=SubScripts[i3]; 1154 1155 if(SubScripts[i3]==-1) break; 1156 i2*=SubScripts[i3]+1; 1157 } 1158 int VarSize=TypeSize*i2; 1159 if(VarSize%8) VarSize+=8-(VarSize%8); 1160 1161 //変数データを追加 1162 lstrcpy(pVar->name,VarName); 1163 if(dwFlags & DIMFLAG_CONST) pVar->bConst = true; 1164 else pVar->bConst = false; 1165 if(SubScripts[0]==-1) pVar->bArray=0; 1166 else pVar->bArray=1; 1167 pVar->type=TypeInfo.type; 1168 pVar->u.index=TypeInfo.u.lpIndex; 1091 if( UserProc::CompilingUserProc().localVars.DuplicateCheck( VarName ) ){ 1092 //2重定義のエラー 1093 SetError(15,VarName,cp); 1094 return; 1095 } 1096 1097 bool isConst = ( dwFlags & DIMFLAG_CONST ) ? true:false; 1098 1099 Variable *pVar = new Variable( VarName, type, isConst, isRef ); 1100 1101 if( SubScripts[0] != -1 ){ 1102 //配列あり 1103 pVar->SetArray( SubScripts ); 1104 } 1105 1106 //コンストラクタ用パラメータ 1107 pVar->paramStrForConstructor = ConstractParameter; 1108 1109 //レキシカルスコープ 1110 pVar->ScopeLevel=obj_LexScopes.GetNowLevel(); 1111 pVar->ScopeStartAddress=obj_LexScopes.GetStartAddress(); 1112 pVar->bLiving=TRUE; 1113 1114 //エラー用 1115 pVar->source_code_address=cp; 1116 1117 // 変数を追加 1118 UserProc::CompilingUserProc().localVars.push_back( pVar ); 1169 1119 1170 1120 //アラインメントを考慮 1171 if( pVar-> type==DEF_STRUCT){1172 int alignment = pVar-> u.pobj_c->iAlign;1121 if( pVar->IsStruct() ){ 1122 int alignment = pVar->GetClass().iAlign; 1173 1123 if( alignment ){ 1174 1124 if( AllLocalVarSize % alignment ){ … … 1178 1128 } 1179 1129 1180 AllLocalVarSize +=VarSize;1181 pVar->offset =AllLocalVarSize;1130 AllLocalVarSize += pVar->GetMemorySize(); 1131 pVar->offset = AllLocalVarSize; 1182 1132 1183 1133 //レキシカルスコープ … … 1188 1138 if(InitBuf[0]){ 1189 1139 //初期代入時のみ、書き込みアクセスを許可する 1190 bool bConstBack = pVar->bConst; 1191 pVar->bConst = false; 1140 if( isConst ){ 1141 pVar->ConstOff(); 1142 } 1192 1143 1193 1144 int result = 0; 1194 if( pVar->type != DEF_OBJECT){1145 if( !pVar->IsObject() ){ 1195 1146 result = InitLocalVar(-pVar->offset, 1196 pVar->type, 1197 pVar->u.index, 1198 pVar->SubScripts, 1147 *pVar, 1148 pVar->GetSubScriptsPtr(), 1199 1149 InitBuf); 1200 1150 } … … 1207 1157 } 1208 1158 1209 pVar->bConst = bConstBack; 1159 if( isConst ){ 1160 pVar->ConstOn(); 1161 } 1210 1162 } 1211 1163 else{ … … 1216 1168 1217 1169 //mov rdx, VarSize 1218 op_mov_RV( sizeof(_int64), REG_RDX, VarSize);1170 op_mov_RV( sizeof(_int64), REG_RDX, pVar->GetMemorySize() ); 1219 1171 1220 1172 //mov rcx, rsp … … 1228 1180 1229 1181 //call FillMemory 1230 D ECLAREINFO *pdi;1231 p di=GetDeclareHash("FillMemory");1232 op_call( p di);1182 DllProc *pDllProc; 1183 pDllProc=GetDeclareHash("FillMemory"); 1184 op_call( pDllProc ); 1233 1185 } 1234 1186 } 1235 1187 1236 1188 //コンストラクタ呼び出し 1237 if( TypeInfo.type==DEF_OBJECT&&(dwFlags&DIMFLAG_NONCALL_CONSTRACTOR)==0&&InitBuf[0]=='\0'){1189 if( type.IsObject() &&(dwFlags&DIMFLAG_NONCALL_CONSTRACTOR)==0&&InitBuf[0]=='\0'){ 1238 1190 char objectSize[255]; 1239 1191 if( SubScripts[0] == -1 ){ … … 1246 1198 sprintf( objectSize, "%d", SubScripts[0] ); 1247 1199 } 1248 Operator_New( *TypeInfo.u.pobj_Class, objectSize, ConstractParameter, TypeInfo ); 1249 1250 int type; 1251 LONG_PTR lpIndex; 1200 Operator_New( type.GetClass(), objectSize, ConstractParameter, type ); 1201 1202 Type tempType; 1252 1203 RELATIVE_VAR RelativeVar; 1253 GetVarOffset( true, false, VarName, & type, &RelativeVar, &lpIndex);1204 GetVarOffset( true, false, VarName, &RelativeVar, tempType ); 1254 1205 if( RelativeVar.dwKind == VAR_DIRECTMEM ){ 1255 1206 SetError(); … … 1258 1209 } 1259 1210 1260 if( TypeInfo.type==DEF_OBJECT){1261 if( TypeInfo.u.pobj_Class->IsAbstract()){1211 if( type.IsObject() ){ 1212 if( type.GetClass().IsAbstract() ){ 1262 1213 //抽象クラスだったとき 1263 SetError(125, TypeInfo.u.pobj_Class->name,cp);1214 SetError(125,type.GetClass().name,cp); 1264 1215 } 1265 1216 } 1266 1217 } 1267 void dim(char *Parameter,DWORD dwFlags){1268 extern BOOL bCompilingGlobal;1269 extern HANDLE hHeap;1270 int i2;1271 char VarName[VN_SIZE];1272 1273 //参照型かどうか1274 bool isRef = false;1275 1276 i2 = 0;1277 1278 if( Parameter[i2] == 1 && Parameter[i2+1] == ESC_BYREF ){1279 //参照型1280 isRef = true;1281 Parameter += 2;1282 }1283 1284 if(dwFlags & DIMFLAG_CONST){1285 1286 //////////////////////////////////1287 // 定数変数の場合を考慮1288 //////////////////////////////////1289 for(;;i2++){1290 if(Parameter[i2] == '=' ||1291 Parameter[i2] == 1 && Parameter[i2] == ESC_AS ||1292 Parameter[i2] =='('){1293 VarName[i2] = 0;1294 break;1295 }1296 VarName[i2] = Parameter[i2];1297 }1298 1299 //定数と2重定義されていないる場合は抜け出す1300 if(CDBConst::obj.GetType(VarName)){1301 return;1302 }1303 1304 //定数マクロとして定義されている場合は抜け出す1305 if(GetConstHash(VarName)){1306 return;1307 }1308 }1309 1310 1311 //構文を解析1312 int SubScripts[MAX_ARRAYDIM];1313 TYPEINFO TypeInfo;1314 char InitBuf[8192];1315 char ConstractParameter[VN_SIZE];1316 if(!GetDimentionFormat(Parameter, isRef , VarName,SubScripts,&TypeInfo,InitBuf,ConstractParameter))1317 return;1318 1319 1320 //定数と2重定義されていないかを調べる1321 if(CDBConst::obj.GetType(VarName)){1322 SetError(15,VarName,cp);1323 return;1324 }1325 1326 //定数マクロとして定義されている場合1327 if(GetConstHash(VarName)){1328 SetError(15,VarName,cp);1329 return;1330 }1331 1332 1333 //タイプサイズを取得1334 int TypeSize;1335 TypeSize=GetTypeSize(TypeInfo.type,TypeInfo.u.lpIndex);1336 1337 extern BOOL bCompilingGlobal;1338 if(dwFlags&DIMFLAG_STATIC){1339 if(bCompilingGlobal){1340 SetError(60,NULL,cp);1341 return;1342 }1343 1344 /////////////////////1345 // Static変数1346 // ※"Static.Object.Method.Variable"1347 /////////////////////1348 1349 char temporary[VN_SIZE];1350 GetNowStaticVarFullName(VarName,temporary);1351 1352 dim( isRef,temporary,SubScripts,TypeInfo,TypeSize,InitBuf,ConstractParameter,dwFlags );1353 1354 /*1355 Note: 静的変数のコンストラクタ呼び出しは1356 _System_InitStaticLocalVariables関数内で一括して行う1357 */1358 }1359 else{1360 dim( isRef,VarName,SubScripts,TypeInfo,TypeSize,InitBuf,ConstractParameter,dwFlags );1361 }1362 }1363 void OpcodeDim(char *Parameter,DWORD dwFlags){1364 int i,i2,i3,IsStr=0;1365 char temporary[8192];1366 1367 for(i=0,i2=0;;i++,i2++){1368 if(Parameter[i]=='\"') IsStr^=1;1369 if(Parameter[i]=='('&&IsStr==0){1370 i3=GetStringInPare(temporary+i2,Parameter+i);1371 i+=i3-1;1372 i2+=i3-1;1373 continue;1374 }1375 if(Parameter[i]=='['&&IsStr==0){1376 i3=GetStringInBracket(temporary+i2,Parameter+i);1377 i+=i3-1;1378 i2+=i3-1;1379 continue;1380 }1381 if((Parameter[i]==','&&IsStr==0)||1382 Parameter[i]=='\0'){1383 temporary[i2]=0;1384 1385 dim(temporary,dwFlags);1386 1387 if(Parameter[i]=='\0') break;1388 i2=-1;1389 continue;1390 }1391 temporary[i2]=Parameter[i];1392 }1393 }1394 1395 1218 void SetVarPtrToReg(int reg,RELATIVE_VAR *pRelativeVar){ 1396 1219 if(!IsGeneralReg(reg)) SetError(300,NULL,cp);
Note:
See TracChangeset
for help on using the changeset viewer.