Ignore:
Timestamp:
Jun 21, 2017, 5:47:44 PM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
e9a3b20b
Parents:
da24468
Message:

add constant value into constants

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Constant.h

    rda24468 rd56e5bc  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun 30 13:33:17 2016
    13 // Update Count     : 6
     12// Last Modified On : Wed Jun 21 16:44:48 2017
     13// Update Count     : 14
    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; }
    3334
    3435        /// generates an integer constant of the given int
     
    3940        static Constant from_double( double d );
    4041
    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;
     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;
    4545  private:
    46         Type *type;
    47         std::string value;
     46        Type * type;
     47        std::string rep;
     48        union Val {
     49                unsigned long long ival;
     50                double dval;
     51                Val( unsigned long long ival ) : ival( ival ) {}
     52                Val( double dval ) : dval( dval ) {}
     53        } val;
    4854};
    4955
Note: See TracChangeset for help on using the changeset viewer.