source: src/SynTree/Constant.h @ 969ee0df

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 969ee0df was d56e5bc, checked in by Peter A. Buhr <pabuhr@…>, 7 years ago

add constant value into constants

  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[0dd3a2f]1//
2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// Constant.h --
8//
9// Author           : Richard C. Bilson
10// Created On       : Mon May 18 07:44:20 2015
11// Last Modified By : Peter A. Buhr
[d56e5bc]12// Last Modified On : Wed Jun 21 16:44:48 2017
13// Update Count     : 14
[0dd3a2f]14//
[51b7345]15
16#ifndef CONSTANT_H
17#define CONSTANT_H
18
19#include "SynTree.h"
20#include "Visitor.h"
21#include "Mutator.h"
22
[0dd3a2f]23class Constant {
24  public:
[d56e5bc]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 );
[0dd3a2f]28        virtual ~Constant();
29
[d56e5bc]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; }
[0dd3a2f]34
[9d7b3ea]35        /// generates an integer constant of the given int
[cb4c607]36        static Constant from_int( int i );
[9d7b3ea]37        /// generates an integer constant of the given unsigned long int
[cb4c607]38        static Constant from_ulong( unsigned long i );
[9d7b3ea]39        /// generates a floating point constant of the given double
[cb4c607]40        static Constant from_double( double d );
[9d7b3ea]41
[d56e5bc]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;
[0dd3a2f]45  private:
[d56e5bc]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;
[51b7345]54};
55
[0dd3a2f]56#endif // CONSTANT_H
[51b7345]57
[0dd3a2f]58// Local Variables: //
59// tab-width: 4 //
60// mode: c++ //
61// compile-command: "make install" //
62// End: //
Note: See TracBrowser for help on using the repository browser.