Skip to content

Commit 52380e6

Browse files
committed
Change the value-preserving fp/bv conversions to be named consistently, collapse signed/unsigned into a parameter, change the pattern-preserving fp/bv conversions to be named consistently, remove simuvex from CI
1 parent 66dbece commit 52380e6

File tree

6 files changed

+35
-32
lines changed

6 files changed

+35
-32
lines changed

.gitlab-ci.yml

-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ lint:
1111
tags: [angr]
1212

1313
### first level
14-
simuvex:
15-
script: "angr-test simuvex"
16-
tags: [angr]
17-
1814
angr:
1915
script: "angr-test angr"
2016
tags: [angr]

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ sudo: required
22
dist: trusty
33
env:
44
- PY=e ANGR_REPO=claripy
5-
- PY=e ANGR_REPO=simuvex
65
- PY=e ANGR_REPO=angr
76
- PY=e ANGR_REPO=angr-bf
87
- PY=e ANGR_REPO=angr-doc

appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ install:
1313
test_script:
1414
- cmd: |
1515
cd \angr-dev
16-
tests\appveyor_test.bat claripy simuvex angr
16+
tests\appveyor_test.bat claripy angr
1717
1818
build: off

claripy/ast/bits.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def size(self):
2525
def _type_name(self):
2626
return self.__class__.__name__ + str(self.length)
2727

28-
def to_bv(self):
28+
def raw_to_bv(self):
2929
"""
3030
Converts this data's bit-pattern to a bitvector.
3131
"""

claripy/ast/bv.py

+13-23
Original file line numberDiff line numberDiff line change
@@ -130,52 +130,42 @@ def _from_str(like, value): #pylint:disable=unused-argument
130130
def _from_BVV(like, value): #pylint:disable=unused-argument
131131
return BVV(value.value, value.size())
132132

133-
def signed_to_fp(self, sort, rm=None):
133+
def val_to_fp(self, sort, signed=True, rm=None):
134134
"""
135-
Interpret this bitvector as a signed integer, and return the floating-point representation of that integer.
135+
Interpret this bitvector as an integer, and return the floating-point representation of that integer.
136136
137137
:param sort: The sort of floating point value to return
138+
:param signed: Optional: whether this value is a signed integer
138139
:param rm: Optional: the rounding mode to use
139-
:return: An FP AST
140+
:return: An FP AST whose value is the same as this BV
140141
"""
141142
if rm is None:
142143
rm = fp.fp.RM.default()
143144
if sort is None:
144145
sort = fp.fp.FSort.from_size(self.length)
145146

146-
return fp.fpToFP(rm, self, sort)
147-
148-
def unsigned_to_fp(self, sort, rm=None):
149-
"""
150-
Interpret this bitvector as an unsigned integer, and return the floating-point representation of that integer.
151-
152-
:param sort: The sort of floating point value to return
153-
:param rm: Optional: the rounding mode to use
154-
:return: An FP AST
155-
"""
156-
if rm is None:
157-
rm = fp.fp.RM.default()
158-
if sort is None:
159-
sort = fp.fp.FSort.from_size(self.length)
160-
161-
return fp.fpToFPUnsigned(rm, self, sort)
147+
op = fp.fpToFP if signed else fp.fpToFPUnsigned
148+
return op(rm, self, sort)
162149

163150
def raw_to_fp(self):
164151
"""
165152
Interpret the bits of this bitvector as an IEEE754 floating point number.
166-
The inverse of this function is to_bv.
153+
The inverse of this function is raw_to_bv.
167154
168-
:return: An FP AST
155+
:return: An FP AST whose bit-pattern is the same as this BV
169156
"""
170157
sort = fp.fp.FSort.from_size(self.length)
171158
return fp.fpToFP(self, sort)
172159

173-
def to_bv(self):
160+
def raw_to_bv(self):
174161
"""
175-
A counterpart to FP.to_bv - does nothing and returns itself.
162+
A counterpart to FP.raw_to_bv - does nothing and returns itself.
176163
"""
177164
return self
178165

166+
def to_bv(self):
167+
return self.raw_to_bv()
168+
179169
def BVS(name, size, min=None, max=None, stride=None, uninitialized=False, #pylint:disable=redefined-builtin
180170
explicit_name=None, discrete_set=False, discrete_set_max_card=None, **kwargs):
181171
"""

claripy/ast/fp.py

+20-2
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,33 @@ def raw_to_fp(self):
3030
"""
3131
return self
3232

33-
def to_bv(self):
33+
def raw_to_bv(self):
3434
"""
3535
Interpret the bit-pattern of this IEEE754 floating point number as a bitvector.
3636
The inverse of this function is to_bv.
3737
38-
:return: A BV AST
38+
:return: A BV AST whose bit-pattern is the same as this FP
3939
"""
4040
return fpToIEEEBV(self)
4141

42+
def to_bv(self):
43+
return self.raw_to_bv()
44+
45+
def val_to_bv(self, size, signed=True, rm=None):
46+
"""
47+
Convert this floating point value to an integer.
48+
49+
:param size: The size of the bitvector to return
50+
:param signed: Optional: Whether the target integer is signed
51+
:param rm: Optional: The rounding mode to use
52+
:return: A bitvector whose value is the rounded version of this FP's value
53+
"""
54+
if rm is None:
55+
rm = fp.RM.default()
56+
57+
op = fpToSBV if signed else fpToUBV
58+
return op(rm, self, size)
59+
4260
@property
4361
def sort(self):
4462
return fp.FSort.from_size(self.length)

0 commit comments

Comments
 (0)