Bugfix for const expressions
This commit is contained in:
parent
bd5a4d9175
commit
632374f8d4
3 changed files with 6 additions and 1 deletions
|
|
@ -606,7 +606,7 @@
|
|||
(defn const
|
||||
"Gets the value of a constant stored in `symbol-or-addr`."
|
||||
[symbol-or-addr type]
|
||||
(mem/deserialize (.address (ensure-symbol symbol-or-addr)) [::mem/pointer type]))
|
||||
(mem/deserialize (ensure-symbol symbol-or-addr) [::mem/pointer type]))
|
||||
|
||||
(s/def ::defconst-args
|
||||
(s/cat :var-name simple-symbol?
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
const int c = 42;
|
||||
|
||||
int add_numbers(int a, int b) {
|
||||
return a + b;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@
|
|||
(t/deftest can-load-symbols
|
||||
(t/is (not (nil? (ffi/find-symbol "add_numbers")))))
|
||||
|
||||
(t/deftest can-fetch-constant
|
||||
(t/is (ffi/const "c" ::mem/int) 42))
|
||||
|
||||
(t/deftest can-call-primitive-fns
|
||||
(t/is (= 5 ((ffi/cfn "add_numbers" [::mem/int ::mem/int] ::mem/int) 2 3))))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue