hac_0.26.0_19beb1f4/src/compile/emit/hac_sys-targets-semantics.ads

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
-------------------------------------------------------------------------------------
--
--  HAC - HAC Ada Compiler
--
--  A compiler in Ada for an Ada subset
--
--  Copyright, license, etc. : see top package.
--
-------------------------------------------------------------------------------------

--  The target Semantics produces no machine code but
--  serves semantics analysis purposes, like cross-references
--  for an editor with auto-complete, contextual menus and tool tips.

with Ada.Containers.Hashed_Maps,
     Ada.Strings.Unbounded.Hash;

with HAC_Sys.Co_Defs;

with HAT;

package HAC_Sys.Targets.Semantics is

  --  Reference map
  --  =============
  --
  --  Key                  Value
  --  ===                  =====
  --  [file_name i j]      index in the Id Table

  package Reference_Mapping is new Ada.Containers.Hashed_Maps
    (Key_Type        => HAT.VString,  --  [file_name i j]
     Element_Type    => Positive,     --  Index in the Id Table
     Hash            => Ada.Strings.Unbounded.Hash,
     Equivalent_Keys => Ada.Strings.Unbounded."=");

  --  Declarations map
  --  ================
  --
  --  Key                  Value
  --  ===                  =====
  --  index in Id Table    file_name, i, j of declaration

  type Declaration_Point_Array is
    array (Co_Defs.Identifier_Table_Type'Range) of Declaration_Point;

  --  Possible sanity checks for an usage within an editor:
  --    - compare identifiers between the one at [file_name i j] and
  --      the one in the identifier table (weak check)
  --    - ensure the analysis was completed after the latest
  --      modification in the editor (keystroke, cut, paste, ...)
  --

  type Machine is limited new Targets.Machine with record
    CD         : Co_Defs.Compiler_Data_Access;
    ref_map    : Reference_Mapping.Map;
    decl_map   : Declaration_Point_Array;
    busy       : Boolean  := False with Volatile;
    started    : HAT.Time;
    finished   : HAT.Time;
    total_time : Duration := 0.0;
  end record;

  --------------------
  --  Informations  --
  --------------------

  overriding function Name (m : Machine) return String is ("HAC Semantics");
  overriding function CPU (m : Machine) return String is ("No CPU");
  overriding function OS (m : Machine) return String is ("Any");
  overriding function Null_Terminated_String_Literals (m : Machine) return Boolean is (False);

  ---------------------------------------
  --  Initialize & Finalize Semantics  --
  ---------------------------------------

  overriding procedure Initialize_Code_Emission (m : in out Machine);
  overriding procedure Finalize_Code_Emission
    (m       : in out Machine;
     strings :        String);

  ----------------------------
  --  Machine Instructions  --
  ----------------------------

  overriding procedure Emit_Arithmetic_Binary_Instruction
    (m         : in out Machine;
     operator  :        Defs.Arithmetic_Binary_Operator;
     base_typ  :        Defs.Numeric_Typ) is null;

  overriding procedure Emit_Halt (m : in out Machine) is null;

  overriding procedure Emit_Push_Discrete_Literal
    (m : in out Machine; x : Defs.HAC_Integer) is null;

  overriding procedure Emit_Push_Discrete_Literals
    (m : in out Machine; x, y : Defs.HAC_Integer) is null;

  ----------------------------
  --  Built-In Subprograms  --
  ----------------------------

  overriding procedure Emit_HAT_Builtin_Procedure
    (m            : in out Machine;
     builtin_proc :        Defs.SP_Code;
     parameter    :        Defs.HAC_Integer) is null;

  -------------
  --  Misc.  --
  -------------

  overriding function Assembler_File_Name (m : Machine) return String is ("");

  overriding procedure Mark_Reference (m : in out Machine; located_id : Natural);

  overriding procedure Mark_Declaration (m : in out Machine; is_built_in : Boolean);

  overriding procedure Find_Declaration
    (m         : in out Machine;
     ref       : in     Reference_Point'Class;
     decl      :    out Declaration_Point'Class;
     was_found :    out Boolean);

end HAC_Sys.Targets.Semantics;