Changeset 4520b77e for src/SynTree
- Timestamp:
- Sep 20, 2022, 8:37:05 PM (3 years ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation
- Children:
- a065f1f
- Parents:
- d489da8 (diff), 12df6fe (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src/SynTree
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Declaration.h
rd489da8 r4520b77e 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
rd489da8 r4520b77e 163 163 }; 164 164 165 // [Qualifier].name; Qualifier is the type_name from the parser 166 class QualifiedNameExpr : public Expression { 167 public: 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 177 virtual ~QualifiedNameExpr() { 178 delete var; 179 delete type_decl; 180 } 181 182 virtual QualifiedNameExpr * clone() const override { 183 return new QualifiedNameExpr( * this ); 184 } 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 191 virtual void print( std::ostream & os, Indenter indent = {} ) const override { 192 type_decl->print( os, indent ); 193 os << name << std::endl; 194 } 195 }; 196 165 197 /// VariableExpr represents an expression that simply refers to the value of a named variable. 166 198 /// Does not take ownership of var. -
src/SynTree/Mutator.h
rd489da8 r4520b77e 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/SynTree.h
rd489da8 r4520b77e 103 103 class DefaultArgExpr; 104 104 class GenericExpr; 105 class QualifiedNameExpr; 105 106 106 107 class Type; -
src/SynTree/Type.h
rd489da8 r4520b77e 345 345 Type * parent; 346 346 Type * child; 347 348 347 QualifiedType( const Type::Qualifiers & tq, Type * parent, Type * child ); 349 348 QualifiedType( const QualifiedType & tq ); -
src/SynTree/Visitor.h
rd489da8 r4520b77e 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.