Ignore:
Timestamp:
Jul 4, 2017, 9:40:16 AM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
208e5be
Parents:
9c951e3 (diff), f7cb0bc (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into references

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Constant.h

    r9c951e3 rb1e63ac5  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Constant.h -- 
     7// Constant.h --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun 30 13:33:17 2016
    13 // Update Count     : 6
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thr Jun 22 10:13:00 2017
     13// Update Count     : 15
    1414//
    1515
     
    2323class Constant {
    2424  public:
    25         Constant( Type *type, std::string value );
    26         Constant( const Constant &other );
     25        Constant( Type * type, std::string rep, unsigned long long val );
     26        Constant( Type * type, std::string rep, double val );
     27        Constant( const Constant & other );
    2728        virtual ~Constant();
    2829
    29         Type *get_type() { return type; }
    30         void set_type( Type *newValue ) { type = newValue; }
    31         std::string &get_value() { return value; }
    32         void set_value( std::string newValue ) { value = newValue; }
     30        Type * get_type() { return type; }
     31        void set_type( Type * newValue ) { type = newValue; }
     32        std::string & get_value() { return rep; }
     33        void set_value( std::string newValue ) { rep = newValue; }
     34        unsigned long long get_ival() const;
     35        double get_dval() const;
    3336
     37        /// generates a boolean constant of the given bool
     38        static Constant from_bool( bool b );
    3439        /// generates an integer constant of the given int
    3540        static Constant from_int( int i );
     
    3944        static Constant from_double( double d );
    4045
    41         virtual Constant *clone() const;
    42         virtual void accept( Visitor &v ) { v.visit( this ); }
    43         virtual Constant *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    44         virtual void print( std::ostream &os ) const;
     46        virtual void accept( Visitor & v ) { v.visit( this ); }
     47        virtual Constant * acceptMutator( Mutator & m ) { return m.mutate( this ); }
     48        virtual void print( std::ostream & os ) const;
    4549  private:
    46         Type *type;
    47         std::string value;
     50        Type * type;
     51        std::string rep;
     52        union Val {
     53                unsigned long long ival;
     54                double dval;
     55                Val( unsigned long long ival ) : ival( ival ) {}
     56                Val( double dval ) : dval( dval ) {}
     57        } val;
    4858};
    4959
Note: See TracChangeset for help on using the changeset viewer.