rizinorg / rizin

UNIX-like reverse engineering framework and command-line toolset.
https://rizin.re
GNU Lesser General Public License v3.0
2.71k stars 363 forks source link

Refactor `RzNum` functions to return `RzNumber` - abstract number structure #3455

Open XVilka opened 1 year ago

XVilka commented 1 year ago

Currently many rz_num_*() functions return ut64/st64 which is not enough to work with big numbers, bitvectors, floats. Thus, we need to introduce the abstract notion of the number, lets call it RzNumValue that could be either ut64/st64 (if small enough) or bitvector/bignum (otherwise), or float/bigfloat/etc underneath. Then all arithmetic operations should be implemented on top of these numbers, plus functions that try to get the value from it, plus printing functions, e.g. char *rz_num_to_string(RzNum *num, RzNumValue *number). Since rz_num_math() is commonly used, rename it to rz_num_math_ut64() and perform the switch to the new API slowly, place by place, only where it's necessary (in many situations it isn't - e.g. calculation of addresses or sizes). First and foremost, the new API should be used in rz-ax and everywhere related to RzIL.

Affected files:

See these APIs:

wargio commented 1 year ago

I agree. and we should convert all the number calculation into RzBitvector

XVilka commented 1 year ago

Work in progress on this one