Changeset 79 in dev for BasicCompiler_Common
- Timestamp:
- Mar 25, 2007, 5:58:57 AM (18 years ago)
- Location:
- BasicCompiler_Common
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler_Common/Class.cpp
r76 r79 106 106 sprintf(temporary,"%s.%s",pobj_c->name,member->name); 107 107 dim( 108 false,109 108 temporary, 110 109 member->SubScripts, -
BasicCompiler_Common/DebugMiddleFile.cpp
r78 r79 138 138 // TypeDef情報 139 139 ////////////////// 140 *(long *)(buffer+i2)= House::typeDefs.size();140 *(long *)(buffer+i2)=(int)House::typeDefs.size(); 141 141 i2+=sizeof(long); 142 142 for(i3=0;i3<(int)House::typeDefs.size();i3++){ -
BasicCompiler_Common/Intermediate_Step1.cpp
r67 r79 328 328 329 329 extern BOOL bStrict; 330 bStrict= 0;330 bStrict=1; 331 331 332 332 for(i=0;;i++){ … … 351 351 else if(lstrcmpi(temporary,"strict")==0){ 352 352 //#strict 353 //旧機能なので、無視 353 354 for(;;i2++){ 354 355 if(basbuf[i2]=='\n'||basbuf[i2]=='\0') break; 355 356 } 356 357 SlideString(basbuf+i2,i-i2); 357 358 //型チェックを厳密に行う359 bStrict=1;360 358 } 361 359 else if(lstrcmpi(temporary,"struct")==0){ -
BasicCompiler_Common/NumOpe_GetType.cpp
r75 r79 340 340 int type_stack[255]; 341 341 LONG_PTR index_stack[255]; 342 bool isNothing_stack[255]; 342 343 _int64 i64data; 343 344 int idCalc; … … 347 348 if(idCalc){ 348 349 if(type_stack[sp-2]==DEF_OBJECT){ 349 //オーバーロードされたオペレータを呼び出す 350 if(!GetReturnType_OperatorProc(idCalc,baseType,type_stack,index_stack,sp)){ 351 goto error; 350 if( idCalc == CALC_AS 351 && type_stack[sp-1] == ( DEF_OBJECT | FLAG_CAST ) 352 && index_stack[sp-1] == index_stack[sp-2] 353 || isNothing_stack[sp-2] ){ 354 // 同一の型、またはNothingに対するAsはAs演算子を呼び出さない 352 355 } 353 354 continue; 356 else{ 357 //オーバーロードされたオペレータを呼び出す 358 if(!GetReturnType_OperatorProc(idCalc,baseType,type_stack,index_stack,sp)){ 359 goto error; 360 } 361 362 continue; 363 } 355 364 } 356 365 … … 362 371 case 0: 363 372 index_stack[sp]=-1; 373 isNothing_stack[sp] = false; 364 374 365 375 char *term; … … 490 500 // Nothing 491 501 if( lstrcmp( term, "Nothing" ) == 0 ){ 502 isNothing_stack[sp] = true; 503 492 504 type_stack[sp] = DEF_OBJECT; 493 505 if( baseType.IsObject() ){ … … 558 570 ////////////// 559 571 560 LONG_PTR lp; 561 i3=GetTypeFixed(term,&lp); 562 if(i3!=-1){ 563 type_stack[sp]=i3|FLAG_CAST; 564 index_stack[sp]=lp; 572 Type tempType; 573 if( Type::StringToType( term, tempType ) ){ 574 type_stack[sp] = tempType.GetBasicType() | FLAG_CAST; 575 index_stack[sp] = tempType.GetIndex(); 565 576 sp++; 566 577 break; 567 578 } 568 569 579 570 580 -
BasicCompiler_Common/Procedure.cpp
r78 r79 120 120 Type::StringToType( temporary, type ); 121 121 122 /*123 TODO: 消す(TypeDef関連の変更)124 if(temporary[0]=='*'&&125 temporary[1]==1&&126 (temporary[2]==ESC_FUNCTION||temporary[2]==ESC_SUB)){127 if(sourceOfParams[i]!='('){128 SetError(10,temporary,nowLine);129 break;130 }131 i3=GetStringInPare(temporary+i2,sourceOfParams+i);132 i+=i3;133 i2+=i3;134 135 if(temporary[2]==ESC_FUNCTION&&sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){136 temporary[i2++]=sourceOfParams[i++];137 temporary[i2++]=sourceOfParams[i++];138 for(;;i++,i2++){139 if(!IsVariableChar(sourceOfParams[i])){140 temporary[i2]=0;141 break;142 }143 temporary[i2]=sourceOfParams[i];144 }145 }146 }147 else{148 //TypeDefをする前のベース型を取得149 GetOriginalTypeName_Old(temporary);150 }*/151 152 122 if( type.IsNull() ){ 153 123 SetError(3,temporary,nowLine); … … 159 129 SetError(-103,temporary,nowLine); 160 130 } 161 162 /*163 TODO: 消す(TypeDef関連の変更)164 if( type.IsProcPtr() ){165 //関数ポインタの場合166 type.SetIndex( AddProcPtrInfo(temporary+3,temporary[2], nowLine) );167 }*/168 131 169 132 Parameter *pParam = new Parameter( name, type, isRef, initValue ); … … 278 241 Type::StringToType( temporary, type ); 279 242 280 /*281 TODO: 消す(TypeDef関連の変更)282 if(temporary[0]=='*'&&283 temporary[1]==1&&284 (temporary[2]==ESC_FUNCTION||temporary[2]==ESC_SUB)){285 if(sourceOfParams[i]!='('){286 SetError(10,temporary,nowLine);287 break;288 }289 i3=GetStringInPare(temporary+i2,sourceOfParams+i);290 i+=i3;291 i2+=i3;292 293 if(temporary[2]==ESC_FUNCTION&&sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){294 temporary[i2++]=sourceOfParams[i++];295 temporary[i2++]=sourceOfParams[i++];296 for(;;i++,i2++){297 if(!IsVariableChar(sourceOfParams[i])){298 temporary[i2]=0;299 break;300 }301 temporary[i2]=sourceOfParams[i];302 }303 }304 }305 else{306 //TypeDefをする前のベース型を取得307 GetOriginalTypeName_Old(temporary);308 }*/309 310 243 if( type.IsNull() ){ 311 244 SetError(3,temporary,nowLine); … … 317 250 SetError(-103,temporary,nowLine); 318 251 } 319 320 /*321 TODO: 消す(TypeDef関連の変更)322 if( type.IsProcPtr() ){323 //関数ポインタの場合324 type.SetIndex( AddProcPtrInfo(temporary+3,temporary[2], nowLine) );325 }*/326 252 327 253 Parameter *pParam = new Parameter( name, type, isRef ); … … 535 461 Type::StringToType( temporary, type ); 536 462 537 /*538 TODO: 消す(TypeDef関連の変更)539 if(temporary[0]=='*'&&540 temporary[1]==1&&541 (temporary[2]==ESC_FUNCTION||temporary[2]==ESC_SUB)){542 if(sourceOfParams[i]!='('){543 SetError(10,temporary,nowLine);544 break;545 }546 i3=GetStringInPare(temporary+i2,sourceOfParams+i);547 i+=i3;548 i2+=i3;549 550 if(temporary[2]==ESC_FUNCTION&&sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){551 temporary[i2++]=sourceOfParams[i++];552 temporary[i2++]=sourceOfParams[i++];553 for(;;i++,i2++){554 if(!IsVariableChar(sourceOfParams[i])){555 temporary[i2]=0;556 break;557 }558 temporary[i2]=sourceOfParams[i];559 }560 }561 }562 else{563 //TypeDefをする前のベース型を取得564 GetOriginalTypeName_Old(temporary);565 }*/566 567 463 if( type.IsNull() ){ 568 464 SetError(3,temporary,nowLine); … … 574 470 SetError(-103,temporary,nowLine); 575 471 } 576 577 /*578 TODO: 消す(TypeDef関連の変更)579 if( type.IsProcPtr() ){580 //関数ポインタの場合581 type.SetIndex( AddProcPtrInfo(temporary+3,temporary[2], nowLine ) );582 }*/583 472 584 473 Parameter *pParam = new Parameter( name, type, isRef ); … … 743 632 Type::StringToType( temporary, type ); 744 633 745 /*746 TODO: 消す(TypeDef関連の変更)747 if(temporary[0]=='*'&&748 temporary[1]==1&&749 (temporary[2]==ESC_FUNCTION||temporary[2]==ESC_SUB)){750 if(sourceOfParams[i]!='('){751 SetError(10,temporary,nowLine);752 break;753 }754 i3=GetStringInPare(temporary+i2,sourceOfParams+i);755 i+=i3;756 i2+=i3;757 758 if(temporary[2]==ESC_FUNCTION&&sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){759 temporary[i2++]=sourceOfParams[i++];760 temporary[i2++]=sourceOfParams[i++];761 for(;;i++,i2++){762 if(!IsVariableChar(sourceOfParams[i])){763 temporary[i2]=0;764 break;765 }766 temporary[i2]=sourceOfParams[i];767 }768 }769 }770 else{771 //TypeDefをする前のベース型を取得772 GetOriginalTypeName_Old(temporary);773 }*/774 775 634 if( type.IsNull() ){ 776 635 SetError(3,temporary,nowLine); … … 782 641 SetError(-103,temporary,nowLine); 783 642 } 784 785 /*786 TODO: 消す(TypeDef関連の変更)787 if( type.IsProcPtr() ){788 //関数ポインタの場合789 type.SetIndex( AddProcPtrInfo(temporary+3,temporary[2], nowLine ) );790 }*/791 643 792 644 Parameter *pParam = new Parameter( name, type, isRef ); -
BasicCompiler_Common/Subroutine.cpp
r78 r79 783 783 House::procPointers.push_back( pProcPointer ); 784 784 785 return House::procPointers.size()-1;785 return (int)House::procPointers.size()-1; 786 786 } 787 787 void DeleteProcPtrInfo(void){ -
BasicCompiler_Common/Type.h
r77 r79 4 4 5 5 class Type{ 6 static const int basicTypeList[];7 static const string basicTypeNameList[];8 9 10 6 int basicType; 11 7 union{ … … 15 11 16 12 public: 17 18 static bool StringToBasicType( const string &typeName, int &basicType );19 static bool StringToType( const string &typeName, Type &type );20 13 static int GetBasicSize( int basicType ); 21 14 … … 124 117 125 118 static Type String(); 119 120 121 private: 122 static const int basicTypeList[]; 123 static const string basicTypeNameList[]; 124 public: 125 static bool StringToBasicType( const string &typeName, int &basicType ); 126 static bool StringToType( const string &typeName, Type &type ); 126 127 }; -
BasicCompiler_Common/TypeDef.cpp
r78 r79 52 52 } 53 53 int TypeDefCollection::GetIndex( const string &typeName ) const{ 54 int max = ( *this).size();54 int max = (int)(*this).size(); 55 55 for( int i=0; i<max; i++ ){ 56 56 if( (*this)[i].newName == typeName ){ -
BasicCompiler_Common/VariableOpe.cpp
r78 r79 179 179 return MAKE_PTR_TYPE(NATURAL_TYPE(type),PTR_LEVEL(type)+1); 180 180 } 181 int GetTypeFixed(const char *TypeName,LONG_PTR *lpNum){182 int type;183 184 if(lpNum) *lpNum=-1;185 186 if(TypeName[0]=='*'){187 if(TypeName[1]==1&&(TypeName[2]==ESC_FUNCTION||TypeName[2]==ESC_SUB)){188 //関数ポインタ(*Function)189 return DEF_PTR_PROC;190 }191 192 type=GetTypeFixed(TypeName+1,lpNum);193 if(type==-1) return -1;194 195 return GetPtrType(type);196 }197 198 //整数型199 if(lstrcmpi(TypeName,"SByte")==0) return DEF_SBYTE;200 else if(lstrcmpi(TypeName,"Byte")==0) return DEF_BYTE;201 else if(lstrcmpi(TypeName,"Integer")==0) return DEF_INTEGER;202 else if(lstrcmpi(TypeName,"WORD")==0) return DEF_WORD;203 else if(lstrcmpi(TypeName,"Long")==0) return DEF_LONG;204 else if(lstrcmpi(TypeName,"DWORD")==0) return DEF_DWORD;205 else if(lstrcmpi(TypeName,"Int64")==0) return DEF_INT64;206 else if(lstrcmpi(TypeName,"QWORD")==0) return DEF_QWORD;207 208 //実数型209 else if(lstrcmpi(TypeName,"Single")==0) return DEF_SINGLE;210 else if(lstrcmpi(TypeName,"Double")==0) return DEF_DOUBLE;211 212 //文字型213 //else if( lstrcmpi( TypeName, "Char" ) == 0 ) return DEF_CHAR;214 215 //bool型216 else if( lstrcmpi( TypeName, "Boolean" ) == 0 ) return DEF_BOOLEAN;217 218 //ポインタ型219 //※VoidPtr型以外のポインタ型はTypeDef宣言により定義される220 else if(lstrcmpi(TypeName,"VoidPtr")==0) return DEF_PTR_VOID;221 222 //その他223 else if(lstrcmpi(TypeName,"Any")==0) return DEF_ANY;224 225 226 ////////////////////227 // TypeDefされた型228 ////////////////////229 int i;230 i=House::typeDefs.GetIndex(TypeName);231 if(i!=-1){232 *lpNum = House::typeDefs[i].GetBaseType().GetIndex();233 return House::typeDefs[i].GetBaseType().GetBasicType();234 }235 236 if(!lpNum) return -1;237 238 //クラス239 CClass *pobj_c;240 pobj_c=pobj_DBClass->check(TypeName);241 if(pobj_c){242 *lpNum=(LONG_PTR)pobj_c;243 244 if( pobj_c->IsStructure() ){245 return DEF_STRUCT;246 }247 else{248 return DEF_OBJECT;249 }250 }251 252 return -1;253 }254 /*255 TODO: 消す(TypeDef関連の変更)256 void GetOriginalTypeName_Old(char *buffer){257 // TypeDefされた型に対して、オリジナルの型の名前に変更する258 259 if(buffer[0]=='*'){260 if(buffer[1]==1&&(buffer[2]==ESC_FUNCTION||buffer[2]==ESC_SUB)) return;261 262 GetOriginalTypeName_Old(buffer+1);263 return;264 }265 266 int i;267 i=House::typeDefs.GetIndex(buffer);268 if(i!=-1){269 lstrcpy(buffer,House::typeDefs[i].GetBaseName().c_str());270 GetOriginalTypeName_Old(buffer);271 }272 }*/273 181 BOOL GetTypeName(int type,LONG_PTR lpIndex,char *name){ 274 182 if(PTR_LEVEL(type)){ … … 948 856 // 初期化データが指定されいるとき 949 857 //////////////////////////////////// 950 951 for(i++,i2=0,IsStr=0;;i++,i2++){ 952 if(buffer[i]=='\"') IsStr^=1; 953 if(buffer[i]=='('&&IsStr==0){ 954 i3=GetStringInPare(InitBuf+i2,buffer+i); 955 i+=i3-1; 956 i2+=i3-1; 957 continue; 958 } 959 if(buffer[i]=='['&&IsStr==0){ 960 i3=GetStringInBracket(InitBuf+i2,buffer+i); 961 i+=i3-1; 962 i2+=i3-1; 963 continue; 964 } 965 if((buffer[i]==1&&buffer[i+1]==ESC_AS)|| 966 (buffer[i]==','&&IsStr==0)|| 967 buffer[i]=='\0'){ 968 InitBuf[i2]=0; 969 break; 970 } 971 InitBuf[i2]=buffer[i]; 858 i++; 859 860 if( buffer[i]=='[' ){ 861 // 構造初期データの場合 862 863 i3=GetStringInBracket(InitBuf,buffer+i); 864 i+=i3; 865 } 866 else{ 867 // 代入初期データの場合 868 869 for(i2=0,IsStr=0;;i++,i2++){ 870 if(buffer[i]=='\"') IsStr^=1; 871 if(buffer[i]=='('&&IsStr==0){ 872 i3=GetStringInPare(InitBuf+i2,buffer+i); 873 i+=i3-1; 874 i2+=i3-1; 875 continue; 876 } 877 if(buffer[i]=='['&&IsStr==0){ 878 i3=GetStringInBracket(InitBuf+i2,buffer+i); 879 i+=i3-1; 880 i2+=i3-1; 881 continue; 882 } 883 if((buffer[i]==','&&IsStr==0)|| 884 buffer[i]=='\0'){ 885 InitBuf[i2]=0; 886 break; 887 } 888 InitBuf[i2]=buffer[i]; 889 } 972 890 } 973 891 } … … 1052 970 return false; 1053 971 } 972 973 if( IS_LITERAL( type.GetIndex() ) ){ 974 type.SetIndex( -1 ); 975 } 1054 976 } 1055 977 … … 1099 1021 1100 1022 1101 void AddGlobalVariable( bool isRef,const char *name,int *SubScripts, const Type &type,char *InitBuf,char *ConstractParameter,DWORD dwFlag){1023 void AddGlobalVariable( const char *name,int *SubScripts, const Type &type,char *InitBuf,char *ConstractParameter,DWORD dwFlag){ 1102 1024 ///////////////////////// 1103 1025 // グローバル変数を追加 … … 1114 1036 bool isConst = ( dwFlag & DIMFLAG_CONST ) ? true:false; 1115 1037 1116 Variable *pVar = new Variable( name, type, isConst , isRef);1038 Variable *pVar = new Variable( name, type, isConst ); 1117 1039 1118 1040 if( SubScripts[0] != -1 ){ … … 1217 1139 char VarName[VN_SIZE]; 1218 1140 1219 //参照型かどうか1220 bool isRef = false;1221 1222 1141 i2 = 0; 1223 1142 1224 1143 if( Parameter[i2] == 1 && Parameter[i2+1] == ESC_BYREF ){ 1225 1144 //参照型 1226 isRef = true;1145 SetError(); 1227 1146 Parameter += 2; 1228 1147 } … … 1290 1209 GetNowStaticVarFullName(VarName,temporary); 1291 1210 1292 dim( isRef,temporary,SubScripts,type,InitBuf,ConstractParameter,dwFlags );1211 dim( temporary,SubScripts,type,InitBuf,ConstractParameter,dwFlags ); 1293 1212 1294 1213 /* … … 1298 1217 } 1299 1218 else{ 1300 dim( isRef,VarName,SubScripts,type,InitBuf,ConstractParameter,dwFlags );1219 dim( VarName,SubScripts,type,InitBuf,ConstractParameter,dwFlags ); 1301 1220 } 1302 1221 } -
BasicCompiler_Common/VariableOpe.h
r78 r79 13 13 int GetTypeSize(int type,LONG_PTR lpIndex); 14 14 int GetPtrType(int type); 15 int GetTypeFixed(const char *TypeName,LONG_PTR *lpNum);16 /*17 TODO: 消す(TypeDef関連の変更)18 void GetOriginalTypeName_Old(char *buffer);19 void GetOriginalTypeName(char *buffer);20 */21 15 BOOL GetTypeName(int type,LONG_PTR lpIndex,char *name); 22 16 bool FormatUseProcReturnObject( const char *term, char *procName, char *parameter, CClass::RefType &refType, char *member ); … … 37 31 char *ConstractParameter ); 38 32 BOOL GetNowStaticVarFullName(char *VarName,char *FullName); 39 void AddGlobalVariable( bool isRef,const char *name,int *SubScripts, const Type &type,char *InitBuf,char *ConstractParameter,DWORD dwFlag);33 void AddGlobalVariable( const char *name,int *SubScripts, const Type &type,char *InitBuf,char *ConstractParameter,DWORD dwFlag); 40 34 void dim(char *Parameter,DWORD dwFlags); 41 35 void OpcodeDim(char *Parameter,DWORD dwFlags); -
BasicCompiler_Common/calculation.cpp
r78 r79 483 483 type[pnum]=DEF_LONG; 484 484 485 LONG_PTR lpIndex; 486 i3=GetTypeFixed(temp2,&lpIndex); 487 if(i3==-1){ 488 extern int cp; 485 Type tempType; 486 if( !Type::StringToType( temp2, tempType ) ){ 489 487 if(enableerror) SetError(3,temp2,cp); 490 488 return false; 491 489 } 492 i64nums[pnum] =GetTypeSize(i3,lpIndex);490 i64nums[pnum] = tempType.GetSize(); 493 491 StrPtr[pnum]=0; 494 492 } … … 688 686 ////////////// 689 687 690 type[pnum]=GetTypeFixed(Parms,&before_index[pnum]); 691 692 if(type[pnum]==-1){ 693 if(bDebuggingWatchList){ 694 if( pIsMemoryAccessError ) *pIsMemoryAccessError = true; 688 { 689 Type tempType; 690 if( !Type::StringToType( Parms, tempType ) ){ 691 if(bDebuggingWatchList){ 692 if( pIsMemoryAccessError ) *pIsMemoryAccessError = true; 693 return false; 694 } 695 //エラー 696 if(enableerror) SetError(3,Parms,cp); 695 697 return false; 696 698 } 697 //エラー 698 if(enableerror) SetError(3,Parms,cp);699 return false;699 700 type[pnum] = tempType.GetBasicType(); 701 before_index[pnum] = tempType.GetIndex(); 700 702 } 703 701 704 JumpConst:; 702 705 } -
BasicCompiler_Common/common.h
r78 r79 47 47 48 48 #ifdef _AMD64_ 49 #define VER_INFO "β1 6(x64)"49 #define VER_INFO "β17 (x64)" 50 50 #else 51 #define VER_INFO "β1 6"51 #define VER_INFO "β17" 52 52 #endif 53 53
Note:
See TracChangeset
for help on using the changeset viewer.