Changeset 113 in dev for BasicCompiler_Common/TypeDef.cpp
- Timestamp:
- May 10, 2007, 12:27:41 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler_Common/TypeDef.cpp
r96 r113 2 2 3 3 4 TypeDef::TypeDef( const string &newName, const string &baseName ): 5 newName( newName ), 6 baseName( baseName ) 4 TypeDef::TypeDef( const NamespaceScopes &namespaceScopes, const string &name, const string &baseName ) 5 : namespaceScopes( namespaceScopes ) 6 , name( name ) 7 , baseName( baseName ) 7 8 { 8 9 if( !Type::StringToType( baseName, baseType ) ){ … … 14 15 } 15 16 17 bool TypeDef::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const 18 { 19 if( GetName() != name ){ 20 return false; 21 } 22 return NamespaceScopes::IsSameArea( this->namespaceScopes, namespaceScopes ); 23 } 24 bool TypeDef::IsEqualSymbol( const string &fullName ) const 25 { 26 char AreaName[VN_SIZE] = ""; //オブジェクト変数 27 char NestName[VN_SIZE] = ""; //入れ子メンバ 28 bool isNest = SplitMemberName( fullName.c_str(), AreaName, NestName ); 29 30 if( IsEqualSymbol( NamespaceScopes( AreaName ), NestName ) ){ 31 return true; 32 } 33 34 if( isNest ){ 35 // 静的メンバを考慮 36 37 char AreaName2[VN_SIZE] = ""; //オブジェクト変数 38 char NestName2[VN_SIZE] = ""; //入れ子メンバ 39 bool isNest = SplitMemberName( AreaName, AreaName2, NestName2 ); 40 lstrcat( NestName2, "." ); 41 lstrcat( NestName2, NestName ); 42 43 return IsEqualSymbol( NamespaceScopes( AreaName2 ), NestName2 ); 44 } 45 46 return false; 47 } 48 49 16 50 17 51 TypeDefCollection::TypeDefCollection(){ … … 19 53 TypeDefCollection::~TypeDefCollection(){ 20 54 } 21 void TypeDefCollection::Add( const string &newName, const string &baseName ){22 TypeDef typeDef( n ewName, baseName );55 void TypeDefCollection::Add( const NamespaceScopes &namespaceScopes, const string &name, const string &baseName ){ 56 TypeDef typeDef( namespaceScopes, name, baseName ); 23 57 this->push_back( typeDef ); 24 58 } … … 26 60 int max = (int)(*this).size(); 27 61 for( int i=0; i<max; i++ ){ 28 if( (*this)[i]. newName == typeName){62 if( (*this)[i].IsEqualSymbol( typeName ) ){ 29 63 return i; 30 64 } … … 33 67 } 34 68 35 void TypeDefCollection::Add( const string &expression, int nowLine ){69 void TypeDefCollection::Add( const NamespaceScopes &namespaceScopes, const string &expression, int nowLine ){ 36 70 int i; 37 71 char temporary[VN_SIZE]; … … 98 132 cp = nowLine; 99 133 100 Smoothie::Meta::typeDefs.Add(temporary,pTemp);134 Add( namespaceScopes, temporary, pTemp ); 101 135 } 102 136 … … 105 139 clear(); 106 140 107 int i=-1; 141 // 名前空間管理 142 NamespaceScopes &namespaceScopes = Smoothie::Lexical::liveingNamespaceScopes; 143 namespaceScopes.clear(); 144 145 // Importsされた名前空間の管理 146 NamespaceScopesCollection &importedNamespaces = Smoothie::Meta::importedNamespaces; 147 importedNamespaces.clear(); 148 149 int i=-1, i2; 150 char temporary[VN_SIZE]; 108 151 while(1){ 152 extern char *basbuf; 153 109 154 i++; 110 155 111 extern char *basbuf; 156 if( basbuf[i] == 1 && basbuf[i+1] == ESC_NAMESPACE ){ 157 for(i+=2,i2=0;;i2++,i++){ 158 if( IsCommandDelimitation( basbuf[i] ) ){ 159 temporary[i2]=0; 160 break; 161 } 162 temporary[i2]=basbuf[i]; 163 } 164 namespaceScopes.push_back( temporary ); 165 166 continue; 167 } 168 else if( basbuf[i] == 1 && basbuf[i+1] == ESC_ENDNAMESPACE ){ 169 if( namespaceScopes.size() <= 0 ){ 170 SetError(12, "End Namespace", i ); 171 } 172 else{ 173 namespaceScopes.pop_back(); 174 } 175 176 i += 2; 177 continue; 178 } 179 else if( basbuf[i] == 1 && basbuf[i+1] == ESC_IMPORTS ){ 180 for(i+=2,i2=0;;i2++,i++){ 181 if( IsCommandDelimitation( basbuf[i] ) ){ 182 temporary[i2]=0; 183 break; 184 } 185 temporary[i2]=basbuf[i]; 186 } 187 importedNamespaces.Imports( temporary ); 188 189 continue; 190 } 191 else if( basbuf[i] == 1 && basbuf[i+1] == ESC_CLEARNAMESPACEIMPORTED ){ 192 importedNamespaces.clear(); 193 continue; 194 } 195 112 196 if( basbuf[i]==1 ){ 113 197 char temporary[VN_SIZE]; … … 122 206 if(basbuf[i]=='\0') break; 123 207 } 124 Add( temporary,i);208 Add( namespaceScopes, temporary, i ); 125 209 126 210 continue; … … 136 220 if(basbuf[i]=='\0') break; 137 221 } 138 Smoothie::Meta::typeDefs.Add(temporary,"Long");222 Add( namespaceScopes, temporary, "Long" ); 139 223 } 140 224 }
Note:
See TracChangeset
for help on using the changeset viewer.