1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-19 01:28:26 +03:00

Merge pull request #383 from asarhaddon/ada2tco-do

ada.2: optimize tail call recursion for last `do` evaluation
This commit is contained in:
Joel Martin 2019-05-19 09:38:29 -05:00 committed by GitHub
commit 7aecf6639a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 12 deletions

View File

@ -138,11 +138,12 @@ procedure Step5_Tco is
declare
Result : Types.T;
begin
for I in 2 .. Ast.Sequence.all.Length loop
for I in 2 .. Ast.Sequence.all.Length - 1 loop
Result := Eval (Ast.Sequence.all.Data (I), Env);
end loop;
return Result;
end;
Ast := Ast.Sequence.all.Data (Ast.Sequence.all.Length);
goto Restart;
elsif First.Str.all = "fn*" then
Err.Check (Ast.Sequence.all.Length = 3, "expected 2 parameters");
declare

View File

@ -142,11 +142,12 @@ procedure Step6_File is
declare
Result : Types.T;
begin
for I in 2 .. Ast.Sequence.all.Length loop
for I in 2 .. Ast.Sequence.all.Length - 1 loop
Result := Eval (Ast.Sequence.all.Data (I), Env);
end loop;
return Result;
end;
Ast := Ast.Sequence.all.Data (Ast.Sequence.all.Length);
goto Restart;
elsif First.Str.all = "fn*" then
Err.Check (Ast.Sequence.all.Length = 3, "expected 2 parameters");
declare

View File

@ -154,11 +154,12 @@ procedure Step7_Quote is
declare
Result : Types.T;
begin
for I in 2 .. Ast.Sequence.all.Length loop
for I in 2 .. Ast.Sequence.all.Length - 1 loop
Result := Eval (Ast.Sequence.all.Data (I), Env);
end loop;
return Result;
end;
Ast := Ast.Sequence.all.Data (Ast.Sequence.all.Length);
goto Restart;
elsif First.Str.all = "fn*" then
Err.Check (Ast.Sequence.all.Length = 3, "expected 2 parameters");
declare

View File

@ -168,11 +168,12 @@ procedure Step8_Macros is
declare
Result : Types.T;
begin
for I in 2 .. Ast.Sequence.all.Length loop
for I in 2 .. Ast.Sequence.all.Length - 1 loop
Result := Eval (Ast.Sequence.all.Data (I), Env);
end loop;
return Result;
end;
Ast := Ast.Sequence.all.Data (Ast.Sequence.all.Length);
goto Restart;
elsif First.Str.all = "fn*" then
Err.Check (Ast.Sequence.all.Length = 3, "expected 2 parameters");
declare

View File

@ -168,11 +168,12 @@ procedure Step9_Try is
declare
Result : Types.T;
begin
for I in 2 .. Ast.Sequence.all.Length loop
for I in 2 .. Ast.Sequence.all.Length - 1 loop
Result := Eval (Ast.Sequence.all.Data (I), Env);
end loop;
return Result;
end;
Ast := Ast.Sequence.all.Data (Ast.Sequence.all.Length);
goto Restart;
elsif First.Str.all = "fn*" then
Err.Check (Ast.Sequence.all.Length = 3, "expected 2 parameters");
declare

View File

@ -169,11 +169,12 @@ procedure StepA_Mal is
declare
Result : Types.T;
begin
for I in 2 .. Ast.Sequence.all.Length loop
for I in 2 .. Ast.Sequence.all.Length - 1 loop
Result := Eval (Ast.Sequence.all.Data (I), Env);
end loop;
return Result;
end;
Ast := Ast.Sequence.all.Data (Ast.Sequence.all.Length);
goto Restart;
elsif First.Str.all = "fn*" then
Err.Check (Ast.Sequence.all.Length = 3, "expected 2 parameters");
declare