2023-05-12 23:10:52 +00:00
|
|
|
(def ir-asm
|
2023-10-22 20:42:03 +00:00
|
|
|
'((link-name "test_function")
|
2023-08-12 15:29:24 +00:00
|
|
|
|
2023-10-22 20:42:03 +00:00
|
|
|
# Types
|
|
|
|
(type-prim Int s32)
|
|
|
|
(type-prim Double f64)
|
|
|
|
(type-struct MyPair 0 1)
|
|
|
|
(type-pointer PInt 0)
|
|
|
|
(type-array DoubleArray 1 1024)
|
2023-08-12 15:29:24 +00:00
|
|
|
|
2023-10-22 20:42:03 +00:00
|
|
|
# Declarations
|
|
|
|
(bind 0 Int)
|
|
|
|
(bind 1 Int)
|
|
|
|
(bind 2 Int)
|
|
|
|
(bind 3 Double)
|
|
|
|
(bind bob Double)
|
|
|
|
(bind 5 Double)
|
|
|
|
(bind 6 MyPair)
|
2023-05-12 23:10:52 +00:00
|
|
|
|
2023-10-22 20:42:03 +00:00
|
|
|
# Code
|
|
|
|
(constant 0 10)
|
|
|
|
(constant 0 21)
|
|
|
|
:location
|
|
|
|
(add 2 1 0)
|
|
|
|
(constant 3 1.77)
|
|
|
|
(call 3 sin 3)
|
|
|
|
(cast bob 2)
|
2024-06-10 13:45:11 +00:00
|
|
|
(call :default bob test_function)
|
2023-10-22 20:42:03 +00:00
|
|
|
(add 5 bob 3)
|
|
|
|
(jump :location)
|
|
|
|
(return 5)))
|
|
|
|
|
|
|
|
(def ctx (sysir/context))
|
|
|
|
(sysir/asm ctx ir-asm)
|
|
|
|
(print (sysir/to-c ctx))
|