source: src/Parser/ParseNode.cc @ 7f5566b

aaron-thesisarm-ehcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationresolv-newstringwith_gc
Last change on this file since 7f5566b was 7f5566b, checked in by Peter A. Buhr <pabuhr@…>, 7 years ago

asm statement, memory leaks

  • Property mode set to 100644
File size: 1.7 KB
Line 
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
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Thu Jul 30 14:55:54 2015
13// Update Count     : 26
14//
15
16#include "ParseNode.h"
17using namespace std;
18
19// Builder
20int ParseNode::indent_by = 4;
21
22ParseNode::ParseNode() : name( 0 ), next( 0 ) {};
23ParseNode::ParseNode( const string *name_ ) : name( name_ ), next( 0 ) {}
24
25ParseNode::~ParseNode() {
26        delete next; delete name;
27};
28
29ParseNode *ParseNode::get_link() const {
30        return next;
31}
32
33ParseNode *ParseNode::get_last() {
34        ParseNode *current = this;
35
36        while ( current->get_link() != 0 )
37        current = current->get_link();
38
39        return current;
40}
41
42ParseNode *ParseNode::set_link( ParseNode *next_ ) {
43        if ( next_ == 0 ) return this;
44
45        get_last()->next = next_;
46
47        return this;
48}
49
50void ParseNode::print( std::ostream &os, int indent ) const {}
51
52
53void ParseNode::printList( std::ostream &os, int indent ) const {
54        print( os, indent );
55
56        if ( next ) {
57                next->printList( os, indent );
58        } // if
59}
60
61ParseNode &ParseNode::operator,( ParseNode &p ) {
62        set_link( &p );
63
64        return *this;
65}
66
67ParseNode *mkList( ParseNode &pn ) {
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;
72}
73
74// Local Variables: //
75// tab-width: 4 //
76// mode: c++ //
77// compile-command: "make install" //
78// End: //
Note: See TracBrowser for help on using the repository browser.