- Timestamp:
- Sep 20, 2022, 8:37:05 PM (22 months 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/AST
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
rd489da8 r4520b77e 310 310 node->name, 311 311 get<Attribute>().acceptL( node->attributes ), 312 false, // Temporary 312 313 LinkageSpec::Spec( node->linkage.val ), 313 314 get<Type>().accept1(node->base) … … 731 732 } 732 733 734 const ast::Expr * visit( const ast::QualifiedNameExpr * node ) override final { 735 auto temp = new QualifiedNameExpr( 736 get<Declaration>().accept1(node->type_decl), 737 node->name 738 ); 739 temp->var = get<DeclarationWithType>().accept1(node->var); 740 auto expr = visitBaseExpr( node, 741 temp 742 ); 743 this->node = expr; 744 return nullptr; 745 } 746 733 747 const ast::Expr * visit( const ast::AddressExpr * node ) override final { 734 748 auto expr = visitBaseExpr( node, … … 1740 1754 old->location, 1741 1755 old->name, 1756 old->isTyped, 1742 1757 GET_ACCEPT_V(attributes, Attribute), 1743 1758 { old->linkage.val }, … … 2266 2281 } 2267 2282 2283 /// xxx - type_decl should be DeclWithType in the final design 2284 /// type_decl is set to EnumDecl as a temporary fix 2285 virtual void visit( const QualifiedNameExpr * old ) override final { 2286 this->node = visitBaseExpr( old, 2287 new ast::QualifiedNameExpr ( 2288 old->location, 2289 GET_ACCEPT_1(type_decl, Decl), 2290 GET_ACCEPT_1(var, DeclWithType), 2291 old->name 2292 ) 2293 ); 2294 } 2295 2268 2296 virtual void visit( const CastExpr * old ) override final { 2269 2297 this->node = visitBaseExpr( old, -
src/AST/Decl.hpp
rd489da8 r4520b77e 312 312 class EnumDecl final : public AggregateDecl { 313 313 public: 314 bool isTyped; 314 315 ptr<Type> base; 315 316 316 EnumDecl( const CodeLocation& loc, const std::string& name, 317 std::vector<ptr<Attribute>>&& attrs = {}, Linkage::Spec linkage = Linkage::Cforall, Type const * base = nullptr, 317 EnumDecl( const CodeLocation& loc, const std::string& name, bool isTyped = false, 318 std::vector<ptr<Attribute>>&& attrs = {}, Linkage::Spec linkage = Linkage::Cforall, 319 Type const * base = nullptr, 318 320 std::unordered_map< std::string, long long > enumValues = std::unordered_map< std::string, long long >() ) 319 : AggregateDecl( loc, name, std::move(attrs), linkage ), base(base), enumValues(enumValues) {}321 : AggregateDecl( loc, name, std::move(attrs), linkage ), isTyped(isTyped), base(base), enumValues(enumValues) {} 320 322 321 323 /// gets the integer value for this enumerator, returning true iff value found … … 327 329 const char * typeString() const override { return aggrString( Enum ); } 328 330 329 bool isTyped() {return base && base.get();}330 331 331 332 private: -
src/AST/Expr.hpp
rd489da8 r4520b77e 254 254 }; 255 255 256 class QualifiedNameExpr final : public Expr { 257 public: 258 ptr<Decl> type_decl; 259 ptr<DeclWithType> var; 260 std::string name; 261 262 QualifiedNameExpr( const CodeLocation & loc, const Decl * d, const DeclWithType * r, const std::string & n ) 263 : Expr( loc ), type_decl( d ), var(r), name( n ) {} 264 265 const Expr * accept( Visitor & v ) const override { return v.visit( this ); } 266 private: 267 QualifiedNameExpr * clone() const override { return new QualifiedNameExpr{ *this }; } 268 MUTATE_FRIEND 269 }; 270 256 271 /// A reference to a named variable. 257 272 class VariableExpr final : public Expr { -
src/AST/Fwd.hpp
rd489da8 r4520b77e 67 67 class UntypedExpr; 68 68 class NameExpr; 69 class QualifiedNameExpr; 69 70 class AddressExpr; 70 71 class LabelAddressExpr; -
src/AST/Pass.hpp
rd489da8 r4520b77e 167 167 const ast::Expr * visit( const ast::UntypedExpr * ) override final; 168 168 const ast::Expr * visit( const ast::NameExpr * ) override final; 169 const ast::Expr * visit( const ast::QualifiedNameExpr * ) override final; 169 170 const ast::Expr * visit( const ast::AddressExpr * ) override final; 170 171 const ast::Expr * visit( const ast::LabelAddressExpr * ) override final; -
src/AST/Pass.impl.hpp
rd489da8 r4520b77e 1199 1199 1200 1200 //-------------------------------------------------------------------------- 1201 // QualifiedNameExpr 1202 template< typename core_t > 1203 const ast::Expr * ast::Pass< core_t >::visit( const ast::QualifiedNameExpr * node ) { 1204 VISIT_START( node ); 1205 if ( __visit_children() ) { 1206 guard_symtab guard { *this }; 1207 maybe_accept( node, &QualifiedNameExpr::var ); 1208 maybe_accept( node, &QualifiedNameExpr::type_decl ); 1209 } 1210 VISIT_END( Expr, node ); 1211 } 1212 1213 //-------------------------------------------------------------------------- 1201 1214 // CastExpr 1202 1215 template< typename core_t > -
src/AST/Print.cpp
rd489da8 r4520b77e 899 899 postprint( node ); 900 900 901 return node; 902 } 903 904 virtual const ast::Expr * visit( const ast::QualifiedNameExpr * node ) override final { 905 os << "QualifiedNameExpr: " << std::endl; 906 os << ++indent << "Type: "; 907 safe_print( node->type_decl ); 908 os << std::endl; 909 os << indent << "Name: " << node->name << std::endl; 910 --indent; 911 postprint( node ); 901 912 return node; 902 913 } -
src/AST/Visitor.hpp
rd489da8 r4520b77e 59 59 virtual const ast::Expr * visit( const ast::UntypedExpr * ) = 0; 60 60 virtual const ast::Expr * visit( const ast::NameExpr * ) = 0; 61 virtual const ast::Expr * visit( const ast::QualifiedNameExpr * ) = 0; 61 62 virtual const ast::Expr * visit( const ast::AddressExpr * ) = 0; 62 63 virtual const ast::Expr * visit( const ast::LabelAddressExpr * ) = 0;
Note: See TracChangeset
for help on using the changeset viewer.