ocarina-analyzer.adb 4.49 KB
Newer Older
1
2
3
4
5
6
7
8
------------------------------------------------------------------------------
--                                                                          --
--                           OCARINA COMPONENTS                             --
--                                                                          --
--                     O C A R I N A . A N A L Y Z E R                      --
--                                                                          --
--                                 B o d y                                  --
--                                                                          --
yoogx's avatar
yoogx committed
9
--       Copyright (C) 2009 Telecom ParisTech, 2010-2016 ESA & ISAE.        --
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
--                                                                          --
-- Ocarina  is free software; you can redistribute it and/or modify under   --
-- terms of the  GNU General Public License as published  by the Free Soft- --
-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
-- sion. Ocarina is distributed in the hope that it will be useful, but     --
-- WITHOUT ANY WARRANTY; without even the implied warranty of               --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     --
--                                                                          --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception,   --
-- version 3.1, as published by the Free Software Foundation.               --
--                                                                          --
-- You should have received a copy of the GNU General Public License and    --
-- a copy of the GCC Runtime Library Exception along with this program;     --
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
-- <http://www.gnu.org/licenses/>.                                          --
26
--                                                                          --
jhugues's avatar
jhugues committed
27
28
--                 Ocarina is maintained by the TASTE project               --
--                      (taste-users@lists.tuxfamily.org)                   --
29
30
31
32
--                                                                          --
------------------------------------------------------------------------------

with Charset;
33
with Ocarina.Namet;
34
35
36
37
38

with GNAT.Table;

with Ocarina.Analyzer.AADL;
with Ocarina.Analyzer.REAL;
39
with Ocarina.Analyzer.AADL_EMA;
40
with Ocarina.Analyzer.AADL_BA;
41
42
43
44

package body Ocarina.Analyzer is

   use Charset;
yoogx's avatar
yoogx committed
45

46
   use Ocarina.Namet;
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66

   type Analyzer_Record is record
      Language : Name_Id;
      Analyzer : Analyzer_Subprogram;
   end record;

   package Analyzers is new GNAT.Table (Analyzer_Record, Nat, 1, 5, 20);

   -------------
   -- Analyze --
   -------------

   function Analyze (Language : Name_Id; Root : Node_Id) return Boolean is
   begin
      for P in Analyzers.First .. Analyzers.Last loop
         if Language = Analyzers.Table (P).Language then
            return Analyzers.Table (P).Analyzer (Root);
         end if;
      end loop;

yoogx's avatar
yoogx committed
67
68
      raise Program_Error with
        "Analyzers : Cannot find language " & Get_Name_String (Language);
69
70
71
72
73
74
75
76
77
78
   end Analyze;

   --------------------
   -- Init_Analyzers --
   --------------------

   procedure Init_Analyzers is
   begin
      Ocarina.Analyzer.AADL.Init;
      Ocarina.Analyzer.REAL.Init;
79
      Ocarina.Analyzer.AADL_EMA.Init;
80
      Ocarina.Analyzer.AADL_BA.Init;
81
82
83
84
85
86
87
88
89
90
91
   end Init_Analyzers;

   ---------------------
   -- Reset_Analyzers --
   ---------------------

   procedure Reset_Analyzers is
   begin
      Analyzers.Init;
      Ocarina.Analyzer.AADL.Reset;
      Ocarina.Analyzer.REAL.Reset;
92
      Ocarina.Analyzer.AADL_EMA.Reset;
93
      Ocarina.Analyzer.AADL_BA.Reset;
94
95
96
97
98
99
100
101
102
103
   end Reset_Analyzers;

   -----------------------
   -- Register_Analyzer --
   -----------------------

   procedure Register_Analyzer
     (Language : String;
      Analyzer : Analyzer_Subprogram)
   is
yoogx's avatar
yoogx committed
104
105
      N : constant Name_Id := Get_String_Name (To_Lower (Language));

106
107
108
   begin
      for B in Analyzers.First .. Analyzers.Last loop
         if Analyzers.Table (B).Language = N then
yoogx's avatar
yoogx committed
109
110
            raise Program_Error with
              "Cannot register twice analyzer " & Language;
111
112
113
         end if;
      end loop;

yoogx's avatar
yoogx committed
114
115
116
117
      Analyzers.Increment_Last;
      Set_Str_To_Name_Buffer (Language);
      Analyzers.Table (Analyzers.Last).Language := Name_Find;
      Analyzers.Table (Analyzers.Last).Analyzer := Analyzer;
118
119
120
   end Register_Analyzer;

end Ocarina.Analyzer;