Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/ParseNode.h

    r033ff37 r25bca42  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 25 22:17:10 2019
    13 // Update Count     : 876
     12// Last Modified On : Wed Jun  6 16:17:18 2018
     13// Update Count     : 843
    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 );
     
    103103        InitializerNode * next_init() const { return kids; }
    104104
    105         void print( std::ostream & os, int indent = 0 ) const;
     105        void print( std::ostream &os, int indent = 0 ) const;
    106106        void printOneLine( std::ostream & ) const;
    107107
     
    127127        ExpressionNode * set_extension( bool exten ) { extension = exten; return this; }
    128128
    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 {}
     129        virtual void print( std::ostream &os, __attribute__((unused)) int indent = 0 ) const override {
     130                os << expr.get() << std::endl;
     131        }
     132        void printOneLine( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent = 0 ) const {}
    133133
    134134        template<typename T>
     
    136136
    137137        Expression * build() const { return const_cast<ExpressionNode *>(this)->expr.release(); }
    138 
    139         std::unique_ptr<Expression> expr;                                       // public because of lifetime implications
    140138  private:
    141139        bool extension = false;
     140        std::unique_ptr<Expression> expr;
    142141}; // ExpressionNode
    143142
     
    206205class DeclarationNode : public ParseNode {
    207206  public:
    208         // These enumerations must harmonize with their names in DeclarationNode.cc.
    209         enum BasicType { Void, Bool, Char, Int, Int128,
    210                                          Float, Double, LongDouble, uuFloat80, uuFloat128,
    211                                          uFloat16, uFloat32, uFloat32x, uFloat64, uFloat64x, uFloat128, uFloat128x, NoBasicType };
     207        // These enumerations must harmonize with their names.
     208        enum BasicType { Void, Bool, Char, Int, Float, Double, LongDouble, Int128, Float80, Float128, NoBasicType };
    212209        static const char * basicTypeNames[];
    213         enum ComplexType { Complex, NoComplexType, Imaginary }; // Imaginary unsupported => parse, but make invisible and print error message
     210        enum ComplexType { Complex, Imaginary, NoComplexType };
    214211        static const char * complexTypeNames[];
    215212        enum Signedness { Signed, Unsigned, NoSignedness };
     
    221218        enum TypeClass { Otype, Dtype, Ftype, Ttype, NoTypeClass };
    222219        static const char * typeClassNames[];
    223         enum BuiltinType { Valist, AutoType, Zero, One, NoBuiltinType };
     220        enum BuiltinType { Valist, Zero, One, NoBuiltinType };
    224221        static const char * builtinTypeNames[];
    225222
     
    234231        static DeclarationNode * newForall( DeclarationNode * );
    235232        static DeclarationNode * newFromTypedef( const std::string * );
    236         static DeclarationNode * newFromGlobalScope();
    237         static DeclarationNode * newQualifiedType( DeclarationNode *, DeclarationNode * );
    238233        static DeclarationNode * newFunction( const std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body );
    239234        static DeclarationNode * newAggregate( Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body );
     
    251246        static DeclarationNode * newBitfield( ExpressionNode * size );
    252247        static DeclarationNode * newTuple( DeclarationNode * members );
    253         static DeclarationNode * newTypeof( ExpressionNode * expr, bool basetypeof = false );
     248        static DeclarationNode * newTypeof( ExpressionNode * expr );
     249        static DeclarationNode * newAttr( const std::string *, ExpressionNode * expr ); // @ attributes
     250        static DeclarationNode * newAttr( const std::string *, DeclarationNode * type ); // @ attributes
    254251        static DeclarationNode * newAttribute( const std::string *, ExpressionNode * expr = nullptr ); // gcc attributes
    255252        static DeclarationNode * newAsmStmt( StatementNode * stmt ); // gcc external asm statement
     
    291288        }
    292289
    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;
     290        virtual void print( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent = 0 ) const override;
     291        virtual void printList( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent = 0 ) const override;
    295292
    296293        Declaration * build() const;
     
    304301        bool get_extension() const { return extension; }
    305302        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; }
    309303  public:
    310304        DeclarationNode * get_last() { return (DeclarationNode *)ParseNode::get_last(); }
     
    331325        StaticAssert_t assert;
    332326
    333         BuiltinType builtin = NoBuiltinType;
    334 
    335         TypeData * type = nullptr;
    336 
    337         bool inLine = false;
     327        BuiltinType builtin;
     328
     329        TypeData * type;
     330
    338331        Type::FuncSpecifiers funcSpecs;
    339332        Type::StorageClasses storageClasses;
    340333
    341         ExpressionNode * bitfieldWidth = nullptr;
     334        ExpressionNode * bitfieldWidth;
    342335        std::unique_ptr<ExpressionNode> enumeratorValue;
    343         bool hasEllipsis = false;
     336        bool hasEllipsis;
    344337        LinkageSpec::Spec linkage;
    345         Expression * asmName = nullptr;
     338        Expression * asmName;
    346339        std::list< Attribute * > attributes;
    347         InitializerNode * initializer = nullptr;
     340        InitializerNode * initializer;
    348341        bool extension = false;
    349342        std::string error;
    350         StatementNode * asmStmt = nullptr;
     343        StatementNode * asmStmt;
    351344
    352345        static UniqueName anonymous;
     
    382375        virtual StatementNode * append_last_case( StatementNode * );
    383376
    384         virtual void print( std::ostream & os, __attribute__((unused)) int indent = 0 ) const override {
     377        virtual void print( std::ostream &os, __attribute__((unused)) int indent = 0 ) const override {
    385378                os << stmt.get() << std::endl;
    386379        }
     
    391384Statement * build_expr( ExpressionNode * ctl );
    392385
    393 struct IfCtrl {
    394         IfCtrl( DeclarationNode * decl, ExpressionNode * condition ) :
     386struct IfCtl {
     387        IfCtl( DeclarationNode * decl, ExpressionNode * condition ) :
    395388                init( decl ? new StatementNode( decl ) : nullptr ), condition( condition ) {}
    396389
     
    399392};
    400393
    401 struct ForCtrl {
    402         ForCtrl( ExpressionNode * expr, ExpressionNode * condition, ExpressionNode * change ) :
     394struct ForCtl {
     395        ForCtl( ExpressionNode * expr, ExpressionNode * condition, ExpressionNode * change ) :
    403396                init( new StatementNode( build_expr( expr ) ) ), condition( condition ), change( change ) {}
    404         ForCtrl( DeclarationNode * decl, ExpressionNode * condition, ExpressionNode * change ) :
     397        ForCtl( DeclarationNode * decl, ExpressionNode * condition, ExpressionNode * change ) :
    405398                init( new StatementNode( decl ) ), condition( condition ), change( change ) {}
    406399
     
    410403};
    411404
    412 Expression * build_if_control( IfCtrl * ctl, std::list< Statement * > & init );
    413 Statement * build_if( IfCtrl * ctl, StatementNode * then_stmt, StatementNode * else_stmt );
     405Expression * build_if_control( IfCtl * ctl, std::list< Statement * > & init );
     406Statement * build_if( IfCtl * ctl, StatementNode * then_stmt, StatementNode * else_stmt );
    414407Statement * build_switch( bool isSwitch, ExpressionNode * ctl, StatementNode * stmt );
    415408Statement * build_case( ExpressionNode * ctl );
    416409Statement * build_default();
    417 Statement * build_while( IfCtrl * ctl, StatementNode * stmt );
     410Statement * build_while( IfCtl * ctl, StatementNode * stmt );
    418411Statement * build_do_while( ExpressionNode * ctl, StatementNode * stmt );
    419 Statement * build_for( ForCtrl * forctl, StatementNode * stmt );
     412Statement * build_for( ForCtl * forctl, StatementNode * stmt );
    420413Statement * build_branch( BranchStmt::Type kind );
    421414Statement * build_branch( std::string * identifier, BranchStmt::Type kind );
     
    435428WaitForStmt * build_waitfor_timeout( ExpressionNode * timeout, StatementNode * stmt, ExpressionNode * when );
    436429WaitForStmt * build_waitfor_timeout( ExpressionNode * timeout, StatementNode * stmt, ExpressionNode * when, StatementNode * else_stmt, ExpressionNode * else_when );
    437 Statement * build_with( ExpressionNode * exprs, StatementNode * stmt );
     430WithStmt * build_with( ExpressionNode * exprs, StatementNode * stmt );
    438431
    439432//##############################################################################
    440433
    441434template< typename SynTreeType, typename NodeType, template< typename, typename...> class Container, typename... Args >
    442 void buildList( const NodeType * firstNode, Container< SynTreeType *, Args... > & outputList ) {
     435void buildList( const NodeType * firstNode, Container< SynTreeType *, Args... > &outputList ) {
    443436        SemanticErrorException errors;
    444437        std::back_insert_iterator< Container< SynTreeType *, Args... > > out( outputList );
     
    454447                                assertf(false, "buildList unknown type");
    455448                        } // if
    456                 } catch( SemanticErrorException & e ) {
     449                } catch( SemanticErrorException &e ) {
    457450                        errors.append( e );
    458451                } // try
     
    465458
    466459// in DeclarationNode.cc
    467 void buildList( const DeclarationNode * firstNode, std::list< Declaration * > & outputList );
    468 void buildList( const DeclarationNode * firstNode, std::list< DeclarationWithType * > & outputList );
    469 void buildTypeList( const DeclarationNode * firstNode, std::list< Type * > & outputList );
     460void buildList( const DeclarationNode * firstNode, std::list< Declaration * > &outputList );
     461void buildList( const DeclarationNode * firstNode, std::list< DeclarationWithType * > &outputList );
     462void buildTypeList( const DeclarationNode * firstNode, std::list< Type * > &outputList );
    470463
    471464template< typename SynTreeType, typename NodeType >
    472 void buildMoveList( const NodeType * firstNode, std::list< SynTreeType * > & outputList ) {
     465void buildMoveList( const NodeType * firstNode, std::list< SynTreeType * > &outputList ) {
    473466        buildList( firstNode, outputList );
    474467        delete firstNode;
Note: See TracChangeset for help on using the changeset viewer.