Changes in src/AST/Pass.proto.hpp [0e42794:d76c588]
- File:
-
- 1 edited
-
src/AST/Pass.proto.hpp (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Pass.proto.hpp
r0e42794 rd76c588 265 265 }; 266 266 267 // Finally certain pass desire an up to date symbol tableautomatically268 // detect the presence of a member name `symtab`and call all the members appropriately269 namespace symtab{267 // Finally certain pass desire an up to date indexer automatically 268 // detect the presence of a member name indexer and call all the members appropriately 269 namespace indexer { 270 270 // Some simple scoping rules 271 271 template<typename pass_t> 272 static inline auto enter( pass_t & pass, int ) -> decltype( pass. symtab.enterScope(), void() ) {273 pass. symtab.enterScope();272 static inline auto enter( pass_t & pass, int ) -> decltype( pass.indexer.enterScope(), void() ) { 273 pass.indexer.enterScope(); 274 274 } 275 275 … … 278 278 279 279 template<typename pass_t> 280 static inline auto leave( pass_t & pass, int ) -> decltype( pass. symtab.leaveScope(), void() ) {281 pass. symtab.leaveScope();280 static inline auto leave( pass_t & pass, int ) -> decltype( pass.indexer.leaveScope(), void() ) { 281 pass.indexer.leaveScope(); 282 282 } 283 283 … … 285 285 static inline auto leave( pass_t &, long ) {} 286 286 287 // The symbol tablehas 2 kind of functions mostly, 1 argument and 2 arguments287 // The indexer has 2 kind of functions mostly, 1 argument and 2 arguments 288 288 // Create macro to condense these common patterns 289 #define SYMTAB_FUNC1( func, type ) \289 #define INDEXER_FUNC1( func, type ) \ 290 290 template<typename pass_t> \ 291 static inline auto func( pass_t & pass, int, type arg ) -> decltype( pass. symtab.func( arg ), void() ) {\292 pass. symtab.func( arg ); \291 static inline auto func( pass_t & pass, int, type arg ) -> decltype( pass.indexer.func( arg ), void() ) {\ 292 pass.indexer.func( arg ); \ 293 293 } \ 294 294 \ … … 296 296 static inline void func( pass_t &, long, type ) {} 297 297 298 #define SYMTAB_FUNC2( func, type1, type2 ) \298 #define INDEXER_FUNC2( func, type1, type2 ) \ 299 299 template<typename pass_t> \ 300 static inline auto func( pass_t & pass, int, type1 arg1, type2 arg2 ) -> decltype( pass. symtab.func( arg1, arg2 ), void () ) {\301 pass. symtab.func( arg1, arg2 ); \300 static inline auto func( pass_t & pass, int, type1 arg1, type2 arg2 ) -> decltype( pass.indexer.func( arg1, arg2 ), void () ) {\ 301 pass.indexer.func( arg1, arg2 ); \ 302 302 } \ 303 303 \ … … 305 305 static inline void func( pass_t &, long, type1, type2 ) {} 306 306 307 SYMTAB_FUNC1( addId , const DeclWithType * );308 SYMTAB_FUNC1( addType , const NamedTypeDecl * );309 SYMTAB_FUNC1( addStruct , const StructDecl * );310 SYMTAB_FUNC1( addEnum , const EnumDecl * );311 SYMTAB_FUNC1( addUnion , const UnionDecl * );312 SYMTAB_FUNC1( addTrait , const TraitDecl * );313 SYMTAB_FUNC2( addWith , const std::vector< ptr<Expr> > &, const Node * );307 INDEXER_FUNC1( addId , const DeclWithType * ); 308 INDEXER_FUNC1( addType , const NamedTypeDecl * ); 309 INDEXER_FUNC1( addStruct , const StructDecl * ); 310 INDEXER_FUNC1( addEnum , const EnumDecl * ); 311 INDEXER_FUNC1( addUnion , const UnionDecl * ); 312 INDEXER_FUNC1( addTrait , const TraitDecl * ); 313 INDEXER_FUNC2( addWith , const std::vector< ptr<Expr> > &, const Node * ); 314 314 315 315 // A few extra functions have more complicated behaviour, they are hand written 316 316 template<typename pass_t> 317 static inline auto addStructFwd( pass_t & pass, int, const ast::StructDecl * decl ) -> decltype( pass. symtab.addStruct( decl ), void() ) {317 static inline auto addStructFwd( pass_t & pass, int, const ast::StructDecl * decl ) -> decltype( pass.indexer.addStruct( decl ), void() ) { 318 318 ast::StructDecl * fwd = new ast::StructDecl( decl->location, decl->name ); 319 319 fwd->params = decl->params; 320 pass. symtab.addStruct( fwd );320 pass.indexer.addStruct( fwd ); 321 321 } 322 322 … … 325 325 326 326 template<typename pass_t> 327 static inline auto addUnionFwd( pass_t & pass, int, const ast::UnionDecl * decl ) -> decltype( pass. symtab.addUnion( decl ), void() ) {327 static inline auto addUnionFwd( pass_t & pass, int, const ast::UnionDecl * decl ) -> decltype( pass.indexer.addUnion( decl ), void() ) { 328 328 UnionDecl * fwd = new UnionDecl( decl->location, decl->name ); 329 329 fwd->params = decl->params; 330 pass. symtab.addUnion( fwd );330 pass.indexer.addUnion( fwd ); 331 331 } 332 332 … … 335 335 336 336 template<typename pass_t> 337 static inline auto addStruct( pass_t & pass, int, const std::string & str ) -> decltype( pass. symtab.addStruct( str ), void() ) {338 if ( ! pass. symtab.lookupStruct( str ) ) {339 pass. symtab.addStruct( str );337 static inline auto addStruct( pass_t & pass, int, const std::string & str ) -> decltype( pass.indexer.addStruct( str ), void() ) { 338 if ( ! pass.indexer.lookupStruct( str ) ) { 339 pass.indexer.addStruct( str ); 340 340 } 341 341 } … … 345 345 346 346 template<typename pass_t> 347 static inline auto addUnion( pass_t & pass, int, const std::string & str ) -> decltype( pass. symtab.addUnion( str ), void() ) {348 if ( ! pass. symtab.lookupUnion( str ) ) {349 pass. symtab.addUnion( str );347 static inline auto addUnion( pass_t & pass, int, const std::string & str ) -> decltype( pass.indexer.addUnion( str ), void() ) { 348 if ( ! pass.indexer.lookupUnion( str ) ) { 349 pass.indexer.addUnion( str ); 350 350 } 351 351 } … … 354 354 static inline void addUnion( pass_t &, long, const std::string & ) {} 355 355 356 #undef SYMTAB_FUNC1357 #undef SYMTAB_FUNC2356 #undef INDEXER_FUNC1 357 #undef INDEXER_FUNC2 358 358 }; 359 359 };
Note:
See TracChangeset
for help on using the changeset viewer.