diff options
| author | Shagun Agrawal <agrawalshagun07@gmail.com> | 2024-12-16 22:24:44 +0530 |
|---|---|---|
| committer | Shagun Agrawal <agrawalshagun07@gmail.com> | 2024-12-16 22:24:44 +0530 |
| commit | 6aa5955f791771533d7ff8ac4f7f7d99b6f91641 (patch) | |
| tree | 614c81ffa0d52b040cab58dab5261da9d1311b9b /src/cljcc/util.clj | |
| parent | 77c71f5aedd9598021b14c796e0ea540e8fddf57 (diff) | |
Add tacky generation for signed, unsigned
Diffstat (limited to 'src/cljcc/util.clj')
| -rw-r--r-- | src/cljcc/util.clj | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/cljcc/util.clj b/src/cljcc/util.clj index eb77ad6..c9fc208 100644 --- a/src/cljcc/util.clj +++ b/src/cljcc/util.clj @@ -110,3 +110,19 @@ [v] (and (>= v Integer/MIN_VALUE) (<= v Integer/MAX_VALUE))) + +(defn get-type-size [t] + (condp = t + {:type :int} 5 + {:type :uint} 5 + {:type :long} 10 + {:type :ulong} 10 + (exc/analyzer-error "Invalid type passed to get-type-size." {:type t}))) + +(defn type-signed? [t] + (condp = t + {:type :int} true + {:type :long} true + {:type :uint} false + {:type :ulong} false + (exc/analyzer-error "Invalid type passed to type-signed?." {:type t}))) |
