Skip to content

Commit

Permalink
Closures
Browse files Browse the repository at this point in the history
LLVM2: Implement closure support for function values. If a function has
captured variables, we need to create a captures array at compile-time,
and we also need to pass that array into the function when it's called.
  • Loading branch information
kengorab committed Nov 26, 2023
1 parent 72f62f4 commit bc7c332
Show file tree
Hide file tree
Showing 3 changed files with 279 additions and 55 deletions.
20 changes: 15 additions & 5 deletions abra_cli/abra-files/example.abra
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
// TODO: This shouldn't stackoverflow
//println([])

val arr = [1, 2, 3, 4]
//func sum(acc: Int, i: Int): Int = acc + i
//println(arr.reduce(0, (acc, i) => acc + i))
var a = 1.1
val arr = [1, 2, 3]
func foo(): Float {
//val x = a + 1
arr.pop()
a += 1.1
//x
}

val fn = (x: Int) => x + 1
println(fn(123))
a = 10.1

println("arr:", arr)
println("a:", a)
println("foo():", foo())
println("a:", a)
println("arr:", arr)
Loading

0 comments on commit bc7c332

Please sign in to comment.