Changeset 73 in dev
- Timestamp:
- Mar 16, 2007, 11:07:14 PM (18 years ago)
- Files:
-
- 54 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler32/BasicCompiler.vcproj
r71 r73 1114 1114 > 1115 1115 </File> 1116 <File1117 RelativePath="..\BasicCompiler_Common\Type.h"1118 >1119 </File>1120 1116 </Filter> 1121 1117 <Filter … … 1278 1274 Name="Procedure" 1279 1275 > 1280 <File1281 RelativePath="..\BasicCompiler_Common\Parameter.h"1282 >1283 </File>1284 1276 <File 1285 1277 RelativePath="..\BasicCompiler_Common\ParamImpl.cpp" … … 1926 1918 /> 1927 1919 </FileConfiguration> 1920 </File> 1921 </Filter> 1922 <Filter 1923 Name="CommonClasses" 1924 > 1925 <File 1926 RelativePath="..\BasicCompiler_Common\Procedure.cpp" 1927 > 1928 </File> 1929 <File 1930 RelativePath="..\BasicCompiler_Common\Type.cpp" 1931 > 1928 1932 </File> 1929 1933 </Filter> … … 1974 1978 <File 1975 1979 RelativePath="..\BasicCompiler_Common\TypeDef.h" 1980 > 1981 </File> 1982 </Filter> 1983 <Filter 1984 Name="CommonClasses" 1985 > 1986 <File 1987 RelativePath="..\BasicCompiler_Common\Parameter.h" 1988 > 1989 </File> 1990 <File 1991 RelativePath="..\BasicCompiler_Common\Procedure.h" 1992 > 1993 </File> 1994 <File 1995 RelativePath="..\BasicCompiler_Common\Type.h" 1976 1996 > 1977 1997 </File> -
BasicCompiler32/CParameter.cpp
r71 r73 40 40 BOOL bByVal; 41 41 if(bEllipse){ 42 DummyTypeInfo.type=NumOpe_GetType (Parms[i2],NULL,&DummyTypeInfo.u.lpIndex);42 DummyTypeInfo.type=NumOpe_GetType_Old(Parms[i2],NULL,&DummyTypeInfo.u.lpIndex); 43 43 bByVal=1; 44 44 } … … 96 96 return nCountOfTempObjects * PTR_SIZE; 97 97 } 98 int ParamImpl::NewTempParameters( const char *procName, const Parameters ¶ms, int SecondParmNum ){ 99 /////////////////////////////////////////////////////// 100 // 一時オブジェクトをあらかじめスタックに積んでおく 101 /////////////////////////////////////////////////////// 102 103 useTempObject = false; 104 105 //一時参照の数 106 nCountOfTempObjects = 0; 107 108 BOOL bEllipse; 109 if(params.size()){ 110 if(params[params.size()-1]->GetBasicType()==DEF_ELLIPSE) bEllipse=1; 111 else bEllipse=0; 112 } 113 else bEllipse=0; 114 115 for(int i2=ParmsNum-1;i2>=0;i2--){ 116 useTempParameters[i2] = false; 117 118 if(bEllipse&&i2<=(int)params.size()-2) bEllipse=0; 119 120 if(i2==0){ 121 if( params[i2]->GetVarName() == "_System_LocalThis" ){ 122 //オブジェクトメンバの第一パラメータのThisポインタ 123 continue; 124 } 125 } 126 if( i2==0||i2==1 ){ 127 if( params[i2]->GetVarName() == procName ){ 128 //オブジェクトメンバの第一または第二パラメータの戻り値用オブジェクト 129 continue; 130 } 131 } 132 133 TYPEINFO DummyTypeInfo; 134 BOOL bByVal; 135 if(bEllipse){ 136 DummyTypeInfo.type=NumOpe_GetType_Old(Parms[i2],NULL,&DummyTypeInfo.u.lpIndex); 137 bByVal=1; 138 } 139 else{ 140 DummyTypeInfo.type=params[i2]->GetBasicType(); 141 DummyTypeInfo.u.lpIndex=params[i2]->GetIndex(); 142 bByVal = ( params[i2]->IsRef() == false ) ? TRUE:FALSE; 143 } 144 145 146 if( !bByVal ){ 147 //ポインタ参照 148 if(Parms[i2][0]==1&&Parms[i2][1]==ESC_BYVAL){ 149 //ポインタ指定 150 continue; 151 } 152 153 LONG_PTR lpVarIndex; 154 if( GetVarType( Parms[i2], &lpVarIndex, FALSE ) == -1 ){ 155 //変数ではないとき 156 int reg = REG_RAX; 157 int type = NumOpe( Parms[i2], DummyTypeInfo.type, DummyTypeInfo.u.lpIndex, &lpVarIndex ); 158 //↑ここでスタックに積む 159 160 nCountOfTempObjects++; 161 162 if( type != DEF_STRUCT ){ 163 //一時参照を作成 164 165 //push esp 166 op_push( REG_ESP ); 167 168 nCountOfTempObjects++; 169 } 170 171 bool result = CheckDifferentType( 172 DummyTypeInfo.type, 173 DummyTypeInfo.u.lpIndex, 174 type, 175 lpVarIndex, 176 procName, 177 i2); 178 179 if( result ){ 180 useTempParameters[i2] = true; 181 useTempObject = true; 182 183 types[i2].type = type; 184 types[i2].u.lpIndex = lpVarIndex; 185 } 186 } 187 } 188 } 189 190 return nCountOfTempObjects * PTR_SIZE; 191 } 98 192 99 193 void ParamImpl::DeleteTempParameters(){ … … 111 205 112 206 //call free 113 extern S UBINFO*pSub_free;207 extern SubInfo *pSub_free; 114 208 op_call(pSub_free); 115 209 } … … 138 232 139 233 //call calloc 140 extern S UBINFO*pSub_calloc;234 extern SubInfo *pSub_calloc; 141 235 op_call(pSub_calloc); 142 236 … … 147 241 TYPEINFO BaseType={DEF_STRUCT,(LONG_PTR)pobj_Class}; 148 242 TYPEINFO CalcType; 149 CalcType.type=NumOpe_GetType (Parameter,&BaseType,&CalcType.u.lpIndex);243 CalcType.type=NumOpe_GetType_Old(Parameter,&BaseType,&CalcType.u.lpIndex); 150 244 151 245 /* … … 267 361 BOOL bByVal; 268 362 if(bEllipse){ 269 DummyTypeInfo.type=NumOpe_GetType (Parms[i2],NULL,&DummyTypeInfo.u.lpIndex);363 DummyTypeInfo.type=NumOpe_GetType_Old(Parms[i2],NULL,&DummyTypeInfo.u.lpIndex); 270 364 bByVal=1; 271 365 } … … 436 530 return ParmSize; 437 531 } 532 int ParamImpl::SetParameter( const char *procName, const Parameters ¶ms, int SecondParmNum ){ 533 /////////////////////////////////////////////////////////// 534 // パラメータをレジスタ及びスタックフレームにセット 535 /////////////////////////////////////////////////////////// 536 int i2,i3; 537 538 BOOL bEllipse; 539 if( params.size() ){ 540 if(params[params.size()-1]->GetBasicType()==DEF_ELLIPSE) bEllipse=1; 541 else bEllipse=0; 542 } 543 else bEllipse=0; 544 545 BOOL bHas_System_LocalThis=0; 546 if(ParmsNum>=1){ 547 if( params[0]->GetVarName() == "_System_LocalThis" ){ 548 bHas_System_LocalThis=1; 549 } 550 } 551 552 //戻り値用の変数名を取得 553 const char *lpszVarNameToReturn = (procName[0]==1&&procName[1]==ESC_OPERATOR)?"_System_ReturnValue":procName; 554 555 //パラメータをレジスタとスタックに格納 556 int CalcType; 557 LONG_PTR lpCalcIndex; 558 BOOL bCalcUseHeap; 559 int ParmSize=0; 560 RELATIVE_VAR RelativeVar; 561 int nCountOfNowTempObjects = 0; 562 for(i2=ParmsNum-1;i2>=0;i2--){ 563 if(bEllipse&&i2<=(int)params.size()-2) bEllipse=0; 564 565 if(i2==0){ 566 if( params[i2]->GetVarName() == "_System_LocalThis" ){ 567 //オブジェクトメンバの第一パラメータのThisポインタ 568 continue; 569 } 570 } 571 if(i2==0||i2==1){ 572 if( params[i2]->GetVarName() == lpszVarNameToReturn ){ 573 //オブジェクトメンバの第一または第二パラメータの戻り値用オブジェクト 574 continue; 575 } 576 } 577 578 TYPEINFO DummyTypeInfo; 579 BOOL bByVal; 580 if(bEllipse){ 581 DummyTypeInfo.type=NumOpe_GetType_Old(Parms[i2],NULL,&DummyTypeInfo.u.lpIndex); 582 bByVal=1; 583 } 584 else{ 585 DummyTypeInfo.type=params[i2]->GetBasicType(); 586 DummyTypeInfo.u.lpIndex=params[i2]->GetIndex(); 587 bByVal = (params[i2]->IsRef() == false ) ? TRUE:FALSE; 588 } 589 590 if(bByVal==1){ 591 //値参照 592 593 if(Parms[i2][0]==1&&Parms[i2][1]==ESC_BYVAL){ 594 char temp2[255]; 595 sprintf(temp2,"%s関数の第%dパラメータ",procName,i2+1); 596 SetError(19,temp2,cp); 597 continue; 598 } 599 600 if(DummyTypeInfo.type==DEF_STRUCT){ 601 SetStructParameter(DummyTypeInfo.u.pobj_Class,Parms[i2]); 602 goto next; 603 } 604 605 606 extern LONG_PTR ProcPtr_BaseIndex; 607 LONG_PTR back_ProcPtr_BaseIndex; 608 back_ProcPtr_BaseIndex=ProcPtr_BaseIndex; 609 if(DummyTypeInfo.type==DEF_PTR_PROC) ProcPtr_BaseIndex=DummyTypeInfo.u.lpIndex; 610 else ProcPtr_BaseIndex=-1; 611 612 CalcType=NumOpe(Parms[i2],DummyTypeInfo.type,DummyTypeInfo.u.lpIndex,&lpCalcIndex,&bCalcUseHeap); 613 614 ProcPtr_BaseIndex=back_ProcPtr_BaseIndex; 615 616 if(CalcType==-1) break; 617 618 if(CalcType==DEF_OBJECT){ 619 if( DummyTypeInfo.type != DEF_OBJECT 620 || 621 DummyTypeInfo.type == DEF_OBJECT && 622 !DummyTypeInfo.u.pobj_Class->IsEqualsOrSubClass( (CClass *)lpCalcIndex ) ){ 623 //キャスト演算子のオーバーロードに対応する 624 CallCastOperatorProc(CalcType,lpCalcIndex,bCalcUseHeap,DummyTypeInfo.type,DummyTypeInfo.u.lpIndex); 625 } 626 } 627 628 if(!bEllipse){ 629 //型チェック 630 if(bHas_System_LocalThis) i3=i2-1; 631 else i3=i2; 632 CheckDifferentType( 633 DummyTypeInfo.type, 634 DummyTypeInfo.u.lpIndex, 635 CalcType, 636 lpCalcIndex, 637 procName, 638 i3); 639 } 640 641 if(DummyTypeInfo.type==DEF_DOUBLE){ 642 ChangeTypeToDouble(CalcType); 643 ParmSize+=sizeof(long)*2; 644 } 645 else if(DummyTypeInfo.type==DEF_SINGLE){ 646 ChangeTypeToSingle(CalcType); 647 ParmSize+=sizeof(long); 648 } 649 else if(DummyTypeInfo.type==DEF_INT64||DummyTypeInfo.type==DEF_QWORD){ 650 ChangeTypeToInt64(CalcType); 651 ParmSize+=sizeof(long)*2; 652 } 653 else if(DummyTypeInfo.type==DEF_LONG||DummyTypeInfo.type==DEF_DWORD||DummyTypeInfo.type==DEF_OBJECT||DummyTypeInfo.type==DEF_STRUCT|| 654 (IsPtrType(DummyTypeInfo.type)/*&&DummyTypeInfo.type!=DEF_PTR_VOID&&DummyTypeInfo.type!=DEF_PTR_BYTE*/)){ 655 ChangeTypeToLong(CalcType); 656 ParmSize+=sizeof(long); 657 } 658 else if(DummyTypeInfo.type==DEF_INTEGER||DummyTypeInfo.type==DEF_WORD || (isUnicode&&DummyTypeInfo.type==DEF_CHAR)){ 659 ChangeTypeToInteger(CalcType); 660 ParmSize+=sizeof(long); 661 } 662 else if(DummyTypeInfo.type==DEF_SBYTE||DummyTypeInfo.type==DEF_BYTE||DummyTypeInfo.type==DEF_BOOLEAN || (isUnicode==false&&DummyTypeInfo.type==DEF_CHAR)){ 663 ChangeTypeToByte(CalcType); 664 ParmSize+=sizeof(long); 665 } 666 else{ 667 SetError(300,NULL,cp); 668 } 669 } 670 else{ 671 //ポインタ参照 672 if(Parms[i2][0]==1&&Parms[i2][1]==ESC_BYVAL){ 673 //ポインタ指定 674 i3=NumOpe(Parms[i2]+2,0,0,0); 675 676 ChangeTypeToLong(i3); 677 } 678 else{ 679 if( useTempParameters[i2] ){ 680 //一時オブジェクトをコピー 681 682 if( types[i2].type != DEF_STRUCT ){ 683 // 一時参照のための領域を考慮する 684 nCountOfNowTempObjects++; 685 } 686 687 nCountOfNowTempObjects++; 688 689 //mov eax, dword ptr[esp+offset] 690 op_mov_RM( 691 sizeof(long), 692 REG_EAX, 693 REG_ESP, 694 ( ( ParmsNum - i2 - 1 ) + ( nCountOfTempObjects - nCountOfNowTempObjects ) ) * PTR_SIZE, 695 MOD_BASE_DISP32 ); 696 697 //push eax 698 op_push(REG_EAX); 699 } 700 else{ 701 //変数のアドレスを取得 702 int VarType; 703 LONG_PTR lpVarIndex; 704 if(GetVarOffset( 705 false, 706 false, 707 Parms[i2], 708 &VarType, 709 &RelativeVar, 710 &lpVarIndex)){ 711 if(DummyTypeInfo.type!=DEF_ANY){ 712 //型チェックを行う 713 if(DummyTypeInfo.type==VarType){ 714 if(DummyTypeInfo.type==DEF_OBJECT){ 715 if( !DummyTypeInfo.u.pobj_Class->IsEqualsOrSubClass( (CClass *)lpVarIndex ) ){ 716 SetError(11,Parms[i2],cp); 717 } 718 } 719 else if(DummyTypeInfo.type==DEF_STRUCT){ 720 if( !DummyTypeInfo.u.pobj_Class->IsEquals( (CClass *)lpVarIndex ) ){ 721 SetError(11,Parms[i2],cp); 722 } 723 } 724 } 725 else if((VarType&FLAG_PTR)&&((int)(VarType^FLAG_PTR)==DummyTypeInfo.type)){ 726 //仮引数がポインタ参照で、実引数が配列の先頭ポインタのとき 727 } 728 else{ 729 SetError(11,Parms[i2],cp); 730 } 731 } 732 733 //変数アドレスをレジスタにセット 734 SetVarPtrToEax(&RelativeVar); 735 736 //push eax 737 op_push(REG_EAX); 738 } 739 } 740 } 741 742 ParmSize+=PTR_SIZE; 743 } 744 745 next:; 746 } 747 748 return ParmSize; 749 } -
BasicCompiler32/Compile_CallProc.cpp
r71 r73 8 8 void Call_DebugSys_SaveContext(){ 9 9 //call _System_GetEip 10 extern S UBINFO*pSub_System_GetEip;10 extern SubInfo *pSub_System_GetEip; 11 11 op_call(pSub_System_GetEip); 12 12 … … 18 18 19 19 //call _DebugSys_SaveContext 20 extern S UBINFO*pSub_DebugSys_SaveContext;20 extern SubInfo *pSub_DebugSys_SaveContext; 21 21 op_call(pSub_DebugSys_SaveContext); 22 22 } … … 94 94 } 95 95 96 void Opcode_CallProc(const char *Parameter,S UBINFO*psi,DWORD dwFlags,char *ObjectName,int RefType){96 void Opcode_CallProc(const char *Parameter,SubInfo *psi,DWORD dwFlags,char *ObjectName,int RefType){ 97 97 int i2; 98 98 … … 230 230 231 231 //エラーチェック 232 if( !pobj_parameter->ErrorCheck(psi->name,psi-> pRealParmInfo,psi->RealParmNum,psi->SecondParmNum) ){232 if( !pobj_parameter->ErrorCheck(psi->name,psi->realParams,psi->SecondParmNum) ){ 233 233 //パラメータにエラーがあるときは処理を終える 234 234 return; … … 237 237 if(psi->dwType==SUBTYPE_MACRO){ 238 238 //マクロ関数の場合は、パラメータ省略を考慮する 239 pobj_parameter->MacroParameterSupport( psi->pRealParmInfo);239 pobj_parameter->MacroParameterSupport( psi->realParams ); 240 240 } 241 241 242 242 //一時オブジェクトを生成 243 int tempSize = pobj_parameter->NewTempParameters( psi->name,psi-> pRealParmInfo,psi->RealParmNum,psi->RealSecondParmNum );243 int tempSize = pobj_parameter->NewTempParameters( psi->name,psi->realParams,psi->RealSecondParmNum ); 244 244 245 245 //レジスタ、スタックフレームにセット 246 246 int ParmSize; 247 ParmSize=pobj_parameter->SetParameter(psi->name,psi-> pRealParmInfo,psi->RealParmNum,psi->RealSecondParmNum);247 ParmSize=pobj_parameter->SetParameter(psi->name,psi->realParams,psi->RealSecondParmNum); 248 248 249 249 if(psi->ReturnType==DEF_STRUCT && psi->isReturnRef == false){ … … 259 259 260 260 //call calloc 261 extern S UBINFO*pSub_calloc;261 extern SubInfo *pSub_calloc; 262 262 op_call(pSub_calloc); 263 263 -
BasicCompiler32/Compile_Func.cpp
r64 r73 243 243 void Opcode_Func_AddressOf(const char *name){ 244 244 extern int cp; 245 S UBINFO*psi;245 SubInfo *psi; 246 246 247 247 extern LONG_PTR ProcPtr_BaseIndex; … … 249 249 //左辺の型にのっとり、オーバーロードを解決 250 250 251 std::vector<S UBINFO*> subs;251 std::vector<SubInfo *> subs; 252 252 GetOverloadSubHash( name, subs ); 253 253 if( subs.size() == 0 ){ -
BasicCompiler32/Compile_Object.cpp
r68 r73 31 31 //////////////////////// 32 32 33 std::vector<S UBINFO*> subs;33 std::vector<SubInfo *> subs; 34 34 pobj_c->EnumMethod( pobj_c->name, subs ); 35 35 36 S UBINFO*psi;36 SubInfo *psi; 37 37 if( subs.size() > 0 ){ 38 38 //オーバーロードを解決 … … 133 133 134 134 //call _System_GC_malloc_ForObject 135 extern S UBINFO*pSub_System_GC_malloc_ForObject;135 extern SubInfo *pSub_System_GC_malloc_ForObject; 136 136 op_call(pSub_System_GC_malloc_ForObject); 137 137 } … … 140 140 141 141 //call _System_GC_malloc_ForObjectPtr 142 extern S UBINFO*pSub_System_GC_malloc_ForObjectPtr;142 extern SubInfo *pSub_System_GC_malloc_ForObjectPtr; 143 143 op_call(pSub_System_GC_malloc_ForObjectPtr); 144 144 } … … 208 208 // コンストラクタの呼び出し 209 209 //////////////////////////// 210 211 if( lstrcmp(classObj.name,"proc")==0){212 int i=0;213 }214 210 215 211 BOOL bSomeObjects; … … 380 376 if( isSweeping ){ 381 377 //call _System_GC_free_for_SweepingDelete 382 extern S UBINFO*pSub_System_GC_free_for_SweepingDelete;378 extern SubInfo *pSub_System_GC_free_for_SweepingDelete; 383 379 op_call(pSub_System_GC_free_for_SweepingDelete); 384 380 } 385 381 else{ 386 382 //call free 387 extern S UBINFO*pSub_free;383 extern SubInfo *pSub_free; 388 384 op_call(pSub_free); 389 385 } -
BasicCompiler32/Compile_ProcOp.cpp
r64 r73 214 214 } 215 215 216 void CompileBufferInProcedure(S UBINFO*psi){216 void CompileBufferInProcedure(SubInfo *psi){ 217 217 extern char *basbuf; 218 218 extern HANDLE hHeap; 219 extern S UBINFO**ppSubHash;219 extern SubInfo **ppSubHash; 220 220 extern BOOL bDebugCompile; 221 221 int i3,i4,VarSize,LocalVarSchedule,EspOffsetSchedule,BufferSize,BaseOffset; … … 280 280 281 281 //パラメータ用の変数データを考慮 282 for(i3=psi->RealParmNum-1;i3>=0;i3--){ 282 for(i3=psi->realParams.size()-1;i3>=0;i3--){ 283 Parameter ¶m = *psi->realParams[i3]; 284 283 285 //変数データを追加 284 286 LocalVar=(VARIABLE *)HeapReAlloc(hHeap,0,LocalVar,(MaxLocalVarNum+1)*sizeof(VARIABLE)); 285 287 286 lstrcpy( LocalVar[MaxLocalVarNum].name,psi->pRealParmInfo[i3].name);288 lstrcpy( LocalVar[MaxLocalVarNum].name,param.GetVarName().c_str() ); 287 289 288 290 // TODO: パラメータのConst定義の指定が未完成 289 291 LocalVar[MaxLocalVarNum].bConst=false; 290 292 291 LocalVar[MaxLocalVarNum].bArray=p si->pRealParmInfo[i3].bArray;292 memcpy(LocalVar[MaxLocalVarNum].SubScripts,p si->pRealParmInfo[i3].SubScripts,MAX_ARRAYDIM*sizeof(int));293 294 LocalVar[MaxLocalVarNum].type=p si->pRealParmInfo[i3].type;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(); 295 297 if(LocalVar[MaxLocalVarNum].type==DEF_OBJECT 296 298 ||LocalVar[MaxLocalVarNum].type==DEF_STRUCT){ … … 299 301 } 300 302 301 LocalVar[MaxLocalVarNum].u.index=p si->pRealParmInfo[i3].u.index;302 303 if( psi->pRealParmInfo[i3].bByVal&&psi->pRealParmInfo[i3].type==DEF_STRUCT){303 LocalVar[MaxLocalVarNum].u.index=param.GetIndex(); 304 305 if( param.IsRef() == false && param.IsStruct() ){ 304 306 //構造体のByValパラメータ 305 307 LocalVar[MaxLocalVarNum].fRef=REF_PARAMETER | OBJECT_PARAMETER; … … 307 309 } 308 310 else{ 309 if( psi->pRealParmInfo[i3].bByVal&&psi->pRealParmInfo[i3].bArray==0){311 if( param.IsRef() == false && param.IsArray() == false ){ 310 312 LocalVar[MaxLocalVarNum].fRef=0; 311 313 VarSize=GetTypeSize(LocalVar[MaxLocalVarNum].type,LocalVar[MaxLocalVarNum].u.index); … … 344 346 345 347 //コンパイル中の関数 346 extern S UBINFO*pCompilingSubInfo;348 extern SubInfo *pCompilingSubInfo; 347 349 pCompilingSubInfo=psi; 348 350 … … 442 444 443 445 //call _DebugSys_StartProc 444 extern S UBINFO*pSub_DebugSys_StartProc;446 extern SubInfo *pSub_DebugSys_StartProc; 445 447 op_call(pSub_DebugSys_StartProc); 446 448 } … … 684 686 685 687 //call _DebugSys_EndProc 686 extern S UBINFO*pSub_DebugSys_EndProc;688 extern SubInfo *pSub_DebugSys_EndProc; 687 689 op_call(pSub_DebugSys_EndProc); 688 690 } … … 806 808 807 809 //call _esp_error 808 extern S UBINFO*pSub_esp_error;810 extern SubInfo *pSub_esp_error; 809 811 op_call( pSub_esp_error ); 810 812 … … 840 842 } 841 843 void CompileLocal(){ 842 extern S UBINFO**ppSubHash;844 extern SubInfo **ppSubHash; 843 845 int i2; 844 S UBINFO*psi;846 SubInfo *psi; 845 847 846 848 extern BOOL bDll; … … 856 858 //_System_InitStaticLocalVariablesは一番最後にコンパイル 857 859 //※一般関数内の静的変数オブジェクトをすべて収集しなければならない 858 extern S UBINFO*pSub_System_InitStaticLocalVariables;860 extern SubInfo *pSub_System_InitStaticLocalVariables; 859 861 pSub_System_InitStaticLocalVariables->bCompile=1; 860 862 861 863 //_System_Call_Destructor_of_GlobalObjectは一番最後にコンパイル 862 extern S UBINFO*pSub_System_Call_Destructor_of_GlobalObject;864 extern SubInfo *pSub_System_Call_Destructor_of_GlobalObject; 863 865 pSub_System_Call_Destructor_of_GlobalObject->bCompile=1; 864 866 -
BasicCompiler32/Compile_Set_Var.cpp
r67 r73 71 71 72 72 //call free 73 extern S UBINFO*pSub_free;73 extern SubInfo *pSub_free; 74 74 op_call(pSub_free); 75 75 } -
BasicCompiler32/Compile_Statement.cpp
r67 r73 5 5 int i,i2; 6 6 char buffer[8192]; 7 S UBINFO*psi;7 SubInfo *psi; 8 8 9 9 for(i=0;;i++){ … … 44 44 45 45 //GetSubHash内でエラー提示が行われた場合 46 if(psi==(S UBINFO*)-1) return;46 if(psi==(SubInfo *)-1) return; 47 47 48 48 if(psi==0){ … … 54 54 55 55 //GetSubHash内でエラー提示が行われた場合 56 if(psi==(S UBINFO*)-1) return;56 if(psi==(SubInfo *)-1) return; 57 57 } 58 58 … … 1076 1076 pobj_c=(CClass *)lpIndex; 1077 1077 1078 std::vector<S UBINFO*> subs;1078 std::vector<SubInfo *> subs; 1079 1079 pobj_c->EnumMethod( CALC_EQUAL, subs ); 1080 1080 if( subs.size() == 0 ){ … … 1093 1093 1094 1094 //オーバーロードを解決 1095 S UBINFO*psi;1095 SubInfo *psi; 1096 1096 psi=OverloadSolution("==",subs,ppi,iParmNum,NULL); 1097 1097 HeapDefaultFree(ppi); … … 1330 1330 //戻り値をセット 1331 1331 if(Parameter[0]){ 1332 extern S UBINFO*pCompilingSubInfo;1332 extern SubInfo *pCompilingSubInfo; 1333 1333 char *temp; 1334 1334 if(pCompilingSubInfo->name[0]==1&&pCompilingSubInfo->name[1]==ESC_OPERATOR) … … 1460 1460 OpcodeCalc(temp2); 1461 1461 1462 S UBINFO*psi;1462 SubInfo *psi; 1463 1463 if(bFile) psi=GetSubHash("INPUT_FromFile"); 1464 1464 else psi=GetSubHash("INPUT_FromPrompt"); … … 1562 1562 OpcodeCalc(temp2); 1563 1563 1564 S UBINFO*psi;1564 SubInfo *psi; 1565 1565 if(bFile) psi=GetSubHash("PRINTUSING_ToFile"); 1566 1566 else psi=GetSubHash("PRINTUSING_ToPrompt"); … … 1666 1666 if(sw) lstrcat(buffer,"+Ex\"\\r\\n\""); 1667 1667 1668 S UBINFO*psi;1668 SubInfo *psi; 1669 1669 if(bFile) psi=GetSubHash("PRINT_ToFile"); 1670 1670 else psi=GetSubHash("PRINT_ToPrompt"); -
BasicCompiler32/Compile_Var.cpp
r69 r73 520 520 521 521 char temporary[VN_SIZE]; 522 extern S UBINFO*pCompilingSubInfo;522 extern SubInfo *pCompilingSubInfo; 523 523 if(pCompilingSubInfo){ 524 524 GetNowStaticVarFullName(VarName,temporary); -
BasicCompiler32/MakePeHdr.cpp
r67 r73 8 8 // 特殊関数の構造体ポインタ 9 9 //////////////////////////// 10 S UBINFO10 SubInfo 11 11 *pSub_System_StartupProgram, 12 12 *pSub_DebugSys_StartProc, … … 391 391 392 392 //call _System_Call_Destructor_of_GlobalObject 393 extern S UBINFO*pSub_System_Call_Destructor_of_GlobalObject;393 extern SubInfo *pSub_System_Call_Destructor_of_GlobalObject; 394 394 op_call(pSub_System_Call_Destructor_of_GlobalObject); 395 395 … … 522 522 ExportNamesLength=lstrlen(lpExportNames)+1; 523 523 524 extern S UBINFO**ppSubHash;525 S UBINFO*psi,*psi2;524 extern SubInfo **ppSubHash; 525 SubInfo *psi,*psi2; 526 526 while(1){ 527 527 //辞書順にサーチ -
BasicCompiler32/NumOpe_Arithmetic.cpp
r67 r73 270 270 271 271 //call _allmul 272 extern S UBINFO*pSub_allmul;272 extern SubInfo *pSub_allmul; 273 273 op_call(pSub_allmul); 274 274 … … 460 460 461 461 //call _aullrem 462 extern S UBINFO*pSub_aullrem;462 extern SubInfo *pSub_aullrem; 463 463 op_call(pSub_aullrem); 464 464 } … … 467 467 468 468 //call _allrem 469 extern S UBINFO*pSub_allrem;469 extern SubInfo *pSub_allrem; 470 470 op_call(pSub_allrem); 471 471 } … … 720 720 721 721 //call _aulldiv 722 extern S UBINFO*pSub_aulldiv;722 extern SubInfo *pSub_aulldiv; 723 723 op_call(pSub_aulldiv); 724 724 } … … 727 727 728 728 //call _alldiv 729 extern S UBINFO*pSub_alldiv;729 extern SubInfo *pSub_alldiv; 730 730 op_call(pSub_alldiv); 731 731 } … … 1000 1000 1001 1001 //call pow 1002 extern S UBINFO*pSub_pow;1002 extern SubInfo *pSub_pow; 1003 1003 op_call(pSub_pow); 1004 1004 … … 1156 1156 1157 1157 //call _allshl 1158 extern S UBINFO*pSub_allshl;1158 extern SubInfo *pSub_allshl; 1159 1159 op_call(pSub_allshl); 1160 1160 … … 1361 1361 1362 1362 //call _aullshr 1363 extern S UBINFO*pSub_aullshr;1363 extern SubInfo *pSub_aullshr; 1364 1364 op_call(pSub_aullshr); 1365 1365 } … … 1368 1368 1369 1369 //call _allshr 1370 extern S UBINFO*pSub_allshr;1370 extern SubInfo *pSub_allshr; 1371 1371 op_call(pSub_allshr); 1372 1372 } -
BasicCompiler32/Opcode.h
r71 r73 214 214 ParamImpl(const char *buffer); 215 215 ParamImpl(const PARAMETER_INFO *pParamInfo, const int ParmNum); 216 ParamImpl::ParamImpl(const Parameters ¶ms); 216 217 ~ParamImpl(); 217 218 void SetReturnType(TYPEINFO *pTypeInfo); 218 219 219 220 private: 220 BOOL _overload_check( PARAMETER_INFO *ppi,int pi_num,TYPEINFO *pReturnTypeInfo,int overload_level);221 S UBINFO *OverloadSolutionWithReturnType( const char *name, std::vector<SUBINFO*> &subs );221 BOOL _overload_check( Parameters ¶ms,TYPEINFO *pReturnTypeInfo,int overload_level); 222 SubInfo *OverloadSolutionWithReturnType( const char *name, std::vector<SubInfo *> &subs ); 222 223 public: 223 S UBINFO *OverloadSolution( const char *name, std::vector<SUBINFO*> &subs );224 SubInfo *OverloadSolution( const char *name, std::vector<SubInfo *> &subs ); 224 225 225 226 BOOL ErrorCheck(const char *FuncName,PARAMETER_INFO *ppi,int pi_num,int SecondParmNum); 227 bool ErrorCheck( const char *procName, const Parameters ¶ms, int SecondParmNum ); 226 228 void MacroParameterSupport(PARAMETER_INFO *ppi); 229 void MacroParameterSupport( const Parameters ¶ms ); 227 230 void SetStructParameter(CClass *pobj_Class,LPSTR Parameter); 228 231 int SetParameter(const char *FuncName,PARAMETER_INFO *ppi,int pi_num,int SecondParmNum); 232 int SetParameter( const char *procName, const Parameters ¶ms, int SecondParmNum ); 229 233 230 234 //一時オブジェクトパラメータの生成と破棄 231 235 int NewTempParameters( const char *FuncName,PARAMETER_INFO *ppi,int pi_num,int SecondParmNum ); 236 int NewTempParameters( const char *procName, const Parameters ¶ms, int SecondParmNum ); 232 237 void DeleteTempParameters(); 233 238 }; … … 237 242 #define PROCFLAG_NEW 1 238 243 int Opcode_CallProcPtr(char *variable,char *Parameter,PROCPTRINFO *pi,LONG_PTR *plpIndex); 239 void Opcode_CallProc(const char *Parameter,S UBINFO*psi,DWORD dwFlags,char *ObjectName,int RefType);244 void Opcode_CallProc(const char *Parameter,SubInfo *psi,DWORD dwFlags,char *ObjectName,int RefType); 240 245 int Opcode_CallDllProc(char *Parameter,DECLAREINFO *pdi,LONG_PTR *plpIndex); 241 246 … … 339 344 void fpu_cast_end(); 340 345 341 void op_call(S UBINFO*psi);346 void op_call(SubInfo *psi); -
BasicCompiler32/OperatorProc.cpp
r67 r73 18 18 19 19 //call free 20 extern S UBINFO*pSub_free;20 extern SubInfo *pSub_free; 21 21 op_call(pSub_free); 22 22 } … … 27 27 pobj_c=(CClass *)index_stack[sp-2]; 28 28 29 std::vector<S UBINFO*> subs;29 std::vector<SubInfo *> subs; 30 30 pobj_c->EnumMethod( idCalc, subs ); 31 31 if( subs.size() == 0 ){ … … 42 42 BOOL bReturnTypeIsObject=1; 43 43 TYPEINFO ReturnType={DEF_OBJECT,subs[0]->u.ReturnIndex}; 44 foreach( S UBINFO*psi, subs ){44 foreach( SubInfo *psi, subs ){ 45 45 if(psi->ReturnType!=DEF_OBJECT) 46 46 bReturnTypeIsObject=0; … … 79 79 if(idCalc==CALC_EQUAL) lstrcpy(temporary,"=="); 80 80 else GetCalcName(idCalc,temporary); 81 S UBINFO*psi;81 SubInfo *psi; 82 82 psi=OverloadSolution(temporary,subs,ppi,iParmNum,pBaseTypeInfo); 83 83 … … 88 88 else{ 89 89 //オーバーロードされていないが、パラメータ個数が一致しないとき 90 if(iParmNum!=psi-> ParmNum){90 if(iParmNum!=psi->params.size()){ 91 91 HeapDefaultFree(ppi); 92 92 return -1; … … 96 96 for(i=0;i<iParmNum;i++){ 97 97 CheckDifferentType( 98 psi->p ParmInfo[i].type,99 psi->p ParmInfo[i].u.index,98 psi->params[i]->GetBasicType(), 99 psi->params[i]->GetIndex(), 100 100 ppi[i].type, 101 101 ppi[i].u.index, … … 109 109 110 110 if(bTwoTerm){ 111 if( psi->pRealParmInfo[1].type==DEF_STRUCT&&psi->pRealParmInfo[1].bByVal){111 if( psi->realParams[1]->IsStruct() &&psi->realParams[1]->IsRef() == false ){ 112 112 //一時オブジェクトはメソッド内で破棄される 113 113 bUseHeap[sp-1]=0; … … 128 128 129 129 //call calloc 130 extern S UBINFO*pSub_calloc;130 extern SubInfo *pSub_calloc; 131 131 op_call(pSub_calloc); 132 132 … … 180 180 } 181 181 182 if( !psi->pRealParmInfo[1].bByVal){182 if( psi->realParams[1]->IsRef() ){ 183 183 //一時参照を作成 184 184 … … 203 203 204 204 if(bTwoTerm){ 205 if( !psi->pRealParmInfo[1].bByVal){205 if( psi->realParams[1]->IsRef() ){ 206 206 //一時参照を破棄 207 207 op_pop( REG_NON ); … … 273 273 } 274 274 void CallIndexerGetterProc(CClass *pobj_Class,char *ObjectName,char *Parameter,TYPEINFO &RetTypeInfo){ 275 std::vector<S UBINFO*> subs;275 std::vector<SubInfo *> subs; 276 276 pobj_Class->EnumMethod( CALC_ARRAY_GET, subs ); 277 277 if( subs.size() == 0 ){ -
BasicCompiler32/VarList.cpp
r69 r73 348 348 if(pobj_dti->lplpSpBase[i2]==0) return; 349 349 350 extern S UBINFO**ppSubHash;351 S UBINFO*psi;350 extern SubInfo **ppSubHash; 351 SubInfo *psi; 352 352 for(i3=0,sw=0;i3<MAX_HASH;i3++){ 353 353 psi=ppSubHash[i3]; … … 583 583 584 584 //プロシージャ コンボボックス 585 extern S UBINFO**ppSubHash;586 S UBINFO*psi;585 extern SubInfo **ppSubHash; 586 SubInfo *psi; 587 587 int sw; 588 588 SendMessage(hProcCombo,CB_RESETCONTENT,0,0); … … 706 706 707 707 if(pobj_dti->lplpSpBase[i2]){ 708 extern S UBINFO**ppSubHash;709 S UBINFO*psi;708 extern SubInfo **ppSubHash; 709 SubInfo *psi; 710 710 for(i3=0,sw=0;i3<MAX_HASH;i3++){ 711 711 psi=ppSubHash[i3]; -
BasicCompiler32/WatchList.cpp
r64 r73 308 308 ULONG_PTR Debugging_GetThisPtrOffset(LONG_PTR obp_Rip){ 309 309 int i; 310 S UBINFO*psi;310 SubInfo *psi; 311 311 312 312 //ripからプロシージャを取得 -
BasicCompiler32/op32_main.cpp
r67 r73 974 974 ///////////////////////////// 975 975 976 void op_call(S UBINFO*psi){976 void op_call(SubInfo *psi){ 977 977 OpBuffer[obp++]=(char)0xE8; 978 978 pobj_SubAddrSchedule->add(psi,1); -
BasicCompiler64/CParameter.cpp
r71 r73 112 112 113 113 //call free 114 extern S UBINFO*pSub_free;114 extern SubInfo *pSub_free; 115 115 op_call(pSub_free); 116 116 } … … 135 135 136 136 //call calloc 137 extern S UBINFO*pSub_calloc;137 extern SubInfo *pSub_calloc; 138 138 op_call(pSub_calloc); 139 139 -
BasicCompiler64/Compile_CallProc.cpp
r71 r73 8 8 void Call_DebugSys_SaveContext(){ 9 9 //call _System_GetEip 10 extern S UBINFO*pSub_System_GetEip;10 extern SubInfo *pSub_System_GetEip; 11 11 op_call(pSub_System_GetEip); 12 12 … … 18 18 19 19 //call _DebugSys_SaveContext 20 extern S UBINFO*pSub_DebugSys_SaveContext;20 extern SubInfo *pSub_DebugSys_SaveContext; 21 21 op_call(pSub_DebugSys_SaveContext); 22 22 } … … 96 96 } 97 97 98 void Opcode_CallProc(const char *Parameter,S UBINFO*psi,DWORD dwFlags,char *ObjectName,int RefType){98 void Opcode_CallProc(const char *Parameter,SubInfo *psi,DWORD dwFlags,char *ObjectName,int RefType){ 99 99 int i2; 100 100 … … 234 234 235 235 //エラーチェック 236 if( !pobj_parameter->ErrorCheck(psi->name,psi-> pRealParmInfo,psi->RealParmNum,psi->SecondParmNum) ){236 if( !pobj_parameter->ErrorCheck(psi->name,psi->realParams,psi->SecondParmNum) ){ 237 237 //パラメータにエラーがあるときは処理を終える 238 238 return; … … 241 241 if(psi->dwType==SUBTYPE_MACRO){ 242 242 //マクロ関数の場合は、パラメータ省略を考慮する 243 pobj_parameter->MacroParameterSupport(psi-> pRealParmInfo);243 pobj_parameter->MacroParameterSupport(psi->realParams); 244 244 } 245 245 … … 248 248 249 249 //一時オブジェクトを生成 250 pobj_parameter->NewTempParameters( psi->name,psi-> pRealParmInfo,psi->RealParmNum,psi->RealSecondParmNum );250 pobj_parameter->NewTempParameters( psi->name,psi->realParams,psi->RealSecondParmNum ); 251 251 252 252 //レジスタ、スタックフレームにセット 253 pobj_parameter->SetParameter(psi->name,psi-> pRealParmInfo,psi->RealParmNum,psi->RealSecondParmNum);253 pobj_parameter->SetParameter(psi->name,psi->realParams,psi->RealSecondParmNum); 254 254 255 255 if(psi->ReturnType==DEF_STRUCT && psi->isReturnRef == false){ … … 271 271 272 272 //call calloc 273 extern S UBINFO*pSub_calloc;273 extern SubInfo *pSub_calloc; 274 274 op_call(pSub_calloc); 275 275 -
BasicCompiler64/Compile_Func.cpp
r64 r73 95 95 void Opcode_Func_AddressOf( const char *name ){ 96 96 extern int cp; 97 S UBINFO*psi;97 SubInfo *psi; 98 98 99 99 extern LONG_PTR ProcPtr_BaseIndex; … … 101 101 //左辺の型にのっとり、オーバーロードを解決 102 102 103 std::vector<S UBINFO*> subs;103 std::vector<SubInfo *> subs; 104 104 GetOverloadSubHash( name, subs ); 105 105 if( subs.size() == 0 ){ -
BasicCompiler64/Compile_Object.cpp
r64 r73 32 32 //////////////////////// 33 33 34 std::vector<S UBINFO*> subs;34 std::vector<SubInfo *> subs; 35 35 pobj_c->EnumMethod( pobj_c->name, subs ); 36 36 37 S UBINFO*psi;37 SubInfo *psi; 38 38 if( subs.size() > 0 ){ 39 39 //オーバーロードを解決 … … 121 121 122 122 //call _System_GC_malloc_ForObject 123 extern S UBINFO*pSub_System_GC_malloc_ForObject;123 extern SubInfo *pSub_System_GC_malloc_ForObject; 124 124 op_call(pSub_System_GC_malloc_ForObject); 125 125 } … … 128 128 129 129 //call _System_GC_malloc_ForObjectPtr 130 extern S UBINFO*pSub_System_GC_malloc_ForObjectPtr;130 extern SubInfo *pSub_System_GC_malloc_ForObjectPtr; 131 131 op_call(pSub_System_GC_malloc_ForObjectPtr); 132 132 } … … 328 328 if( isSweeping ){ 329 329 //call _System_GC_free_for_SweepingDelete 330 extern S UBINFO*pSub_System_GC_free_for_SweepingDelete;330 extern SubInfo *pSub_System_GC_free_for_SweepingDelete; 331 331 op_call(pSub_System_GC_free_for_SweepingDelete); 332 332 } 333 333 else{ 334 334 //call free 335 extern S UBINFO*pSub_free;335 extern SubInfo *pSub_free; 336 336 op_call(pSub_free); 337 337 } -
BasicCompiler64/Compile_ProcOp.cpp
r64 r73 204 204 } 205 205 } 206 void CompileBufferInProcedure(S UBINFO*psi){206 void CompileBufferInProcedure(SubInfo *psi){ 207 207 extern char *basbuf; 208 208 extern HANDLE hHeap; 209 extern S UBINFO**ppSubHash;209 extern SubInfo **ppSubHash; 210 210 extern BOOL bDebugCompile; 211 211 int i3,i4,VarSize,BufferSize; … … 328 328 LocalVar=(VARIABLE *)HeapReAlloc(hHeap,0,LocalVar,(MaxLocalVarNum+1)*sizeof(VARIABLE)); 329 329 330 lstrcpy(LocalVar[MaxLocalVarNum].name,psi-> pRealParmInfo[i3].name);330 lstrcpy(LocalVar[MaxLocalVarNum].name,psi->realParams[i3].GetVarName.c_str()); 331 331 332 332 // TODO: パラメータのConst定義の指定が未完成 333 333 LocalVar[MaxLocalVarNum].bConst=false; 334 334 335 LocalVar[MaxLocalVarNum].bArray=psi-> pRealParmInfo[i3].bArray;336 memcpy(LocalVar[MaxLocalVarNum].SubScripts,psi-> pRealParmInfo[i3].SubScripts,MAX_ARRAYDIM*sizeof(int));337 338 LocalVar[MaxLocalVarNum].type=psi-> pRealParmInfo[i3].type;335 LocalVar[MaxLocalVarNum].bArray=psi->realParams[i3].IsArray()?TRUE:FALSE; 336 memcpy(LocalVar[MaxLocalVarNum].SubScripts,psi->realParams[i3].GetSubScriptsPtr(),MAX_ARRAYDIM*sizeof(int)); 337 338 LocalVar[MaxLocalVarNum].type=psi->realParams[i3].GetBasicType(); 339 339 if(LocalVar[MaxLocalVarNum].type==DEF_OBJECT 340 340 ||LocalVar[MaxLocalVarNum].type==DEF_STRUCT){ … … 343 343 } 344 344 345 LocalVar[MaxLocalVarNum].u.index=psi-> pRealParmInfo[i3].u.index;346 347 if(psi-> pRealParmInfo[i3].bByVal&&psi->pRealParmInfo[i3].type==DEF_STRUCT){345 LocalVar[MaxLocalVarNum].u.index=psi->realParams[i3].GetIndex(); 346 347 if(psi->realParams[i3].IsRef() == false&&psi->realParams[i3].IsStruct()){ 348 348 //構造体のByValパラメータ 349 349 LocalVar[MaxLocalVarNum].fRef=REF_PARAMETER | OBJECT_PARAMETER; … … 351 351 } 352 352 else{ 353 if(psi-> pRealParmInfo[i3].bByVal&&psi->pRealParmInfo[i3].bArray==0){353 if(psi->realParams[i3].IsRef() == false&&psi->realParams[i3].IsArray()){ 354 354 LocalVar[MaxLocalVarNum].fRef=0; 355 355 VarSize=GetTypeSize(LocalVar[MaxLocalVarNum].type,LocalVar[MaxLocalVarNum].u.index); … … 383 383 384 384 //コンパイル中の関数 385 extern S UBINFO*pCompilingSubInfo;385 extern SubInfo *pCompilingSubInfo; 386 386 pCompilingSubInfo=psi; 387 387 … … 396 396 for(i3=psi->RealParmNum-1;i3>=0;i3--){ 397 397 if(i3==3){ 398 if( IsRealNumberType(psi->pRealParmInfo[i3].type)&&psi->pRealParmInfo[i3].bByVal){398 if(psi->realParams[i3].IsReal()&&psi->realParams[i3].IsRef() == false){ 399 399 //movsd qword ptr[rsp+0x20],xmm3 400 400 op_movsd_MR(REG_XMM3,REG_RSP,0x20,MOD_BASE_DISP32); … … 406 406 } 407 407 if(i3==2){ 408 if( IsRealNumberType(psi->pRealParmInfo[i3].type)&&psi->pRealParmInfo[i3].bByVal){408 if(psi->realParams[i3].IsReal()&&psi->realParams[i3].IsRef() == false){ 409 409 //movsd qword ptr[rsp+0x18],xmm2 410 410 op_movsd_MR(REG_XMM2,REG_RSP,0x18,MOD_BASE_DISP32); … … 416 416 } 417 417 if(i3==1){ 418 if( IsRealNumberType(psi->pRealParmInfo[i3].type)&&psi->pRealParmInfo[i3].bByVal){418 if(psi->realParams[i3].IsReal()&&psi->realParams[i3].IsRef() == false){ 419 419 //movsd qword ptr[rsp+0x10],xmm1 420 420 op_movsd_MR(REG_XMM1,REG_RSP,0x10,MOD_BASE_DISP32); … … 426 426 } 427 427 if(i3==0){ 428 if( IsRealNumberType(psi->pRealParmInfo[i3].type)&&psi->pRealParmInfo[i3].bByVal){428 if(psi->realParams[i3].IsReal()&&psi->realParams[i3].IsRef() == false){ 429 429 //movsd qword ptr[rsp+0x8],xmm0 430 430 op_movsd_MR(REG_XMM0,REG_RSP,0x8,MOD_BASE_DISP32); … … 497 497 498 498 //call _DebugSys_StartProc 499 extern S UBINFO*pSub_DebugSys_StartProc;499 extern SubInfo *pSub_DebugSys_StartProc; 500 500 op_call(pSub_DebugSys_StartProc); 501 501 } … … 720 720 if(bDebugCompile&&bDebugSupportProc==0){ 721 721 //call _DebugSys_EndProc 722 extern S UBINFO*pSub_DebugSys_EndProc;722 extern SubInfo *pSub_DebugSys_EndProc; 723 723 op_call(pSub_DebugSys_EndProc); 724 724 } … … 819 819 } 820 820 void CompileLocal(){ 821 extern S UBINFO**ppSubHash;821 extern SubInfo **ppSubHash; 822 822 int i2; 823 S UBINFO*psi;823 SubInfo *psi; 824 824 825 825 extern BOOL bDll; … … 835 835 //_System_InitStaticLocalVariablesは一番最後にコンパイル 836 836 //※一般関数内の静的変数オブジェクトをすべて収集しなければならない 837 extern S UBINFO*pSub_System_InitStaticLocalVariables;837 extern SubInfo *pSub_System_InitStaticLocalVariables; 838 838 pSub_System_InitStaticLocalVariables->bCompile=1; 839 839 840 840 //_System_Call_Destructor_of_GlobalObjectは一番最後にコンパイル 841 extern S UBINFO*pSub_System_Call_Destructor_of_GlobalObject;841 extern SubInfo *pSub_System_Call_Destructor_of_GlobalObject; 842 842 pSub_System_Call_Destructor_of_GlobalObject->bCompile=1; 843 843 -
BasicCompiler64/Compile_Set_Var.cpp
r66 r73 107 107 108 108 //call free 109 extern S UBINFO*pSub_free;109 extern SubInfo *pSub_free; 110 110 op_call(pSub_free); 111 111 } -
BasicCompiler64/Compile_Statement.cpp
r64 r73 5 5 int i,i2; 6 6 char buffer[8192]; 7 S UBINFO*psi;7 SubInfo *psi; 8 8 9 9 for(i=0;;i++){ … … 44 44 45 45 //GetSubHash内でエラー提示が行われた場合 46 if(psi==(S UBINFO*)-1) return;46 if(psi==(SubInfo *)-1) return; 47 47 48 48 if(psi==0){ … … 54 54 55 55 //GetSubHash内でエラー提示が行われた場合 56 if(psi==(S UBINFO*)-1) return;56 if(psi==(SubInfo *)-1) return; 57 57 } 58 58 … … 722 722 pobj_c=(CClass *)lpIndex; 723 723 724 std::vector<S UBINFO*> subs;724 std::vector<SubInfo *> subs; 725 725 pobj_c->EnumMethod( CALC_EQUAL, subs ); 726 726 if( subs.size() == 0 ){ … … 739 739 740 740 //オーバーロードを解決 741 S UBINFO*psi;741 SubInfo *psi; 742 742 psi=OverloadSolution("==",subs,ppi,iParmNum,NULL); 743 743 HeapDefaultFree(ppi); … … 883 883 884 884 //call _System_GetEip 885 extern S UBINFO*pSub_System_GetEip;885 extern SubInfo *pSub_System_GetEip; 886 886 op_call(pSub_System_GetEip); 887 887 … … 945 945 //戻り値をセット 946 946 if(Parameter[0]){ 947 extern S UBINFO*pCompilingSubInfo;947 extern SubInfo *pCompilingSubInfo; 948 948 char *temp; 949 949 if(pCompilingSubInfo->name[0]==1&&pCompilingSubInfo->name[1]==ESC_OPERATOR) … … 1075 1075 OpcodeCalc(temp2); 1076 1076 1077 S UBINFO*psi;1077 SubInfo *psi; 1078 1078 if(bFile) psi=GetSubHash("INPUT_FromFile"); 1079 1079 else psi=GetSubHash("INPUT_FromPrompt"); … … 1177 1177 OpcodeCalc(temp2); 1178 1178 1179 S UBINFO*psi;1179 SubInfo *psi; 1180 1180 if(bFile) psi=GetSubHash("PRINTUSING_ToFile"); 1181 1181 else psi=GetSubHash("PRINTUSING_ToPrompt"); … … 1281 1281 if(sw) lstrcat(buffer,"+Ex\"\\r\\n\""); 1282 1282 1283 S UBINFO*psi;1283 SubInfo *psi; 1284 1284 if(bFile) psi=GetSubHash("PRINT_ToFile"); 1285 1285 else psi=GetSubHash("PRINT_ToPrompt"); -
BasicCompiler64/Compile_Var.cpp
r69 r73 562 562 563 563 char temporary[VN_SIZE]; 564 extern S UBINFO*pCompilingSubInfo;564 extern SubInfo *pCompilingSubInfo; 565 565 if(pCompilingSubInfo){ 566 566 GetNowStaticVarFullName(VarName,temporary); -
BasicCompiler64/MakePeHdr.cpp
r67 r73 6 6 // 特殊関数の構造体ポインタ 7 7 //////////////////////////// 8 S UBINFO8 SubInfo 9 9 *pSub_System_StartupProgram, 10 10 *pSub_DebugSys_StartProc, … … 352 352 353 353 //call _System_Call_Destructor_of_GlobalObject 354 extern S UBINFO*pSub_System_Call_Destructor_of_GlobalObject;354 extern SubInfo *pSub_System_Call_Destructor_of_GlobalObject; 355 355 op_call(pSub_System_Call_Destructor_of_GlobalObject); 356 356 … … 500 500 ExportNamesLength=lstrlen(lpExportNames)+1; 501 501 502 extern S UBINFO**ppSubHash;503 S UBINFO*psi,*psi2;502 extern SubInfo **ppSubHash; 503 SubInfo *psi,*psi2; 504 504 while(1){ 505 505 //辞書順にサーチ -
BasicCompiler64/NumOpe_Arithmetic.cpp
r64 r73 559 559 560 560 //call pow 561 extern S UBINFO*pSub_pow;561 extern SubInfo *pSub_pow; 562 562 op_call(pSub_pow); 563 563 -
BasicCompiler64/Opcode.h
r71 r73 350 350 351 351 private: 352 BOOL _overload_check( PARAMETER_INFO *ppi,int pi_num,TYPEINFO *pReturnTypeInfo,int overload_level);353 S UBINFO *OverloadSolutionWithReturnType( const char *name, std::vector<SUBINFO*> &subs );352 BOOL _overload_check( Parameters ¶ms, TYPEINFO *pReturnTypeInfo,int overload_level); 353 SubInfo *OverloadSolutionWithReturnType( const char *name, std::vector<SubInfo *> &subs ); 354 354 public: 355 S UBINFO *OverloadSolution( const char *name, std::vector<SUBINFO*> &subs );355 SubInfo *OverloadSolution( const char *name, std::vector<SubInfo *> &subs ); 356 356 357 357 BOOL ErrorCheck(const char *FuncName,PARAMETER_INFO *ppi,int pi_num,int SecondParmNum); … … 385 385 #define PROCFLAG_NEW 1 386 386 int Opcode_CallProcPtr(char *variable,char *Parameter,PROCPTRINFO *pi,LONG_PTR *plpIndex); 387 void Opcode_CallProc(const char *Parameter,S UBINFO*psi,DWORD dwFlags,char *ObjectName,int RefType);387 void Opcode_CallProc(const char *Parameter,SubInfo *psi,DWORD dwFlags,char *ObjectName,int RefType); 388 388 int Opcode_CallDllProc(char *Parameter,DECLAREINFO *pdi,LONG_PTR *plpIndex); 389 389 … … 512 512 void op_fld_ptr_esp(int type); 513 513 void op_zero_reg(int reg); 514 void op_call( S UBINFO*psi );514 void op_call( SubInfo *psi ); 515 515 void op_call( DECLAREINFO *pdi ); -
BasicCompiler64/OperatorProc.cpp
r64 r73 23 23 24 24 //call free 25 extern S UBINFO*pSub_free;25 extern SubInfo *pSub_free; 26 26 op_call(pSub_free); 27 27 } … … 32 32 pobj_c=(CClass *)index_stack[sp-2]; 33 33 34 std::vector<S UBINFO*> subs;34 std::vector<SubInfo *> subs; 35 35 pobj_c->EnumMethod( idCalc, subs ); 36 36 if( subs.size() == 0 ){ … … 84 84 if(idCalc==CALC_EQUAL) lstrcpy(temporary,"=="); 85 85 else GetCalcName(idCalc,temporary); 86 S UBINFO*psi;86 SubInfo *psi; 87 87 psi=OverloadSolution(temporary,subs,ppi,iParmNum,pBaseTypeInfo); 88 88 … … 94 94 else{ 95 95 //オーバーロードされていないが、パラメータ個数が一致しないとき 96 if(iParmNum!=psi-> ParmNum){96 if(iParmNum!=psi->params.size()){ 97 97 HeapDefaultFree(ppi); 98 98 return -1; … … 102 102 for(i=0;i<iParmNum;i++){ 103 103 CheckDifferentType( 104 psi->p ParmInfo[i].type,105 psi->p ParmInfo[i].u.index,104 psi->params[i]->GetBasicType(), 105 psi->params[i]->GetIndex(), 106 106 ppi[i].type, 107 107 ppi[i].u.index, … … 113 113 114 114 if(bTwoTerm){ 115 if( psi->pRealParmInfo[1].type==DEF_STRUCT&&psi->pRealParmInfo[1].bByVal){115 if( psi->realParams[1]->IsStruct() && psi->realParams[1]->IsRef() == false ){ 116 116 //一時オブジェクトはメソッド内で破棄される 117 117 bUseHeap[sp-1]=0; … … 137 137 138 138 //call calloc 139 extern S UBINFO*pSub_calloc;139 extern SubInfo *pSub_calloc; 140 140 op_call(pSub_calloc); 141 141 … … 154 154 SetOneTermToReg_Whole64Calc(type[sp-1],®2); 155 155 pobj_reg->UnlockReg(); 156 if( !psi-> pRealParmInfo[1].bByVal){156 if( !psi->realParams[1]->IsRef() == false ){ 157 157 //一時参照を作成 158 158 pobj_sf->push( reg2 ); … … 253 253 254 254 if(bTwoTerm){ 255 if( !psi-> pRealParmInfo[1].bByVal){255 if( !psi->realParams[1]->IsRef() == false ){ 256 256 //一時参照を破棄 257 257 pobj_sf->pop(); … … 341 341 void CallIndexerGetterProc(int reg,CClass *pobj_Class,char *ObjectName,char *Parameter,TYPEINFO &RetTypeInfo){ 342 342 343 std::vector<S UBINFO*> subs;343 std::vector<SubInfo *> subs; 344 344 pobj_Class->EnumMethod( CALC_ARRAY_GET, subs ); 345 345 if( subs.size() == 0 ){ -
BasicCompiler64/WatchList.cpp
r64 r73 309 309 ULONG_PTR Debugging_GetThisPtrOffset(LONG_PTR obp_Rip){ 310 310 int i; 311 S UBINFO*psi;311 SubInfo *psi; 312 312 313 313 //ripからプロシージャを取得 -
BasicCompiler64/amd64_main.cpp
r64 r73 1791 1791 ///////////////////////////// 1792 1792 1793 void op_call( S UBINFO*psi ){1793 void op_call( SubInfo *psi ){ 1794 1794 OpBuffer[obp++] = (char)0xE8; 1795 1795 pobj_SubAddrSchedule->add( psi, 1 ); -
BasicCompiler64/varlist.cpp
r69 r73 354 354 if(pobj_dti->lplpSpBase[i2]==0) return; 355 355 356 extern S UBINFO**ppSubHash;357 S UBINFO*psi;356 extern SubInfo **ppSubHash; 357 SubInfo *psi; 358 358 for(i3=0,sw=0;i3<MAX_HASH;i3++){ 359 359 psi=ppSubHash[i3]; … … 586 586 587 587 //プロシージャ コンボボックス 588 extern S UBINFO**ppSubHash;589 S UBINFO*psi;588 extern SubInfo **ppSubHash; 589 SubInfo *psi; 590 590 int sw; 591 591 SendMessage(hProcCombo,CB_RESETCONTENT,0,0); … … 709 709 710 710 if(pobj_dti->lplpSpBase[i2]){ 711 extern S UBINFO**ppSubHash;712 S UBINFO*psi;711 extern SubInfo **ppSubHash; 712 SubInfo *psi; 713 713 for(i3=0,sw=0;i3<MAX_HASH;i3++){ 714 714 psi=ppSubHash[i3]; -
BasicCompiler_Common/BasicCompiler.h
r69 r73 24 24 DWORD ImageBase; 25 25 INCLUDEFILEINFO IncludeFileInfo; 26 S UBINFO**ppSubHash;26 SubInfo **ppSubHash; 27 27 int SubNum; 28 28 char **ppMacroNames; -
BasicCompiler_Common/Class.cpp
r71 r73 267 267 staticMembers.push_back( member ); 268 268 } 269 void CClass::AddMethod( S UBINFO*psi,DWORD dwAccess, bool isConst, BOOL bAbstract, BOOL bVirtual ){269 void CClass::AddMethod( SubInfo *psi,DWORD dwAccess, bool isConst, BOOL bAbstract, BOOL bVirtual ){ 270 270 CMethod *method = new CMethod(); 271 271 method->psi = psi; … … 278 278 methods.push_back( method ); 279 279 } 280 void CClass::AddStaticMethod(S UBINFO*psi,DWORD dwAccess){280 void CClass::AddStaticMethod(SubInfo *psi,DWORD dwAccess){ 281 281 CMethod *method = new CMethod(); 282 282 method->psi=psi; … … 322 322 return 0; 323 323 } 324 CMethod *CClass::GetMethodInfo( S UBINFO*psi ){324 CMethod *CClass::GetMethodInfo( SubInfo *psi ){ 325 325 for( int i=(int)methods.size()-1; i>=0; i-- ){ 326 326 if( psi == methods[i]->psi ) return methods[i]; … … 328 328 return NULL; 329 329 } 330 CMethod *CClass::GetStaticMethodInfo( S UBINFO*psi ){330 CMethod *CClass::GetStaticMethodInfo( SubInfo *psi ){ 331 331 for( int i=(int)staticMethods.size()-1; i>=0; i-- ){ 332 332 if( psi == staticMethods[i]->psi ) return staticMethods[i]; … … 347 347 } 348 348 349 void CClass::EnumStaticMethod( const char *methodName, std::vector<S UBINFO*> &subs ) const349 void CClass::EnumStaticMethod( const char *methodName, std::vector<SubInfo *> &subs ) const 350 350 { 351 351 foreach( CMethod *method, staticMethods ){ … … 356 356 } 357 357 358 void CClass::EnumMethod( const char *methodName, std::vector<S UBINFO*> &subs ) const358 void CClass::EnumMethod( const char *methodName, std::vector<SubInfo *> &subs ) const 359 359 { 360 360 //オブジェクトのメンバ関数の場合 … … 367 367 } 368 368 369 void CClass::EnumMethod( const BYTE idOperatorCalc, std::vector<S UBINFO*> &subs ) const369 void CClass::EnumMethod( const BYTE idOperatorCalc, std::vector<SubInfo *> &subs ) const 370 370 { 371 371 //オブジェクトのメンバ関数の場合 372 372 //※オーバーライドされた関数を先にサーチする必要があるため、バックサーチを行う 373 373 for( int i=(int)methods.size()-1; i>=0; i-- ){ 374 S UBINFO*psi = methods[i]->psi;374 SubInfo *psi = methods[i]->psi; 375 375 char *temp = psi->name; 376 376 if(temp[0]==1&&temp[1]==ESC_OPERATOR){ … … 508 508 509 509 510 int CClass::GetFuncNumInVtbl( const S UBINFO*psi ) const510 int CClass::GetFuncNumInVtbl( const SubInfo *psi ) const 511 511 { 512 512 int n = 0; … … 527 527 ////////////////////////////////////// 528 528 529 S UBINFO**ppsi;530 ppsi=(S UBINFO **)HeapAlloc(hHeap,0,vtbl_num*sizeof(SUBINFO*));529 SubInfo **ppsi; 530 ppsi=(SubInfo **)HeapAlloc(hHeap,0,vtbl_num*sizeof(SubInfo *)); 531 531 532 532 //関数テーブルに値をセット … … 565 565 int i; 566 566 for(i=0;i<vtbl_num;i++){ 567 S UBINFO*psi;568 psi=(S UBINFO*)pVtbl[i];567 SubInfo *psi; 568 psi=(SubInfo *)pVtbl[i]; 569 569 if(!psi) continue; 570 570 pVtbl[i]=psi->CompileAddress+ImageBase+MemPos_CodeSection; … … 835 835 836 836 //関数ハッシュへ登録 837 S UBINFO*psi;837 SubInfo *psi; 838 838 psi=AddSubData(buffer,NowLine,bVirtual,pobj_c,bStatic); 839 839 if(!psi) return; … … 849 849 850 850 //標準コンストラクタ(引数なし) 851 if(psi-> ParmNum==0) fConstructor=1;851 if(psi->params.size()==0) fConstructor=1; 852 852 853 853 //強制的にConst修飾子をつける … … 894 894 895 895 if(lstrcmp(temporary,method->psi->name)==0){ 896 if(CompareParameter( 897 method->psi->pParmInfo,method->psi->ParmNum, 898 psi->pParmInfo,psi->ParmNum 899 )==0){ 896 if( Parameter::Equals( method->psi->params, psi->params ) ){ 900 897 //関数名、パラメータ属性が合致したとき 901 898 SetError(15,psi->name,NowLine); … … 911 908 foreach( CMethod *method, pobj_c->methods ){ 912 909 if(lstrcmp(temporary,method->psi->name)==0){ 913 if(CompareParameter( 914 method->psi->pParmInfo,method->psi->ParmNum, 915 psi->pParmInfo,psi->ParmNum 916 )==0){ 910 if( Parameter::Equals( method->psi->params, psi->params ) ){ 917 911 918 912 if(method->psi->bVirtual){ … … 1444 1438 } 1445 1439 1446 void CDBClass::StartCompile( S UBINFO*psi ){1440 void CDBClass::StartCompile( SubInfo *psi ){ 1447 1441 pCompilingClass = psi->pobj_ParentClass; 1448 1442 if( pCompilingClass ){ -
BasicCompiler_Common/Class.h
r71 r73 2 2 3 3 class CClass; 4 struct SUBINFO;4 class SubInfo; 5 5 6 6 //データ型 … … 48 48 class CMethod{ 49 49 public: 50 S UBINFO*psi;50 SubInfo *psi; 51 51 DWORD dwAccess; 52 52 BOOL bAbstract; … … 116 116 void AddMember( DWORD dwAccess, bool idConst, bool isRef, char *buffer ); 117 117 void AddStaticMember( DWORD dwAccess, bool isConst, bool isRef, char *buffer, int NowLine ); 118 void AddMethod( S UBINFO*psi,DWORD dwAccess, bool isConst, BOOL bAbstract, BOOL bVirtual );119 void AddStaticMethod(S UBINFO*psi,DWORD dwAccess);118 void AddMethod( SubInfo *psi,DWORD dwAccess, bool isConst, BOOL bAbstract, BOOL bVirtual ); 119 void AddStaticMethod(SubInfo *psi,DWORD dwAccess); 120 120 121 121 //重複チェック … … 124 124 125 125 //メソッド取得 126 CMethod *GetMethodInfo( S UBINFO*psi );127 CMethod *GetStaticMethodInfo( S UBINFO*psi );126 CMethod *GetMethodInfo( SubInfo *psi ); 127 CMethod *GetStaticMethodInfo( SubInfo *psi ); 128 128 129 129 //メソッドの存在を確認 … … 132 132 133 133 //メソッドを列挙 134 void EnumStaticMethod( const char *methodName, std::vector<S UBINFO*> &subs ) const;135 void EnumMethod( const char *methodName, std::vector<S UBINFO*> &subs ) const;136 void EnumMethod( const BYTE idOperatorCalc, std::vector<S UBINFO*> &subs ) const;134 void EnumStaticMethod( const char *methodName, std::vector<SubInfo *> &subs ) const; 135 void EnumMethod( const char *methodName, std::vector<SubInfo *> &subs ) const; 136 void EnumMethod( const BYTE idOperatorCalc, std::vector<SubInfo *> &subs ) const; 137 137 138 138 //デフォルト コンストラクタ メソッドを取得 … … 157 157 long vtbl_offset; 158 158 public: 159 int GetFuncNumInVtbl( const S UBINFO*psi ) const;159 int GetFuncNumInVtbl( const SubInfo *psi ) const; 160 160 LONG_PTR GetVtblGlobalOffset(void); 161 161 void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection); … … 245 245 public: 246 246 //コンパイル開始の通知を受け取るメソッド 247 void StartCompile( S UBINFO*psi );247 void StartCompile( SubInfo *psi ); 248 248 249 249 //現在コンパイル中のメソッド情報を取得 -
BasicCompiler_Common/Debug.cpp
r4 r73 224 224 SendDlgItemMessage(hMainDlg,IDC_DEBUGLIST,EM_REPLACESEL,0,(LPARAM)buffer); 225 225 } 226 S UBINFO*GetSubFromObp(ULONG_PTR pos){227 extern S UBINFO**ppSubHash;228 S UBINFO*psi;226 SubInfo *GetSubFromObp(ULONG_PTR pos){ 227 extern SubInfo **ppSubHash; 228 SubInfo *psi; 229 229 int i2; 230 230 … … 447 447 pobj_dti=new CDebugThreadInfo(); 448 448 449 S UBINFO*psi;449 SubInfo *psi; 450 450 451 451 extern DWORD dwStepRun; … … 681 681 if(!bRet) MessageBox(hMainDlg,"プロセスメモリーの読み込みに失敗","error",MB_OK); 682 682 683 extern S UBINFO*pSub_DebugSys_EndProc;683 extern SubInfo *pSub_DebugSys_EndProc; 684 684 if((BYTE)temporary[0]==0xE8&& 685 685 *((long *)(temporary+1))+5==(long)rva_to_real(pSub_DebugSys_EndProc->CompileAddress)-(long)EIP_RIP(Context)){ -
BasicCompiler_Common/DebugMiddleFile.cpp
r64 r73 213 213 214 214 //プロシージャ情報 215 extern S UBINFO**ppSubHash;215 extern SubInfo **ppSubHash; 216 216 extern int SubNum; 217 S UBINFO*psi;217 SubInfo *psi; 218 218 *(long *)(buffer+i2)=SubNum; 219 219 i2+=sizeof(long); … … 585 585 586 586 //プロシージャ情報 587 S UBINFO*psi;587 SubInfo *psi; 588 588 SubNum=*(long *)(buffer+i2); 589 589 i2+=sizeof(long); 590 ppSubHash=(S UBINFO **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(SUBINFO*));590 ppSubHash=(SubInfo **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(SubInfo *)); 591 591 for(i3=0;i3<SubNum;i3++){ 592 psi =(SUBINFO *)HeapAlloc(hHeap,0,sizeof(SUBINFO));592 psi = new SubInfo(); 593 593 psi->pNextData=0; 594 594 … … 618 618 i2+=sizeof(long); 619 619 620 psi->ParmNum=0;621 psi->pParmInfo=0;622 psi->RealParmNum=0;623 psi->pRealParmInfo=0;624 620 psi->bCompile=1; 625 621 … … 677 673 i4=hash_default(psi->name); 678 674 679 S UBINFO*psi2;675 SubInfo *psi2; 680 676 if(ppSubHash[i4]){ 681 677 psi2=ppSubHash[i4]; … … 804 800 805 801 806 extern S UBINFO**ppSubHash;802 extern SubInfo **ppSubHash; 807 803 ppSubHash=this->ppSubHash; 808 804 pSub_DebugSys_EndProc=GetSubHash("_DebugSys_EndProc"); … … 973 969 extern char **ppMacroNames; 974 970 ppMacroNames=0; 975 extern S UBINFO**ppSubHash;971 extern SubInfo **ppSubHash; 976 972 extern int SubNum; 977 973 ppSubHash=this->ppSubHash; 978 974 SubNum=this->SubNum; 979 975 980 extern S UBINFO*pSub_DebugSys_EndProc;976 extern SubInfo *pSub_DebugSys_EndProc; 981 977 pSub_DebugSys_EndProc=this->pSub_DebugSys_EndProc; 982 978 … … 998 994 999 995 //ローカル変数に関する情報を解放 1000 S UBINFO*psi;996 SubInfo *psi; 1001 997 for(i2=0;i2<MAX_HASH;i2++){ 1002 998 psi=ppSubHash[i2]; -
BasicCompiler_Common/DebugSection.h
r15 r73 49 49 50 50 //プロシージャ 51 S UBINFO**ppSubHash;51 SubInfo **ppSubHash; 52 52 int SubNum; 53 53 54 S UBINFO*pSub_DebugSys_EndProc;54 SubInfo *pSub_DebugSys_EndProc; 55 55 56 56 //ネイティブコードバッファ -
BasicCompiler_Common/LexicalScoping.cpp
r64 r73 226 226 227 227 //call free 228 extern S UBINFO*pSub_free;228 extern SubInfo *pSub_free; 229 229 op_call(pSub_free); 230 230 -
BasicCompiler_Common/MakeExe.cpp
r15 r73 223 223 224 224 //ローカル変数に関する情報を解放 225 extern S UBINFO**ppSubHash;226 S UBINFO*psi;225 extern SubInfo **ppSubHash; 226 SubInfo *psi; 227 227 for(i2=0;i2<MAX_HASH;i2++){ 228 228 psi=ppSubHash[i2]; … … 238 238 239 239 //サブルーチン(ユーザー定義)情報のメモリ解放 240 extern S UBINFO**ppSubHash;240 extern SubInfo **ppSubHash; 241 241 extern char **ppMacroNames; 242 242 extern int MacroNum; -
BasicCompiler_Common/NumOpe_GetType.cpp
r69 r73 193 193 pobj_c=(CClass *)index_stack[sp-2]; 194 194 195 std::vector<S UBINFO*> subs;195 std::vector<SubInfo *> subs; 196 196 pobj_c->EnumMethod( idCalc, subs ); 197 197 if( subs.size() == 0 ){ … … 230 230 if(idCalc==CALC_EQUAL) lstrcpy(temporary,"=="); 231 231 else GetCalcName(idCalc,temporary); 232 S UBINFO*psi;232 SubInfo *psi; 233 233 psi=OverloadSolution(temporary,subs,ppi,iParmNum,pBaseTypeInfo); 234 234 … … 240 240 else{ 241 241 //オーバーロードされていないが、パラメータ個数が一致しないとき 242 if(iParmNum!=psi-> ParmNum){242 if(iParmNum!=psi->params.size()){ 243 243 HeapDefaultFree(ppi); 244 244 return 0; … … 299 299 } 300 300 301 int NumOpe_GetType (char *Command,TYPEINFO *pBaseType,LONG_PTR *plpIndex){301 int NumOpe_GetType_Old( const char *Command,TYPEINFO *pBaseType,LONG_PTR *plpIndex){ 302 302 extern int cp; 303 303 int i,i2,i3,i4; … … 454 454 455 455 //マクロ関数の場合 456 i2=NumOpe_GetType (temp3,NULL,&index_stack[sp]);456 i2=NumOpe_GetType_Old(temp3,NULL,&index_stack[sp]); 457 457 458 458 if(!IS_LITERAL(index_stack[sp])){ … … 740 740 return RetType; 741 741 } 742 743 bool NumOpe_GetType( const char *expression, const Type &baseType, Type &resultType ){ 744 TYPEINFO baseTypeInfo = { 745 baseType.GetBasicType(), 746 baseType.GetIndex() 747 }; 748 LONG_PTR lpIndex; 749 int basicType = NumOpe_GetType_Old( expression, 750 baseType.IsNull() ? NULL:&baseTypeInfo, 751 &lpIndex ); 752 753 resultType.SetBasicType( basicType ); 754 resultType.SetIndex( lpIndex ); 755 756 return ( basicType != -1 ); 757 } -
BasicCompiler_Common/Object.cpp
r63 r73 19 19 pobj_c=(CClass *)TypeInfo.u.lpIndex; 20 20 21 S UBINFO*psi;21 SubInfo *psi; 22 22 psi=GetMethodHash(ObjectName,pobj_c->name,Parameter); 23 23 if(!psi){ -
BasicCompiler_Common/Overload.cpp
r71 r73 7 7 #endif 8 8 9 S UBINFO*OverloadSolutionWithStrParam(9 SubInfo *OverloadSolutionWithStrParam( 10 10 const char *name, 11 std::vector<S UBINFO*> &subs,11 std::vector<SubInfo *> &subs, 12 12 const char *Parameter, 13 13 const char *ObjectName, … … 37 37 */ 38 38 //パラメータオブジェクトを生成 39 if(lstrcmp(Parameter,"\"test\"")==0){ 40 int i=0; 41 } 39 42 pobj_parameter=new ParamImpl(Parameter); 40 43 if(pReturnTypeInfo) pobj_parameter->SetReturnType(pReturnTypeInfo); 41 44 42 45 43 S UBINFO*psi;46 SubInfo *psi; 44 47 psi=pobj_parameter->OverloadSolution(name,subs); 45 48 … … 52 55 } 53 56 54 S UBINFO*OverloadSolution(57 SubInfo *OverloadSolution( 55 58 const char *name, 56 std::vector<S UBINFO*> &subs,59 std::vector<SubInfo *> &subs, 57 60 const PARAMETER_INFO *ppi, 58 61 const int ParmNum, … … 68 71 if(pReturnTypeInfo) pobj_Parameter->SetReturnType(pReturnTypeInfo); 69 72 70 S UBINFO*psi;73 SubInfo *psi; 71 74 psi=pobj_Parameter->OverloadSolution(name,subs); 72 75 -
BasicCompiler_Common/PESchedule.cpp
r44 r73 220 220 221 221 CSubAddrSchedule::CSubAddrSchedule(){ 222 ppsi=(S UBINFO**)HeapAlloc(hHeap,0,1);222 ppsi=(SubInfo **)HeapAlloc(hHeap,0,1); 223 223 pbCall=(BOOL *)HeapAlloc(hHeap,0,1); 224 224 } … … 228 228 } 229 229 230 void CSubAddrSchedule::add(S UBINFO*psi,BOOL bCall){230 void CSubAddrSchedule::add(SubInfo *psi,BOOL bCall){ 231 231 if(!psi) return; 232 232 233 ppsi=(S UBINFO **)HeapReAlloc(hHeap,0,ppsi,(num+1)*sizeof(SUBINFO*));233 ppsi=(SubInfo **)HeapReAlloc(hHeap,0,ppsi,(num+1)*sizeof(SubInfo *)); 234 234 ppsi[num]=psi; 235 235 pbCall=(BOOL *)HeapReAlloc(hHeap,0,pbCall,(num+1)*sizeof(BOOL)); … … 282 282 CTempSchedule *pobj_TempSchedule; 283 283 284 -
BasicCompiler_Common/PESchedule.h
r34 r73 79 79 class CSubAddrSchedule:public CSchedule{ 80 80 public: 81 S UBINFO**ppsi;81 SubInfo **ppsi; 82 82 BOOL *pbCall; 83 83 … … 85 85 ~CSubAddrSchedule(); 86 86 87 void add(S UBINFO*psi,BOOL bCall);87 void add(SubInfo *psi,BOOL bCall); 88 88 }; 89 89 extern CSubAddrSchedule *pobj_SubAddrSchedule; -
BasicCompiler_Common/ParamImpl.cpp
r71 r73 73 73 ReturnTypeInfo.u.lpIndex=-1; 74 74 } 75 ParamImpl::ParamImpl(const Parameters ¶ms){ 76 int count = 0; 77 foreach( Parameter *pParam, params ){ 78 types[count].type = pParam->GetBasicType(); 79 types[count].u.lpIndex = pParam->GetIndex(); 80 count++; 81 } 82 this->ParmsNum=params.size(); 83 84 ReturnTypeInfo.type=DEF_NON; 85 ReturnTypeInfo.u.lpIndex=-1; 86 } 75 87 ParamImpl::~ParamImpl(){ 76 88 int i2; … … 88 100 } 89 101 90 BOOL ParamImpl::_overload_check( PARAMETER_INFO *ppi,int pi_num,TYPEINFO *pReturnTypeInfo,int overload_level){102 BOOL ParamImpl::_overload_check( Parameters ¶ms,TYPEINFO *pReturnTypeInfo,int overload_level){ 91 103 //パラメータを識別してオーバーロードを解決 92 104 93 105 //パラメータの個数が不一致の場合 94 if(pi_num!=ParmsNum) return 0; 95 96 int i,type; 97 LONG_PTR lpIndex; 98 for(i=0;i<pi_num;i++){ 106 int max = (int)params.size(); 107 if(max!=ParmsNum) return 0; 108 109 Type argType; 110 for(int i=0;i<max;i++){ 111 Parameter ¶m = *params[i]; 112 99 113 if(Parms[i]){ 100 TYPEINFO BaseType={ppi[i].type,ppi[i].u.index}; 101 type=NumOpe_GetType(Parms[i], 102 (overload_level==OVERLOAD_LEVEL0) ? NULL : &BaseType, 103 &lpIndex); 114 Type nullParam( DEF_NON ); 115 116 NumOpe_GetType(Parms[i], 117 (overload_level==OVERLOAD_LEVEL0)? nullParam : param, 118 argType); 104 119 } 105 120 else{ 106 type=types[i].type; 107 lpIndex=types[i].u.lpIndex; 108 } 109 110 if(type!=ppi[i].type){ 121 argType.SetType( types[i].type, types[i].u.lpIndex ); 122 } 123 124 if(argType.GetBasicType()!=param.GetBasicType()){ 111 125 if(overload_level==OVERLOAD_LEVEL1 || overload_level == OVERLOAD_LEVEL0){ 112 126 return 0; … … 114 128 else if(overload_level==OVERLOAD_LEVEL2){ 115 129 if(!( 116 IsWholeNumberType( type)&&IsWholeNumberType(ppi[i].type)||117 IsRealNumberType( type)&&IsRealNumberType(ppi[i].type)130 IsWholeNumberType(argType.GetBasicType())&&IsWholeNumberType(param.GetBasicType())|| 131 IsRealNumberType(argType.GetBasicType())&&IsRealNumberType(param.GetBasicType()) 118 132 )) return 0; 119 133 } 120 134 else if(overload_level==OVERLOAD_LEVEL3){ 121 if( type==DEF_OBJECT||ppi[i].type==DEF_OBJECT) return 0;135 if(argType.GetBasicType()==DEF_OBJECT||param.GetBasicType()==DEF_OBJECT) return 0; 122 136 } 123 137 } 124 138 else{ 125 if(NATURAL_TYPE( type)==DEF_OBJECT || NATURAL_TYPE(type)==DEF_STRUCT){126 if( lpIndex!=ppi[i].u.index) return 0;139 if(NATURAL_TYPE(argType.GetBasicType())==DEF_OBJECT || NATURAL_TYPE(argType.GetBasicType())==DEF_STRUCT){ 140 if(argType.GetIndex()!=param.GetIndex()) return 0; 127 141 } 128 142 } … … 143 157 } 144 158 145 S UBINFO *ParamImpl::OverloadSolutionWithReturnType( const char *name, std::vector<SUBINFO*> &subs ){159 SubInfo *ParamImpl::OverloadSolutionWithReturnType( const char *name, std::vector<SubInfo *> &subs ){ 146 160 int sw=0; 147 S UBINFO*psi;161 SubInfo *psi; 148 162 psi=0; 149 163 150 164 for( int level=OVERLOAD_MIN_LEVEL; level<=OVERLOAD_MAX_LEVEL; level++ ){ 151 foreach( S UBINFO*temp_psi, subs ){165 foreach( SubInfo *temp_psi, subs ){ 152 166 153 167 TYPEINFO ReturnTypeInfo; … … 156 170 157 171 //エラーチェック 158 if(_overload_check(temp_psi->p ParmInfo,temp_psi->ParmNum,&ReturnTypeInfo,level)){172 if(_overload_check(temp_psi->params,&ReturnTypeInfo,level)){ 159 173 if(sw){ 160 174 SetError(52,name,cp); … … 178 192 return psi; 179 193 } 180 S UBINFO *ParamImpl::OverloadSolution( const char *name, std::vector<SUBINFO*> &subs ){194 SubInfo *ParamImpl::OverloadSolution( const char *name, std::vector<SubInfo *> &subs ){ 181 195 int sw=0; 182 S UBINFO*psi;196 SubInfo *psi; 183 197 psi=0; 184 198 185 199 for( int level=OVERLOAD_MIN_LEVEL; level<=OVERLOAD_MAX_LEVEL; level++ ){ 186 200 187 foreach( S UBINFO*temp_psi, subs ){201 foreach( SubInfo *temp_psi, subs ){ 188 202 189 203 //エラーチェック 190 if(_overload_check(temp_psi->p ParmInfo,temp_psi->ParmNum,NULL,level)){204 if(_overload_check(temp_psi->params,NULL,level)){ 191 205 if(sw){ 192 206 return OverloadSolutionWithReturnType(name,subs); … … 202 216 203 217 if(!sw){ 204 S UBINFO*temp_psi;218 SubInfo *temp_psi; 205 219 foreach( temp_psi, subs ){ 206 220 207 221 //エラーチェック 208 if(temp_psi-> ParmNum==this->ParmsNum){222 if(temp_psi->params.size()==this->ParmsNum){ 209 223 if(sw){ 210 224 sw=0; … … 258 272 return 1; 259 273 } 274 bool ParamImpl::ErrorCheck( const char *procName, const Parameters ¶ms, int SecondParmNum ){ 275 if(ParmsNum>(int)params.size()){ 276 if(params[params.size()-1]->GetBasicType()!=DEF_ELLIPSE){ 277 //パラメータが多すぎるとき 278 SetError(10,procName,cp); 279 return false; 280 } 281 } 282 else if(ParmsNum<(int)params.size()){ 283 if(ParmsNum<SecondParmNum){ 284 if(params[ParmsNum]->GetBasicType()==DEF_ELLIPSE){ 285 return true; 286 } 287 288 //パラメータが少なすぎるとき 289 SetError(10,procName,cp); 290 return false; 291 } 292 293 //省略パラメータに "0" を指定する 294 for(;ParmsNum < (int)params.size();ParmsNum++){ 295 extern HANDLE hHeap; 296 char temporary[64]; 297 if(params[ParmsNum]->IsRef() == false) lstrcpy(temporary,"0"); 298 else sprintf(temporary,"%c%c0",1,ESC_BYVAL); 299 Parms[ParmsNum]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1); 300 lstrcpy(Parms[ParmsNum],temporary); 301 } 302 } 303 304 return true; 305 } 260 306 261 307 void ParamImpl::MacroParameterSupport(PARAMETER_INFO *ppi){ 262 int i; 263 for(i=0;i<ParmsNum;i++){ 308 for(int i=0;i<ParmsNum;i++){ 264 309 if(Parms[i][0]=='\0'){ 265 310 extern HANDLE hHeap; … … 273 318 } 274 319 } 320 void ParamImpl::MacroParameterSupport( const Parameters ¶ms ){ 321 for(int i=0;i<ParmsNum;i++){ 322 if(Parms[i][0]=='\0'){ 323 extern HANDLE hHeap; 324 char temporary[64]; 325 if( params[i]->IsRef() == false ) lstrcpy(temporary,"0"); 326 else sprintf(temporary,"%c%c0",1,ESC_BYVAL); 327 HeapDefaultFree(Parms[i]); 328 Parms[i]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1); 329 lstrcpy(Parms[i],temporary); 330 } 331 } 332 } -
BasicCompiler_Common/Parameter.h
r71 r73 5 5 6 6 class Parameter; 7 typedef vector<Parameter > Parameters;7 typedef vector<Parameter *> Parameters; 8 8 9 9 class Parameter : public Type … … 16 16 public: 17 17 Parameter( const string &varName, const Type &type, bool isRef = false ): 18 Type( type ) 18 Type( type ), 19 varName( varName ), 20 isRef( isRef ), 21 isArray( false ) 19 22 { 20 this->varName = varName; 21 this->isRef = isRef; 22 isArray = false; 23 subScripts[0] = -1; 24 } 25 Parameter( const Parameter ¶m ): 26 Type( param ), 27 varName( param.varName ), 28 isRef( param.isRef ), 29 isArray( false ) 30 { 31 subScripts[0] = -1; 32 if( param.isArray ){ 33 SetArray( param.subScripts ); 34 } 23 35 } 24 36 ~Parameter(){} … … 27 39 isArray = true; 28 40 memcpy( this->subScripts, pSubScripts, sizeof(int) * MAX_ARRAYDIM ); 41 } 42 43 const string &GetVarName() const 44 { 45 return varName; 29 46 } 30 47 … … 46 63 else{ 47 64 48 if( this->isRef && this-> BasicType() == DEF_ANY &&65 if( this->isRef && this->GetBasicType() == DEF_ANY && 49 66 param.isRef == false && param.IsPointer() 50 67 || 51 68 this->isRef == false && this->IsPointer() && 52 param.isRef && param. BasicType() == DEF_ANY ){69 param.isRef && param.GetBasicType() == DEF_ANY ){ 53 70 /* ByRef var As Any 54 71 と … … 71 88 int max = (int)paramsA.size(); 72 89 for( int i=0; i<max; i++ ){ 73 if( !paramsA[i] .Equals(paramsB[i] ) ){90 if( !paramsA[i]->Equals( *paramsB[i] ) ){ 74 91 return false; 75 92 } -
BasicCompiler_Common/Subroutine.cpp
r69 r73 8 8 9 9 //コンパイル中の関数情報 10 S UBINFO*pCompilingSubInfo;10 SubInfo *pCompilingSubInfo; 11 11 12 12 int GetCallProcName(char *buffer,char *name){ … … 114 114 ///////////////////// 115 115 116 S UBINFO *psi;117 p si=(SUBINFO*)pInfo;116 SubInfo *pSub; 117 pSub=(SubInfo *)pInfo; 118 118 119 119 //GetSubHash内でエラー提示が行われた場合 120 if(p si==(SUBINFO*)-1) return -1;120 if(pSub==(SubInfo *)-1) return -1; 121 121 122 122 … … 131 131 //////////////////////// 132 132 133 std::vector<S UBINFO*> subs;133 std::vector<SubInfo *> subs; 134 134 GetOverloadSubHash(name,subs); 135 135 if(subs.size()){ 136 136 //オーバーロードを解決 137 p si=OverloadSolutionWithStrParam(name,subs,Parameter,ObjectName,NULL);138 139 if(!p si) return 0;140 } 141 142 143 Opcode_CallProc(Parameter,p si,0,ObjectName,RefType);137 pSub=OverloadSolutionWithStrParam(name,subs,Parameter,ObjectName,NULL); 138 139 if(!pSub) return 0; 140 } 141 142 143 Opcode_CallProc(Parameter,pSub,0,ObjectName,RefType); 144 144 if( plpRetIndex ){ 145 *plpRetIndex = p si->u.ReturnIndex;146 } 147 return p si->ReturnType;145 *plpRetIndex = pSub->u.ReturnIndex; 146 } 147 return pSub->ReturnType; 148 148 } 149 149 else if(idProc==PROC_DLL){ … … 197 197 198 198 //オーバーロード用の関数リストを作成 199 std::vector<S UBINFO*> subs;199 std::vector<SubInfo *> subs; 200 200 GetOverloadSubHash(VarName,subs); 201 201 if(subs.size()==0){ … … 213 213 214 214 //オーバーロードを解決 215 S UBINFO *psi;216 p si=OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName,NULL);217 218 if(p si){215 SubInfo *pSub; 216 pSub=OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName,NULL); 217 218 if(pSub){ 219 219 //呼び出し 220 Opcode_CallProc(Parameter,p si,0,ObjectName,RefType);220 Opcode_CallProc(Parameter,pSub,0,ObjectName,RefType); 221 221 222 222 if( pRetTypeInfo ){ 223 pRetTypeInfo->type = p si->ReturnType;224 pRetTypeInfo->u.lpIndex = p si->u.ReturnIndex;223 pRetTypeInfo->type = pSub->ReturnType; 224 pRetTypeInfo->u.lpIndex = pSub->u.ReturnIndex; 225 225 } 226 226 } … … 240 240 ///////////////////// 241 241 242 S UBINFO *psi;243 p si=(SUBINFO*)pInfo;242 SubInfo *pSub; 243 pSub=(SubInfo *)pInfo; 244 244 245 245 //GetSubHash内でエラー提示が行われた場合 246 if(p si==(SUBINFO*)-1) return -1;246 if(pSub==(SubInfo *)-1) return -1; 247 247 248 248 … … 257 257 //////////////////////// 258 258 259 std::vector<S UBINFO*> subs;259 std::vector<SubInfo *> subs; 260 260 GetOverloadSubHash(name,subs); 261 261 if( subs.size() > 0 ){ 262 262 //オーバーロードを解決 263 p si=OverloadSolutionWithStrParam(name,subs,Parameter,ObjectName,NULL);264 265 if(!p si) return 0;266 } 267 268 269 ret_type=p si->ReturnType;270 *plpRetIndex=p si->u.ReturnIndex;263 pSub=OverloadSolutionWithStrParam(name,subs,Parameter,ObjectName,NULL); 264 265 if(!pSub) return 0; 266 } 267 268 269 ret_type=pSub->ReturnType; 270 *plpRetIndex=pSub->u.ReturnIndex; 271 271 } 272 272 else if(idProc==PROC_DLL){ … … 318 318 319 319 //オーバーロード用の関数リストを作成 320 std::vector<S UBINFO*> subs;320 std::vector<SubInfo *> subs; 321 321 GetOverloadSubHash(VarName,subs); 322 322 if(subs.size()==0){ … … 334 334 335 335 //オーバーロードを解決 336 S UBINFO *psi;337 p si=OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName,NULL);338 339 if(p si){336 SubInfo *pSub; 337 pSub=OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName,NULL); 338 339 if(pSub){ 340 340 if(pRetTypeInfo){ 341 pRetTypeInfo->type=p si->ReturnType;342 pRetTypeInfo->u.lpIndex=p si->u.ReturnIndex;341 pRetTypeInfo->type=pSub->ReturnType; 342 pRetTypeInfo->u.lpIndex=pSub->u.ReturnIndex; 343 343 } 344 344 } … … 349 349 //インデクサ(getter)の戻り値を取得 350 350 bool GetReturnTypeOfIndexerGetterProc(CClass *pobj_Class,TYPEINFO &RetTypeInfo){ 351 std::vector<S UBINFO*> subs;351 std::vector<SubInfo *> subs; 352 352 pobj_Class->EnumMethod( CALC_ARRAY_GET, subs ); 353 353 if( subs.size() == 0 ){ … … 644 644 return 0; 645 645 } 646 S UBINFO*AddSubData(char *buffer,int NowLine,BOOL bVirtual,CClass *pobj_c,BOOL bStatic){646 SubInfo *AddSubData(char *buffer,int NowLine,BOOL bVirtual,CClass *pobj_c,BOOL bStatic){ 647 647 int i,i2,i3,sw; 648 648 DWORD dwType; … … 761 761 SubNum++; 762 762 763 SUBINFO *psi; 764 psi=(SUBINFO *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,sizeof(SUBINFO)); 763 SubInfo *pSub = new SubInfo(); 765 764 766 765 //クラス名 767 p si->pobj_ParentClass=pobj_c;766 pSub->pobj_ParentClass=pobj_c; 768 767 769 768 //ID 770 769 static int id_base=0; 771 p si->id=(id_base++);770 pSub->id=(id_base++); 772 771 773 772 //関数名 774 p si->name=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);775 lstrcpy(p si->name,temporary);773 pSub->name=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1); 774 lstrcpy(pSub->name,temporary); 776 775 777 776 //ソースコードの位置 778 p si->address=NowLine;779 780 p si->bExport=bExport;781 p si->bCdecl=bCdecl;782 p si->bVirtual=bVirtual;783 if(bExport) p si->bUse=1;784 else p si->bUse=0;785 p si->bCompile=0;786 p si->bSystem=0;787 788 p si->dwType=dwType;789 790 791 if(p si->dwType==SUBTYPE_FUNCTION){777 pSub->address=NowLine; 778 779 pSub->bExport=bExport; 780 pSub->bCdecl=bCdecl; 781 pSub->bVirtual=bVirtual; 782 if(bExport) pSub->bUse=1; 783 else pSub->bUse=0; 784 pSub->bCompile=0; 785 pSub->bSystem=0; 786 787 pSub->dwType=dwType; 788 789 790 if(pSub->dwType==SUBTYPE_FUNCTION){ 792 791 /////////////////// 793 792 // 戻り値を取得 794 793 /////////////////// 795 794 796 p si->isReturnRef = false;795 pSub->isReturnRef = false; 797 796 798 797 if(pobj_c){ 799 if(lstrcmp(p si->name,pobj_c->name)==0||800 p si->name[0]=='~'){798 if(lstrcmp(pSub->name,pobj_c->name)==0|| 799 pSub->name[0]=='~'){ 801 800 //クラスのコンストラクタ、デストラクタがFunction定義の場合はエラーをだす 802 801 SetError(115,NULL,NowLine); … … 814 813 if( buffer[i2-2] == 1 && buffer[i2-1] == ESC_BYREF ){ 815 814 //参照型 816 p si->isReturnRef = true;815 pSub->isReturnRef = true; 817 816 } 818 817 … … 827 826 temporary[i3]=buffer[i2]; 828 827 } 829 p si->ReturnType=GetTypeFixed(temporary,&psi->u.ReturnIndex);830 if(p si->ReturnType==DEF_NON) SetError(3,temporary,NowLine);828 pSub->ReturnType=GetTypeFixed(temporary,&pSub->u.ReturnIndex); 829 if(pSub->ReturnType==DEF_NON) SetError(3,temporary,NowLine); 831 830 832 831 sw_as=1; … … 836 835 837 836 if(!sw_as){ 838 SetError(-104,p si->name,NowLine);839 840 p si->ReturnType=DEF_DOUBLE;837 SetError(-104,pSub->name,NowLine); 838 839 pSub->ReturnType=DEF_DOUBLE; 841 840 } 842 841 } 843 842 else{ 844 843 //戻り値なしのSub定義 845 psi->ReturnType=DEF_NON; 846 psi->u.ReturnIndex=-1; 847 } 848 849 850 851 psi->pParmInfo=(PARAMETER_INFO *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,sizeof(PARAMETER_INFO)*2); 852 psi->ParmNum=0; 844 pSub->ReturnType=DEF_NON; 845 pSub->u.ReturnIndex=-1; 846 } 853 847 854 848 //パラメータ … … 860 854 if(buffer[i]!=')'&&pobj_c){ 861 855 //クラスのメンバ関数の場合のみ、デストラクタにパラメータがある場合にエラーをだす 862 if(p si->name[0]=='~'){856 if(pSub->name[0]=='~'){ 863 857 SetError(114,NULL,NowLine); 864 858 i=JumpStringInPare(buffer,i); … … 868 862 if(buffer[i]==')') break; 869 863 870 psi->pParmInfo=(PARAMETER_INFO *)HeapReAlloc(hHeap,0,psi->pParmInfo,(psi->ParmNum+1)*sizeof(PARAMETER_INFO)); 871 872 //ByVal 864 //ByRef 865 bool isRef; 873 866 if(buffer[i]==1&&buffer[i+1]==ESC_BYVAL){ 874 psi->pParmInfo[psi->ParmNum].bByVal=1;867 isRef = false; 875 868 i+=2; 876 869 } 877 870 else if(buffer[i]==1&&buffer[i+1]==ESC_BYREF){ 878 psi->pParmInfo[psi->ParmNum].bByVal=0;871 isRef = true; 879 872 i+=2; 880 873 } 881 else psi->pParmInfo[psi->ParmNum].bByVal=1;874 else isRef = false; 882 875 883 876 //パラメータ名 877 bool isArray = false; 878 int subScripts[MAX_ARRAYDIM]; 879 char name[VN_SIZE]; 884 880 sw=0; 885 881 for(i2=0;;i++,i2++){ … … 887 883 if(!sw) sw=1; 888 884 889 i3=GetStringInPare( temporary+i2,buffer+i);885 i3=GetStringInPare(name+i2,buffer+i); 890 886 i2+=i3-1; 891 887 i+=i3-1; … … 895 891 if(!sw) sw=1; 896 892 897 i3=GetStringInBracket( temporary+i2,buffer+i);893 i3=GetStringInBracket(name+i2,buffer+i); 898 894 i2+=i3-1; 899 895 i+=i3-1; … … 901 897 } 902 898 if(!IsVariableChar(buffer[i])){ 903 temporary[i2]=0;899 name[i2]=0; 904 900 break; 905 901 } 906 temporary[i2]=buffer[i];902 name[i2]=buffer[i]; 907 903 } 908 904 if(sw){ 909 905 //配列パラメータ 910 if( psi->pParmInfo[psi->ParmNum].bByVal) SetError(29,NULL,NowLine);911 psi->pParmInfo[psi->ParmNum].bArray=1;912 913 if(( temporary[i2-2]=='('&&temporary[i2-1]==')')||914 ( temporary[i2-2]=='['&&temporary[i2-1]==']')){915 psi->pParmInfo[psi->ParmNum].SubScripts[0]=LONG_MAX;916 psi->pParmInfo[psi->ParmNum].SubScripts[1]=-1;917 918 temporary[i2-2]=0;906 if( isRef == false ) SetError(29,NULL,NowLine); 907 isArray = true; 908 909 if((name[i2-2]=='('&&name[i2-1]==')')|| 910 (name[i2-2]=='['&&name[i2-1]==']')){ 911 subScripts[0]=LONG_MAX; 912 subScripts[1]=-1; 913 914 name[i2-2]=0; 919 915 } 920 916 else{ 921 GetArrange(temporary,temp2,psi->pParmInfo[psi->ParmNum].SubScripts); 922 lstrcpy(temporary,temp2); 923 } 924 925 i2=lstrlen(temporary); 926 } 927 else{ 928 psi->pParmInfo[psi->ParmNum].bArray=0; 929 psi->pParmInfo[psi->ParmNum].SubScripts[0]=-1; 930 } 931 psi->pParmInfo[psi->ParmNum].name=(char *)HeapAlloc(hHeap,0,i2+1); 932 lstrcpy(psi->pParmInfo[psi->ParmNum].name,temporary); 917 GetArrange(name,temp2,subScripts); 918 lstrcpy(name,temp2); 919 } 920 921 i2=lstrlen(name); 922 } 933 923 934 924 //型 925 Type type( DEF_NON ); 935 926 if(buffer[i]==1&&buffer[i+1]==ESC_AS){ 936 927 i+=2; … … 955 946 } 956 947 957 psi->pParmInfo[psi->ParmNum].type= 958 GetTypeFixed(temporary,&psi->pParmInfo[psi->ParmNum].u.index); 948 Type::StringToType( temporary, type ); 959 949 960 950 if(temporary[0]=='*'&& … … 963 953 if(buffer[i]!='('){ 964 954 SetError(10,temporary,NowLine); 965 return 0;955 break; 966 956 } 967 957 i3=GetStringInPare(temporary+i2,buffer+i); … … 986 976 } 987 977 988 if( psi->pParmInfo[psi->ParmNum].type==-1){978 if( type.IsNull() ){ 989 979 SetError(3,temporary,NowLine); 990 psi->pParmInfo[psi->ParmNum].type=DEF_PTR_VOID; 991 } 992 993 /*未完成(構造体パラメータを値参照として渡してよいものか!?) 994 if(psi->pParmInfo[psi->ParmNum].type==DEF_OBJECT){ 995 if(psi->pParmInfo[psi->ParmNum].bByVal) SetError(28,temporary,NowLine); 996 }*/ 980 type.SetBasicType( DEF_PTR_VOID ); 981 } 997 982 } 998 983 else{ 999 psi->pParmInfo[psi->ParmNum].type=GetTypeFromSimpleName(temporary);984 type.SetBasicType( GetTypeFromSimpleName(temporary) ); 1000 985 SetError(-103,temporary,NowLine); 1001 986 } 1002 987 1003 if( psi->pParmInfo[psi->ParmNum].type==DEF_PTR_PROC){988 if( type.IsProcPtr() ){ 1004 989 //関数ポインタの場合 1005 psi->pParmInfo[psi->ParmNum].u.index=AddProcPtrInfo(temporary+3,temporary[2]); 1006 } 1007 1008 //パラメータの数を更新 1009 psi->ParmNum++; 990 type.SetIndex( AddProcPtrInfo(temporary+3,temporary[2]) ); 991 } 992 993 Parameter *pParam = new Parameter( name, type, isRef ); 994 if( isArray ){ 995 pParam->SetArray( subScripts ); 996 } 997 998 //パラメータを追加 999 pSub->params.push_back( pParam ); 1010 1000 1011 1001 if(buffer[i]==','){ … … 1016 1006 else{ 1017 1007 SetError(1,NULL,NowLine); 1018 return 0;1019 } 1020 } 1021 p si->SecondParmNum=psi->ParmNum;1008 break; 1009 } 1010 } 1011 pSub->SecondParmNum = (int)pSub->params.size(); 1022 1012 i++; 1023 1013 if(buffer[i]=='('){ … … 1026 1016 if(buffer[i]==')') break; 1027 1017 1028 psi->pParmInfo=(PARAMETER_INFO *)HeapReAlloc(hHeap,0,psi->pParmInfo,(psi->ParmNum+1)*sizeof(PARAMETER_INFO)); 1029 1030 //ByVal 1018 //ByRef 1019 bool isRef; 1031 1020 if(buffer[i]==1&&buffer[i+1]==ESC_BYVAL){ 1032 psi->pParmInfo[psi->ParmNum].bByVal=1;1021 isRef = false; 1033 1022 i+=2; 1034 1023 } 1035 1024 else if(buffer[i]==1&&buffer[i+1]==ESC_BYREF){ 1036 psi->pParmInfo[psi->ParmNum].bByVal=0;1025 isRef = true; 1037 1026 i+=2; 1038 1027 } 1039 else psi->pParmInfo[psi->ParmNum].bByVal=1;1028 else isRef = false; 1040 1029 1041 1030 //パラメータ名 1031 bool isArray = false; 1032 int subScripts[MAX_ARRAYDIM]; 1033 char name[VN_SIZE]; 1042 1034 sw=0; 1043 1035 for(i2=0;;i++,i2++){ … … 1045 1037 if(!sw) sw=1; 1046 1038 1047 i3=GetStringInPare( temporary+i2,buffer+i);1039 i3=GetStringInPare(name+i2,buffer+i); 1048 1040 i2+=i3-1; 1049 1041 i+=i3-1; … … 1053 1045 if(!sw) sw=1; 1054 1046 1055 i3=GetStringInBracket( temporary+i2,buffer+i);1047 i3=GetStringInBracket(name+i2,buffer+i); 1056 1048 i2+=i3-1; 1057 1049 i+=i3-1; … … 1059 1051 } 1060 1052 if(!IsVariableChar(buffer[i])){ 1061 temporary[i2]=0;1053 name[i2]=0; 1062 1054 break; 1063 1055 } 1064 temporary[i2]=buffer[i];1056 name[i2]=buffer[i]; 1065 1057 } 1066 1058 if(sw){ 1067 1059 //配列パラメータ 1068 if( psi->pParmInfo[psi->ParmNum].bByVal) SetError(29,NULL,NowLine);1069 psi->pParmInfo[psi->ParmNum].bArray=1;1070 1071 if(( temporary[i2-2]=='('&&temporary[i2-1]==')')||1072 ( temporary[i2-2]=='['&&temporary[i2-1]==']')){1073 psi->pParmInfo[psi->ParmNum].SubScripts[0]=LONG_MAX;1074 psi->pParmInfo[psi->ParmNum].SubScripts[1]=-1;1075 1076 temporary[i2-2]=0;1060 if( isRef == false ) SetError(29,NULL,NowLine); 1061 isArray = true; 1062 1063 if((name[i2-2]=='('&&name[i2-1]==')')|| 1064 (name[i2-2]=='['&&name[i2-1]==']')){ 1065 subScripts[0]=LONG_MAX; 1066 subScripts[1]=-1; 1067 1068 name[i2-2]=0; 1077 1069 } 1078 1070 else{ 1079 GetArrange(temporary,temp2,psi->pParmInfo[psi->ParmNum].SubScripts); 1080 lstrcpy(temporary,temp2); 1081 } 1082 1083 i2=lstrlen(temporary); 1084 } 1085 else{ 1086 psi->pParmInfo[psi->ParmNum].bArray=0; 1087 psi->pParmInfo[psi->ParmNum].SubScripts[0]=-1; 1088 } 1089 psi->pParmInfo[psi->ParmNum].name=(char *)HeapAlloc(hHeap,0,i2+1); 1090 lstrcpy(psi->pParmInfo[psi->ParmNum].name,temporary); 1071 GetArrange(name,temp2,subScripts); 1072 lstrcpy(name,temp2); 1073 } 1074 1075 i2=lstrlen(name); 1076 } 1091 1077 1092 1078 //型 1079 Type type( DEF_NON ); 1093 1080 if(buffer[i]==1&&buffer[i+1]==ESC_AS){ 1094 1081 i+=2; 1082 1095 1083 i2=0; 1096 1084 while(buffer[i]=='*'){ … … 1101 1089 for(;;i++,i2++){ 1102 1090 if(!IsVariableChar(buffer[i])){ 1091 if(buffer[i]==1&&(buffer[i+1]==ESC_FUNCTION||buffer[i+1]==ESC_SUB)){ 1092 temporary[i2++]=buffer[i++]; 1093 temporary[i2]=buffer[i]; 1094 continue; 1095 } 1103 1096 temporary[i2]=0; 1104 1097 break; … … 1106 1099 temporary[i2]=buffer[i]; 1107 1100 } 1108 psi->pParmInfo[psi->ParmNum].type= 1109 GetTypeFixed(temporary,&psi->pParmInfo[psi->ParmNum].u.index); 1110 if(psi->pParmInfo[psi->ParmNum].type==-1) SetError(3,temporary,NowLine); 1101 1102 Type::StringToType( temporary, type ); 1103 1104 if(temporary[0]=='*'&& 1105 temporary[1]==1&& 1106 (temporary[2]==ESC_FUNCTION||temporary[2]==ESC_SUB)){ 1107 if(buffer[i]!='('){ 1108 SetError(10,temporary,NowLine); 1109 break; 1110 } 1111 i3=GetStringInPare(temporary+i2,buffer+i); 1112 i+=i3; 1113 i2+=i3; 1114 1115 if(temporary[2]==ESC_FUNCTION&&buffer[i]==1&&buffer[i+1]==ESC_AS){ 1116 temporary[i2++]=buffer[i++]; 1117 temporary[i2++]=buffer[i++]; 1118 for(;;i++,i2++){ 1119 if(!IsVariableChar(buffer[i])){ 1120 temporary[i2]=0; 1121 break; 1122 } 1123 temporary[i2]=buffer[i]; 1124 } 1125 } 1126 } 1127 else{ 1128 //TypeDefをする前のベース型を取得 1129 GetOriginalTypeName(temporary); 1130 } 1131 1132 if( type.IsNull() ){ 1133 SetError(3,temporary,NowLine); 1134 type.SetBasicType( DEF_PTR_VOID ); 1135 } 1111 1136 } 1112 1137 else{ 1113 psi->pParmInfo[psi->ParmNum].type=GetTypeFromSimpleName(temporary);1138 type.SetBasicType( GetTypeFromSimpleName(temporary) ); 1114 1139 SetError(-103,temporary,NowLine); 1115 1140 } 1116 1141 1117 psi->ParmNum++; 1142 if( type.IsProcPtr() ){ 1143 //関数ポインタの場合 1144 type.SetIndex( AddProcPtrInfo(temporary+3,temporary[2]) ); 1145 } 1146 1147 Parameter *pParam = new Parameter( name, type, isRef ); 1148 if( isArray ){ 1149 pParam->SetArray( subScripts ); 1150 } 1151 1152 //パラメータを追加 1153 pSub->params.push_back( pParam ); 1118 1154 1119 1155 if(buffer[i]==','){ … … 1124 1160 else{ 1125 1161 SetError(1,NULL,NowLine); 1126 return 0;1162 break; 1127 1163 } 1128 1164 } … … 1130 1166 } 1131 1167 1132 //リアルパラメータ領域を取得(_System_LocalThisを考慮して2つだけ多く確保する) 1133 psi->pRealParmInfo=(PARAMETER_INFO *)HeapAlloc(hHeap,0,(psi->ParmNum+2)*sizeof(PARAMETER_INFO)); 1134 psi->RealParmNum=0; 1168 //リアルパラメータ領域を取得(_System_LocalThisを考慮して2つだけ多く確保する場合がある) 1135 1169 1136 1170 if(pobj_c&&bStatic==0){ 1137 i = psi->RealParmNum;1138 1139 1171 //オブジェクトメンバの場合は、第一パラメータを_System_LocalThis引き渡し用として利用 1140 psi->pRealParmInfo[i].name = "_System_LocalThis"; 1141 psi->pRealParmInfo[i].type=DEF_PTR_VOID; 1142 psi->pRealParmInfo[i].u.index=-1; 1143 psi->pRealParmInfo[i].bByVal=1; 1144 psi->pRealParmInfo[i].bArray=0; 1145 psi->pRealParmInfo[i].SubScripts[0]=-1; 1146 1147 psi->RealParmNum++; 1148 } 1149 1150 if(psi->ReturnType==DEF_STRUCT){ 1151 i = psi->RealParmNum; 1152 1172 string name = "_System_LocalThis"; 1173 Type type( DEF_PTR_VOID ); 1174 pSub->realParams.push_back( new Parameter( name, type ) ); 1175 } 1176 1177 if(pSub->ReturnType==DEF_STRUCT){ 1153 1178 //構造体を戻り値として持つ場合 1154 1179 //※第一パラメータ(Thisポインタありの場合は第二パラメータ)を戻り値用の参照宣言にする 1155 1180 1156 if(psi->name[0]==1&&psi->name[1]==ESC_OPERATOR) 1157 psi->pRealParmInfo[i].name="_System_ReturnValue"; 1158 else psi->pRealParmInfo[i].name=psi->name; 1159 psi->pRealParmInfo[i].type=DEF_STRUCT; 1160 psi->pRealParmInfo[i].u.index=psi->u.ReturnIndex; 1161 psi->pRealParmInfo[i].bByVal=0; 1162 psi->pRealParmInfo[i].bArray=0; 1163 psi->pRealParmInfo[i].SubScripts[0]=-1; 1164 1165 psi->RealParmNum++; 1181 string name = pSub->name; 1182 if(pSub->name[0]==1&&pSub->name[1]==ESC_OPERATOR){ 1183 name="_System_ReturnValue"; 1184 } 1185 Type type( DEF_STRUCT, pSub->u.ReturnIndex ); 1186 pSub->realParams.push_back( new Parameter( name, type, true ) ); 1166 1187 } 1167 1188 1168 1189 //パラメータをコピー 1169 for ( i = 0; i < psi->ParmNum; i++, psi->RealParmNum++){1170 p si->pRealParmInfo[psi->RealParmNum]=psi->pParmInfo[i];1190 foreach( Parameter *pParam, pSub->params ){ 1191 pSub->realParams.push_back( new Parameter( *pParam ) ); 1171 1192 } 1172 1193 … … 1177 1198 1178 1199 int key; 1179 key=hash_default(p si->name);1180 1181 extern S UBINFO**ppSubHash;1200 key=hash_default(pSub->name); 1201 1202 extern SubInfo **ppSubHash; 1182 1203 if(ppSubHash[key]){ 1183 S UBINFO*psi2;1204 SubInfo *psi2; 1184 1205 psi2=ppSubHash[key]; 1185 1206 while(1){ 1186 1207 if(pobj_c==psi2->pobj_ParentClass){ 1187 1208 //重複エラーチェックを行う 1188 if(lstrcmp(psi2->name,p si->name)==0){1189 if( CompareParameter(psi2->pParmInfo,psi2->ParmNum,psi->pParmInfo,psi->ParmNum)==0){1190 SetError(15,p si->name,NowLine);1209 if(lstrcmp(psi2->name,pSub->name)==0){ 1210 if( Parameter::Equals( psi2->params, pSub->params ) ){ 1211 SetError(15,pSub->name,NowLine); 1191 1212 return 0; 1192 1213 } … … 1197 1218 psi2=psi2->pNextData; 1198 1219 } 1199 psi2->pNextData=p si;1220 psi2->pNextData=pSub; 1200 1221 } 1201 1222 else{ 1202 ppSubHash[key]=p si;1203 } 1204 1205 return p si;1223 ppSubHash[key]=pSub; 1224 } 1225 1226 return pSub; 1206 1227 } 1207 1228 … … 1217 1238 1218 1239 //サブルーチン(ユーザー定義)情報を初期化 1219 extern S UBINFO**ppSubHash;1240 extern SubInfo **ppSubHash; 1220 1241 extern int SubNum; 1221 ppSubHash=(S UBINFO **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(SUBINFO*));1242 ppSubHash=(SubInfo **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(SubInfo *)); 1222 1243 SubNum=0; 1223 1244 … … 1313 1334 AddSubData(temporary,0,0,0); 1314 1335 } 1315 void Delete_si(SUBINFO *psi){ 1316 int i2; 1317 1318 for(i2=0;i2<psi->ParmNum;i2++){ 1319 HeapDefaultFree(psi->pParmInfo[i2].name); 1320 } 1321 HeapDefaultFree(psi->pRealParmInfo); 1322 if(psi->pParmInfo) HeapDefaultFree(psi->pParmInfo); 1323 psi->pRealParmInfo=0; 1324 psi->pParmInfo=0; 1325 1326 if(psi->pNextData) Delete_si(psi->pNextData); 1327 1328 HeapDefaultFree(psi->name); 1329 HeapDefaultFree(psi); 1330 } 1331 void DeleteSubInfo(SUBINFO **ppSubHash,char **ppMacroNames,int MacroNum){ //サブルーチン情報のメモリ解放 1336 void Delete_si(SubInfo *pSub){ 1337 foreach( Parameter *pParam, pSub->params ){ 1338 delete pParam; 1339 } 1340 1341 foreach( Parameter *pParam, pSub->realParams ){ 1342 delete pParam; 1343 } 1344 1345 if(pSub->pNextData) Delete_si(pSub->pNextData); 1346 1347 HeapDefaultFree(pSub->name); 1348 delete pSub; 1349 } 1350 void DeleteSubInfo(SubInfo **ppSubHash,char **ppMacroNames,int MacroNum){ //サブルーチン情報のメモリ解放 1332 1351 int i; 1333 1352 for(i=0;i<MAX_HASH;i++){ -
BasicCompiler_Common/Type.cpp
r71 r73 108 108 return false; 109 109 } 110 111 112 bool Type::Equals( const Type &type ) const 113 { 114 if( basicType == type.basicType ){ 115 if( NATURAL_TYPE( basicType ) == DEF_OBJECT 116 || NATURAL_TYPE( basicType ) == DEF_STRUCT ){ 117 118 if( index == type.index ){ 119 return true; 120 } 121 122 } 123 else{ 124 return true; 125 } 126 } 127 return false; 128 } 129 130 bool Type::IsNull() const{ 131 if( basicType == DEF_NON ){ 132 return true; 133 } 134 return false; 135 } 136 bool Type::IsPointer() const 137 { 138 if(PTR_LEVEL( basicType )|| basicType == DEF_PTR_VOID || basicType == DEF_PTR_PROC 139 || ( basicType & FLAG_PTR ) ){ 140 return true; 141 } 142 143 return false; 144 } 145 bool Type::IsSigned() const 146 { 147 switch( basicType ){ 148 case DEF_SBYTE: 149 case DEF_INTEGER: 150 case DEF_LONG: 151 case DEF_INT64: 152 case DEF_SINGLE: 153 case DEF_DOUBLE: 154 return true; 155 default: 156 break; 157 } 158 return false; 159 } 160 bool Type::IsNaturalWhole() const 161 { 162 switch( basicType ){ 163 case DEF_SBYTE: 164 case DEF_BYTE: 165 case DEF_INTEGER: 166 case DEF_WORD: 167 case DEF_LONG: 168 case DEF_DWORD: 169 case DEF_INT64: 170 case DEF_QWORD: 171 return true; 172 default: 173 break; 174 } 175 return false; 176 } 177 bool Type::IsWhole() const 178 { 179 return ( 180 IsNaturalWhole() 181 || IsPtrType( basicType ) 182 || basicType == DEF_BOOLEAN 183 ); 184 } 185 bool Type::IsReal() const 186 { 187 switch( basicType ){ 188 case DEF_SINGLE: 189 case DEF_DOUBLE: 190 return true; 191 default: 192 break; 193 } 194 return false; 195 } 196 bool Type::Is64() const 197 { 198 switch( basicType ){ 199 case DEF_QWORD: 200 case DEF_INT64: 201 return true; 202 default: 203 break; 204 } 205 return false; 206 } 207 bool Type::IsProcPtr() const 208 { 209 if( basicType == DEF_PTR_PROC ){ 210 return true; 211 } 212 return false; 213 } 214 bool Type::IsStruct() const 215 { 216 if( basicType == DEF_STRUCT ){ 217 return true; 218 } 219 return false; 220 } -
BasicCompiler_Common/Type.h
r71 r73 4 4 5 5 class Type{ 6 static const int basicTypeList[]; 7 static const string basicTypeNameList[]; 8 9 6 10 int basicType; 7 11 union{ … … 10 14 }; 11 15 12 static const int basicTypeList[];13 static const string basicTypeNameList[];14 15 16 public: 16 17 18 static bool StringToBasicType( const string &typeName, int &basicType ); 19 static bool StringToType( const string &typeName, Type &type ); 20 21 Type(): 22 basicType( DEF_NON ), 23 index( -1 ){} 17 24 Type( int basicType ): 18 25 basicType( basicType ), … … 31 38 index( type.index ){} 32 39 33 int BasicType() const40 int GetBasicType() const 34 41 { 42 #ifdef _DEBUG 43 if( basicType<-10000 ){ 44 DebugBreak(); 45 } 46 #endif 35 47 return basicType; 36 48 } … … 44 56 } 45 57 58 void SetBasicType( int basicType ){ 59 this->basicType = basicType; 60 } 61 void SetIndex( LONG_PTR index ){ 62 this->index = index; 63 } 64 void SetNull(){ 65 SetBasicType( DEF_NON ); 66 } 67 void SetType( int basicType, LONG_PTR index ){ 68 SetBasicType( basicType ); 69 SetIndex( index ); 70 } 71 void SetType( int basicType, CClass *pClass ){ 72 SetBasicType( basicType ); 73 this->pClass = pClass; 74 } 75 46 76 void PtrLevelUp(){ 47 77 PTR_LEVEL_UP( basicType ); 48 78 } 49 79 50 bool Equals( const Type &type ) const 51 { 52 if( basicType == type.basicType ){ 53 if( NATURAL_TYPE( basicType ) == DEF_OBJECT 54 || NATURAL_TYPE( basicType ) == DEF_STRUCT ){ 80 bool Equals( const Type &type ) const; 55 81 56 if( index == type.index ){ 57 return true; 58 } 82 bool IsNull() const; 83 bool IsPointer() const; 84 bool IsSigned() const; 85 bool IsNaturalWhole() const; 86 bool IsWhole() const; 87 bool IsReal() const; 88 bool Is64() const; 89 bool IsProcPtr() const; 90 bool IsStruct() const; 59 91 60 }61 else{62 return true;63 }64 }65 return false;66 }67 68 bool IsPointer() const69 {70 if(PTR_LEVEL( basicType )|| basicType == DEF_PTR_VOID || basicType == DEF_PTR_PROC71 || ( basicType & FLAG_PTR ) ){72 return true;73 }74 75 return false;76 }77 78 79 80 static bool StringToBasicType( const string &typeName, int &basicType );81 static bool StringToType( const string &typeName, Type &type );82 92 }; 83 93 -
BasicCompiler_Common/Variable.cpp
r68 r73 819 819 820 820 char temporary[VN_SIZE]; 821 extern S UBINFO*pCompilingSubInfo;821 extern SubInfo *pCompilingSubInfo; 822 822 if(pCompilingSubInfo){ 823 823 GetNowStaticVarFullName(VarName,temporary); … … 1100 1100 //初期値の型を判別して自動的に型情報を付加する 1101 1101 TYPEINFO BaseType = GetStringTypeInfo(); 1102 int result = NumOpe_GetType ( InitBuf, &BaseType, &pTypeInfo->u.lpIndex );1102 int result = NumOpe_GetType_Old( InitBuf, &BaseType, &pTypeInfo->u.lpIndex ); 1103 1103 1104 1104 //エラーの場合 … … 1130 1130 1131 1131 BOOL GetNowStaticVarFullName(char *VarName,char *FullName){ 1132 extern S UBINFO*pCompilingSubInfo;1132 extern SubInfo *pCompilingSubInfo; 1133 1133 if(!pCompilingSubInfo) return 0; 1134 1134 -
BasicCompiler_Common/calculation.cpp
r69 r73 1195 1195 return 0; 1196 1196 } 1197 BOOL IsStringSubsituation(CClass *pobj_c){1198 //String受け入れ可能な "=" 演算子をオーバーロードしているかどうかを調べる1199 BOOL bRet=0;1200 1201 std::vector<SUBINFO *> subs;1202 pobj_c->EnumMethod( CALC_SUBSITUATION, subs );1203 if( subs.size() == 0 ){1204 bRet=0;1205 goto finish;1206 }1207 1208 foreach( SUBINFO *psi, subs ){1209 if(psi->ParmNum==2){1210 TYPEINFO TypeInfo={psi->pParmInfo[1].type,psi->pParmInfo[1].u.index};1211 if(IsStringObjectType( TypeInfo )){1212 bRet=1;1213 goto finish;1214 }1215 }1216 }1217 1218 finish:1219 return bRet;1220 }1221 1197 int IsStrCalculation(char *Command){ 1222 1198 int i,i2,i3,i4,type,PareNum; … … 1282 1258 1283 1259 //ユーザー定義関数 1284 S UBINFO*psi;1260 SubInfo *psi; 1285 1261 psi=GetSubHash(temporary); 1286 1262 if(psi){ -
BasicCompiler_Common/common.h
r71 r73 155 155 #include "Parameter.h" 156 156 157 // プロシージャ管理用のクラス 158 #include "Procedure.h" 159 157 160 158 161 … … 229 232 }; 230 233 231 #define SUBTYPE_SUB 1232 #define SUBTYPE_FUNCTION 2233 #define SUBTYPE_MACRO 3234 struct SUBINFO{235 DWORD dwType;236 237 //クラス情報238 CClass *pobj_ParentClass;239 240 long id;241 242 char *name;243 long address;244 245 //パラメータ246 PARAMETER_INFO *pParmInfo;247 int ParmNum;248 int SecondParmNum;249 PARAMETER_INFO *pRealParmInfo;250 int RealParmNum;251 int RealSecondParmNum;252 253 /*254 //パラメータ255 Parameters params;256 int SecondParmNum;257 Parameters realParams;258 int RealSecondParmNum;*/259 260 //戻り値261 int ReturnType;262 union{263 LONG_PTR ReturnIndex;264 CClass *Return_pobj_c;265 }u;266 bool isReturnRef;267 268 DWORD CompileAddress;269 DWORD EndOpAddr;270 VARIABLE *pVar;271 int VarNum;272 273 BOOL bExport;274 BOOL bCdecl;275 BOOL bVirtual;276 BOOL bUse;277 BOOL bCompile;278 BOOL bSystem;279 280 SUBINFO *pNextData;281 };282 234 #define DECLARE_DYNAMIC 1 283 235 #define DECLARE_STATIC 2 … … 435 387 CONSTINFO *GetConstHash(char *name); 436 388 DECLAREINFO *GetDeclareHash(char *name); 437 S UBINFO*GetSubHash(const char *name,BOOL bError=0);438 S UBINFO*GetMethodHash(char *ObjectName,char *MethodName,char *Parameter,BOOL bError=0);439 void GetOverloadSubHash( const char *lpszName, std::vector<S UBINFO*> &subs );389 SubInfo *GetSubHash(const char *name,BOOL bError=0); 390 SubInfo *GetMethodHash(char *ObjectName,char *MethodName,char *Parameter,BOOL bError=0); 391 void GetOverloadSubHash( const char *lpszName, std::vector<SubInfo *> &subs ); 440 392 441 393 //Object.cpp … … 444 396 445 397 //Overload.sbp 446 S UBINFO*OverloadSolutionWithStrParam(398 SubInfo *OverloadSolutionWithStrParam( 447 399 const char *name, 448 std::vector<S UBINFO*> &subs,400 std::vector<SubInfo *> &subs, 449 401 const char *Parameter, 450 402 const char *ObjectName, 451 403 TYPEINFO *pReturnTypeInfo); 452 S UBINFO*OverloadSolution(404 SubInfo *OverloadSolution( 453 405 const char *name, 454 std::vector<S UBINFO*> &subs,406 std::vector<SubInfo *> &subs, 455 407 const PARAMETER_INFO *ppi, 456 408 const int ParmNum, … … 464 416 void Debugger_Pause(void); 465 417 ULONG_PTR rva_to_real(DWORD p); 466 S UBINFO*GetSubFromObp(ULONG_PTR pos);418 SubInfo *GetSubFromObp(ULONG_PTR pos); 467 419 void ReadOpBuffer(); 468 420 void DebugProgram(void); … … 561 513 DWORD GetConstValue(char *name,double *dbl,char *buffer,LONG_PTR *plpIndex); 562 514 bool IsStringObjectType(const TYPEINFO &TypeInfo); 563 BOOL IsStringSubsituation(CClass *pobj_c);564 515 int IsStrCalculation(char *Command); 565 516 BYTE GetCalcId(const char *Command,int *pi); … … 567 518 char *values[255],long calc[255],long stack[255]); 568 519 569 //NumOpe_GetType .cpp520 //NumOpe_GetType_Old.cpp 570 521 int AutoBigCast(int BaseType,int CalcType); 571 522 BOOL CheckCalcType(int idCalc,int *type,int sp); 572 int NumOpe_GetType(char *Command,TYPEINFO *pBaseType,LONG_PTR *plpIndex); 523 int NumOpe_GetType_Old( const char *Command, TYPEINFO *pBaseTypeInfo, LONG_PTR *plpIndex ); 524 bool NumOpe_GetType( const char *expression, const Type &baseType, Type &resultType ); 573 525 574 526 //Subroutine.cpp … … 583 535 bool GetReturnTypeOfIndexerGetterProc(CClass *pobj_Class,TYPEINFO &RetTypeInfo); 584 536 BOOL CompareParameter(PARAMETER_INFO *ppi1,int pi_num1,PARAMETER_INFO *ppi2,int pi_num2); 585 S UBINFO*AddSubData(char *buffer,int NowLine,BOOL bVirtual,CClass *pobj_c,BOOL bStatic=0);537 SubInfo *AddSubData(char *buffer,int NowLine,BOOL bVirtual,CClass *pobj_c,BOOL bStatic=0); 586 538 void GetSubInfo(void); 587 void DeleteSubInfo(S UBINFO**ppSubHash,char **ppMacroNames,int MacroNum);539 void DeleteSubInfo(SubInfo **ppSubHash,char **ppMacroNames,int MacroNum); 588 540 void DeleteDeclareInfo(void); 589 541 int AddProcPtrInfo(char *buffer,DWORD dwProcType); -
BasicCompiler_Common/hash.cpp
r51 r73 53 53 } 54 54 55 void GetOverloadSubHash( const char *lpszName, std::vector<SUBINFO *> &subs ){ 56 extern SUBINFO *pSubInfo; 57 extern int SubInfoNum; 58 extern int cp; 59 55 void GetOverloadSubHash( const char *lpszName, std::vector<SubInfo *> &subs ){ 60 56 char name[VN_SIZE]; 61 57 … … 127 123 128 124 //格納位置を取得 129 extern S UBINFO**ppSubHash;130 S UBINFO*psi;125 extern SubInfo **ppSubHash; 126 SubInfo *psi; 131 127 psi=ppSubHash[key]; 132 128 while(psi){ … … 144 140 145 141 //オーバーロードされていない関数を取得(昔のコンパイラソースコードとの互換性保持) 146 S UBINFO*GetSubHash(const char *lpszName,BOOL bError){147 std::vector<S UBINFO*> subs;142 SubInfo *GetSubHash(const char *lpszName,BOOL bError){ 143 std::vector<SubInfo *> subs; 148 144 GetOverloadSubHash(lpszName,subs); 149 145 … … 158 154 } 159 155 160 S UBINFO*psi;156 SubInfo *psi; 161 157 psi = subs[0]; 162 158 163 159 return psi; 164 160 } 165 S UBINFO*GetMethodHash(char *ObjectName,char *MethodName,char *Parameter,BOOL bError){161 SubInfo *GetMethodHash(char *ObjectName,char *MethodName,char *Parameter,BOOL bError){ 166 162 char temporary[VN_SIZE]; 167 163 sprintf(temporary,"%s.%s",ObjectName,MethodName); 168 164 169 std::vector<S UBINFO*> subs;170 S UBINFO*psi;165 std::vector<SubInfo *> subs; 166 SubInfo *psi; 171 167 GetOverloadSubHash(temporary,subs); 172 168 -
ProjectEditor/DocumentAdvice.cpp
r24 r73 129 129 130 130 for(i=0;;i++){ 131 if( memcmp(buffer+i,"#include",8)==0&&(!IsVariableChar(buffer[i+8]))){131 if( ( memcmp(buffer+i,"#include",8)==0 || memcmp(buffer+i,"#require",8)==0 )&&(!IsVariableChar(buffer[i+8]))){ 132 132 i2=i+8; 133 133 while(buffer[i2]==' '||buffer[i2]=='\t') i2++;
Note:
See TracChangeset
for help on using the changeset viewer.