Changeset 548


Ignore:
Timestamp:
Apr 28, 2018, 12:25:22 PM (4 years ago)
Author:
Maxim Reznik
Message:

Add chosen_interpretation to number_declaration

to distinguish integer and real numbers.

Location:
trunk/ada-2012/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/ada-2012/src/ag/chosen.ag

    r531 r548  
    22  function_call,
    33  identifier,
    4   composite_constraint
     4  composite_constraint,
     5  number_declaration
    56   : Gela.Interpretations.Interpretation_Kinds : chosen_interpretation;
    67
     
    4748.)
    4849
     50Rules for number_declaration. :
     51(.
     52      --  choose between Integer_Number and Real_Number
     53      --  ${number_declaration.env_in},
     54      --  ${Initialization_Expression.Up},
     55      Gela.Pass_Utils.Choose_Number_Declaration_Interpretation
     56        (Self.Compilation,
     57         Node,
     58         ${number_declaration.chosen_interpretation});
     59.)
  • trunk/ada-2012/src/api/gela-interpretations.ads

    r525 r548  
    4141      --  Interpretation of Composite_Constraint
    4242      Index_Constraint,
    43       Discriminant_Constraint);
     43      Discriminant_Constraint,
     44      --  Interpretation of number_declaration
     45      Integer_Number,
     46      Real_Number);
    4447
    4548   subtype Auxiliary_Apply_Kinds is Interpretation_Kinds
     
    5154   subtype Constraint_Kinds is Interpretation_Kinds
    5255     range Index_Constraint .. Discriminant_Constraint;
     56
     57   subtype Number_Declaration_Kinds is Interpretation_Kinds
     58     range Integer_Number .. Real_Number;
    5359
    5460   type Interpretation_Manager is limited interface;
  • trunk/ada-2012/src/asis/asis-extensions-flat_kinds.adb

    r547 r548  
    20072007     (Self : in out Visiter;
    20082008      Node : not null Gela.Elements.Number_Declarations.
    2009         Number_Declaration_Access)
    2010    is
    2011       pragma Unreferenced (Node);
    2012    begin
    2013       Self.Result := An_Integer_Number_Declaration;
     2009        Number_Declaration_Access) is
     2010   begin
     2011      if Node.Chosen_Interpretation in Gela.Interpretations.Integer_Number then
     2012         Self.Result := An_Integer_Number_Declaration;
     2013      else
     2014         Self.Result := A_Real_Number_Declaration;
     2015      end if;
    20142016   end Number_Declaration;
    20152017
  • trunk/ada-2012/src/semantic/gela-pass_utils.adb

    r547 r548  
    1616with Gela.Elements.Defining_Designators;
    1717with Gela.Elements.Enumeration_Type_Definitions;
     18with Gela.Elements.Expressions;
    1819with Gela.Elements.Full_Type_Declarations;
    1920with Gela.Elements.Function_Declarations;
     
    635636   end Choose_Composite_Constraint_Interpretation;
    636637
     638   ----------------------------------------------
     639   -- Choose_Number_Declaration_Interpretation --
     640   ----------------------------------------------
     641
     642   procedure Choose_Number_Declaration_Interpretation
     643     (Comp   : Gela.Compilations.Compilation_Access;
     644      Node   : access Gela.Elements.Number_Declarations.
     645        Number_Declaration'Class;
     646      Result : out Gela.Interpretations.Number_Declaration_Kinds)
     647   is
     648      IM : constant Gela.Interpretations.Interpretation_Manager_Access :=
     649        Comp.Context.Interpretation_Manager;
     650
     651      TM : constant Gela.Type_Managers.Type_Manager_Access :=
     652        Comp.Context.Types;
     653
     654      Init : constant Gela.Elements.Expressions.Expression_Access :=
     655        Node.Initialization_Expression;
     656
     657      Down : constant Gela.Interpretations.Interpretation_Index := Init.Down;
     658
     659      package Visiters is
     660         type Visiter is new Gela.Interpretations.Down_Visiter with record
     661            Result : Gela.Interpretations.Number_Declaration_Kinds;
     662         end record;
     663
     664         overriding procedure On_Expression
     665           (Self   : in out Visiter;
     666            Tipe   : Gela.Semantic_Types.Type_Index;
     667            Kind   : Gela.Interpretations.Unknown_Auxiliary_Apply_Kinds;
     668            Down   : Gela.Interpretations.Interpretation_Index_Array);
     669
     670      end Visiters;
     671
     672      package body Visiters is
     673
     674         overriding procedure On_Expression
     675           (Self   : in out Visiter;
     676            Tipe   : Gela.Semantic_Types.Type_Index;
     677            Kind   : Gela.Interpretations.Unknown_Auxiliary_Apply_Kinds;
     678            Down   : Gela.Interpretations.Interpretation_Index_Array)
     679         is
     680            pragma Unreferenced (Down, Kind);
     681            use type Gela.Types.Type_View_Access;
     682
     683            Type_View : constant Gela.Types.Type_View_Access := TM.Get (Tipe);
     684         begin
     685            if Type_View /= null and then Type_View.Is_Integer then
     686               Self.Result := Gela.Interpretations.Integer_Number;
     687            end if;
     688         end On_Expression;
     689
     690      end Visiters;
     691
     692      V : Visiters.Visiter := (Result => Gela.Interpretations.Real_Number);
     693   begin
     694      IM.Visit (Down, V);
     695      Result := V.Result;
     696   end Choose_Number_Declaration_Interpretation;
     697
    637698   ------------------------------
    638699   -- Create_Completion_Region --
  • trunk/ada-2012/src/semantic/gela-pass_utils.ads

    r531 r548  
    1212with Gela.Elements.Defining_Names;
    1313with Gela.Elements.Defining_Identifiers;
     14with Gela.Elements.Number_Declarations;
    1415with Gela.Elements.Use_Package_Clauses;
    1516with Gela.Lexical_Types;
     
    128129      Result : out Gela.Interpretations.Constraint_Kinds);
    129130
     131   procedure Choose_Number_Declaration_Interpretation
     132     (Comp   : Gela.Compilations.Compilation_Access;
     133      Node   : access Gela.Elements.Number_Declarations.
     134        Number_Declaration'Class;
     135      Result : out Gela.Interpretations.Number_Declaration_Kinds);
     136
    130137end Gela.Pass_Utils;
Note: See TracChangeset for help on using the changeset viewer.