ocarina-backends-ada_values.ads 4.76 KB
Newer Older
1 2 3 4 5 6 7 8
------------------------------------------------------------------------------
--                                                                          --
--                           OCARINA COMPONENTS                             --
--                                                                          --
--          O C A R I N A . B A C K E N D S . A D A _ V A L U E S           --
--                                                                          --
--                                 S p e c                                  --
--                                                                          --
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
--    Copyright (C) 2006-2009 Telecom ParisTech, 2010-2015 ESA & ISAE.      --
--                                                                          --
-- 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 33 34 35
--                                                                          --
------------------------------------------------------------------------------

with Ocarina.Backends.Ada_Tree.Nodes; use Ocarina.Backends.Ada_Tree.Nodes;

package Ocarina.Backends.Ada_Values is

36 37 38 39 40 41
   type Value_Type (K : Node_Kind := K_Boolean) is record
      case K is
         when K_Integer | K_Boolean =>
            IVal : Unsigned_Long_Long;
            Sign : Short_Short;
            Base : Unsigned_Short_Short;
42

43 44
         when K_Float =>
            FVal : Long_Double;
45

46 47
         when K_String | K_Wide_String =>
            SVal : Name_Id;
48

49 50
         when K_Character | K_Wide_Character =>
            CVal : Unsigned_Short;
51

52 53 54 55
         when others =>
            null;
      end case;
   end record;
56 57

   Bad_Value : constant Value_Type;
58
   No_Value : constant Value_Id;
59

60
   function New_Boolean_Value (Value : Boolean) return Value_Id;
61

62
   function New_Floating_Point_Value (Value : Long_Double) return Value_Id;
63 64 65 66

   function New_Integer_Value
     (Value : Unsigned_Long_Long;
      Sign  : Short_Short;
67
      Base  : Unsigned_Short_Short) return Value_Id;
68 69 70

   function New_String_Value
     (Value : Name_Id;
71
      Wide  : Boolean := False) return Value_Id;
72 73 74

   function New_Character_Value
     (Value : Unsigned_Short;
75
      Wide  : Boolean := False) return Value_Id;
76

77
   function New_Value (Value : Value_Type) return Value_Id;
78 79 80 81 82 83 84 85 86 87

   function Value (V : Value_Id) return Value_Type;
   procedure Set_Value (V : Value_Id; X : Value_Type);

   function Image (Value : Value_Id) return String;

   function To_Ada_Value (V : Value_Id) return Value_Id;
   --  Converts an AADL value to and Ada one

   function "not" (R : Value_Type) return Value_Type;
88 89 90
   function "-" (R : Value_Type) return Value_Type;
   function "-" (L, R : Value_Type) return Value_Type;
   function "+" (L, R : Value_Type) return Value_Type;
91
   function "mod" (L, R : Value_Type) return Value_Type;
92 93
   function "/" (L, R : Value_Type) return Value_Type;
   function "*" (L, R : Value_Type) return Value_Type;
94
   function "and" (L, R : Value_Type) return Value_Type;
95
   function "or" (L, R : Value_Type) return Value_Type;
96
   function "xor" (L, R : Value_Type) return Value_Type;
97
   function Shift_Left (L, R : Value_Type) return Value_Type;
98 99
   function Shift_Right (L, R : Value_Type) return Value_Type;

100
   function "<" (L, R : Value_Type) return Boolean;
101 102 103 104 105 106 107 108
   --  Assume L and R have the same type.

   procedure Reset;
   --  Reset the value table

private

   Bad_Value : constant Value_Type := Value_Type'((K => K_Node_Id));
109
   No_Value  : constant Value_Id   := 0;
110 111

end Ocarina.Backends.Ada_Values;