source: src/SynTree/Constant.h@ 65240bb

ADT arm-eh ast-experimental enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr pthread-emulation qualifiedEnum
Last change on this file since 65240bb was 39156ed, checked in by Peter A. Buhr <pabuhr@…>, 6 years ago

add assignment declarations using "default" implementation required by g++-9

  • Property mode set to 100644
File size: 2.0 KB
Line 
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
12// Last Modified On : Wed Jul 10 15:57:38 2019
13// Update Count : 19
14//
15
16#pragma once
17
18#include <iosfwd> // for ostream
19#include <string> // for string
20#include <optional> // for optional
21
22#include "BaseSyntaxNode.h"
23#include "Mutator.h" // for Mutator
24#include "Visitor.h" // for Visitor
25
26class Type;
27
28class Constant : public BaseSyntaxNode {
29 public:
30 Constant( Type * type, std::string rep, std::optional<unsigned long long> i );
31 Constant( const Constant & other );
32 Constant & operator=( const Constant & ) = default;
33 virtual ~Constant();
34
35 virtual Constant * clone() const { return new Constant( *this ); }
36
37 Type * get_type() { return type; }
38 void set_type( Type * newValue ) { type = newValue; }
39 std::string & get_value() { return rep; }
40 void set_value( std::string newValue ) { rep = newValue; }
41 unsigned long long get_ival() const;
42
43 /// generates a boolean constant of the given bool
44 static Constant from_bool( bool b );
45 /// generates an integer constant of the given int
46 static Constant from_int( int i );
47 /// generates an integer constant of the given unsigned long int
48 static Constant from_ulong( unsigned long i );
49
50 /// generates a null pointer value for the given type. void * if omitted.
51 static Constant null( Type * ptrtype = nullptr );
52
53 virtual void accept( Visitor & v ) { v.visit( this ); }
54 virtual Constant * acceptMutator( Mutator & m ) { return m.mutate( this ); }
55 virtual void print( std::ostream & os, Indenter indent = 0 ) const;
56 private:
57 Type * type;
58 std::string rep;
59 std::optional<unsigned long long> ival;
60
61 friend class ConverterOldToNew;
62};
63
64// Local Variables: //
65// tab-width: 4 //
66// mode: c++ //
67// compile-command: "make install" //
68// End: //
Note: See TracBrowser for help on using the repository browser.