Changeset 28f8f15 for src/AST


Ignore:
Timestamp:
Apr 27, 2023, 3:13:24 PM (3 years ago)
Author:
JiadaL <j82liang@…>
Branches:
ADT
Children:
561354f
Parents:
b110bcc
Message:

Save progress

Location:
src/AST
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    rb110bcc r28f8f15  
    321321                        get<Type>().accept1(node->base)
    322322                );
     323                decl->data_constructors = get<StructDecl>().acceptL( node->data_constructors );
     324                decl->data_union = get<UnionDecl>().accept1( node->data_union );
     325                decl->tags = get<EnumDecl>().accept1( node->tag );
     326                decl->tag_union = get<StructDecl>().accept1( node->tag_union );
    323327                return aggregatePostamble( decl, node );
    324328        }
  • src/AST/Decl.cpp

    rb110bcc r28f8f15  
    132132
    133133// These must harmonize with the corresponding AggregateDecl::Aggregate enumerations.
    134 static const char * aggregateNames[] = { "struct", "union", "enum", "exception", "trait", "generator", "coroutine", "monitor", "thread", "NoAggregateName" };
     134static const char * aggregateNames[] = { "struct", "union", "enum", "exception", "trait", "generator", "coroutine", "monitor", "thread", "NoAggregateName", "data" };
    135135
    136136const char * AggregateDecl::aggrString( AggregateDecl::Aggregate aggr ) {
  • src/AST/Decl.hpp

    rb110bcc r28f8f15  
    248248class AggregateDecl : public Decl {
    249249public:
    250         enum Aggregate { Struct, Union, Enum, Exception, Trait, Generator, Coroutine, Monitor, Thread, NoAggregate };
     250        enum Aggregate { Struct, Union, Enum, Exception, Trait, Generator, Coroutine, Monitor, Thread, NoAggregate, ADT };
    251251        static const char * aggrString( Aggregate aggr );
    252252
     
    286286        bool is_monitor  () const { return kind == Monitor  ; }
    287287        bool is_thread   () const { return kind == Thread   ; }
     288        bool is_adt              () const { return kind == ADT          ; }
    288289
    289290        const Decl * accept( Visitor & v ) const override { return v.visit( this ); }
     
    320321        enum class EnumHiding { Visible, Hide } hide;
    321322
     323        std::vector<ptr<StructDecl>> data_constructors;
     324        bool isData = false;
     325        ptr<UnionDecl> data_union;
     326        ptr<EnumDecl> tag;
     327        ptr<StructDecl> tag_union;
     328
    322329        EnumDecl( const CodeLocation& loc, const std::string& name, bool isTyped = false,
    323330                std::vector<ptr<Attribute>>&& attrs = {}, Linkage::Spec linkage = Linkage::Cforall,
    324                 Type const * base = nullptr, EnumHiding hide = EnumHiding::Hide,
     331                Type const * base = nullptr, EnumHiding hide = EnumHiding::Visible,
    325332                std::unordered_map< std::string, long long > enumValues = std::unordered_map< std::string, long long >() )
    326333        : AggregateDecl( loc, name, std::move(attrs), linkage ), isTyped(isTyped), base(base), hide(hide), enumValues(enumValues) {}
  • src/AST/Pass.impl.hpp

    rb110bcc r28f8f15  
    693693                        maybe_accept( node, &EnumDecl::members    );
    694694                        maybe_accept( node, &EnumDecl::attributes );
     695                        maybe_accept( node, &EnumDecl::data_constructors );
     696                        maybe_accept( node, &EnumDecl::data_union );
     697                        maybe_accept( node, &EnumDecl::tag );
     698                        maybe_accept( node, &EnumDecl::tag_union );
    695699                } else {
    696700                        maybe_accept( node, &EnumDecl::base );
     
    698702                        maybe_accept( node, &EnumDecl::members    );
    699703                        maybe_accept( node, &EnumDecl::attributes );
     704                        maybe_accept( node, &EnumDecl::data_constructors );
     705                        maybe_accept( node, &EnumDecl::data_union );
     706                        maybe_accept( node, &EnumDecl::tag );
     707                        maybe_accept( node, &EnumDecl::tag_union );
    700708                }
    701709        }
Note: See TracChangeset for help on using the changeset viewer.