Remove dead code.

This commit is contained in:
Romain Beguet
2023-02-22 12:13:20 +01:00
committed by Romain Béguet
parent eb1eece052
commit 99e08fdc81
43 changed files with 6 additions and 462 deletions

View File

@@ -3,8 +3,6 @@
-- SPDX-License-Identifier: Apache-2.0
--
with Ada.Command_Line;
with Ada.Environment_Variables;
with Ada.Exceptions; use Ada.Exceptions;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Unchecked_Deallocation;
@@ -17,14 +15,6 @@ package body Langkit_Support.Adalog.Generic_Main_Support is
procedure Free is new Ada.Unchecked_Deallocation
(Logic_Var_Record, Refs.Logic_Var);
-- The following booleans determine which solver configurations to run in
-- tests. The ``Setup_Traces`` procedure initializes them with default
-- values, possibly modified depending on environment variables, for
-- convenience when debugging tests.
Run_Sym_Without_Opts : Boolean;
Run_Sym_With_Opts : Boolean;
------------
-- Create --
------------
@@ -81,14 +71,7 @@ package body Langkit_Support.Adalog.Generic_Main_Support is
procedure Free (Self : in out Solution_Vectors.Vector);
-- Free all solutions in Self and destroy the vector
function Equivalent
(Left, Right : Solution_Vectors.Vector) return Boolean;
-- Return whether the two vectors of solutions are equal
Solutions : Solution_Vectors.Vector :=
Solution_Vectors.Empty_Vector;
Solutions_Without_Opts : Solution_Vectors.Vector :=
Solution_Vectors.Empty_Vector;
Solutions : Solution_Vectors.Vector := Solution_Vectors.Empty_Vector;
function Solution_Callback (Vars : Logic_Var_Array) return Boolean;
-- Callback for ``Solve``. Print the given solution and append it to
@@ -116,46 +99,6 @@ package body Langkit_Support.Adalog.Generic_Main_Support is
Self.Destroy;
end Free;
----------------
-- Equivalent --
----------------
function Equivalent
(Left, Right : Solution_Vectors.Vector) return Boolean
is
begin
if Left.Length /= Right.Length then
return False;
end if;
for I in 1 .. Left.Length loop
declare
S_L : Solution renames Left.Get (I).all;
S_R : Solution renames Right.Get (I).all;
begin
if S_L'Length /= S_R'Length then
return False;
end if;
for J in S_L'Range loop
declare
L : Var_And_Val renames S_L (J);
R : Var_And_Val renames S_R (J);
begin
if Refs."/=" (L.Var, R.Var)
or else L.Defined /= R.Defined
or else (L.Defined and then L.Val /= R.Val)
then
return False;
end if;
end;
end loop;
end;
end loop;
return True;
end Equivalent;
-----------------------
-- Solution_Callback --
-----------------------
@@ -198,42 +141,15 @@ package body Langkit_Support.Adalog.Generic_Main_Support is
begin
Put_Line ("Solving relation:");
Put_Line (Image (Rel));
-- Solve both without and with optimizations
if Run_Sym_Without_Opts then
Put_Line ("... without optimizations:");
Run_Solve ((others => False));
New_Line;
Solutions_Without_Opts := Solutions;
Solutions := Solution_Vectors.Empty_Vector;
end if;
if Run_Sym_With_Opts then
Put_Line ("... with all optimizations:");
Run_Solve ((others => True));
New_Line;
end if;
-- Check that we had the same results in both cases
if Run_Sym_Without_Opts
and then Run_Sym_With_Opts
and then not Equivalent (Solutions_Without_Opts, Solutions)
then
Put_Line ("ERROR: solutions are not the same");
New_Line;
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
end if;
Run_Solve (Default_Options);
New_Line;
-- Clean up, we are done
Free (Solutions_Without_Opts);
Free (Solutions);
exception
when others =>
Free (Solutions_Without_Opts);
Free (Solutions);
raise;
end Solve_All;
@@ -255,38 +171,11 @@ package body Langkit_Support.Adalog.Generic_Main_Support is
procedure Run_Main (Main : access procedure) is
begin
Setup_Traces;
GNATCOLL.Traces.Parse_Config_File;
Main.all;
Finalize;
end Run_Main;
------------------
-- Setup_Traces --
------------------
procedure Setup_Traces is
package Env renames Ada.Environment_Variables;
Var_Name : constant String := "ADALOG_SOLVER_CFG";
Cfg : constant String := Env.Value (Var_Name, Default => "");
begin
GNATCOLL.Traces.Parse_Config_File;
Run_Sym_Without_Opts := False;
Run_Sym_With_Opts := False;
if Cfg = "" then
Run_Sym_Without_Opts := True;
Run_Sym_With_Opts := True;
elsif Cfg = "sym" then
Run_Sym_Without_Opts := True;
elsif Cfg = "sym-opts" then
Run_Sym_With_Opts := True;
else
raise Program_Error
with "Invalid value for env var """ & Var_Name & """";
end if;
end Setup_Traces;
--------------
-- Finalize --
--------------

View File

@@ -103,7 +103,6 @@ package Langkit_Support.Adalog.Generic_Main_Support is
procedure Solve_All (Rel : Relation; Timeout : Natural := 0);
procedure Run_Main (Main : access procedure);
procedure Setup_Traces;
procedure Finalize;
private

View File

@@ -18,13 +18,9 @@ package Langkit_Support.Adalog is
-- Solving options --
---------------------
type Solve_Options_Type is record
Cut_Dead_Branches : Boolean := True;
-- Whether to enable an optimization that will cut branches that
-- necessarily contain falsy solutions.
end record;
type Solve_Options_Type is null record;
Default_Options : Solve_Options_Type := (others => <>);
Default_Options : Solve_Options_Type;
-- Mutate this to affect the behavior of all calls to the solver which just
-- use the default options.
@@ -88,10 +84,4 @@ package Langkit_Support.Adalog is
-- * the number of tried solutions;
-- * valid solutions found.
Cst_Folding_Trace : GNATCOLL.Traces.Trace_Handle := GNATCOLL.Traces.Create
("LANGKIT.SOLVER.CONSTANT_FOLDING",
Default => GNATCOLL.Traces.From_Config);
-- Trace to show the result of relation constant folding pass done during
-- the preparation stage in the symbolic solver.
end Langkit_Support.Adalog;

View File

@@ -3,10 +3,6 @@ Any:
False
%X <- 12
... without optimizations:
Solution: [%X = 12]
... with all optimizations:
Solution: [%X = 12]
Done.

View File

@@ -3,7 +3,6 @@ All:
%X <- 12
Is_Even?(%X)
... with all optimizations:
Solution: [%X = 12]
Solving relation:
@@ -15,7 +14,6 @@ All:
Is_Even?(%X)
... with all optimizations:
Solution: [%X = 2]
Solving relation:
@@ -28,7 +26,6 @@ All:
Is_Even?(%X)
... with all optimizations:
Solution: [%X = 2]
Solution: [%X = 4]
@@ -39,7 +36,6 @@ Any:
%X <- 3
%X <- 4
... with all optimizations:
Solution: [%X = 1]
Solution: [%X = 2]
Solution: [%X = 3]

View File

@@ -10,15 +10,6 @@ All:
%Y <- Square(%X)
... without optimizations:
Solution: [%X = 1, %Y = 1]
Solution: [%X = 2, %Y = 4]
Solution: [%X = 3, %Y = 9]
Solution: [%X = 4, %Y = 16]
Solution: [%X = 5, %Y = 25]
Solution: [%X = 6, %Y = 36]
... with all optimizations:
Solution: [%X = 1, %Y = 1]
Solution: [%X = 2, %Y = 4]
Solution: [%X = 3, %Y = 9]
@@ -39,10 +30,6 @@ All:
%Y <- Square(%X)
%Y <- 36
... without optimizations:
Solution: [%X = 6, %Y = 36]
... with all optimizations:
Solution: [%X = 6, %Y = 36]
Done.

View File

@@ -9,12 +9,6 @@ All:
%X <- 3 main.adb:28
... without optimizations:
Solution: [%X = 1, %Y = 1]
Solution: [%X = 2, %Y = 2]
Solution: [%X = 3, %Y = 3]
... with all optimizations:
Solution: [%X = 1, %Y = 1]
Solution: [%X = 2, %Y = 2]
Solution: [%X = 3, %Y = 3]
@@ -40,12 +34,6 @@ All: main.adb:34
%Y <- 10 main.adb:34
... without optimizations:
Solution: [%X = 1, %Y = 10]
Solution: [%X = 2, %Y = 10]
Solution: [%X = 3, %Y = 10]
... with all optimizations:
Solution: [%X = 1, %Y = 10]
Solution: [%X = 2, %Y = 10]
Solution: [%X = 3, %Y = 10]
@@ -61,9 +49,6 @@ All: main.adb:38
%X <- 3 main.adb:38
... without optimizations:
... with all optimizations:
========================================================================
@@ -72,9 +57,6 @@ All: main.adb:42
Is_Even?(%Y) main.adb:42
Is_Even?(%X) main.adb:42
... without optimizations:
... with all optimizations:
========================================================================
@@ -84,11 +66,6 @@ Any: main.adb:45
%X <- 1 main.adb:45
%X <- 2 main.adb:45
... without optimizations:
Solution: [%Y = <undefined>, %X = 1]
Solution: [%Y = <undefined>, %X = 2]
... with all optimizations:
Solution: [%Y = <undefined>, %X = 1]
Solution: [%Y = <undefined>, %X = 2]
@@ -99,9 +76,6 @@ Any: main.adb:48
Is_Even?(%X) main.adb:48
Is_Even?(%Y) main.adb:48
... without optimizations:
... with all optimizations:
========================================================================
@@ -117,9 +91,6 @@ Any: main.adb:51
Is_Even?(%Y) main.adb:51
... without optimizations:
... with all optimizations:
========================================================================
@@ -136,10 +107,6 @@ All: main.adb:56
%X <-> %Y main.adb:56
... without optimizations:
Solution: [%X = 2, %Y = 2]
... with all optimizations:
Solution: [%X = 2, %Y = 2]
Done.

View File

@@ -4,10 +4,6 @@ All:
%X <- %Y
%X <- 1
... without optimizations:
Solution: [%Y = 1, %X = 1]
... with all optimizations:
Solution: [%Y = 1, %X = 1]
Done.

View File

@@ -4,8 +4,5 @@ All:
%Z <- %Y
%X <- %Z
... without optimizations:
... with all optimizations:
Done.

View File

@@ -11,10 +11,6 @@ All:
%X <- 1
Is_Odd?(%X)
... without optimizations:
Solution: [%X = 1]
... with all optimizations:
Solution: [%X = 1]
Done.

View File

@@ -10,12 +10,6 @@ All:
%X <- 6
... without optimizations:
Solution: [%X = 2]
Solution: [%X = 4]
Solution: [%X = 6]
... with all optimizations:
Solution: [%X = 2]
Solution: [%X = 4]
Solution: [%X = 6]

View File

@@ -7,15 +7,6 @@ Any:
%X <- 5
%X <- 6
... without optimizations:
Solution: [%X = 1]
Solution: [%X = 2]
Solution: [%X = 3]
Solution: [%X = 4]
Solution: [%X = 5]
Solution: [%X = 6]
... with all optimizations:
Solution: [%X = 1]
Solution: [%X = 2]
Solution: [%X = 3]

View File

@@ -14,12 +14,6 @@ All:
%X <- 5
... without optimizations:
Solution: [%X = 3]
Solution: [%X = 4]
Solution: [%X = 5]
... with all optimizations:
Solution: [%X = 3]
Solution: [%X = 4]
Solution: [%X = 5]

View File

@@ -9,17 +9,6 @@ Any:
%X <- 7
%X <- 8
... without optimizations:
Solution: [%X = 1]
Solution: [%X = 2]
Solution: [%X = 3]
Solution: [%X = 4]
Solution: [%X = 5]
Solution: [%X = 6]
Solution: [%X = 7]
Solution: [%X = 8]
... with all optimizations:
Solution: [%X = 1]
Solution: [%X = 2]
Solution: [%X = 3]
@@ -46,12 +35,6 @@ All:
%Y <- 1
... without optimizations:
Solution: [%X = 1, %Y = 1]
Solution: [%X = 2, %Y = 2]
Solution: [%X = 3, %Y = 3]
... with all optimizations:
Solution: [%X = 1, %Y = 1]
Solution: [%X = 2, %Y = 2]
Solution: [%X = 3, %Y = 3]

View File

@@ -7,15 +7,6 @@ Any:
%X <- 5
%X <- 6
... without optimizations:
Solution: [%X = 1]
Solution: [%X = 2]
Solution: [%X = 3]
Solution: [%X = 4]
Solution: [%X = 5]
Solution: [%X = 6]
... with all optimizations:
Solution: [%X = 1]
Solution: [%X = 2]
Solution: [%X = 3]

View File

@@ -9,12 +9,6 @@ All:
%X <- 3
... without optimizations:
Solution: [%X = 1, %Y = 1]
Solution: [%X = 2, %Y = 2]
Solution: [%X = 3, %Y = 3]
... with all optimizations:
Solution: [%X = 1, %Y = 1]
Solution: [%X = 2, %Y = 2]
Solution: [%X = 3, %Y = 3]
@@ -40,12 +34,6 @@ All:
%Y <- 10
... without optimizations:
Solution: [%X = 1, %Y = 10]
Solution: [%X = 2, %Y = 10]
Solution: [%X = 3, %Y = 10]
... with all optimizations:
Solution: [%X = 1, %Y = 10]
Solution: [%X = 2, %Y = 10]
Solution: [%X = 3, %Y = 10]
@@ -61,9 +49,6 @@ All:
%X <- 3
... without optimizations:
... with all optimizations:
========================================================================
@@ -72,9 +57,6 @@ All:
Is_Even?(%Y)
Is_Even?(%X)
... without optimizations:
... with all optimizations:
========================================================================
@@ -84,11 +66,6 @@ Any:
%X <- 1
%X <- 2
... without optimizations:
Solution: [%Y = <undefined>, %X = 1]
Solution: [%Y = <undefined>, %X = 2]
... with all optimizations:
Solution: [%Y = <undefined>, %X = 1]
Solution: [%Y = <undefined>, %X = 2]
@@ -99,9 +76,6 @@ Any:
Is_Even?(%X)
Is_Even?(%Y)
... without optimizations:
... with all optimizations:
========================================================================
@@ -117,9 +91,6 @@ Any:
Is_Even?(%Y)
... without optimizations:
... with all optimizations:
========================================================================
@@ -136,10 +107,6 @@ All:
%X <-> %Y
... without optimizations:
Solution: [%X = 2, %Y = 2]
... with all optimizations:
Solution: [%X = 2, %Y = 2]
Done.

View File

@@ -163,8 +163,5 @@ All:
Is_Even?(%X3)
Is_Even?(%X6)
... without optimizations:
... with all optimizations:
Done.

View File

@@ -1,7 +1,4 @@
Solving relation:
False
... without optimizations:
... with all optimizations:
Done.

View File

@@ -15,11 +15,6 @@ All:
%Y <- 18
... without optimizations:
Solution: [%X = 4, %Y = 12]
Solution: [%X = 6, %Y = 18]
... with all optimizations:
Solution: [%X = 4, %Y = 12]
Solution: [%X = 6, %Y = 18]

View File

@@ -19,18 +19,6 @@ All:
True
... without optimizations:
Solution: [%X = 1, %Y = 1]
Solution: [%X = 2, %Y = 2]
Solution: [%X = 3, %Y = 3]
Solution: [%X = 4, %Y = 4]
Solution: [%X = 5, %Y = 5]
Solution: [%X = 6, %Y = 6]
Solution: [%X = 10, %Y = 10]
Solution: [%X = 11, %Y = 11]
Solution: [%X = <undefined>, %Y = <undefined>]
... with all optimizations:
Solution: [%X = 1, %Y = 1]
Solution: [%X = 2, %Y = 2]
Solution: [%X = 3, %Y = 3]

Some files were not shown because too many files have changed in this diff Show More