mirror of
https://github.com/janet-lang/janet
synced 2024-11-16 13:44:48 +00:00
3a782d27b1
Allows for in memory linking.
29 lines
549 B
Plaintext
29 lines
549 B
Plaintext
(def types-asm
|
|
'((type-prim Double f64)
|
|
(type-array BigVec Double 100)))
|
|
|
|
(def add-asm
|
|
'((link-name "add_vector")
|
|
(parameter-count 2)
|
|
# Declarations
|
|
(bind a BigVec)
|
|
(bind b BigVec)
|
|
(bind c BigVec)
|
|
(add c a b)
|
|
(return c)))
|
|
|
|
(def sub-asm
|
|
'((link-name "sub_vector")
|
|
(parameter-count 2)
|
|
(bind a BigVec)
|
|
(bind b BigVec)
|
|
(bind c BigVec)
|
|
(subtract c a b)
|
|
(return c)))
|
|
|
|
(def ctx (sysir/context))
|
|
(sysir/asm ctx types-asm)
|
|
(sysir/asm ctx add-asm)
|
|
(sysir/asm ctx sub-asm)
|
|
(print (sysir/to-c ctx))
|