Changeset c36298d for src/SynTree/Constant.h
- Timestamp:
- Jun 17, 2019, 11:01:04 AM (7 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- b4d34fa
- Parents:
- 6a1dfda
- File:
-
- 1 edited
-
src/SynTree/Constant.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Constant.h
r6a1dfda rc36298d 18 18 #include <iosfwd> // for ostream 19 19 #include <string> // for string 20 #include <optional> // for optional 20 21 21 22 #include "BaseSyntaxNode.h" … … 27 28 class Constant : public BaseSyntaxNode { 28 29 public: 29 Constant( Type * type, std::string rep, unsigned long long val ); 30 Constant( Type * type, std::string rep, double val ); 30 Constant( Type * type, std::string rep, std::optional<unsigned long long> i ); 31 31 Constant( const Constant & other ); 32 32 virtual ~Constant(); … … 39 39 void set_value( std::string newValue ) { rep = newValue; } 40 40 unsigned long long get_ival() const; 41 double get_dval() const;42 41 43 42 /// generates a boolean constant of the given bool 44 43 static Constant from_bool( bool b ); 45 /// generates a char constant of the given char46 static Constant from_char( char c );47 44 /// generates an integer constant of the given int 48 45 static Constant from_int( int i ); 49 46 /// generates an integer constant of the given unsigned long int 50 47 static Constant from_ulong( unsigned long i ); 51 /// generates a floating point constant of the given double52 static Constant from_double( double d );53 /// generates an array of chars constant of the given string54 static Constant from_string( std::string const & cEscapedVal, Type *charType );55 48 56 49 /// generates a null pointer value for the given type. void * if omitted. … … 63 56 Type * type; 64 57 std::string rep; 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; 58 std::optional<unsigned long long> ival; 59 60 friend class ConverterOldToNew; 71 61 }; 72 62
Note:
See TracChangeset
for help on using the changeset viewer.