Changeset 578 in dev for trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer_Const.cpp
- Timestamp:
- May 8, 2008, 2:20:23 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer_Const.cpp
r564 r578 202 202 compiler.GetObjectModule().meta.GetGlobalConstMacros().Iterator_Init(); 203 203 } 204 205 bool LexicalAnalyzer::ConstMacroToExpression( const ConstMacro &constMacro, const char *parameterStr, char *dest ) 206 { 207 extern HANDLE hHeap; 208 int i2,i3,i4,num; 209 char temporary[VN_SIZE]; 210 char *pParms[MAX_PARMS]; 211 num=0; 212 i2=0; 213 while(1){ 214 i2=GetOneParameter(parameterStr,i2,temporary); 215 216 pParms[num]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1); 217 lstrcpy(pParms[num],temporary); 218 219 num++; 220 if(parameterStr[i2]=='\0') break; 221 } 222 if( num != constMacro.GetParameters().size() ){ 223 extern int cp; 224 for(i2=0;i2<num;i2++) HeapDefaultFree(pParms[i2]); 225 compiler.errorMessenger.Output(10,constMacro.GetName().c_str(),cp); 226 lstrcpy(dest,"0"); 227 return true; 228 } 229 230 i2=0; 231 i4=0; 232 while(1){ 233 234 //数式内の項を取得 235 for(i3=0;;i2++,i3++){ 236 if(!IsVariableChar( constMacro.GetExpression()[i2] )){ 237 temporary[i3]=0; 238 break; 239 } 240 temporary[i3] = constMacro.GetExpression()[i2]; 241 } 242 243 //パラメータと照合する 244 for( i3=0; i3<(int)constMacro.GetParameters().size(); i3++ ){ 245 if( constMacro.GetParameters()[i3] == temporary ) break; 246 } 247 248 if( i3 == (int)constMacro.GetParameters().size() ){ 249 //パラメータでないとき 250 lstrcpy(dest+i4,temporary); 251 i4+=lstrlen(temporary); 252 } 253 else{ 254 //パラメータのとき 255 lstrcpy(dest+i4,pParms[i3]); 256 i4+=lstrlen(pParms[i3]); 257 } 258 259 //演算子をコピー 260 for(;;i2++,i4++){ 261 if( constMacro.GetExpression()[i2] == 1 ){ 262 dest[i4++] = constMacro.GetExpression()[i2++]; 263 dest[i4] = constMacro.GetExpression()[i2]; 264 continue; 265 } 266 if(IsVariableTopChar( constMacro.GetExpression()[i2] )) break; 267 dest[i4] = constMacro.GetExpression()[i2]; 268 if( constMacro.GetExpression()[i2] == '\0' ) break; 269 } 270 271 if( constMacro.GetExpression()[i2] == '\0' ) break; 272 } 273 274 for(i2=0;i2<num;i2++) HeapDefaultFree(pParms[i2]); 275 276 return true; 277 }
Note:
See TracChangeset
for help on using the changeset viewer.