diff options
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}))) |
