source: src/Parser/ParseNode.cc @ e5609dd

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since e5609dd was 71bd8c6, checked in by Rob Schluntz <rschlunt@…>, 9 years ago

fix isVarLen in array types, fix loss of typedef when variable of aggregate type is declared, fix duplicate typedef with arrays of constant size

  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[b87a5ed]1//
2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// ParseNode.cc --
8//
9// Author           : Rodolfo G. Esteves
10// Created On       : Sat May 16 13:26:29 2015
[71bd8c6]11// Last Modified By : Rob Schluntz
12// Last Modified On : Wed Jul 08 14:46:45 2015
13// Update Count     : 25
[b87a5ed]14//
15
[51b7345]16#include "ParseNode.h"
17using namespace std;
18
19// Builder
20int ParseNode::indent_by = 4;
21
[59db689]22ParseNode::ParseNode() : name( 0 ), next( 0 ) {};
23ParseNode::ParseNode( const string *name_ ) : name( name_ ), next( 0 ) {}
[51b7345]24
[59db689]25ParseNode::~ParseNode() {
[a08ba92]26        delete next;
[51b7345]27};
28
[59db689]29ParseNode *ParseNode::get_link() const {
[a08ba92]30        return next;
[51b7345]31}
32
[59db689]33ParseNode *ParseNode::get_last() {
[a08ba92]34        ParseNode *current = this;
[51b7345]35
[a08ba92]36        while ( current->get_link() != 0 )
[3848e0e]37        current = current->get_link();
[51b7345]38
[a08ba92]39        return current;
[51b7345]40}
41
[59db689]42ParseNode *ParseNode::set_link( ParseNode *next_ ) {
43        if ( next_ == 0 ) return this;
[51b7345]44
[71bd8c6]45        get_last()->next = next_;
[51b7345]46
[a08ba92]47        return this;
[51b7345]48}
49
[a61fea9a]50void ParseNode::print( std::ostream &os, int indent ) const {}
[51b7345]51
52
[3848e0e]53void ParseNode::printList( std::ostream &os, int indent ) const {
[a08ba92]54        print( os, indent );
[51b7345]55
[a08ba92]56        if ( next ) {
[a61fea9a]57                next->printList( os, indent );
[59db689]58        } // if
[51b7345]59}
60
[3848e0e]61ParseNode &ParseNode::operator,( ParseNode &p ) {
[a08ba92]62        set_link( &p );
[51b7345]63
[a08ba92]64        return *this;
[51b7345]65}
66
[bdd516a]67ParseNode *mkList( ParseNode &pn ) {
[a08ba92]68        // it just relies on `operator,' to take care of the "arguments" and provides a nice interface to an awful-looking
69        // address-of, rendering, for example (StatementNode *)(&(*$5 + *$7)) into (StatementNode *)mkList(($5, $7))
70        // (although "nice" is probably not the word)
71        return &pn;
[51b7345]72}
73
74// Local Variables: //
[b87a5ed]75// tab-width: 4 //
76// mode: c++ //
77// compile-command: "make install" //
[51b7345]78// End: //
Note: See TracBrowser for help on using the repository browser.