mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-07 07:18:48 +00:00
Fixed bug in tail-call optimization
This commit is contained in:
parent
b7ec1c2e63
commit
7748144a8f
4 changed files with 19 additions and 3 deletions
|
|
@ -194,7 +194,7 @@ let compile cmd env imports code =
|
||||||
in
|
in
|
||||||
let env, pushs = push_args env [] n in
|
let env, pushs = push_args env [] n in
|
||||||
let y, env = env#allocate in
|
let y, env = env#allocate in
|
||||||
env, pushs @ [Mov (ebp, esp); Pop (ebp); Jmp f]
|
env, pushs @ [Mov (ebp, esp); Pop (ebp)] @ (if env#has_closure then [Pop ebx] else []) @ [Jmp f]
|
||||||
)
|
)
|
||||||
else (
|
else (
|
||||||
let pushr, popr =
|
let pushr, popr =
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
let version = "Version 1.00, eeab48ed3, Sun Mar 22 21:58:11 2020 +0300"
|
let version = "Version 1.00, b7ec1c2e6, Mon Mar 23 00:51:00 2020 +0300"
|
||||||
|
|
|
||||||
1
stdlib/regression/orig/test27.log
Normal file
1
stdlib/regression/orig/test27.log
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Yes
|
||||||
15
stdlib/regression/test27.lama
Normal file
15
stdlib/regression/test27.lama
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
import Ostap;
|
||||||
|
|
||||||
|
fun pure(v) {
|
||||||
|
empty @ lift(v)
|
||||||
|
}
|
||||||
|
|
||||||
|
local parse =
|
||||||
|
token(".") |> fun(e1) {
|
||||||
|
token(".") |> fun(e2) {
|
||||||
|
pure(Dot(e1, e2)) }};
|
||||||
|
|
||||||
|
case parseString(parse |> bypass(eof), "..") of
|
||||||
|
Succ(_) -> printf("Yes\n")
|
||||||
|
| Fail(_, _, _) -> printf("No\n")
|
||||||
|
esac
|
||||||
Loading…
Add table
Add a link
Reference in a new issue