mirror of
https://github.com/janet-lang/janet
synced 2025-10-29 06:37:41 +00:00
Add support for using operators on arrays (and pointers to arrays).
Allows more expressive yet type checked representation of array algorithms.
This commit is contained in:
18
examples/sysir/arrays1.janet
Normal file
18
examples/sysir/arrays1.janet
Normal file
@@ -0,0 +1,18 @@
|
||||
(def ir-asm
|
||||
@{:instructions
|
||||
'(
|
||||
# Types
|
||||
(type-prim Double f64)
|
||||
(type-array BigVec Double 100)
|
||||
|
||||
# Declarations
|
||||
(bind 0 BigVec)
|
||||
(bind 1 BigVec)
|
||||
(bind 2 BigVec)
|
||||
(add 2 0 1)
|
||||
(return 2))
|
||||
:parameter-count 2
|
||||
:link-name "add_vector"})
|
||||
|
||||
(def as (sysir/asm ir-asm))
|
||||
(print (sysir/to-c as))
|
||||
20
examples/sysir/arrays2.janet
Normal file
20
examples/sysir/arrays2.janet
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
(def ir-asm
|
||||
@{:instructions
|
||||
'(
|
||||
# Types
|
||||
(type-prim Double f64)
|
||||
(type-array BigVec Double 100)
|
||||
(type-pointer BigVecP BigVec)
|
||||
|
||||
# Declarations
|
||||
(bind 0 BigVecP)
|
||||
(bind 1 BigVecP)
|
||||
(bind 2 BigVecP)
|
||||
(add 2 0 1)
|
||||
(return 2))
|
||||
:parameter-count 2
|
||||
:link-name "add_vectorp"})
|
||||
|
||||
(def as (sysir/asm ir-asm))
|
||||
(print (sysir/to-c as))
|
||||
Reference in New Issue
Block a user