diff options
author | Bernhard Schommer <bernhardschommer@gmail.com> | 2017-02-06 14:33:12 +0100 |
---|---|---|
committer | Bernhard Schommer <bernhardschommer@gmail.com> | 2017-02-06 14:33:12 +0100 |
commit | 9e9ef45a2315694bf6efbfe8b8c9a0dd9f19e292 (patch) | |
tree | c147d0be486d8edbb9594649b99576aebe689651 /cparser/Cutil.ml | |
parent | cbc198ed8447e2089af65f790ceac6c620d361f5 (diff) | |
download | compcert-9e9ef45a2315694bf6efbfe8b8c9a0dd9f19e292.tar.gz compcert-9e9ef45a2315694bf6efbfe8b8c9a0dd9f19e292.zip |
Generalized function to allow adding hex strings.
The intconst function comes with an optional parameter to add an
hex string for later printing.
Diffstat (limited to 'cparser/Cutil.ml')
-rw-r--r-- | cparser/Cutil.ml | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/cparser/Cutil.ml b/cparser/Cutil.ml index 20cdc038..9f893fb0 100644 --- a/cparser/Cutil.ml +++ b/cparser/Cutil.ml @@ -981,8 +981,12 @@ let int_pointer_conversion env tfrom tto = (* Construct an integer constant *) -let intconst v ik = - { edesc = EConst(CInt(v, ik, "")); etyp = TInt(ik, []) } +let intconst ?hex v ik = + let ist = match hex with + | Some hex when hex -> + Printf.sprintf "0x%LXU" v + | _ -> "" in + { edesc = EConst(CInt(v, ik, ist)); etyp = TInt(ik, []) } (* Construct the 0 float constant of double type *) |