Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Initializer.h

    rf1b1e4c r05d47278  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Initializer.h --
     7// Initializer.h -- 
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Tue Apr 12 13:49:13 2016
    13 // Update Count     : 19
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Mon May 18 09:03:48 2015
     13// Update Count     : 1
    1414//
    1515
     
    2020#include "Visitor.h"
    2121#include "Mutator.h"
    22 #include "Type.h"
    2322
    2423#include <cassert>
     
    2827  public:
    2928        //      Initializer( std::string _name = std::string(""), int _pos = 0 );
    30         Initializer( bool maybeConstructed );
    31         Initializer( const Initializer & other );
     29        Initializer( );
    3230        virtual ~Initializer();
    3331
     
    4543        }
    4644
    47         bool get_maybeConstructed() { return maybeConstructed; }
    48 
    4945        virtual Initializer *clone() const = 0;
    5046        virtual void accept( Visitor &v ) = 0;
     
    5450        //      std::string name;
    5551        //      int pos;
    56         bool maybeConstructed;
    5752};
    5853
     
    6055class SingleInit : public Initializer {
    6156  public:
    62         SingleInit( Expression *value, const std::list< Expression *> &designators = std::list< Expression * >(), bool maybeConstructed = false );
     57        SingleInit( Expression *value, std::list< Expression *> &designators = *(new std::list<Expression *>()) );
    6358        SingleInit( const SingleInit &other );
    6459        virtual ~SingleInit();
    65 
     60       
    6661        Expression *get_value() { return value; }
    6762        void set_value( Expression *newValue ) { value = newValue; }
     
    7065        std::list<Expression *> &get_designators() { return designators; }
    7166
    72         virtual SingleInit *clone() const { return new SingleInit( *this); }
     67        virtual SingleInit *clone() const;
    7368        virtual void accept( Visitor &v ) { v.visit( this ); }
    7469        virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     
    8479class ListInit : public Initializer {
    8580  public:
    86         ListInit( const std::list<Initializer*> &initializers,
    87                           const std::list<Expression *> &designators = std::list< Expression * >(), bool maybeConstructed = false );
     81        ListInit( std::list<Initializer*> &,
     82                          std::list<Expression *> &designators = *(new std::list<Expression *>()) );
    8883        virtual ~ListInit();
    8984
     
    9691        std::list<Initializer*>::iterator end_initializers() { return initializers.end(); }
    9792
    98         virtual ListInit *clone() const { return new ListInit( *this ); }
     93        virtual ListInit *clone() const;
    9994        virtual void accept( Visitor &v ) { v.visit( this ); }
    10095        virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     
    105100};
    106101
    107 // ConstructorInit represents an initializer that is either a constructor expression or
    108 // a C-style initializer.
    109 class ConstructorInit : public Initializer {
    110   public:
    111         ConstructorInit( Statement * ctor, Statement * dtor, Initializer * init );
    112         ConstructorInit( const ConstructorInit &other );
    113         virtual ~ConstructorInit();
    114 
    115         void set_ctor( Statement * newValue ) { ctor = newValue; }
    116         Statement * get_ctor() const { return ctor; }
    117         void set_dtor( Statement * newValue ) { dtor = newValue; }
    118         Statement * get_dtor() const { return dtor; }
    119         void set_init( Initializer * newValue ) { init = newValue; }
    120         Initializer * get_init() const { return init; }
    121 
    122         ConstructorInit *clone() const { return new ConstructorInit( *this ); }
    123         virtual void accept( Visitor &v ) { v.visit( this ); }
    124         virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    125         virtual void print( std::ostream &os, int indent = 0 );
    126 
    127   private:
    128         Statement * ctor;
    129         Statement * dtor;
    130         // C-style initializer made up of SingleInit and ListInit nodes to use as a fallback
    131         // if an appropriate constructor definition is not found by the resolver
    132         Initializer * init;
    133 };
    134 
    135 std::ostream & operator<<( std::ostream & out, Initializer * init );
    136 
    137102#endif // INITIALIZER_H
    138103
Note: See TracChangeset for help on using the changeset viewer.