while loop support, and native functions (including ffi!)

This commit is contained in:
alex committed 2023-09-06 19:07:28 -07:00
1 parent ddff6cb365
commit 236f812caf
34 files changed
+467 -115

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
func malloc(size)
native ffi "libc.dylib:malloc:void*"
func free(pointer)
native ffi "libc.dylib:free:void"
export func main() {
while true {
let pointer = malloc(8192)
println(pointer)
free(pointer)
}
}
+9 -5
View File
@@ -1,10 +1,14 @@
/* fibonacci sequence */
func fib(n) {
if n == 0
then 0
else if n == 1
then 1
else fib(n - 1) + fib(n - 2)
if n == 0 {
0
} else {
if n == 1 {
1
} else {
fib(n - 1) + fib(n - 2)
}
}
}
export func main() {
+6
View File
@@ -0,0 +1,6 @@
export func main() {
while true {
println("Hello World")
break
}
}