2016-10-10 20:08:59 +03:00
|
|
|
with Ada.Text_IO.Unbounded_IO;
|
2019-02-28 00:27:12 +03:00
|
|
|
|
2016-10-10 20:08:59 +03:00
|
|
|
with Core;
|
2019-03-06 21:48:51 +03:00
|
|
|
with Envs;
|
2019-03-17 13:24:03 +03:00
|
|
|
with Err;
|
ada.2: fix memory leaks with garbage collection. Various simplifications.
Cyclic references were never deallocated by reference conuting.
Symbols cannot create cyclic structures and are less frequent (one
allocation per symbol), keep reference counting for them.
This slightly improves performances even though many previous
optimizations are removed (environment stack, reuse of memory).
Step caching hash of symbols. This does not seem to improve
performances. Hashing them instead of ordering them does.
Define Repl in the step file instead of globally. Move the eval
built-in function from core into the step file.
When possible, pass Ada records instead of explicit pointers.
In the reader, construct more objects directly as described in the MAL
process, reserve the buffer for sequences and maps
In eval, iterate on vectors without delegation. The increased
complexity was not improving performances. Keep demonstrating Ada
type-safe genericity for maps, where iterating outside Types.Maps
would be less easy and/or efficient.
In quasiquote_list, concatenate in one buffer instead of allocating a
list for each element. The buffer may be reallocated behind the
curtain, but not once per element anymore.
In environments, illustrate tail call optimization when recursion is
more readable than a loop.
2019-03-31 20:06:00 +03:00
|
|
|
with Garbage_Collected;
|
2016-10-10 20:08:59 +03:00
|
|
|
with Printer;
|
|
|
|
with Reader;
|
2019-03-06 21:48:51 +03:00
|
|
|
with Readline;
|
2019-03-17 13:24:03 +03:00
|
|
|
with Types.Fns;
|
2019-02-28 00:27:12 +03:00
|
|
|
with Types.Maps;
|
2019-03-17 13:24:03 +03:00
|
|
|
with Types.Sequences;
|
2019-05-02 22:19:34 +03:00
|
|
|
with Types.Strings;
|
2016-10-10 20:08:59 +03:00
|
|
|
|
|
|
|
procedure Step4_If_Fn_Do is
|
|
|
|
|
2022-01-10 02:15:40 +03:00
|
|
|
Dbgeval : constant Types.String_Ptr := Types.Strings.Alloc ("DEBUG-EVAL");
|
2019-03-17 13:24:03 +03:00
|
|
|
|
2019-05-02 22:19:34 +03:00
|
|
|
use type Types.T;
|
|
|
|
use all type Types.Kind_Type;
|
|
|
|
use type Types.Strings.Instance;
|
2019-02-28 00:27:12 +03:00
|
|
|
|
2019-05-02 22:19:34 +03:00
|
|
|
function Read return Types.T_Array with Inline;
|
2016-10-10 20:08:59 +03:00
|
|
|
|
2019-05-02 22:19:34 +03:00
|
|
|
function Eval (Ast : in Types.T;
|
|
|
|
Env : in Envs.Ptr) return Types.T;
|
2016-10-10 20:08:59 +03:00
|
|
|
|
2019-05-02 22:19:34 +03:00
|
|
|
procedure Print (Ast : in Types.T) with Inline;
|
2016-10-10 20:08:59 +03:00
|
|
|
|
2019-03-06 21:48:51 +03:00
|
|
|
procedure Rep (Env : in Envs.Ptr) with Inline;
|
2019-02-28 00:27:12 +03:00
|
|
|
|
2019-05-02 22:19:34 +03:00
|
|
|
function Eval_Map (Source : in Types.Maps.Instance;
|
|
|
|
Env : in Envs.Ptr) return Types.T;
|
|
|
|
function Eval_Vector (Source : in Types.Sequences.Instance;
|
|
|
|
Env : in Envs.Ptr) return Types.T;
|
|
|
|
-- Helpers for the Eval function.
|
2016-10-10 20:08:59 +03:00
|
|
|
|
2019-03-17 13:24:03 +03:00
|
|
|
procedure Exec (Script : in String;
|
|
|
|
Env : in Envs.Ptr) with Inline;
|
|
|
|
-- Read the script, eval its elements, but ignore the result.
|
2016-10-10 20:08:59 +03:00
|
|
|
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
|
2019-05-02 22:19:34 +03:00
|
|
|
function Eval (Ast : in Types.T;
|
|
|
|
Env : in Envs.Ptr) return Types.T
|
2019-03-06 21:48:51 +03:00
|
|
|
is
|
2019-05-02 22:19:34 +03:00
|
|
|
First : Types.T;
|
2016-10-10 20:08:59 +03:00
|
|
|
begin
|
2022-01-10 02:15:40 +03:00
|
|
|
if Types.To_Boolean (Env.all.Get_Or_Nil (Dbgeval)) then
|
2019-03-17 13:24:03 +03:00
|
|
|
Ada.Text_IO.Put ("EVAL: ");
|
|
|
|
Print (Ast);
|
ada.2: fix memory leaks with garbage collection. Various simplifications.
Cyclic references were never deallocated by reference conuting.
Symbols cannot create cyclic structures and are less frequent (one
allocation per symbol), keep reference counting for them.
This slightly improves performances even though many previous
optimizations are removed (environment stack, reuse of memory).
Step caching hash of symbols. This does not seem to improve
performances. Hashing them instead of ordering them does.
Define Repl in the step file instead of globally. Move the eval
built-in function from core into the step file.
When possible, pass Ada records instead of explicit pointers.
In the reader, construct more objects directly as described in the MAL
process, reserve the buffer for sequences and maps
In eval, iterate on vectors without delegation. The increased
complexity was not improving performances. Keep demonstrating Ada
type-safe genericity for maps, where iterating outside Types.Maps
would be less easy and/or efficient.
In quasiquote_list, concatenate in one buffer instead of allocating a
list for each element. The buffer may be reallocated behind the
curtain, but not once per element anymore.
In environments, illustrate tail call optimization when recursion is
more readable than a loop.
2019-03-31 20:06:00 +03:00
|
|
|
Envs.Dump_Stack (Env.all);
|
2019-03-17 13:24:03 +03:00
|
|
|
end if;
|
ada.2: fix memory leaks with garbage collection. Various simplifications.
Cyclic references were never deallocated by reference conuting.
Symbols cannot create cyclic structures and are less frequent (one
allocation per symbol), keep reference counting for them.
This slightly improves performances even though many previous
optimizations are removed (environment stack, reuse of memory).
Step caching hash of symbols. This does not seem to improve
performances. Hashing them instead of ordering them does.
Define Repl in the step file instead of globally. Move the eval
built-in function from core into the step file.
When possible, pass Ada records instead of explicit pointers.
In the reader, construct more objects directly as described in the MAL
process, reserve the buffer for sequences and maps
In eval, iterate on vectors without delegation. The increased
complexity was not improving performances. Keep demonstrating Ada
type-safe genericity for maps, where iterating outside Types.Maps
would be less easy and/or efficient.
In quasiquote_list, concatenate in one buffer instead of allocating a
list for each element. The buffer may be reallocated behind the
curtain, but not once per element anymore.
In environments, illustrate tail call optimization when recursion is
more readable than a loop.
2019-03-31 20:06:00 +03:00
|
|
|
|
2016-10-10 20:08:59 +03:00
|
|
|
case Ast.Kind is
|
2019-05-02 22:19:34 +03:00
|
|
|
when Kind_Nil | Kind_Atom | Kind_Boolean | Kind_Number | Types.Kind_Key
|
|
|
|
| Kind_Macro | Types.Kind_Function =>
|
2019-03-03 20:07:18 +03:00
|
|
|
return Ast;
|
2016-10-10 20:08:59 +03:00
|
|
|
when Kind_Symbol =>
|
2019-05-02 22:19:34 +03:00
|
|
|
return Env.all.Get (Ast.Str);
|
2016-10-10 20:08:59 +03:00
|
|
|
when Kind_Map =>
|
2019-05-02 22:19:34 +03:00
|
|
|
return Eval_Map (Ast.Map.all, Env);
|
2016-10-10 20:08:59 +03:00
|
|
|
when Kind_Vector =>
|
2019-05-02 22:19:34 +03:00
|
|
|
return Eval_Vector (Ast.Sequence.all, Env);
|
2016-10-10 20:08:59 +03:00
|
|
|
when Kind_List =>
|
2019-03-10 02:14:59 +03:00
|
|
|
null;
|
|
|
|
end case;
|
|
|
|
|
|
|
|
-- Ast is a list.
|
ada.2: fix memory leaks with garbage collection. Various simplifications.
Cyclic references were never deallocated by reference conuting.
Symbols cannot create cyclic structures and are less frequent (one
allocation per symbol), keep reference counting for them.
This slightly improves performances even though many previous
optimizations are removed (environment stack, reuse of memory).
Step caching hash of symbols. This does not seem to improve
performances. Hashing them instead of ordering them does.
Define Repl in the step file instead of globally. Move the eval
built-in function from core into the step file.
When possible, pass Ada records instead of explicit pointers.
In the reader, construct more objects directly as described in the MAL
process, reserve the buffer for sequences and maps
In eval, iterate on vectors without delegation. The increased
complexity was not improving performances. Keep demonstrating Ada
type-safe genericity for maps, where iterating outside Types.Maps
would be less easy and/or efficient.
In quasiquote_list, concatenate in one buffer instead of allocating a
list for each element. The buffer may be reallocated behind the
curtain, but not once per element anymore.
In environments, illustrate tail call optimization when recursion is
more readable than a loop.
2019-03-31 20:06:00 +03:00
|
|
|
if Ast.Sequence.all.Length = 0 then
|
2019-03-10 02:14:59 +03:00
|
|
|
return Ast;
|
|
|
|
end if;
|
2019-05-02 22:19:34 +03:00
|
|
|
First := Ast.Sequence.all.Data (1);
|
2019-03-10 02:14:59 +03:00
|
|
|
|
|
|
|
-- Special forms
|
|
|
|
-- Ast is a non-empty list, First is its first element.
|
|
|
|
case First.Kind is
|
|
|
|
when Kind_Symbol =>
|
2019-05-02 22:19:34 +03:00
|
|
|
if First.Str.all = "if" then
|
ada.2: fix memory leaks with garbage collection. Various simplifications.
Cyclic references were never deallocated by reference conuting.
Symbols cannot create cyclic structures and are less frequent (one
allocation per symbol), keep reference counting for them.
This slightly improves performances even though many previous
optimizations are removed (environment stack, reuse of memory).
Step caching hash of symbols. This does not seem to improve
performances. Hashing them instead of ordering them does.
Define Repl in the step file instead of globally. Move the eval
built-in function from core into the step file.
When possible, pass Ada records instead of explicit pointers.
In the reader, construct more objects directly as described in the MAL
process, reserve the buffer for sequences and maps
In eval, iterate on vectors without delegation. The increased
complexity was not improving performances. Keep demonstrating Ada
type-safe genericity for maps, where iterating outside Types.Maps
would be less easy and/or efficient.
In quasiquote_list, concatenate in one buffer instead of allocating a
list for each element. The buffer may be reallocated behind the
curtain, but not once per element anymore.
In environments, illustrate tail call optimization when recursion is
more readable than a loop.
2019-03-31 20:06:00 +03:00
|
|
|
Err.Check (Ast.Sequence.all.Length in 3 .. 4,
|
2019-03-17 13:24:03 +03:00
|
|
|
"expected 2 or 3 parameters");
|
2022-01-10 02:15:40 +03:00
|
|
|
if Types.To_Boolean (Eval (Ast.Sequence.all.Data (2), Env)) then
|
|
|
|
return Eval (Ast.Sequence.all.Data (3), Env);
|
|
|
|
elsif Ast.Sequence.all.Length = 3 then
|
|
|
|
return Types.Nil;
|
|
|
|
else
|
|
|
|
return Eval (Ast.Sequence.all.Data (4), Env);
|
|
|
|
end if;
|
2019-05-02 22:19:34 +03:00
|
|
|
elsif First.Str.all = "let*" then
|
|
|
|
Err.Check (Ast.Sequence.all.Length = 3
|
|
|
|
and then Ast.Sequence.all.Data (2).Kind in Types.Kind_Sequence,
|
|
|
|
"expected a sequence then a value");
|
2019-02-28 00:27:12 +03:00
|
|
|
declare
|
2019-05-02 22:19:34 +03:00
|
|
|
Bindings : Types.T_Array
|
|
|
|
renames Ast.Sequence.all.Data (2).Sequence.all.Data;
|
|
|
|
New_Env : constant Envs.Ptr := Envs.New_Env (Outer => Env);
|
2019-02-28 00:27:12 +03:00
|
|
|
begin
|
2019-05-02 22:19:34 +03:00
|
|
|
Err.Check (Bindings'Length mod 2 = 0, "expected even binds");
|
|
|
|
for I in 0 .. Bindings'Length / 2 - 1 loop
|
|
|
|
New_Env.all.Set (Bindings (Bindings'First + 2 * I),
|
|
|
|
Eval (Bindings (Bindings'First + 2 * I + 1), New_Env));
|
|
|
|
-- This call checks key kind.
|
2019-02-28 00:27:12 +03:00
|
|
|
end loop;
|
2019-05-02 22:19:34 +03:00
|
|
|
return Eval (Ast.Sequence.all.Data (3), New_Env);
|
|
|
|
end;
|
|
|
|
elsif First.Str.all = "def!" then
|
|
|
|
Err.Check (Ast.Sequence.all.Length = 3, "expected 2 parameters");
|
|
|
|
declare
|
|
|
|
Key : Types.T renames Ast.Sequence.all.Data (2);
|
|
|
|
Val : constant Types.T := Eval (Ast.Sequence.all.Data (3), Env);
|
|
|
|
begin
|
|
|
|
Env.all.Set (Key, Val); -- Check key kind.
|
|
|
|
return Val;
|
|
|
|
end;
|
2019-05-08 04:07:45 +03:00
|
|
|
elsif First.Str.all = "do" then
|
|
|
|
Err.Check (1 < Ast.Sequence.all.Length, "do expects arguments");
|
|
|
|
declare
|
|
|
|
Result : Types.T;
|
|
|
|
begin
|
|
|
|
for I in 2 .. Ast.Sequence.all.Length loop
|
|
|
|
Result := Eval (Ast.Sequence.all.Data (I), Env);
|
|
|
|
end loop;
|
|
|
|
return Result;
|
|
|
|
end;
|
2019-05-02 22:19:34 +03:00
|
|
|
elsif First.Str.all = "fn*" then
|
|
|
|
Err.Check (Ast.Sequence.all.Length = 3, "expected 2 parameters");
|
|
|
|
declare
|
|
|
|
Params : Types.T renames Ast.Sequence.all.Data (2);
|
|
|
|
begin
|
|
|
|
Err.Check (Params.Kind in Types.Kind_Sequence,
|
|
|
|
"first argument of fn* must be a sequence");
|
2019-07-01 00:37:25 +03:00
|
|
|
return (Kind_Fn, Types.Fns.New_Function
|
2019-05-02 22:19:34 +03:00
|
|
|
(Params => Params.Sequence,
|
|
|
|
Ast => Ast.Sequence.all.Data (3),
|
2019-07-01 00:37:25 +03:00
|
|
|
Env => Env));
|
2019-02-28 00:27:12 +03:00
|
|
|
end;
|
|
|
|
else
|
2019-03-10 02:14:59 +03:00
|
|
|
First := Eval (First, Env);
|
2019-02-28 00:27:12 +03:00
|
|
|
end if;
|
2019-03-10 02:14:59 +03:00
|
|
|
when others =>
|
|
|
|
First := Eval (First, Env);
|
|
|
|
end case;
|
|
|
|
|
|
|
|
-- Apply phase.
|
|
|
|
-- Ast is a non-empty list,
|
|
|
|
-- First is its non-special evaluated first element.
|
2019-05-02 22:19:34 +03:00
|
|
|
Err.Check (First.Kind in Types.Kind_Function,
|
|
|
|
"first element must be a function");
|
|
|
|
-- We are applying a function. Evaluate its arguments.
|
|
|
|
declare
|
|
|
|
Args : Types.T_Array (2 .. Ast.Sequence.all.Length);
|
|
|
|
begin
|
|
|
|
for I in Args'Range loop
|
|
|
|
Args (I) := Eval (Ast.Sequence.all.Data (I), Env);
|
|
|
|
end loop;
|
|
|
|
if First.Kind = Kind_Builtin then
|
|
|
|
return First.Builtin.all (Args);
|
|
|
|
end if;
|
|
|
|
return First.Fn.all.Apply (Args);
|
|
|
|
end;
|
2019-03-17 13:24:03 +03:00
|
|
|
exception
|
|
|
|
when Err.Error =>
|
|
|
|
Err.Add_Trace_Line ("eval", Ast);
|
|
|
|
raise;
|
2016-10-10 20:08:59 +03:00
|
|
|
end Eval;
|
|
|
|
|
2019-05-02 22:19:34 +03:00
|
|
|
function Eval_Map (Source : in Types.Maps.Instance;
|
|
|
|
Env : in Envs.Ptr) return Types.T
|
|
|
|
is
|
|
|
|
use all type Types.Maps.Cursor;
|
|
|
|
-- Copy the whole map so that keys are not hashed again.
|
|
|
|
Result : constant Types.T := Types.Maps.New_Map (Source);
|
|
|
|
Position : Types.Maps.Cursor := Result.Map.all.First;
|
|
|
|
begin
|
|
|
|
while Has_Element (Position) loop
|
|
|
|
Result.Map.all.Replace_Element (Position,
|
|
|
|
Eval (Element (Position), Env));
|
|
|
|
Next (Position);
|
|
|
|
end loop;
|
|
|
|
return Result;
|
|
|
|
end Eval_Map;
|
|
|
|
|
|
|
|
function Eval_Vector (Source : in Types.Sequences.Instance;
|
|
|
|
Env : in Envs.Ptr) return Types.T
|
|
|
|
is
|
|
|
|
Ref : constant Types.Sequence_Ptr
|
|
|
|
:= Types.Sequences.Constructor (Source.Length);
|
|
|
|
begin
|
|
|
|
for I in Source.Data'Range loop
|
|
|
|
Ref.all.Data (I) := Eval (Source.Data (I), Env);
|
|
|
|
end loop;
|
|
|
|
return (Kind_Vector, Ref);
|
|
|
|
end Eval_Vector;
|
|
|
|
|
2019-03-17 13:24:03 +03:00
|
|
|
procedure Exec (Script : in String;
|
|
|
|
Env : in Envs.Ptr)
|
2019-03-06 21:48:51 +03:00
|
|
|
is
|
2019-05-02 22:19:34 +03:00
|
|
|
Result : Types.T;
|
2016-10-10 20:08:59 +03:00
|
|
|
begin
|
2019-03-17 13:24:03 +03:00
|
|
|
for Expression of Reader.Read_Str (Script) loop
|
|
|
|
Result := Eval (Expression, Env);
|
|
|
|
end loop;
|
2019-03-06 21:48:51 +03:00
|
|
|
pragma Unreferenced (Result);
|
2019-03-17 13:24:03 +03:00
|
|
|
end Exec;
|
2019-03-06 21:48:51 +03:00
|
|
|
|
2019-05-02 22:19:34 +03:00
|
|
|
procedure Print (Ast : in Types.T) is
|
2019-03-06 21:48:51 +03:00
|
|
|
begin
|
|
|
|
Ada.Text_IO.Unbounded_IO.Put_Line (Printer.Pr_Str (Ast));
|
|
|
|
end Print;
|
|
|
|
|
2019-05-02 22:19:34 +03:00
|
|
|
function Read return Types.T_Array
|
2019-03-17 13:24:03 +03:00
|
|
|
is (Reader.Read_Str (Readline.Input ("user> ")));
|
2019-03-06 21:48:51 +03:00
|
|
|
|
|
|
|
procedure Rep (Env : in Envs.Ptr) is
|
|
|
|
begin
|
2019-03-17 13:24:03 +03:00
|
|
|
for Expression of Read loop
|
|
|
|
Print (Eval (Expression, Env));
|
|
|
|
end loop;
|
2019-03-06 21:48:51 +03:00
|
|
|
end Rep;
|
2016-10-10 20:08:59 +03:00
|
|
|
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
|
2019-03-17 13:24:03 +03:00
|
|
|
Startup : constant String
|
|
|
|
:= "(def! not (fn* (a) (if a false true)))";
|
ada.2: fix memory leaks with garbage collection. Various simplifications.
Cyclic references were never deallocated by reference conuting.
Symbols cannot create cyclic structures and are less frequent (one
allocation per symbol), keep reference counting for them.
This slightly improves performances even though many previous
optimizations are removed (environment stack, reuse of memory).
Step caching hash of symbols. This does not seem to improve
performances. Hashing them instead of ordering them does.
Define Repl in the step file instead of globally. Move the eval
built-in function from core into the step file.
When possible, pass Ada records instead of explicit pointers.
In the reader, construct more objects directly as described in the MAL
process, reserve the buffer for sequences and maps
In eval, iterate on vectors without delegation. The increased
complexity was not improving performances. Keep demonstrating Ada
type-safe genericity for maps, where iterating outside Types.Maps
would be less easy and/or efficient.
In quasiquote_list, concatenate in one buffer instead of allocating a
list for each element. The buffer may be reallocated behind the
curtain, but not once per element anymore.
In environments, illustrate tail call optimization when recursion is
more readable than a loop.
2019-03-31 20:06:00 +03:00
|
|
|
Repl : constant Envs.Ptr := Envs.New_Env;
|
2016-10-10 20:08:59 +03:00
|
|
|
begin
|
2019-03-06 21:48:51 +03:00
|
|
|
-- Show the Eval function to other packages.
|
2019-05-02 22:19:34 +03:00
|
|
|
Types.Fns.Eval_Cb := Eval'Unrestricted_Access;
|
2019-03-06 21:48:51 +03:00
|
|
|
-- Add Core functions into the top environment.
|
ada.2: fix memory leaks with garbage collection. Various simplifications.
Cyclic references were never deallocated by reference conuting.
Symbols cannot create cyclic structures and are less frequent (one
allocation per symbol), keep reference counting for them.
This slightly improves performances even though many previous
optimizations are removed (environment stack, reuse of memory).
Step caching hash of symbols. This does not seem to improve
performances. Hashing them instead of ordering them does.
Define Repl in the step file instead of globally. Move the eval
built-in function from core into the step file.
When possible, pass Ada records instead of explicit pointers.
In the reader, construct more objects directly as described in the MAL
process, reserve the buffer for sequences and maps
In eval, iterate on vectors without delegation. The increased
complexity was not improving performances. Keep demonstrating Ada
type-safe genericity for maps, where iterating outside Types.Maps
would be less easy and/or efficient.
In quasiquote_list, concatenate in one buffer instead of allocating a
list for each element. The buffer may be reallocated behind the
curtain, but not once per element anymore.
In environments, illustrate tail call optimization when recursion is
more readable than a loop.
2019-03-31 20:06:00 +03:00
|
|
|
Core.NS_Add_To_Repl (Repl);
|
2019-03-06 21:48:51 +03:00
|
|
|
-- Native startup procedure.
|
2019-03-17 13:24:03 +03:00
|
|
|
Exec (Startup, Repl);
|
ada.2: fix memory leaks with garbage collection. Various simplifications.
Cyclic references were never deallocated by reference conuting.
Symbols cannot create cyclic structures and are less frequent (one
allocation per symbol), keep reference counting for them.
This slightly improves performances even though many previous
optimizations are removed (environment stack, reuse of memory).
Step caching hash of symbols. This does not seem to improve
performances. Hashing them instead of ordering them does.
Define Repl in the step file instead of globally. Move the eval
built-in function from core into the step file.
When possible, pass Ada records instead of explicit pointers.
In the reader, construct more objects directly as described in the MAL
process, reserve the buffer for sequences and maps
In eval, iterate on vectors without delegation. The increased
complexity was not improving performances. Keep demonstrating Ada
type-safe genericity for maps, where iterating outside Types.Maps
would be less easy and/or efficient.
In quasiquote_list, concatenate in one buffer instead of allocating a
list for each element. The buffer may be reallocated behind the
curtain, but not once per element anymore.
In environments, illustrate tail call optimization when recursion is
more readable than a loop.
2019-03-31 20:06:00 +03:00
|
|
|
-- Execute user commands.
|
2019-03-06 21:48:51 +03:00
|
|
|
loop
|
|
|
|
begin
|
|
|
|
Rep (Repl);
|
|
|
|
exception
|
|
|
|
when Readline.End_Of_File =>
|
|
|
|
exit;
|
2019-03-17 13:24:03 +03:00
|
|
|
when Err.Error =>
|
|
|
|
Ada.Text_IO.Unbounded_IO.Put (Err.Trace);
|
2019-03-06 21:48:51 +03:00
|
|
|
end;
|
2019-03-17 13:24:03 +03:00
|
|
|
-- Other exceptions are really unexpected.
|
ada.2: fix memory leaks with garbage collection. Various simplifications.
Cyclic references were never deallocated by reference conuting.
Symbols cannot create cyclic structures and are less frequent (one
allocation per symbol), keep reference counting for them.
This slightly improves performances even though many previous
optimizations are removed (environment stack, reuse of memory).
Step caching hash of symbols. This does not seem to improve
performances. Hashing them instead of ordering them does.
Define Repl in the step file instead of globally. Move the eval
built-in function from core into the step file.
When possible, pass Ada records instead of explicit pointers.
In the reader, construct more objects directly as described in the MAL
process, reserve the buffer for sequences and maps
In eval, iterate on vectors without delegation. The increased
complexity was not improving performances. Keep demonstrating Ada
type-safe genericity for maps, where iterating outside Types.Maps
would be less easy and/or efficient.
In quasiquote_list, concatenate in one buffer instead of allocating a
list for each element. The buffer may be reallocated behind the
curtain, but not once per element anymore.
In environments, illustrate tail call optimization when recursion is
more readable than a loop.
2019-03-31 20:06:00 +03:00
|
|
|
|
|
|
|
-- Collect garbage.
|
2019-05-02 22:19:34 +03:00
|
|
|
Err.Data := Types.Nil;
|
ada.2: fix memory leaks with garbage collection. Various simplifications.
Cyclic references were never deallocated by reference conuting.
Symbols cannot create cyclic structures and are less frequent (one
allocation per symbol), keep reference counting for them.
This slightly improves performances even though many previous
optimizations are removed (environment stack, reuse of memory).
Step caching hash of symbols. This does not seem to improve
performances. Hashing them instead of ordering them does.
Define Repl in the step file instead of globally. Move the eval
built-in function from core into the step file.
When possible, pass Ada records instead of explicit pointers.
In the reader, construct more objects directly as described in the MAL
process, reserve the buffer for sequences and maps
In eval, iterate on vectors without delegation. The increased
complexity was not improving performances. Keep demonstrating Ada
type-safe genericity for maps, where iterating outside Types.Maps
would be less easy and/or efficient.
In quasiquote_list, concatenate in one buffer instead of allocating a
list for each element. The buffer may be reallocated behind the
curtain, but not once per element anymore.
In environments, illustrate tail call optimization when recursion is
more readable than a loop.
2019-03-31 20:06:00 +03:00
|
|
|
Repl.all.Keep;
|
2022-01-10 02:15:40 +03:00
|
|
|
Dbgeval.Keep;
|
ada.2: fix memory leaks with garbage collection. Various simplifications.
Cyclic references were never deallocated by reference conuting.
Symbols cannot create cyclic structures and are less frequent (one
allocation per symbol), keep reference counting for them.
This slightly improves performances even though many previous
optimizations are removed (environment stack, reuse of memory).
Step caching hash of symbols. This does not seem to improve
performances. Hashing them instead of ordering them does.
Define Repl in the step file instead of globally. Move the eval
built-in function from core into the step file.
When possible, pass Ada records instead of explicit pointers.
In the reader, construct more objects directly as described in the MAL
process, reserve the buffer for sequences and maps
In eval, iterate on vectors without delegation. The increased
complexity was not improving performances. Keep demonstrating Ada
type-safe genericity for maps, where iterating outside Types.Maps
would be less easy and/or efficient.
In quasiquote_list, concatenate in one buffer instead of allocating a
list for each element. The buffer may be reallocated behind the
curtain, but not once per element anymore.
In environments, illustrate tail call optimization when recursion is
more readable than a loop.
2019-03-31 20:06:00 +03:00
|
|
|
Garbage_Collected.Clean;
|
2019-03-06 21:48:51 +03:00
|
|
|
end loop;
|
|
|
|
Ada.Text_IO.New_Line;
|
ada.2: fix memory leaks with garbage collection. Various simplifications.
Cyclic references were never deallocated by reference conuting.
Symbols cannot create cyclic structures and are less frequent (one
allocation per symbol), keep reference counting for them.
This slightly improves performances even though many previous
optimizations are removed (environment stack, reuse of memory).
Step caching hash of symbols. This does not seem to improve
performances. Hashing them instead of ordering them does.
Define Repl in the step file instead of globally. Move the eval
built-in function from core into the step file.
When possible, pass Ada records instead of explicit pointers.
In the reader, construct more objects directly as described in the MAL
process, reserve the buffer for sequences and maps
In eval, iterate on vectors without delegation. The increased
complexity was not improving performances. Keep demonstrating Ada
type-safe genericity for maps, where iterating outside Types.Maps
would be less easy and/or efficient.
In quasiquote_list, concatenate in one buffer instead of allocating a
list for each element. The buffer may be reallocated behind the
curtain, but not once per element anymore.
In environments, illustrate tail call optimization when recursion is
more readable than a loop.
2019-03-31 20:06:00 +03:00
|
|
|
|
2019-03-17 13:24:03 +03:00
|
|
|
-- If assertions are enabled, check deallocations.
|
2019-05-02 22:19:34 +03:00
|
|
|
-- Normal runs do not need to deallocate before termination.
|
|
|
|
-- Beware that all pointers are now dangling.
|
ada.2: fix memory leaks with garbage collection. Various simplifications.
Cyclic references were never deallocated by reference conuting.
Symbols cannot create cyclic structures and are less frequent (one
allocation per symbol), keep reference counting for them.
This slightly improves performances even though many previous
optimizations are removed (environment stack, reuse of memory).
Step caching hash of symbols. This does not seem to improve
performances. Hashing them instead of ordering them does.
Define Repl in the step file instead of globally. Move the eval
built-in function from core into the step file.
When possible, pass Ada records instead of explicit pointers.
In the reader, construct more objects directly as described in the MAL
process, reserve the buffer for sequences and maps
In eval, iterate on vectors without delegation. The increased
complexity was not improving performances. Keep demonstrating Ada
type-safe genericity for maps, where iterating outside Types.Maps
would be less easy and/or efficient.
In quasiquote_list, concatenate in one buffer instead of allocating a
list for each element. The buffer may be reallocated behind the
curtain, but not once per element anymore.
In environments, illustrate tail call optimization when recursion is
more readable than a loop.
2019-03-31 20:06:00 +03:00
|
|
|
pragma Debug (Garbage_Collected.Clean);
|
|
|
|
Garbage_Collected.Check_Allocations;
|
2016-10-10 20:08:59 +03:00
|
|
|
end Step4_If_Fn_Do;
|