text stringlengths 0 234 |
|---|
Arguments => F.New_Name (+"Self")); |
----------------- |
-- Prop_Getter -- |
----------------- |
function Prop_Getter |
(F : aliased in out Ada_Pretty.Factory; |
Prop : Classes.Property) return Ada_Pretty.Node_Access |
is |
Pragmas : Ada_Pretty.Node_Access; |
Return_Expr : Ada_Pretty.Node_Access; |
Token : League.Strings.Universal_String; |
begin |
if Is_Node and then Prop.Name.Starts_With ("Has_") then |
if Prop.Name.Starts_With ("Has_Not_Null") then |
Token := Prop.Name.Tail_From (9); -- Null or Null_2 |
else |
Token := Prop.Name.Tail_From (5); |
end if; |
Return_Expr := F.New_Selected_Name |
("Self." & Token & "_Token.Assigned"); |
elsif Is_Text (Prop.Type_Name) then |
if Is_Node then |
Return_Expr := F.New_Selected_Name |
("Self." & Only_Tokens (Item.Properties) (1).Name & ".Image"); |
else |
Return_Expr := F.New_Name (+""""""); |
Pragmas := Unreferenced; |
end if; |
else |
Return_Expr := F.New_Selected_Name ("Self." & Prop.Name); |
end if; |
return F.New_Subprogram_Body |
(Specification => F.New_Subprogram_Specification |
(Is_Overriding => Ada_Pretty.True, |
Name => F.New_Name (Prop.Name), |
Parameters => F.New_Parameter |
(Name => F.New_Name (+"Self"), |
Type_Definition => Type_Name), |
Result => Property_Type (F, Prop)), |
Declarations => Pragmas, |
Statements => F.New_Return (Return_Expr)); |
end Prop_Getter; |
Set_Enclosing_Element : constant Ada_Pretty.Node_Access := |
F.New_Name (+"Set_Enclosing_Element"); |
------------------------ |
-- Prop_Set_Enclosing -- |
------------------------ |
function Prop_Set_Enclosing |
(F : aliased in out Ada_Pretty.Factory; |
Prop : Classes.Property) return Ada_Pretty.Node_Access |
is |
Result : Ada_Pretty.Node_Access; |
Attr : constant Ada_Pretty.Node_Access := |
F.New_Argument_Association |
(Value => F.New_Name (+"Self." & Prop.Name)); |
Self : constant Ada_Pretty.Node_Access := |
F.New_Argument_Association |
(Value => F.New_Name (+"Self'Unchecked_Access")); |
Item : constant Ada_Pretty.Node_Access := |
F.New_Argument_Association |
(Value => F.New_Selected_Name (+"Item.Element")); |
begin |
case Prop.Capacity is |
when Meta.Classes.Just_One => |
Result := F.New_Statement |
(F.New_Apply |
(Set_Enclosing_Element, F.New_List (Attr, Self))); |
when Meta.Classes.Zero_Or_One => |
Result := F.New_If |
(Condition => F.New_Selected_Name |
(Prefix => Attr, |
Selector => F.New_Name (+"Assigned")), |
Then_Path => F.New_Statement |
(F.New_Apply |
(Set_Enclosing_Element, F.New_List (Attr, Self)))); |
when others => |
Result := F.New_For |
(Name => F.New_Name (+"Item"), |
Iterator => F.New_Selected_Name |
(Prefix => Attr, |
Selector => F.New_Name (+"Each_Element")), |
Statements => F.New_Statement |
(F.New_Apply |
(Set_Enclosing_Element, |
F.New_List (Item, Self)))); |
end case; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.