Changeset 5408b59
- Timestamp:
- Oct 18, 2022, 9:12:19 PM (2 years ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- c2b3243
- Parents:
- 1e30df7
- Location:
- src
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/AST/Convert.cpp ¶
r1e30df7 r5408b59 310 310 node->name, 311 311 get<Attribute>().acceptL( node->attributes ), 312 false, // Temporary312 node->isTyped, 313 313 LinkageSpec::Spec( node->linkage.val ), 314 314 get<Type>().accept1(node->base) 315 315 ); 316 return aggregatePostamble( decl, node ); // Node info, including members, processed in aggregatePostamble316 return aggregatePostamble( decl, node ); 317 317 } 318 318 … … 737 737 node->name 738 738 ); 739 temp->var = get<DeclarationWithType>().accept1(node->var);740 739 auto expr = visitBaseExpr( node, 741 740 temp … … 2282 2281 } 2283 2282 2284 /// xxx - type_decl should be DeclWithType in the final design2285 /// type_decl is set to EnumDecl as a temporary fix2286 2283 virtual void visit( const QualifiedNameExpr * old ) override final { 2287 2284 this->node = visitBaseExpr( old, … … 2289 2286 old->location, 2290 2287 GET_ACCEPT_1(type_decl, Decl), 2291 GET_ACCEPT_1(var, DeclWithType),2292 2288 old->name 2293 2289 ) -
TabularUnified src/AST/Decl.hpp ¶
r1e30df7 r5408b59 315 315 class EnumDecl final : public AggregateDecl { 316 316 public: 317 bool isTyped; 318 ptr<Type> base; 317 bool isTyped; // isTyped indicated if the enum has a declaration like: 318 // enum (type_optional) Name {...} 319 ptr<Type> base; // if isTyped == true && base.get() == nullptr, it is a "void" type enum 319 320 320 321 EnumDecl( const CodeLocation& loc, const std::string& name, bool isTyped = false, -
TabularUnified src/AST/Expr.hpp ¶
r1e30df7 r5408b59 257 257 public: 258 258 ptr<Decl> type_decl; 259 ptr<DeclWithType> var;260 259 std::string name; 261 260 262 QualifiedNameExpr( const CodeLocation & loc, const Decl * d, const DeclWithType * r, conststd::string & n )263 : Expr( loc ), type_decl( d ), var(r),name( n ) {}261 QualifiedNameExpr( const CodeLocation & loc, const Decl * d, const std::string & n ) 262 : Expr( loc ), type_decl( d ), name( n ) {} 264 263 265 264 const Expr * accept( Visitor & v ) const override { return v.visit( this ); } -
TabularUnified src/AST/Pass.impl.hpp ¶
r1e30df7 r5408b59 1205 1205 if ( __visit_children() ) { 1206 1206 guard_symtab guard { *this }; 1207 maybe_accept( node, &QualifiedNameExpr::var );1208 1207 maybe_accept( node, &QualifiedNameExpr::type_decl ); 1209 1208 } -
TabularUnified src/CodeGen/CodeGenerator.cc ¶
r1e30df7 r5408b59 912 912 } 913 913 output << ")"; 914 }915 916 // QualifiedNameExpr should not reach to CodeGen.917 // FixQualifiedName Convert QualifiedNameExpr to VariableExpr918 void CodeGenerator::postvisit( QualifiedNameExpr * expr ) {919 output << "/* label */" << mangleName(expr->var);920 914 } 921 915 -
TabularUnified src/CodeGen/CodeGenerator.h ¶
r1e30df7 r5408b59 103 103 void postvisit( DefaultArgExpr * ); 104 104 void postvisit( GenericExpr * ); 105 void postvisit( QualifiedNameExpr *);106 105 107 106 //*** Statements -
TabularUnified src/Common/PassVisitor.impl.h ¶
r1e30df7 r5408b59 1934 1934 indexerScopedAccept( node->result, *this ); 1935 1935 maybeAccept_impl( node->type_decl, *this ); 1936 maybeAccept_impl( node->var, *this );1937 1936 1938 1937 VISIT_END( node ); … … 1945 1944 indexerScopedAccept( node->result, *this ); 1946 1945 maybeAccept_impl( node->type_decl, *this ); 1947 maybeAccept_impl( node->var, *this );1948 1946 1949 1947 VISIT_END( node ); … … 1957 1955 indexerScopedMutate( node->result, *this ); 1958 1956 maybeMutate_impl( node->type_decl, *this ); 1959 maybeAccept_impl( node->var, *this );1960 1957 1961 1958 MUTATE_END( Expression, node ); -
TabularUnified src/Parser/ExpressionNode.cc ¶
r1e30df7 r5408b59 523 523 auto enumInst = new EnumInstType( Type::Qualifiers(), e ); 524 524 auto obj = new ObjectDecl( name->name, Type::StorageClasses(), LinkageSpec::Cforall, nullptr, enumInst, nullptr ); 525 ret->set_var( obj );526 525 } 527 526 return ret; -
TabularUnified src/ResolvExpr/CandidateFinder.cpp ¶
r1e30df7 r5408b59 862 862 } 863 863 } 864 }865 866 void postvisit( const ast::QualifiedNameExpr * qualifiedNameExpr ) {867 auto mangleName = Mangle::mangle(qualifiedNameExpr->var);868 addCandidate( qualifiedNameExpr, tenv );869 864 } 870 865 -
TabularUnified src/SymTab/Mangler.cc ¶
r1e30df7 r5408b59 65 65 void postvisit( const QualifiedType * qualType ); 66 66 67 void postvisit( const QualifiedNameExpr * qualNameExpr );68 69 67 std::string get_mangleName() { return mangleName; } 70 68 private: … … 307 305 mangleName += Encoding::qualifiedTypeEnd; 308 306 } 309 }310 311 void Mangler_old::postvisit( const QualifiedNameExpr * qual ) {312 maybeAccept( qual->var, *visitor );313 307 } 314 308 … … 423 417 void postvisit( const ast::OneType * oneType ); 424 418 void postvisit( const ast::QualifiedType * qualType ); 425 void postvisit( const ast::QualifiedNameExpr * qualNameExpr );426 419 427 420 std::string get_mangleName() { return mangleName; } … … 652 645 mangleName += Encoding::qualifiedTypeEnd; 653 646 } 654 }655 void Mangler_new::postvisit( const ast::QualifiedNameExpr * qual ) {656 maybeAccept( qual->var.get(), *visitor );657 647 } 658 648 -
TabularUnified src/SymTab/Validate.cc ¶
r1e30df7 r5408b59 858 858 declsToAddBefore.push_back( new UnionDecl( aggDecl->name, noAttributes, tyDecl->linkage ) ); 859 859 } else if ( EnumInstType * enumInst = dynamic_cast< EnumInstType * >( designatorType ) ) { 860 // declsToAddBefore.push_back( new EnumDecl( enumDecl->name, noAttributes, tyDecl->linkage, enumDecl->baseEnum->base ) );861 860 if ( enumInst->baseEnum ) { 862 861 const EnumDecl * enumDecl = enumInst->baseEnum; -
TabularUnified src/SymTab/ValidateType.cc ¶
r1e30df7 r5408b59 81 81 void previsit( QualifiedType * qualType ); 82 82 void postvisit( QualifiedType * qualType ); 83 84 83 void postvisit( QualifiedNameExpr * qualExpr ); 85 84 86 85 void postvisit( EnumDecl * enumDecl ); 87 86 void postvisit( StructDecl * structDecl ); -
TabularUnified src/SynTree/Expression.h ¶
r1e30df7 r5408b59 168 168 Declaration * type_decl; 169 169 std::string name; 170 DeclarationWithType * var;171 170 172 171 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; } 172 QualifiedNameExpr( const QualifiedNameExpr & other): Expression(other), type_decl(other.type_decl), name(other.name) {} 176 173 177 174 virtual ~QualifiedNameExpr() { 178 delete var;179 175 delete type_decl; 180 176 } -
TabularUnified src/Validate/FixQualifiedTypes.cpp ¶
r1e30df7 r5408b59 102 102 } 103 103 104 105 auto var = new ast::ObjectDecl( t->var->location, t->name, 106 new ast::EnumInstType(enumDecl, ast::CV::Const), nullptr, {}, ast::Linkage::Cforall ); 107 var->scopeLevel = 1; // 1 for now; should copy the scopeLevel of the enumValue 104 auto var = new ast::ObjectDecl( t->location, t->name, 105 new ast::EnumInstType(enumDecl, ast::CV::Const), nullptr, {}, ast::Linkage::Cforall ); 108 106 var->mangleName = Mangle::mangle( var ); 109 107 return new ast::VariableExpr( t->location, var ); 110 // return ret;111 108 } 112 109 -
TabularUnified src/Validate/LinkReferenceToTypes.cpp ¶
r1e30df7 r5408b59 44 44 void postvisit( ast::UnionDecl const * decl ); 45 45 ast::TraitDecl const * postvisit( ast::TraitDecl const * decl ); 46 ast::QualifiedNameExpr const * previsit( ast::QualifiedNameExpr const * decl);47 46 48 47 private: … … 316 315 } 317 316 318 ast::QualifiedNameExpr const * LinkTypesCore::previsit( ast::QualifiedNameExpr const * decl ) {319 // Try to lookup type320 if ( auto objDecl = decl->type_decl.as<ast::ObjectDecl>() ) {321 if ( auto inst = objDecl->type.as<ast::TypeInstType>()) {322 if ( auto enumDecl = symtab.lookupEnum ( inst->name ) ) {323 auto mut = ast::mutate( decl );324 mut->type_decl = enumDecl;325 auto enumInst = new ast::EnumInstType( enumDecl );326 enumInst->name = decl->name;327 // Adding result; addCandidate() use result328 mut->result = enumInst;329 decl = mut;330 }331 }332 } else if ( auto enumDecl = decl->type_decl.as<ast::EnumDecl>() ) {333 auto mut = ast::mutate( decl );334 auto enumInst = new ast::EnumInstType( enumDecl );335 enumInst->name = decl->name;336 // Adding result; addCandidate() use result337 mut->result = enumInst;338 decl = mut;339 }340 // ast::EnumDecl const * decl = symtab.lookupEnum( type->name );341 // // It's not a semantic error if the enum is not found, just an implicit forward declaration.342 // if ( decl ) {343 // // Just linking in the node.344 // auto mut = ast::mutate( type );345 // mut->base = const_cast<ast::EnumDecl *>( decl );346 // type = mut;347 // }348 return decl;349 }350 351 317 } // namespace 352 318
Note: See TracChangeset
for help on using the changeset viewer.