Ignore:
Timestamp:
Aug 27, 2018, 4:40:34 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
b7c89aa
Parents:
f9feab8 (diff), 305581d (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.
Message:

Merge branch 'master' into cleanup-dtors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/ParseNode.h

    rf9feab8 r90152a4  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Nov 27 17:33:35 2017
    13 // Update Count     : 824
     12// Last Modified On : Sat Aug  4 09:39:40 2018
     13// Update Count     : 853
    1414//
    1515
     
    6868        }
    6969
    70         virtual void print( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent = 0 ) const {}
    71         virtual void printList( std::ostream &os, int indent = 0 ) const {
     70        virtual void print( __attribute__((unused)) std::ostream & os, __attribute__((unused)) int indent = 0 ) const {}
     71        virtual void printList( std::ostream & os, int indent = 0 ) const {
    7272                print( os, indent );
    7373                if ( next ) next->print( os, indent );
     
    7777
    7878        ParseNode * next = nullptr;
    79         std::string * name = nullptr;
     79        const std::string * name = nullptr;
    8080        CodeLocation location = yylloc;
    8181}; // ParseNode
     
    8787        InitializerNode( ExpressionNode *, bool aggrp = false,  ExpressionNode * des = nullptr );
    8888        InitializerNode( InitializerNode *, bool aggrp = false, ExpressionNode * des = nullptr );
     89        InitializerNode( bool isDelete );
    8990        ~InitializerNode();
    9091        virtual InitializerNode * clone() const { assert( false ); return nullptr; }
     
    9899        bool get_maybeConstructed() const { return maybeConstructed; }
    99100
     101        bool get_isDelete() const { return isDelete; }
     102
    100103        InitializerNode * next_init() const { return kids; }
    101104
    102         void print( std::ostream &os, int indent = 0 ) const;
     105        void print( std::ostream & os, int indent = 0 ) const;
    103106        void printOneLine( std::ostream & ) const;
    104107
     
    110113        InitializerNode * kids;
    111114        bool maybeConstructed;
     115        bool isDelete;
    112116}; // InitializerNode
    113117
     
    123127        ExpressionNode * set_extension( bool exten ) { extension = exten; return this; }
    124128
    125         virtual void print( std::ostream &os, __attribute__((unused)) int indent = 0 ) const override {
    126                 os << expr.get() << std::endl;
    127         }
    128         void printOneLine( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent = 0 ) const {}
    129 
     129        virtual void print( std::ostream & os, __attribute__((unused)) int indent = 0 ) const override {
     130                os << expr.get();
     131        }
     132        void printOneLine( __attribute__((unused)) std::ostream & os, __attribute__((unused)) int indent = 0 ) const {}
     133
     134        Expression *get_expr() const { return expr.get(); }
    130135        template<typename T>
    131136        bool isExpressionType() const { return nullptr != dynamic_cast<T>(expr.get()); }
     
    167172};
    168173
    169 Expression * build_constantInteger( std::string &str );
    170 Expression * build_constantFloat( std::string &str );
    171 Expression * build_constantChar( std::string &str );
    172 Expression * build_constantStr( std::string &str );
     174Expression * build_constantInteger( std::string & str ); // these 4 routines modify the string
     175Expression * build_constantFloat( std::string & str );
     176Expression * build_constantChar( std::string & str );
     177Expression * build_constantStr( std::string & str );
    173178Expression * build_field_name_FLOATING_FRACTIONconstant( const std::string & str );
    174179Expression * build_field_name_FLOATING_DECIMALconstant( const std::string & str );
     
    179184
    180185Expression * build_cast( DeclarationNode * decl_node, ExpressionNode * expr_node );
     186Expression * build_keyword_cast( KeywordCastExpr::Target target, ExpressionNode * expr_node );
    181187Expression * build_virtual_cast( DeclarationNode * decl_node, ExpressionNode * expr_node );
    182188Expression * build_fieldSel( ExpressionNode * expr_node, Expression * member );
     
    209215        enum Length { Short, Long, LongLong, NoLength };
    210216        static const char * lengthNames[];
    211         enum Aggregate { Struct, Union, Trait, Coroutine, Monitor, Thread, NoAggregate };
     217        enum Aggregate { Struct, Union, Exception, Trait, Coroutine, Monitor, Thread, NoAggregate };
    212218        static const char * aggregateNames[];
    213219        enum TypeClass { Otype, Dtype, Ftype, Ttype, NoTypeClass };
     
    225231        static DeclarationNode * newBuiltinType( BuiltinType );
    226232        static DeclarationNode * newForall( DeclarationNode * );
    227         static DeclarationNode * newFromTypedef( std::string * );
    228         static DeclarationNode * newFunction( std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body, bool newStyle = false );
     233        static DeclarationNode * newFromTypedef( const std::string * );
     234        static DeclarationNode * newFromGlobalScope();
     235        static DeclarationNode * newQualifiedType( DeclarationNode *, DeclarationNode * );
     236        static DeclarationNode * newFunction( const std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body );
    229237        static DeclarationNode * newAggregate( Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body );
    230         static DeclarationNode * newEnum( std::string * name, DeclarationNode * constants, bool body );
    231         static DeclarationNode * newEnumConstant( std::string * name, ExpressionNode * constant );
    232         static DeclarationNode * newName( std::string * );
    233         static DeclarationNode * newFromTypeGen( std::string *, ExpressionNode * params );
    234         static DeclarationNode * newTypeParam( TypeClass, std::string * );
     238        static DeclarationNode * newEnum( const std::string * name, DeclarationNode * constants, bool body );
     239        static DeclarationNode * newEnumConstant( const std::string * name, ExpressionNode * constant );
     240        static DeclarationNode * newName( const std::string * );
     241        static DeclarationNode * newFromTypeGen( const std::string *, ExpressionNode * params );
     242        static DeclarationNode * newTypeParam( TypeClass, const std::string * );
    235243        static DeclarationNode * newTrait( const std::string * name, DeclarationNode * params, DeclarationNode * asserts );
    236244        static DeclarationNode * newTraitUse( const std::string * name, ExpressionNode * params );
    237         static DeclarationNode * newTypeDecl( std::string * name, DeclarationNode * typeParams );
     245        static DeclarationNode * newTypeDecl( const std::string * name, DeclarationNode * typeParams );
    238246        static DeclarationNode * newPointer( DeclarationNode * qualifiers, OperKinds kind );
    239247        static DeclarationNode * newArray( ExpressionNode * size, DeclarationNode * qualifiers, bool isStatic );
     
    242250        static DeclarationNode * newTuple( DeclarationNode * members );
    243251        static DeclarationNode * newTypeof( ExpressionNode * expr );
    244         static DeclarationNode * newAttr( std::string *, ExpressionNode * expr ); // @ attributes
    245         static DeclarationNode * newAttr( std::string *, DeclarationNode * type ); // @ attributes
    246         static DeclarationNode * newAttribute( std::string *, ExpressionNode * expr = nullptr ); // gcc attributes
     252        static DeclarationNode * newAttr( const std::string *, ExpressionNode * expr ); // @ attributes
     253        static DeclarationNode * newAttr( const std::string *, DeclarationNode * type ); // @ attributes
     254        static DeclarationNode * newAttribute( const std::string *, ExpressionNode * expr = nullptr ); // gcc attributes
    247255        static DeclarationNode * newAsmStmt( StatementNode * stmt ); // gcc external asm statement
     256        static DeclarationNode * newStaticAssert( ExpressionNode * condition, Expression * message );
    248257
    249258        DeclarationNode();
     
    262271        DeclarationNode * addBitfield( ExpressionNode * size );
    263272        DeclarationNode * addVarArgs();
    264         DeclarationNode * addFunctionBody( StatementNode * body, StatementNode * with = nullptr );
     273        DeclarationNode * addFunctionBody( StatementNode * body, ExpressionNode * with = nullptr );
    265274        DeclarationNode * addOldDeclList( DeclarationNode * list );
    266275        DeclarationNode * setBase( TypeData * newType );
     
    282291        }
    283292
    284         virtual void print( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent = 0 ) const override;
    285         virtual void printList( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent = 0 ) const override;
     293        virtual void print( __attribute__((unused)) std::ostream & os, __attribute__((unused)) int indent = 0 ) const override;
     294        virtual void printList( __attribute__((unused)) std::ostream & os, __attribute__((unused)) int indent = 0 ) const override;
    286295
    287296        Declaration * build() const;
    288297        Type * buildType() const;
    289298
    290         bool get_hasEllipsis() const;
    291299        LinkageSpec::Spec get_linkage() const { return linkage; }
    292300        DeclarationNode * extractAggregate() const;
     
    296304        bool get_extension() const { return extension; }
    297305        DeclarationNode * set_extension( bool exten ) { extension = exten; return this; }
     306
     307        bool get_inLine() const { return inLine; }
     308        DeclarationNode * set_inLine( bool inL ) { inLine = inL; return this; }
    298309  public:
    299310        DeclarationNode * get_last() { return (DeclarationNode *)ParseNode::get_last(); }
     
    314325        Attr_t attr;
    315326
    316         BuiltinType builtin;
    317 
    318         TypeData * type;
    319 
     327        struct StaticAssert_t {
     328                ExpressionNode * condition;
     329                Expression * message;
     330        };
     331        StaticAssert_t assert;
     332
     333        BuiltinType builtin = NoBuiltinType;
     334
     335        TypeData * type = nullptr;
     336
     337        bool inLine = false;
    320338        Type::FuncSpecifiers funcSpecs;
    321339        Type::StorageClasses storageClasses;
    322340
    323         ExpressionNode * bitfieldWidth;
     341        ExpressionNode * bitfieldWidth = nullptr;
    324342        std::unique_ptr<ExpressionNode> enumeratorValue;
    325         bool hasEllipsis;
     343        bool hasEllipsis = false;
    326344        LinkageSpec::Spec linkage;
    327         Expression *asmName;
     345        Expression * asmName = nullptr;
    328346        std::list< Attribute * > attributes;
    329         InitializerNode * initializer;
     347        InitializerNode * initializer = nullptr;
    330348        bool extension = false;
    331349        std::string error;
    332         StatementNode * asmStmt;
     350        StatementNode * asmStmt = nullptr;
    333351
    334352        static UniqueName anonymous;
     
    364382        virtual StatementNode * append_last_case( StatementNode * );
    365383
    366         virtual void print( std::ostream &os, __attribute__((unused)) int indent = 0 ) const override {
     384        virtual void print( std::ostream & os, __attribute__((unused)) int indent = 0 ) const override {
    367385                os << stmt.get() << std::endl;
    368386        }
     
    373391Statement * build_expr( ExpressionNode * ctl );
    374392
    375 struct IfCtl {
    376         IfCtl( DeclarationNode * decl, ExpressionNode * condition ) :
     393struct IfCtrl {
     394        IfCtrl( DeclarationNode * decl, ExpressionNode * condition ) :
    377395                init( decl ? new StatementNode( decl ) : nullptr ), condition( condition ) {}
    378396
     
    381399};
    382400
    383 struct ForCtl {
    384         ForCtl( ExpressionNode * expr, ExpressionNode * condition, ExpressionNode * change ) :
     401struct ForCtrl {
     402        ForCtrl( ExpressionNode * expr, ExpressionNode * condition, ExpressionNode * change ) :
    385403                init( new StatementNode( build_expr( expr ) ) ), condition( condition ), change( change ) {}
    386         ForCtl( DeclarationNode * decl, ExpressionNode * condition, ExpressionNode * change ) :
     404        ForCtrl( DeclarationNode * decl, ExpressionNode * condition, ExpressionNode * change ) :
    387405                init( new StatementNode( decl ) ), condition( condition ), change( change ) {}
    388406
     
    392410};
    393411
    394 Statement * build_if( IfCtl * ctl, StatementNode * then_stmt, StatementNode * else_stmt );
    395 Statement * build_switch( ExpressionNode * ctl, StatementNode * stmt );
     412Expression * build_if_control( IfCtrl * ctl, std::list< Statement * > & init );
     413Statement * build_if( IfCtrl * ctl, StatementNode * then_stmt, StatementNode * else_stmt );
     414Statement * build_switch( bool isSwitch, ExpressionNode * ctl, StatementNode * stmt );
    396415Statement * build_case( ExpressionNode * ctl );
    397416Statement * build_default();
    398 Statement * build_while( ExpressionNode * ctl, StatementNode * stmt, bool kind = false );
    399 Statement * build_for( ForCtl * forctl, StatementNode * stmt );
     417Statement * build_while( IfCtrl * ctl, StatementNode * stmt );
     418Statement * build_do_while( ExpressionNode * ctl, StatementNode * stmt );
     419Statement * build_for( ForCtrl * forctl, StatementNode * stmt );
    400420Statement * build_branch( BranchStmt::Type kind );
    401421Statement * build_branch( std::string * identifier, BranchStmt::Type kind );
     
    409429Statement * build_finally( StatementNode * stmt );
    410430Statement * build_compound( StatementNode * first );
    411 Statement * build_asmstmt( bool voltile, Expression * instruction, ExpressionNode * output = nullptr, ExpressionNode * input = nullptr, ExpressionNode * clobber = nullptr, LabelNode * gotolabels = nullptr );
     431Statement * build_asm( bool voltile, Expression * instruction, ExpressionNode * output = nullptr, ExpressionNode * input = nullptr, ExpressionNode * clobber = nullptr, LabelNode * gotolabels = nullptr );
     432Statement * build_directive( std::string * directive );
    412433WaitForStmt * build_waitfor( ExpressionNode * target, StatementNode * stmt, ExpressionNode * when );
    413434WaitForStmt * build_waitfor( ExpressionNode * target, StatementNode * stmt, ExpressionNode * when, WaitForStmt * existing );
     
    419440
    420441template< typename SynTreeType, typename NodeType, template< typename, typename...> class Container, typename... Args >
    421 void buildList( const NodeType * firstNode, Container< SynTreeType *, Args... > &outputList ) {
    422         SemanticError errors;
     442void buildList( const NodeType * firstNode, Container< SynTreeType *, Args... > & outputList ) {
     443        SemanticErrorException errors;
    423444        std::back_insert_iterator< Container< SynTreeType *, Args... > > out( outputList );
    424445        const NodeType * cur = firstNode;
     
    433454                                assertf(false, "buildList unknown type");
    434455                        } // if
    435                 } catch( SemanticError &e ) {
    436                         e.set_location( cur->location );
     456                } catch( SemanticErrorException & e ) {
    437457                        errors.append( e );
    438458                } // try
     
    445465
    446466// in DeclarationNode.cc
    447 void buildList( const DeclarationNode * firstNode, std::list< Declaration * > &outputList );
    448 void buildList( const DeclarationNode * firstNode, std::list< DeclarationWithType * > &outputList );
    449 void buildTypeList( const DeclarationNode * firstNode, std::list< Type * > &outputList );
     467void buildList( const DeclarationNode * firstNode, std::list< Declaration * > & outputList );
     468void buildList( const DeclarationNode * firstNode, std::list< DeclarationWithType * > & outputList );
     469void buildTypeList( const DeclarationNode * firstNode, std::list< Type * > & outputList );
    450470
    451471template< typename SynTreeType, typename NodeType >
    452 void buildMoveList( const NodeType * firstNode, std::list< SynTreeType * > &outputList ) {
     472void buildMoveList( const NodeType * firstNode, std::list< SynTreeType * > & outputList ) {
    453473        buildList( firstNode, outputList );
    454474        delete firstNode;
Note: See TracChangeset for help on using the changeset viewer.