Changeset 7f6a7c9 for src/SynTree
- Timestamp:
- Sep 21, 2022, 11:02:15 AM (3 years ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation
- Children:
- 95dab9e
- Parents:
- 428adbc (diff), 0bd46fd (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:
-
- 9 edited
-
Declaration.h (modified) (2 diffs)
-
Expression.h (modified) (1 diff)
-
Mutator.h (modified) (1 diff)
-
Statement.cc (modified) (4 diffs)
-
Statement.h (modified) (2 diffs)
-
SynTree.h (modified) (1 diff)
-
Type.cc (modified) (1 diff)
-
Type.h (modified) (4 diffs)
-
Visitor.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Declaration.h
r428adbc r7f6a7c9 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
r428adbc r7f6a7c9 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
r428adbc r7f6a7c9 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/Statement.cc
r428adbc r7f6a7c9 105 105 }; 106 106 107 BranchStmt::BranchStmt( Label target, Type type ) throw ( SemanticErrorException ):107 BranchStmt::BranchStmt( Label target, Type type ) : 108 108 Statement(), originalTarget( target ), target( target ), computedTarget( nullptr ), type( type ) { 109 109 //actually this is a syntactic error signaled by the parser … … 113 113 } 114 114 115 BranchStmt::BranchStmt( Expression * computedTarget, Type type ) throw ( SemanticErrorException ):115 BranchStmt::BranchStmt( Expression * computedTarget, Type type ) : 116 116 Statement(), computedTarget( computedTarget ), type( type ) { 117 117 if ( type != BranchStmt::Goto || computedTarget == nullptr ) { … … 211 211 } 212 212 213 CaseStmt::CaseStmt( Expression * condition, const list<Statement *> & statements, bool deflt ) throw ( SemanticErrorException ):213 CaseStmt::CaseStmt( Expression * condition, const list<Statement *> & statements, bool deflt ) : 214 214 Statement(), condition( condition ), stmts( statements ), _isDefault( deflt ) { 215 215 if ( isDefault() && condition != nullptr ) SemanticError( condition, "default case with condition: " ); … … 575 575 } 576 576 577 MutexStmt::MutexStmt( Statement * stmt, const list<Expression *> mutexObjs ) 577 MutexStmt::MutexStmt( Statement * stmt, const list<Expression *> mutexObjs ) 578 578 : Statement(), stmt( stmt ), mutexObjs( mutexObjs ) { } 579 579 -
src/SynTree/Statement.h
r428adbc r7f6a7c9 200 200 std::list<Statement *> stmts; 201 201 202 CaseStmt( Expression * conditions, const std::list<Statement *> & stmts, bool isdef = false ) throw (SemanticErrorException);202 CaseStmt( Expression * conditions, const std::list<Statement *> & stmts, bool isdef = false ); 203 203 CaseStmt( const CaseStmt & other ); 204 204 virtual ~CaseStmt(); … … 289 289 Type type; 290 290 291 BranchStmt( Label target, Type ) throw (SemanticErrorException);292 BranchStmt( Expression * computedTarget, Type ) throw (SemanticErrorException);291 BranchStmt( Label target, Type ); 292 BranchStmt( Expression * computedTarget, Type ); 293 293 294 294 Label get_originalTarget() { return originalTarget; } -
src/SynTree/SynTree.h
r428adbc r7f6a7c9 103 103 class DefaultArgExpr; 104 104 class GenericExpr; 105 class QualifiedNameExpr; 105 106 106 107 class Type; -
src/SynTree/Type.cc
r428adbc r7f6a7c9 80 80 // These must remain in the same order as the corresponding bit fields. 81 81 const char * Type::FuncSpecifiersNames[] = { "inline", "_Noreturn", "fortran" }; 82 const char * Type::StorageClassesNames[] = { "extern", "static", "auto", "register", "_ Thread_local" };82 const char * Type::StorageClassesNames[] = { "extern", "static", "auto", "register", "__thread", "_Thread_local" }; 83 83 const char * Type::QualifiersNames[] = { "const", "restrict", "volatile", "mutex", "_Atomic" }; 84 84 -
src/SynTree/Type.h
r428adbc r7f6a7c9 84 84 }; // FuncSpecifiers 85 85 86 enum { Extern = 1 << 0, Static = 1 << 1, Auto = 1 << 2, Register = 1 << 3, Threadlocal = 1 << 4, NumStorageClass = 5};86 enum { Extern = 1 << 0, Static = 1 << 1, Auto = 1 << 2, Register = 1 << 3, ThreadlocalGcc = 1 << 4, ThreadlocalC11 = 1 << 5, NumStorageClass = 6 }; 87 87 static const char * StorageClassesNames[]; 88 88 union StorageClasses { … … 93 93 bool is_auto : 1; 94 94 bool is_register : 1; 95 bool is_threadlocal : 1; 95 bool is_threadlocalGcc : 1; 96 bool is_threadlocalC11 : 1; 96 97 }; 97 98 … … 100 101 // equality (==, !=) works implicitly on first field "val", relational operations are undefined. 101 102 BFCommon( StorageClasses, NumStorageClass ) 103 104 bool is_threadlocal_any() { return this->is_threadlocalC11 || this->is_threadlocalGcc; } 102 105 }; // StorageClasses 103 106 … … 342 345 Type * parent; 343 346 Type * child; 344 345 347 QualifiedType( const Type::Qualifiers & tq, Type * parent, Type * child ); 346 348 QualifiedType( const QualifiedType & tq ); -
src/SynTree/Visitor.h
r428adbc r7f6a7c9 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.