-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. smv_ranget is moved into a header file 2. Use override instead of virtual for the methods in smv_typecheckt. 3. Remove unnecessary declarators on method parameters. 4. Use ranged for instead of Forall_operands and forall_operands.
- Loading branch information
Showing
2 changed files
with
164 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/*******************************************************************\ | ||
Module: SMV Typechecking | ||
Author: Daniel Kroening, [email protected] | ||
\*******************************************************************/ | ||
|
||
#ifndef CPROVER_SMV_RANGE_H | ||
#define CPROVER_SMV_RANGE_H | ||
|
||
#include <util/arith_tools.h> | ||
|
||
class smv_ranget | ||
{ | ||
public: | ||
smv_ranget() : from(0), to(0) | ||
{ | ||
} | ||
|
||
smv_ranget(mp_integer _from, mp_integer _to) | ||
: from(std::move(_from)), to(std::move(_to)) | ||
{ | ||
} | ||
|
||
mp_integer from, to; | ||
|
||
bool is_contained_in(const smv_ranget &other) const | ||
{ | ||
if(other.from > from) | ||
return false; | ||
if(other.to < to) | ||
return false; | ||
return true; | ||
} | ||
|
||
void make_union(const smv_ranget &other) | ||
{ | ||
mp_min(from, other.from); | ||
mp_max(to, other.to); | ||
} | ||
|
||
void to_type(typet &dest) const | ||
{ | ||
dest = typet(ID_range); | ||
dest.set(ID_from, integer2string(from)); | ||
dest.set(ID_to, integer2string(to)); | ||
} | ||
|
||
bool is_bool() const | ||
{ | ||
return from == 0 && to == 1; | ||
} | ||
|
||
bool is_singleton() const | ||
{ | ||
return from == to; | ||
} | ||
|
||
smv_ranget &operator+(const smv_ranget &other) | ||
{ | ||
from += other.from; | ||
to += other.to; | ||
return *this; | ||
} | ||
|
||
smv_ranget &operator-(const smv_ranget &other) | ||
{ | ||
from -= other.from; | ||
to -= other.to; | ||
return *this; | ||
} | ||
|
||
smv_ranget &operator*(const smv_ranget &other) | ||
{ | ||
mp_integer p1 = from * other.from; | ||
mp_integer p2 = from * other.to; | ||
mp_integer p3 = to * other.from; | ||
mp_integer p4 = to * other.to; | ||
|
||
from = std::min(p1, std::min(p2, std::min(p3, p4))); | ||
to = std::max(p1, std::max(p2, std::max(p3, p4))); | ||
|
||
return *this; | ||
} | ||
}; | ||
|
||
#endif // CPROVER_SMV_RANGE_H |
Oops, something went wrong.