Changeset 543 in dev for trunk/ab5.0/abdev/BasicCompiler_Common
- Timestamp:
- May 4, 2008, 2:00:36 AM (17 years ago)
- Location:
- trunk/ab5.0/abdev/BasicCompiler_Common
- Files:
-
- 1 added
- 5 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]; -
trunk/ab5.0/abdev/BasicCompiler_Common/common.h
r523 r543 290 290 291 291 //Intermediate_Step2.cpp 292 bool GetConstInfo(void);293 292 void ChangeCommandToCode(char *buffer); 294 293 -
trunk/ab5.0/abdev/BasicCompiler_Common/include/Const.h
r524 r543 1 1 #pragma once 2 3 void AddConst( const NamespaceScopes &namespaceScopes, char *buffer );4 2 5 3 //定数 … … 71 69 public: 72 70 73 void Add( const NamespaceScopes &namespaceScopes, char *buffer); 74 void Add( const NamespaceScopes &namespaceScopes, const std::string &name, char *Expression); 71 void Add( const NamespaceScopes &namespaceScopes, const std::string &name, const char *Expression); 75 72 void Add( const NamespaceScopes &namespaceScopes, const std::string &name, int value); 76 73 -
trunk/ab5.0/abdev/BasicCompiler_Common/include/LexicalAnalyzer.h
r542 r543 34 34 static void CollectTypeDefs( const char *source, TypeDefCollection &typeDefs ); 35 35 36 // 定数を収集する 37 static void AddConstEnum( Consts &consts, const NamespaceScopes &namespaceScopes, const char *buffer ); 38 static void CollectConsts( const char *source, Consts &consts, ConstMacros &constMacros ); 39 36 40 // クラスを収集する 37 41 static void AddMethod(CClass *pobj_c, UserProc *pUserProc, Prototype::Accessibility accessibility, BOOL bStatic, bool isConst, bool isAbstract, -
trunk/ab5.0/abdev/BasicCompiler_Common/src/Const.cpp
r523 r543 11 11 } 12 12 13 void AddConst( const NamespaceScopes &namespaceScopes, char *buffer ){ 14 int i; 15 16 //名前を取得 17 char name[VN_SIZE]; 18 for(i=0;;i++){ 19 if(buffer[i]=='\0'){ 20 compiler.errorMessenger.Output(10,"Const",cp); 21 return; 22 } 23 if(buffer[i]=='='||buffer[i]=='('){ 24 name[i]=0; 25 break; 26 } 27 name[i]=buffer[i]; 28 } 29 30 //重複チェック 31 if( compiler.GetObjectModule().meta.GetGlobalConstMacros().IsExist( name ) 32 || compiler.GetObjectModule().meta.GetGlobalConsts().IsExist( name ) ) 33 { 34 compiler.errorMessenger.Output(15,name,cp); 35 return; 36 } 37 38 if(buffer[i] == '('){ 39 //定数マクロ 40 41 compiler.GetObjectModule().meta.GetGlobalConstMacros().Add( namespaceScopes, name, buffer + i ); 42 } 43 else{ 44 //一般の定数 45 char *expression = buffer + i + 1; 46 47 compiler.GetObjectModule().meta.GetGlobalConsts().Add( namespaceScopes, name, expression ); 48 } 49 } 50 51 void Consts::Add( const NamespaceScopes &namespaceScopes, const std::string &name , char *Expression) 13 void Consts::Add( const NamespaceScopes &namespaceScopes, const std::string &name , const char *Expression) 52 14 { 53 15 _int64 i64data;
Note:
See TracChangeset
for help on using the changeset viewer.