Changeset 543 in dev for trunk/ab5.0/abdev/BasicCompiler_Common/Intermediate_Step2.cpp
- Timestamp:
- May 4, 2008, 2:00:36 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/abdev/BasicCompiler_Common/Intermediate_Step2.cpp
r465 r543 5 5 #include "../BasicCompiler_Common/common.h" 6 6 7 8 void AddConstEnum( const NamespaceScopes &namespaceScopes, char *buffer){9 extern int cp;10 int i=0,i2;11 12 if(!(buffer[i]==1&&buffer[i+1]==ESC_ENUM)) return;13 i+=2;14 15 //列挙体の名前を取得16 char temporary[VN_SIZE];17 for(i2=0;;i++,i2++){18 if(IsCommandDelimitation(buffer[i])){19 temporary[i2]=0;20 break;21 }22 if(!IsVariableChar(buffer[i])){23 compiler.errorMessenger.Output(1,NULL,i);24 break;25 }26 temporary[i2]=buffer[i];27 }28 29 if(buffer[i]=='\0'){30 compiler.errorMessenger.Output(22,"Enum",cp);31 return;32 }33 34 int NextValue=0;35 while(1){36 i++;37 38 if(buffer[i]==1&&buffer[i+1]==ESC_ENDENUM) break;39 40 for(i2=0;;i2++,i++){41 if(IsCommandDelimitation(buffer[i])){42 temporary[i2]=0;43 break;44 }45 if(buffer[i]=='='){46 temporary[i2]=0;47 break;48 }49 temporary[i2]=buffer[i];50 }51 if(temporary[0]=='\0'){52 if(buffer[i]=='\0'){53 compiler.errorMessenger.Output(22,"Enum",cp);54 break;55 }56 continue;57 }58 59 if(buffer[i]!='='){60 NextValue++;61 }62 else{63 char temp2[VN_SIZE];64 for(i++,i2=0;;i2++,i++){65 if(IsCommandDelimitation(buffer[i])){66 temp2[i2]=0;67 break;68 }69 temp2[i2]=buffer[i];70 }71 72 _int64 i64data;73 StaticCalculation(true, temp2,DEF_LONG,&i64data,Type());74 NextValue=(int)i64data;75 }76 77 //定数を追加78 compiler.GetObjectModule().meta.GetGlobalConsts().Add( namespaceScopes, temporary, NextValue);79 }80 }81 bool GetConstInfo(void){82 ////////////////////////////////////////////83 // Const命令の情報を取得84 ////////////////////////////////////////////85 86 int i2;87 char temporary[1024];88 89 // 名前空間管理90 NamespaceScopes &namespaceScopes = compiler.GetNamespaceSupporter().GetLivingNamespaceScopes();91 namespaceScopes.clear();92 93 extern char *basbuf;94 for(int i=0;;i++){95 if( basbuf[i] == '\0' ) break;96 97 if( basbuf[i] == 1 && basbuf[i+1] == ESC_NAMESPACE ){98 for(i+=2,i2=0;;i2++,i++){99 if( IsCommandDelimitation( basbuf[i] ) ){100 temporary[i2]=0;101 break;102 }103 temporary[i2]=basbuf[i];104 }105 namespaceScopes.push_back( temporary );106 107 continue;108 }109 else if( basbuf[i] == 1 && basbuf[i+1] == ESC_ENDNAMESPACE ){110 if( namespaceScopes.size() <= 0 ){111 compiler.errorMessenger.Output(12, "End Namespace", i );112 }113 else{114 namespaceScopes.pop_back();115 }116 117 i += 2;118 continue;119 }120 121 if( basbuf[i] == 1 ){122 if(basbuf[i]==1&&basbuf[i+1]==ESC_CONST){123 i+=2;124 125 extern int cp;126 cp=i; //エラー用127 128 129 if(basbuf[i]==1&&basbuf[i+1]==ESC_ENUM){130 AddConstEnum( namespaceScopes, basbuf+i);131 continue;132 }133 134 for(i2=0;;i++,i2++){135 if(basbuf[i]=='\"'){136 temporary[i2]=basbuf[i];137 for(i++,i2++;;i++,i2++){138 temporary[i2]=basbuf[i];139 if(basbuf[i]=='\"') break;140 }141 continue;142 }143 if(IsCommandDelimitation(basbuf[i])){144 temporary[i2]=0;145 break;146 }147 temporary[i2]=basbuf[i];148 }149 AddConst( namespaceScopes, temporary);150 if(basbuf[i]=='\0') break;151 }152 else{153 int result = JumpStatement( basbuf, i );154 if( result == -1 ){155 //エラー156 return false;157 }158 else if( result == 1 ){159 //ジャンプした場合160 i--;161 }162 }163 }164 }165 166 // イテレータを初期化167 compiler.GetObjectModule().meta.GetGlobalConsts().Iterator_Init();168 compiler.GetObjectModule().meta.GetGlobalConstMacros().Iterator_Init();169 170 return true;171 }172 7 173 8 char ConstructorDestructorSchedule[MAX_PATH];
Note:
See TracChangeset
for help on using the changeset viewer.