Changeset 578 in dev
- Timestamp:
- May 8, 2008, 2:20:23 PM (17 years ago)
- Location:
- trunk/ab5.0/abdev
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/abdev/BasicCompiler_Common/NumOpe_GetType.cpp
r566 r578 537 537 if( pConstMacro ) 538 538 { 539 if( pConstMacro->GetCalcBuffer(parameter, temporary ) )539 if( ActiveBasic::Compiler::LexicalAnalyzer::ConstMacroToExpression( *pConstMacro, parameter, temporary ) ) 540 540 { 541 541 ///////////////////////// -
trunk/ab5.0/abdev/BasicCompiler_Common/calculation.cpp
r485 r578 504 504 return false; 505 505 } 506 if( ! pConstMacro->GetCalcBuffer(temp2, Parms ) )506 if( !ActiveBasic::Compiler::LexicalAnalyzer::ConstMacroToExpression( *pConstMacro, temp2, Parms ) ) 507 507 { 508 508 if(enableerror) compiler.errorMessenger.Output(3,temporary,cp); … … 1227 1227 //マクロ関数の場合 1228 1228 GetStringInPare_RemovePare(temporary,Command+i2+i3+1); 1229 pConstMacro->GetCalcBuffer(temporary, temp2 );1229 ActiveBasic::Compiler::LexicalAnalyzer::ConstMacroToExpression( *pConstMacro, temporary, temp2 ); 1230 1230 return IsStrCalculation(temp2); 1231 1231 } -
trunk/ab5.0/abdev/BasicCompiler_Common/include/Const.h
r543 r578 127 127 return expression; 128 128 } 129 130 bool GetCalcBuffer( const char *parameterStr, char *dest ) const;131 129 }; 132 130 class ConstMacros : public Jenga::Common::Hashmap<ConstMacro> -
trunk/ab5.0/abdev/BasicCompiler_Common/include/LexicalAnalyzer.h
r573 r578 42 42 static void AddConstEnum( Consts &consts, const NamespaceScopes &namespaceScopes, const char *buffer ); 43 43 static void CollectConsts( const char *source, Consts &consts, ConstMacros &constMacros ); 44 static bool ConstMacroToExpression( const ConstMacro &constMacro, const char *parameterStr, char *dest ); 44 45 45 46 // クラスを収集する -
trunk/ab5.0/abdev/BasicCompiler_Common/src/Const.cpp
r543 r578 86 86 } 87 87 88 89 bool ConstMacro::GetCalcBuffer( const char *parameterStr, char *dest ) const90 {91 extern HANDLE hHeap;92 int i2,i3,i4,num;93 char temporary[VN_SIZE];94 char *pParms[MAX_PARMS];95 num=0;96 i2=0;97 while(1){98 i2=GetOneParameter(parameterStr,i2,temporary);99 100 pParms[num]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);101 lstrcpy(pParms[num],temporary);102 103 num++;104 if(parameterStr[i2]=='\0') break;105 }106 if( num != this->GetParameters().size() ){107 extern int cp;108 for(i2=0;i2<num;i2++) HeapDefaultFree(pParms[i2]);109 compiler.errorMessenger.Output(10,GetName().c_str(),cp);110 lstrcpy(dest,"0");111 return 1;112 }113 114 i2=0;115 i4=0;116 while(1){117 118 //数式内の項を取得119 for(i3=0;;i2++,i3++){120 if(!IsVariableChar( this->GetExpression()[i2] )){121 temporary[i3]=0;122 break;123 }124 temporary[i3] = this->GetExpression()[i2];125 }126 127 //パラメータと照合する128 for( i3=0; i3<(int)this->GetParameters().size(); i3++ ){129 if( this->GetParameters()[i3] == temporary ) break;130 }131 132 if( i3 == (int)this->GetParameters().size() ){133 //パラメータでないとき134 lstrcpy(dest+i4,temporary);135 i4+=lstrlen(temporary);136 }137 else{138 //パラメータのとき139 lstrcpy(dest+i4,pParms[i3]);140 i4+=lstrlen(pParms[i3]);141 }142 143 //演算子をコピー144 for(;;i2++,i4++){145 if( this->GetExpression()[i2] == 1 ){146 dest[i4++] = this->GetExpression()[i2++];147 dest[i4] = this->GetExpression()[i2];148 continue;149 }150 if(IsVariableTopChar( this->GetExpression()[i2] )) break;151 dest[i4] = this->GetExpression()[i2];152 if( this->GetExpression()[i2] == '\0' ) break;153 }154 155 if( this->GetExpression()[i2] == '\0' ) break;156 }157 158 for(i2=0;i2<num;i2++) HeapDefaultFree(pParms[i2]);159 160 return 1;161 }162 163 88 // マクロ定数を追加するための関数 164 89 void ConstMacros::Add( const NamespaceScopes &namespaceScopes, const std::string &name, const char *parameterStr ) -
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 } -
trunk/ab5.0/abdev/compiler_x86/NumOpe.cpp
r566 r578 518 518 if( pConstMacro ) 519 519 { 520 if( pConstMacro->GetCalcBuffer(parameter, temporary ) )520 if( ActiveBasic::Compiler::LexicalAnalyzer::ConstMacroToExpression( *pConstMacro, parameter, temporary ) ) 521 521 { 522 522 /////////////////////////
Note:
See TracChangeset
for help on using the changeset viewer.