Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Constant.h

    rc36298d r6c89ecc  
    1818#include <iosfwd>     // for ostream
    1919#include <string>     // for string
    20 #include <optional>   // for optional
    2120
    2221#include "BaseSyntaxNode.h"
     
    2827class Constant : public BaseSyntaxNode {
    2928  public:
    30         Constant( Type * type, std::string rep, std::optional<unsigned long long> i );
     29        Constant( Type * type, std::string rep, unsigned long long val );
     30        Constant( Type * type, std::string rep, double val );
    3131        Constant( const Constant & other );
    3232        virtual ~Constant();
     
    3939        void set_value( std::string newValue ) { rep = newValue; }
    4040        unsigned long long get_ival() const;
     41        double get_dval() const;
    4142
    4243        /// generates a boolean constant of the given bool
    4344        static Constant from_bool( bool b );
     45        /// generates a char constant of the given char
     46        static Constant from_char( char c );
    4447        /// generates an integer constant of the given int
    4548        static Constant from_int( int i );
    4649        /// generates an integer constant of the given unsigned long int
    4750        static Constant from_ulong( unsigned long i );
     51        /// generates a floating point constant of the given double
     52        static Constant from_double( double d );
     53        /// generates an array of chars constant of the given string
     54        static Constant from_string( std::string const & s );
    4855
    4956        /// generates a null pointer value for the given type. void * if omitted.
     
    5663        Type * type;
    5764        std::string rep;
    58         std::optional<unsigned long long> ival;
    59 
    60         friend class ConverterOldToNew;
     65        union Val {
     66                unsigned long long ival;
     67                double dval;
     68                Val( unsigned long long ival ) : ival( ival ) {}
     69                Val( double dval ) : dval( dval ) {}
     70        } val;
    6171};
    6272
Note: See TracChangeset for help on using the changeset viewer.