Changeset 205 in dev for trunk/jenga/src
- Timestamp:
- Jul 12, 2007, 2:57:04 AM (17 years ago)
- Location:
- trunk/jenga/src/smoothie
- Files:
-
- 7 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/jenga/src/smoothie/LexicalAnalysis.cpp
r173 r205 1 #include <jenga/include/smoothie/SmoothieException.h> 1 2 #include <jenga/include/smoothie/LexicalAnalysis.h> 3 #include <jenga/include/smoothie/BasicFixed.h> 2 4 3 5 #include <windows.h> … … 212 214 return i; 213 215 } 216 217 bool SplitMemberName( const char *desc, char *object, char *member, ReferenceKind &refType ){ 218 int lastIndex = -1; 219 for( int i=0; desc[i]; i++ ){ 220 if( desc[i] == '(' ){ 221 i=JumpStringInPare(desc,i+1); 222 continue; 223 } 224 else if( desc[i] == '[' ){ 225 i=JumpStringInBracket(desc,i+1); 226 continue; 227 } 228 else if(desc[i]=='.'||(desc[i]==1&&desc[i+1]==ESC_PSMEM)){ 229 lastIndex = i; 230 } 231 } 232 if( lastIndex == -1 ){ 233 lstrcpy( member, desc ); 234 return false; 235 } 236 237 if(desc[lastIndex]=='.'){ 238 lstrcpy(member,desc+lastIndex+1); 239 refType = RefDot; 240 } 241 else{ 242 lstrcpy(member,desc+lastIndex+2); 243 refType = RefPointer; 244 } 245 246 if( object ){ 247 lstrcpy( object, desc ); 248 object[lastIndex]=0; 249 } 250 251 return true; 252 } 253 bool SplitMemberName( const char *desc, char *object, char *member ){ 254 ReferenceKind dummyRefType; 255 return SplitMemberName( desc, object, member, dummyRefType ); 256 } 257 258 char *calcNames[255] = { 259 "xor", 260 }; 261 void InitCalcNames() 262 { 263 if( calcNames[CALC_XOR] ) 264 { 265 return; 266 } 267 268 memset( calcNames, 0, 255 * sizeof(char *) ); 269 calcNames[CALC_XOR] = "xor"; 270 calcNames[CALC_OR] = "or"; 271 calcNames[CALC_AND] = "and"; 272 calcNames[CALC_NOT] = "Not"; 273 calcNames[CALC_PE] = "<="; 274 calcNames[CALC_QE] = ">="; 275 calcNames[CALC_NOTEQUAL] = "<>"; 276 calcNames[CALC_EQUAL] = "=(compare)"; 277 calcNames[CALC_P] = "<"; 278 calcNames[CALC_Q] = ">"; 279 calcNames[CALC_SHL] = "<<"; 280 calcNames[CALC_SHR] = ">>"; 281 calcNames[CALC_ADDITION] = "+"; 282 calcNames[CALC_SUBTRACTION] = "-"; 283 calcNames[CALC_STRPLUS] = "-"; 284 calcNames[CALC_MOD] = "mod"; 285 calcNames[CALC_PRODUCT] = "*"; 286 calcNames[CALC_QUOTIENT] = "/"; 287 calcNames[CALC_INTQUOTIENT] = "\\"; 288 calcNames[CALC_AS] = "As"; 289 calcNames[CALC_BYVAL] = "ByVal"; 290 calcNames[CALC_MINUSMARK] = "-(mark)"; 291 calcNames[CALC_POWER] = "^"; 292 calcNames[CALC_SUBSITUATION] = "="; 293 calcNames[CALC_ARRAY_GET] = "[]"; 294 calcNames[CALC_ARRAY_SET] = "[]="; 295 } 296 void GetCalcName(int idCalc,char *name){ 297 InitCalcNames(); 298 299 if( calcNames[idCalc] == NULL ) 300 { 301 SmoothieException::Throw(); 302 } 303 lstrcpy( name, calcNames[idCalc] ); 304 } 305 BYTE ToCalcId( const char *name ) 306 { 307 InitCalcNames(); 308 309 for( int i=0; i<255; i++ ) 310 { 311 if( calcNames[i] ) 312 { 313 if( lstrcmp( name, calcNames[i] ) == 0 ) 314 { 315 return i; 316 } 317 } 318 } 319 SmoothieException::Throw(); 320 return 0; 321 } 322 323 std::string Operator_NaturalStringToCalcMarkString( const std::string &name ) 324 { 325 if( name[0] == 1 && name[1] == ESC_OPERATOR ) 326 { 327 BYTE calcId = ToCalcId( name.c_str()+2 ); 328 char temporary[255]; 329 temporary[0] = name[0]; 330 temporary[1] = name[1]; 331 temporary[2] = calcId; 332 temporary[3] = 0; 333 return temporary; 334 } 335 return name; 336 } 337 std::string Operator_CalcMarkStringToNaturalString( const std::string &name ) 338 { 339 if( name[0] == 1 && name[1] == ESC_OPERATOR ) 340 { 341 BYTE calcId = name[2]; 342 char temporary[255], calcName[255]; 343 GetCalcName( calcId, calcName ); 344 temporary[0] = name[0]; 345 temporary[1] = name[1]; 346 lstrcpy( temporary+2, calcName ); 347 return temporary; 348 } 349 return name; 350 } -
trunk/jenga/src/smoothie/LexicalScoping.cpp
r186 r205 1 1 #include <jenga/include/smoothie/LexicalScoping.h> 2 2 #include <jenga/include/smoothie/SmoothieException.h> 3 #include <jenga/include/smoothie/Variable.h>4 #include <jenga/include/smoothie/Procedure.h>5 3 6 4 … … 54 52 ppScopes[level] = CreateScope( level, addr, TypeOfStatement ); 55 53 } 56 void CLexicalScopes::End(){57 if( level <= 0 ){58 SmoothieException::Throw();59 return;60 }61 62 //デストラクタを呼ぶ63 CallDestructorsOfScopeEnd();64 65 Variables &vars = UserProc::IsGlobalAreaCompiling()?66 globalVars :67 UserProc::CompilingUserProc().localVars;68 69 //使用済みローカル変数の生存チェックを外す70 BOOST_FOREACH( Variable *pVar, vars ){71 if(pVar->bLiving&&pVar->ScopeLevel==level){72 pVar->bLiving=0;73 extern int obp;74 pVar->ScopeEndAddress=obp;75 }76 }77 78 79 //スコープ抜け出しスケジュール80 ppScopes[level]->RunScheduleOfBreak();81 82 83 //スコープレベルを下げる84 delete ppScopes[level];85 level--;86 }87 54 88 55 int CLexicalScopes::GetNowLevel(){ -
trunk/jenga/src/smoothie/Smoothie.cpp
r194 r205 4 4 BasicSource Smoothie::Lexical::source; 5 5 6 const CClass *Smoothie::Temp::pCompilingClass = NULL;7 8 6 bool Smoothie::isFullCompile = false;
Note:
See TracChangeset
for help on using the changeset viewer.