Changeset 321


Ignore:
Timestamp:
Nov 3, 2014, 1:31:34 PM (6 years ago)
Author:
Maxim Reznik
Message:

Add initial compiler code

Location:
trunk/compiler
Files:
15 added
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/compiler/gnat/compiler.gpr

    r318 r321  
    22with "gela_asis";
    33
    4 project Gela_ASIS_Tests is
     4project Compiler is
    55
    6    for Main use
    7      ("ts_00018", "def_name");
     6   for Main use ("gela-compiler.adb");
    87
    98   for Source_Dirs use
    10      ("../tests/asis/ts_00018",
    11       "../tests/asis/def_name");
     9     ("../source/compiler");
    1210
    13    for Object_Dir use Gela_Common.Build & "/asis";
     11   for Object_Dir use Gela_Common.Build;
    1412
    1513   package Compiler is
     
    1715   end Compiler;
    1816
    19 end Gela_ASIS_Tests;
     17end Compiler;
  • trunk/compiler/source/compiler/gela-compiler.adb

    r318 r321  
     1with Ada.Text_IO;
    12with Ada.Wide_Text_IO;
    23with Ada.Command_Line;
     
    56with Asis.Ada_Environments;
    67with Asis.Compilation_Units;
     8with Asis.Elements;
    79with Asis.Errors;
    810with Asis.Exceptions;
     
    1315with League.String_Vectors;
    1416
    15 procedure TS_00018 is
    16    Args : constant League.String_Vectors.Universal_String_Vector :=
    17      League.Application.Arguments;
     17with Gela.Engines;
     18with Gela.Properties.Text;
     19with Gela.Rule.Register_All;
     20
     21procedure Gela.Compiler is
     22   use type League.Strings.Universal_String;
     23
     24   procedure Compile_Unit (Unit : Asis.Compilation_Unit);
     25
     26   Args    : League.String_Vectors.Universal_String_Vector;
    1827   Params  : League.Strings.Universal_String;
     28   File    : League.Strings.Universal_String;
    1929   Context : Asis.Context;
     30   Engine  : constant Gela.Engines.Engine_Access := new Gela.Engines.Engine;
     31
     32   ------------------
     33   -- Compile_Unit --
     34   ------------------
     35
     36   procedure Compile_Unit (Unit : Asis.Compilation_Unit) is
     37      Decl : constant Asis.Declaration :=
     38        Asis.Elements.Unit_Declaration (Unit);
     39      Text : constant Gela.Properties.Text.Text :=
     40        Engine.Get (Decl, Gela.Properties.Code);
     41   begin
     42      Ada.Text_IO.Put_Line (Engine.Text_Container.Value (Text));
     43   end Compile_Unit;
     44
    2045begin
     46   for J in 1 .. League.Application.Arguments.Length loop
     47      declare
     48         Item : constant League.Strings.Universal_String :=
     49           League.Application.Arguments.Element (J);
     50      begin
     51         if not Item.Starts_With ("-") then
     52            File := "/" & Item;
     53         end if;
     54
     55         Args.Append (Item);
     56      end;
     57   end loop;
     58
    2159   Params := Args.Join (' ');
    2260
     
    2967
    3068   Asis.Ada_Environments.Open (Context);
     69   Gela.Rule.Register_All (Engine.all);
    3170
    3271   declare
    3372      List : constant Asis.Compilation_Unit_List :=
    3473        Asis.Compilation_Units.Compilation_Units (Context);
    35       pragma Unreferenced (List);
    3674   begin
    37       null;
     75      for J in List'Range loop
     76         if League.Strings.From_UTF_16_Wide_String
     77           (Asis.Compilation_Units.Text_Name (List (J))).Ends_With (File)
     78         then
     79            Compile_Unit (List (J));
     80         end if;
     81      end loop;
    3882   end;
    3983
     
    5094      Ada.Wide_Text_IO.Put_Line (Asis.Implementation.Diagnosis);
    5195      Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
    52 end TS_00018;
     96end Gela.Compiler;
Note: See TracChangeset for help on using the changeset viewer.