1 // -*- mode: C++ -*-
2 //
3 // Copyright (c) 2007, 2008, 2009, 2010, 2011, 2015 The University of Utah
4 // All rights reserved.
5 //
6 // This file is part of `csmith', a random generator of C programs.
7 //
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions are met:
10 //
11 //   * Redistributions of source code must retain the above copyright notice,
12 //     this list of conditions and the following disclaimer.
13 //
14 //   * Redistributions in binary form must reproduce the above copyright
15 //     notice, this list of conditions and the following disclaimer in the
16 //     documentation and/or other materials provided with the distribution.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 // POSSIBILITY OF SUCH DAMAGE.
29 
30 #ifndef LHS_H
31 #define LHS_H
32 
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #include <ostream>
36 
37 #include "Expression.h"
38 
39 class CGContext;
40 class Variable;
41 class Constant;
42 
43 /*
44  *
45  */
46 class Lhs : public Expression
47 {
48 public:
49 	// Factory method.
50 	static Lhs *make_random(CGContext &cg_context, const Type* t, const CVQualifiers* qfer, bool for_compound_assign, bool no_signed_overflow=false);
51 
52 	explicit Lhs(const Variable &v);
53 
54 	Lhs(const Variable &v, const Type* t, bool compound_assign);
55 
56 	virtual ~Lhs(void);
57 
58 	virtual Expression *clone() const;
59 
60 	virtual CVQualifiers get_qualifiers(void) const;
61 
get_eval_to_subexps(vector<const Expression * > & subs)62 	virtual void get_eval_to_subexps(vector<const Expression*>& subs) const {subs.push_back(this);}
63 
64 	int get_indirect_level(void) const;
65 
66 	void get_lvars(const vector<const Fact*>& facts, vector<const Variable*>& vars) const;
67 
68 	bool is_volatile() const;
69 
get_var(void)70 	const Variable* get_var(void) const {return &var;};
71 
72 	bool compatible(const Variable *v) const;
73 
74 	bool compatible(const Expression *c) const;
75 
76 	bool visit_indices(vector<const Fact*>& inputs, CGContext& cg_context) const;
77 	//
78 	virtual std::vector<const ExpressionVariable*> get_dereferenced_ptrs(void) const;
79 	virtual void get_referenced_ptrs(std::vector<const Variable*>& ptrs) const;
get_complexity(void)80 	virtual unsigned int get_complexity(void) const { return 1;}
81 
82 	virtual bool visit_facts(vector<const Fact*>& inputs, CGContext& cg_context) const;
83 
84 	virtual const Type &get_type(void) const;
85 
86 	virtual void Output(std::ostream &) const;
87 
88 private:
89 	explicit Lhs(const Lhs &lhs);
90 
91 	bool ptr_modified_in_rhs(vector<const Fact*>& inputs, CGContext& cg_context) const;
92 
93 	const Variable &var;
94 
95 	const Type* type;
96 
97 	const bool for_compound_assign;
98 
99 	// unimplementable
100 	Lhs &operator=(const Lhs &ev);
101 };
102 
103 ///////////////////////////////////////////////////////////////////////////////
104 
105 #endif // ELHS_H
106 
107 // Local Variables:
108 // c-basic-offset: 4
109 // tab-width: 4
110 // End:
111 
112 // End of file.
113