aboutsummaryrefslogtreecommitdiff
path: root/gcc/sym-exec/expression.cc
blob: e2aad4b483ebb942e540dc9b9fdd4fbca48d4395 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/* Every class defined here represents a single bit value of a variable.
   Every variable will be represented as a vector of these classes which later
   will be used for bit-level symbolic execution.  */

#include "stddef.h"
#include "expression.h"


bit_expression::bit_expression (value* left, value* right)
{
  this->left = left;
  this->right = right;
}


value *
bit_expression::get_left ()
{
  return left;
}


value *
bit_expression::get_right ()
{
  return right;
}


void
bit_expression::set_left (value *expr)
{
  left = expr;
}


void
bit_expression::set_right (value *expr)
{
  right = expr;
}


size_t
value::get_index () const
{
  return index;
}


unsigned char
bit::get_val () const
{
  return val;
}


void
bit::set_val (unsigned char new_val)
{
  val = new_val;
}


bit_complement_expression::bit_complement_expression (value *right) :
  bit_expression (nullptr, right)
{}


value*
symbolic_bit::copy () const
{
  return new symbolic_bit (*this);
}


value *
bit::copy () const
{
  return new bit (*this);
}


bit_expression::bit_expression (const bit_expression &expr)
{
  if (expr.left)
    {
      left = expr.left->copy ();
    }

  if (expr.right)
    {
      right = expr.right->copy ();
    }
}


value *
bit_expression::copy () const
{
  return new bit_expression (*this);
}


value *
bit_xor_expression::copy () const
{
  return bit_expression::copy ();
}


value *
bit_and_expression::copy () const
{
  return bit_expression::copy ();
}


value *
bit_or_expression::copy () const
{
  return bit_expression::copy ();
}


value *
shift_right_expression::copy () const
{
  return bit_expression::copy ();
}


value *
shift_left_expression::copy () const
{
  return bit_expression::copy ();
}


value *
add_expression::copy () const
{
  return bit_expression::copy ();
}


value *
sub_expression::copy () const
{
  return bit_expression::copy ();
}


value *
bit_complement_expression::copy () const
{
  return bit_expression::copy ();
}


bit_expression::~bit_expression ()
{
  delete left;
  left = nullptr;

  delete right;
  right = nullptr;
}