Changeset 99cad3aa


Ignore:
Timestamp:
Aug 18, 2016, 5:00:28 PM (6 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
5b7a60c8
Parents:
1cb2282
Message:

more refactoring of parser code

Location:
src/Parser
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r1cb2282 r99cad3aa  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 17 11:08:56 2016
    13 // Update Count     : 180
     12// Last Modified On : Wed Aug 17 23:14:51 2016
     13// Update Count     : 181
    1414//
    1515
     
    779779}
    780780
    781 DeclarationNode *DeclarationNode::appendList( DeclarationNode *node ) {
    782         return (DeclarationNode *)set_last( node );
    783 }
    784 
    785781DeclarationNode *DeclarationNode::extractAggregate() const {
    786782        if ( type ) {
  • src/Parser/ParseNode.cc

    r1cb2282 r99cad3aa  
    1010// Created On       : Sat May 16 13:26:29 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Aug 16 21:31:47 2016
    13 // Update Count     : 125
     12// Last Modified On : Wed Aug 17 23:14:16 2016
     13// Update Count     : 126
    1414//
    1515
     
    1919int ParseNode::indent_by = 4;
    2020
    21 ParseNode::ParseNode() {};
    22 ParseNode::ParseNode( const string *name ) : name( *name ) { assert( false ); delete name; }
    23 ParseNode::ParseNode( const string &name ) : name( name ) { assert( false ); }
    24 
    25 ParseNode::~ParseNode() {
    26         delete next;
    27 };
    28 
    29 ParseNode *ParseNode::get_last() {
    30         ParseNode *current;
    31         for ( current = this; current->get_next() != 0; current = current->get_next() );
    32         return current;
    33 }
    34 
    35 ParseNode *ParseNode::set_last( ParseNode *newlast ) {
    36         if ( newlast != 0 ) get_last()->set_next( newlast );
    37         return this;
    38 }
    39 
    4021// Local Variables: //
    4122// tab-width: 4 //
  • src/Parser/ParseNode.h

    r1cb2282 r99cad3aa  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Aug 16 21:32:18 2016
    13 // Update Count     : 538
     12// Last Modified On : Wed Aug 17 23:15:59 2016
     13// Update Count     : 541
    1414//
    1515
     
    4040class ParseNode {
    4141  public:
    42         ParseNode();
    43         ParseNode( const std::string * );
    44         ParseNode( const std::string & );                                       // for copy constructing subclasses
    45         virtual ~ParseNode();
     42        ParseNode() {};
     43        ParseNode( const std::string *name ) : name( *name ) { assert( false ); delete name; }
     44        ParseNode( const std::string &name ) : name( name ) { assert( false ); }
     45        virtual ~ParseNode() { delete next; };
    4646        virtual ParseNode *clone() const = 0;
    4747
    4848        ParseNode *get_next() const { return next; }
    4949        ParseNode *set_next( ParseNode *newlink ) { next = newlink; return this; }
    50         ParseNode *get_last();
    51         ParseNode *set_last( ParseNode *newlast );
     50        ParseNode *get_last() {
     51                ParseNode *current;
     52                for ( current = this; current->get_next() != 0; current = current->get_next() );
     53                return current;
     54        }
     55        ParseNode *set_last( ParseNode *newlast ) {
     56                if ( newlast != 0 ) get_last()->set_next( newlast );
     57                return this;
     58        }
    5259
    5360        const std::string &get_name() const { return name; }
     
    254261        DeclarationNode *cloneBaseType( DeclarationNode *newdecl );
    255262
    256         DeclarationNode *appendList( DeclarationNode * );
     263        DeclarationNode *appendList( DeclarationNode *node ) {
     264                return (DeclarationNode *)set_last( node );
     265        }
    257266
    258267        void print( std::ostream &os, int indent = 0 ) const;
Note: See TracChangeset for help on using the changeset viewer.