Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/ParseNode.h

    r8d7bef2 r9a705dc8  
    124124
    125125        virtual void print( std::ostream &os, __attribute__((unused)) int indent = 0 ) const override {
    126                 os << expr << std::endl;
     126                os << expr.get() << std::endl;
    127127        }
    128128        void printOneLine( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent = 0 ) const {}
    129129
    130130        template<typename T>
    131         bool isExpressionType() const { return nullptr != dynamic_cast<T>(expr); }
    132 
    133         Expression * build() const { return expr; }
     131        bool isExpressionType() const { return nullptr != dynamic_cast<T>(expr.get()); }
     132
     133        Expression * build() const { return const_cast<ExpressionNode *>(this)->expr.release(); }
    134134  private:
    135135        bool extension = false;
    136         Expression* expr;
     136        std::unique_ptr<Expression> expr;
    137137}; // ExpressionNode
    138138
     
    179179
    180180Expression * build_cast( DeclarationNode * decl_node, ExpressionNode * expr_node );
     181Expression * build_keyword_cast( KeywordCastExpr::Target target, ExpressionNode * expr_node );
    181182Expression * build_virtual_cast( DeclarationNode * decl_node, ExpressionNode * expr_node );
    182183Expression * build_fieldSel( ExpressionNode * expr_node, Expression * member );
     
    246247        static DeclarationNode * newAttribute( std::string *, ExpressionNode * expr = nullptr ); // gcc attributes
    247248        static DeclarationNode * newAsmStmt( StatementNode * stmt ); // gcc external asm statement
     249        static DeclarationNode * newStaticAssert( ExpressionNode * condition, Expression * message );
    248250
    249251        DeclarationNode();
     
    313315        Attr_t attr;
    314316
     317        struct StaticAssert_t {
     318                ExpressionNode * condition;
     319                Expression * message;
     320        };
     321        StaticAssert_t assert;
     322
    315323        BuiltinType builtin;
    316324
     
    352360
    353361        virtual StatementNode * clone() const final { assert( false ); return nullptr; }
    354         Statement * build() const { return stmt; }
     362        Statement * build() const { return const_cast<StatementNode *>(this)->stmt.release(); }
    355363
    356364        virtual StatementNode * add_label( const std::string * name, DeclarationNode * attr = nullptr ) {
     
    364372
    365373        virtual void print( std::ostream &os, __attribute__((unused)) int indent = 0 ) const override {
    366                 os << stmt << std::endl;
     374                os << stmt.get() << std::endl;
    367375        }
    368376  private:
    369         Statement* stmt;
     377        std::unique_ptr<Statement> stmt;
    370378}; // StatementNode
    371379
     
    392400
    393401Statement * build_if( IfCtl * ctl, StatementNode * then_stmt, StatementNode * else_stmt );
    394 Statement * build_switch( ExpressionNode * ctl, StatementNode * stmt );
     402Statement * build_switch( bool isSwitch, ExpressionNode * ctl, StatementNode * stmt );
    395403Statement * build_case( ExpressionNode * ctl );
    396404Statement * build_default();
Note: See TracChangeset for help on using the changeset viewer.