source: src/SynTree/Initializer.cc @ bfbf97f

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 bfbf97f was 843054c2, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

licencing: seventh groups of files

  • Property mode set to 100644
File size: 2.4 KB
RevLine 
[0dd3a2f]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// Initializer.cc --
8//
9// Author           : Richard C. Bilson
10// Created On       : Mon May 18 07:44:20 2015
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Mon May 18 09:02:45 2015
13// Update Count     : 2
14//
15
[51b7345]16#include "Initializer.h"
17#include "Expression.h"
18#include "utility.h"
19
[d9a0e76]20Initializer::Initializer() {}
[51b7345]21
[d9a0e76]22Initializer::~Initializer() {}
[51b7345]23
24std::string Initializer::designator_name( Expression *des ) {
[0dd3a2f]25        if ( NameExpr *n = dynamic_cast<NameExpr *>(des) )
26                return n->get_name();
27        else
28                throw 0;
[51b7345]29}
30
[d9a0e76]31void Initializer::print( std::ostream &os, int indent ) {}
[51b7345]32
[d9a0e76]33SingleInit::SingleInit( Expression *v, std::list< Expression *> &_designators ) : value ( v ), designators( _designators ) { 
[51b7345]34}
35
[d9a0e76]36SingleInit::SingleInit( const SingleInit &other ) : value ( other.value ) {
[0dd3a2f]37        cloneAll(other.designators, designators );
[51b7345]38}
39
[d9a0e76]40SingleInit::~SingleInit() {}
[51b7345]41
42SingleInit *SingleInit::clone() const { return new SingleInit( *this); }
43
[d9a0e76]44void SingleInit::print( std::ostream &os, int indent ) {
[0dd3a2f]45        os << std::endl << std::string(indent, ' ' ) << "Simple Initializer: ";
46        value->print( os, indent+2 );
47
48        if ( ! designators.empty() ) {
49                os << std::endl << std::string(indent + 2, ' ' ) << "designated by: "  ;
50                for ( std::list < Expression * >::iterator i = designators.begin(); i != designators.end(); i++ )
51                        ( *i )->print(os, indent + 4 );
52        } // if
[51b7345]53}
54
55ListInit::ListInit( std::list<Initializer*> &_initializers, std::list<Expression *> &_designators )
[0dd3a2f]56        : initializers( _initializers ), designators( _designators ) {
[51b7345]57}
58
[d9a0e76]59ListInit::~ListInit() {}
[51b7345]60
[d9a0e76]61ListInit *ListInit::clone() const {
[0dd3a2f]62        return new ListInit( *this );
[51b7345]63}
64
[d9a0e76]65void ListInit::print( std::ostream &os, int indent ) {
[0dd3a2f]66        os << std::endl << std::string(indent, ' ') << "Compound initializer:  "; 
67        if ( ! designators.empty() ) {
68                os << std::string(indent + 2, ' ' ) << "designated by: [";
69                for ( std::list < Expression * >::iterator i = designators.begin();
70                          i != designators.end(); i++ ) {
71                        ( *i )->print(os, indent + 4 ); 
72                } // for
[51b7345]73       
[0dd3a2f]74                os << std::string(indent + 2, ' ' ) << "]";
75        } // if
[51b7345]76
[0dd3a2f]77        for ( std::list<Initializer *>::iterator i = initializers.begin(); i != initializers.end(); i++ ) 
78                (*i)->print( os, indent + 2 );
[51b7345]79}
[0dd3a2f]80// Local Variables: //
81// tab-width: 4 //
82// mode: c++ //
83// compile-command: "make install" //
84// End: //
Note: See TracBrowser for help on using the repository browser.