- Timestamp:
- Apr 15, 2024, 12:03:53 PM (3 months ago)
- Branches:
- master
- Children:
- dc58e5d
- Parents:
- d9bad51
- Location:
- src/AST
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Decl.cpp
rd9bad51 raf746cc 169 169 } 170 170 171 const std::string EnumDecl::getUnmangeldArrayName( const ast::EnumAttribute attr ) const { 172 switch( attr ) { 173 case ast::EnumAttribute::Value: return "values_" + name ; 174 case ast::EnumAttribute::Label: return "labels_" + name; 175 default: /* Posn does not generate array */ 176 return ""; 177 } 178 } 179 171 180 } 172 181 -
src/AST/Decl.hpp
rd9bad51 raf746cc 303 303 }; 304 304 305 enum class EnumAttribute{ Value, Posn, Label }; 305 306 /// enum declaration `enum Foo { ... };` 306 307 class EnumDecl final : public AggregateDecl { … … 326 327 const char * typeString() const override { return aggrString( Enum ); } 327 328 328 329 const std::string getUnmangeldArrayName( const EnumAttribute attr ) const; 329 330 private: 330 331 EnumDecl * clone() const override { return new EnumDecl{ *this }; } -
src/AST/Fwd.hpp
rd9bad51 raf746cc 133 133 class OneType; 134 134 class GlobalScopeType; 135 class Enum PosType;135 class EnumAttrType; 136 136 137 137 class Designation; -
src/AST/Pass.hpp
rd9bad51 raf746cc 222 222 const ast::Type * visit( const ast::UnionInstType * ) override final; 223 223 const ast::Type * visit( const ast::EnumInstType * ) override final; 224 const ast::Type * visit( const ast::Enum PosType* ) override final;224 const ast::Type * visit( const ast::EnumAttrType * ) override final; 225 225 const ast::Type * visit( const ast::TraitInstType * ) override final; 226 226 const ast::Type * visit( const ast::TypeInstType * ) override final; -
src/AST/Pass.impl.hpp
rd9bad51 raf746cc 1986 1986 1987 1987 //-------------------------------------------------------------------------- 1988 // EnumPosType 1989 template< typename core_t > 1990 const ast::Type * ast::Pass< core_t >::visit( const ast::EnumPosType * node ) { 1991 VISIT_START( node ); 1992 1988 // EnumAttrType 1989 template< typename core_t > 1990 const ast::Type * ast::Pass< core_t >::visit( const ast::EnumAttrType * node ) { 1991 VISIT_START( node ); 1993 1992 VISIT_END( Type, node ); 1994 1993 } -
src/AST/Print.cpp
rd9bad51 raf746cc 1576 1576 } 1577 1577 1578 virtual const ast::Type * visit( const ast::EnumPosType * node ) override final { 1579 preprint( node ); 1580 os << "enum pos with "; 1578 virtual const ast::Type * visit( const ast::EnumAttrType * node ) override final { 1579 preprint( node ); 1580 os << "enum attr "; 1581 if ( node->attr == ast::EnumAttribute::Label ) { 1582 os << "Label "; 1583 } else if ( node->attr == ast::EnumAttribute::Value ) { 1584 os << "Value "; 1585 } else { 1586 os << "Posn "; 1587 } 1581 1588 (*(node->instance)).accept( *this ); 1582 1589 return node; -
src/AST/Type.hpp
rd9bad51 raf746cc 362 362 using EnumInstType = SueInstType<EnumDecl>; 363 363 364 class Enum PosType final : public Type {364 class EnumAttrType final : public Type { 365 365 public: 366 366 readonly<EnumInstType> instance; 367 const Type * accept( Visitor & v ) const override { return v.visit( this ); } 368 EnumPosType( const EnumInstType * instance ): instance(instance) {} 367 EnumAttribute attr; 368 const Type * accept( Visitor & v ) const override { return v.visit( this ); } 369 EnumAttrType( const EnumInstType * instance, EnumAttribute attr = EnumAttribute::Posn ) 370 : instance(instance), attr(attr) {} 369 371 370 private: 371 EnumPosType * clone() const override { return new EnumPosType{ *this }; } 372 bool match( const ast::EnumAttrType * other) const { 373 return instance->base->name == other->instance->base->name && attr == other->attr; 374 } 375 private: 376 EnumAttrType * clone() const override { return new EnumAttrType{ *this }; } 372 377 MUTATE_FRIEND 373 378 }; -
src/AST/Visitor.hpp
rd9bad51 raf746cc 119 119 virtual const ast::Type * visit( const ast::OneType * ) = 0; 120 120 virtual const ast::Type * visit( const ast::GlobalScopeType * ) = 0; 121 virtual const ast::Type * visit( const ast::Enum PosType* ) = 0;121 virtual const ast::Type * visit( const ast::EnumAttrType * ) = 0; 122 122 virtual const ast::Designation * visit( const ast::Designation * ) = 0; 123 123 virtual const ast::Init * visit( const ast::SingleInit * ) = 0;
Note: See TracChangeset
for help on using the changeset viewer.