Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/ParseNode.h

    r777bfcf r8cc5cb0  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Aug 14 16:29:20 2016
    13 // Update Count     : 483
     12// Last Modified On : Thu Aug 11 12:24:11 2016
     13// Update Count     : 443
    1414//
    1515
     
    4545        virtual ~ParseNode();
    4646
    47         ParseNode *get_next() const { return next; }
    48         ParseNode *set_next( ParseNode *newlink ) { next = newlink; return this; }
     47        ParseNode *get_link() const { return next; }
    4948        ParseNode *get_last();
    50         ParseNode *set_last( ParseNode * );
     49        ParseNode *set_link( ParseNode * );
     50        void set_next( ParseNode *newlink ) { next = newlink; }
    5151
    5252        virtual ParseNode *clone() const { return 0; };
     
    9292        ExpressionNode *expr;
    9393        bool aggregate;
    94         ExpressionNode *designator;                                                     // may be list
     94        ExpressionNode *designator; // may be list
    9595        InitializerNode *kids;
    9696        bool maybeConstructed;
     
    336336
    337337        StatementNode();
     338        StatementNode( const std::string *name );
     339        StatementNode( Type t, ExpressionNode *control = 0, StatementNode *block = 0 );
     340        StatementNode( Type t, std::string *target );
    338341        StatementNode( DeclarationNode *decl );
     342
    339343        ~StatementNode();
     344
     345        static StatementNode *newCatchStmt( DeclarationNode *d = 0, StatementNode *s = 0, bool catchRestP = false );
     346
     347        StatementNode *set_block( StatementNode *b ) { block = b; return this; }
     348        StatementNode *get_block() const { return block; }
     349
     350        void set_control( ExpressionNode *c ) { control = c; }
     351        ExpressionNode *get_control() const { return control; }
    340352
    341353        StatementNode::Type get_type() const { return type; }
     
    345357
    346358        void addDeclaration( DeclarationNode *newDecl ) { decl = newDecl; }
    347 
     359        void setCatchRest( bool newVal ) { isCatchRest = newVal; }
     360
     361        std::string get_target() const;
     362
     363        // StatementNode *add_controlexp( ExpressionNode * );
     364        StatementNode *append_block( StatementNode * );
    348365        virtual StatementNode *append_last_case( StatementNode * );
    349366
    350         virtual void print( std::ostream &os, int indent = 0) const {}
     367        void print( std::ostream &os, int indent = 0) const;
    351368        virtual StatementNode *clone() const;
    352369        virtual Statement *build() const;
    353   public:
     370  private:
    354371        static const char *StType[];
    355372        Type type;
     373        ExpressionNode *control;
     374        StatementNode *block;
    356375        std::list<std::string> labels;
     376        std::string *target;                            // target label for jump statements
    357377        DeclarationNode *decl;
     378        bool isCatchRest;
    358379}; // StatementNode
    359380
    360381class StatementNode2 : public StatementNode {
    361382  public:
    362         StatementNode2() { stmt = nullptr; }
     383        StatementNode2() {}
    363384        StatementNode2( Statement *stmt ) : stmt( stmt ) {}
    364         StatementNode2( DeclarationNode *decl );
    365385        virtual ~StatementNode2() {}
    366386
     
    372392                return this;
    373393        }
     394        virtual StatementNode *append_last_case( StatementNode * );
    374395        virtual std::list<std::string> get_labels() const { assert( false ); return StatementNode::get_labels(); }
    375 
    376         virtual StatementNode *append_last_case( StatementNode * );
    377396
    378397        virtual void print( std::ostream &os, int indent = 0 ) {}
     
    382401}; // StatementNode
    383402
    384 Statement *build_expr( ExpressionNode *ctl );
    385 
    386403struct ForCtl {
    387404        ForCtl( ExpressionNode *expr, ExpressionNode *condition, ExpressionNode *change ) :
    388                 init( new StatementNode2( build_expr( expr ) ) ), condition( condition ), change( change ) {}
     405                init( new StatementNode( StatementNode::Exp, expr ) ), condition( condition ), change( change ) {}
    389406        ForCtl( DeclarationNode *decl, ExpressionNode *condition, ExpressionNode *change ) :
    390                 init( new StatementNode2( decl ) ), condition( condition ), change( change ) {}
     407                init( new StatementNode( decl ) ), condition( condition ), change( change ) {}
    391408
    392409        StatementNode *init;
     
    395412};
    396413
     414Statement *build_expr( ExpressionNode *ctl );
    397415Statement *build_if( ExpressionNode *ctl, StatementNode *then_stmt, StatementNode *else_stmt );
    398416Statement *build_switch( ExpressionNode *ctl, StatementNode *stmt );
     
    405423Statement *build_return( ExpressionNode *ctl );
    406424Statement *build_throw( ExpressionNode *ctl );
    407 Statement *build_try( StatementNode *try_stmt, StatementNode *catch_stmt, StatementNode *finally_stmt );
    408 Statement *build_catch( DeclarationNode *decl, StatementNode *stmt, bool catchAny = false );
    409 Statement *build_finally( StatementNode *stmt );
    410425
    411426//##############################################################################
     
    414429  public:
    415430        CompoundStmtNode();
     431        CompoundStmtNode( const std::string * );
    416432        CompoundStmtNode( StatementNode * );
    417433        ~CompoundStmtNode();
     
    429445class AsmStmtNode : public StatementNode {
    430446  public:
    431         AsmStmtNode( bool voltile, ConstantExpr *instruction, ExpressionNode *output = 0, ExpressionNode *input = 0, ExpressionNode *clobber = 0, LabelNode *gotolabels = 0 );
     447        AsmStmtNode( Type, bool voltile, ConstantExpr *instruction, ExpressionNode *output = 0, ExpressionNode *input = 0, ExpressionNode *clobber = 0, LabelNode *gotolabels = 0 );
    432448        ~AsmStmtNode();
    433449
    434         void print( std::ostream &os, int indent = 0 ) const {}
     450        void print( std::ostream &os, int indent = 0 ) const;
    435451        Statement *build() const;
    436452  private:
     
    461477                        errors.append( e );
    462478                } // try
    463                 cur = dynamic_cast< NodeType *>( cur->get_next() );
     479                cur = dynamic_cast< NodeType *>( cur->get_link() );
    464480        } // while
    465481        if ( ! errors.isEmpty() ) {
Note: See TracChangeset for help on using the changeset viewer.