Changeset b0d9ff7 for src/SynTree
- Timestamp:
- Sep 1, 2022, 1:27:52 PM (2 years ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
- Children:
- 12df6fe
- Parents:
- def751f
- Location:
- src/SynTree
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Declaration.h
rdef751f rb0d9ff7 145 145 virtual void printShort( std::ostream & os, Indenter indent = {} ) const override; 146 146 147 // TODO: Move to the right place148 147 void checkAssignedValue() const; 149 148 }; … … 338 337 typedef AggregateDecl Parent; 339 338 public: 339 bool isTyped; 340 Type * base; 341 340 342 EnumDecl( const std::string & name, 341 343 const std::list< Attribute * > & attributes = std::list< class Attribute * >(), 342 LinkageSpec::Spec linkage = LinkageSpec::Cforall, 343 Type * baseType = nullptr ) : Parent( name, attributes, linkage ) , base( baseType ){} 344 EnumDecl( const EnumDecl & other ) : Parent( other ), base( other.base ) {} 345 344 bool isTyped = false, LinkageSpec::Spec linkage = LinkageSpec::Cforall, 345 Type * baseType = nullptr ) 346 : Parent( name, attributes, linkage ),isTyped(isTyped), base( baseType ) {} 347 EnumDecl( const EnumDecl & other ) 348 : Parent( other ), isTyped( other.isTyped), base( other.base ) {} 346 349 bool valueOf( Declaration * enumerator, long long int & value ); 347 348 350 virtual EnumDecl * clone() const override { return new EnumDecl( *this ); } 349 351 virtual void accept( Visitor & v ) override { v.visit( this ); } 350 352 virtual void accept( Visitor & v ) const override { v.visit( this ); } 351 353 virtual Declaration * acceptMutator( Mutator & m ) override { return m.mutate( this ); } 352 Type * base; 353 std::unordered_map< std::string, long long int > enumValues; 354 355 std::unordered_map< std::string, long long int > enumValues; // This attribute is unused 354 356 virtual void print( std::ostream & os, Indenter indent = {} ) const override final; 355 357 private: -
src/SynTree/Expression.h
rdef751f rb0d9ff7 166 166 class QualifiedNameExpr : public Expression { 167 167 public: 168 Type * type; // Convert to [parent] QualifiedNameExpr 169 std::string name; // Convert from NameExpr 170 171 QualifiedNameExpr( Type * type, std::string name): 172 Expression(), type(type), name(name) { 173 std::cout << "Making QualifiedNameExpr" << std::endl; 174 print( std::cout ); 175 } 176 QualifiedNameExpr( const QualifiedNameExpr & other): Expression(other), type(other.type), name(other.name) { 177 178 } 168 Declaration * type_decl; 169 std::string name; 170 DeclarationWithType * var; 171 172 QualifiedNameExpr( Declaration * decl, std::string name): Expression(), type_decl(decl), name(name) {} 173 QualifiedNameExpr( const QualifiedNameExpr & other): Expression(other), type_decl(other.type_decl), name(other.name), var(other.var) {} 174 DeclarationWithType * get_var() const { return var; } 175 void set_var( DeclarationWithType * newValue ) { var = newValue; } 176 179 177 virtual ~QualifiedNameExpr() { 180 delete type; 178 delete var; 179 delete type_decl; 181 180 } 182 181 … … 184 183 return new QualifiedNameExpr( * this ); 185 184 } 186 virtual void accept( Visitor & v ) override { (void)v; } 187 virtual void accept( Visitor & v ) const override { (void)v; } 188 virtual Expression * acceptMutator( Mutator & m ) override { (void) m;return nullptr; } 185 virtual void accept( Visitor & v ) override { v.visit(this); } 186 virtual void accept( Visitor & v ) const override { v.visit(this); } 187 virtual Expression * acceptMutator( Mutator & m ) override { 188 return m.mutate( this ); 189 } 190 189 191 virtual void print( std::ostream & os, Indenter indent = {} ) const override { 190 type ->print( os, indent );191 std::cout<< name << std::endl;192 type_decl->print( os, indent ); 193 os << name << std::endl; 192 194 } 193 195 }; -
src/SynTree/Mutator.h
rdef751f rb0d9ff7 98 98 virtual Expression * mutate( DefaultArgExpr * argExpr ) = 0; 99 99 virtual Expression * mutate( GenericExpr * genExpr ) = 0; 100 virtual Expression * mutate( QualifiedNameExpr * qualifiedNameExpr ) = 0; 100 101 101 102 virtual Type * mutate( VoidType * basicType ) = 0; -
src/SynTree/Type.h
rdef751f rb0d9ff7 342 342 Type * parent; 343 343 Type * child; 344 345 344 QualifiedType( const Type::Qualifiers & tq, Type * parent, Type * child ); 346 345 QualifiedType( const QualifiedType & tq ); -
src/SynTree/Visitor.h
rdef751f rb0d9ff7 101 101 virtual void visit( NameExpr * node ) { visit( const_cast<const NameExpr *>(node) ); } 102 102 virtual void visit( const NameExpr * nameExpr ) = 0; 103 virtual void visit( QualifiedNameExpr * node ) { visit( const_cast<const QualifiedNameExpr*>(node) );} 104 virtual void visit( const QualifiedNameExpr* qualifiednameExpr ) = 0; 103 105 virtual void visit( CastExpr * node ) { visit( const_cast<const CastExpr *>(node) ); } 104 106 virtual void visit( const CastExpr * castExpr ) = 0;
Note: See TracChangeset
for help on using the changeset viewer.