Skip to content

Commit

Permalink
Factorize float type definitions/constraints RangeSpec equation
Browse files Browse the repository at this point in the history
  • Loading branch information
thvnx committed Oct 18, 2023
1 parent 5fafc5f commit 1deda72
Showing 1 changed file with 13 additions and 39 deletions.
52 changes: 13 additions & 39 deletions ada/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -8199,15 +8199,7 @@ def xref_equation():
Entity.delta.sub_equation,
Entity.delta.matches_expected_type,

# Expressions from the range specification are expected to be of
# any real type, the types need not be the same.
Entity.range.then(
lambda r:
Entity.universal_real_bind(r.range.expected_type_var)
& r.range.sub_equation
& r.range.matches_expected_type,
default_val=LogicTrue()
)
If(Self.range.is_null, LogicTrue(), Entity.range.sub_equation)
)

@langkit_property(memoized=True)
Expand Down Expand Up @@ -8267,15 +8259,7 @@ def xref_equation():
Entity.digits.sub_equation,
Entity.digits.matches_expected_type,

# Expressions from the range specification are expected to be of
# any real type, the types need not be the same.
Entity.range.then(
lambda r:
Entity.universal_real_bind(r.range.expected_type_var)
& r.range.sub_equation
& r.range.matches_expected_type,
default_val=LogicTrue()
)
If(Self.range.is_null, LogicTrue(), Entity.range.sub_equation)
)

@langkit_property(memoized=True)
Expand Down Expand Up @@ -8394,16 +8378,7 @@ def xref_equation():
Entity.universal_int_bind(Entity.digits.expected_type_var),
Entity.digits.sub_equation,
Entity.digits.matches_expected_type,

# Expressions from the range specification are expected to be of
# any real type, the types need not be the same.
Entity.range.then(
lambda r:
Entity.universal_real_bind(r.range.expected_type_var)
& r.range.sub_equation
& r.range.matches_expected_type,
default_val=LogicTrue()
)
If(Self.range.is_null, LogicTrue(), Entity.range.sub_equation)
)


Expand All @@ -8425,16 +8400,7 @@ def xref_equation():
Entity.universal_real_bind(Entity.delta.expected_type_var),
Entity.delta.sub_equation,
Entity.delta.matches_expected_type,

# Expressions from the range specification are expected to be of
# any real type, the types need not be the same.
Entity.range.then(
lambda r:
Entity.universal_real_bind(r.range.expected_type_var)
& r.range.sub_equation
& r.range.matches_expected_type,
default_val=LogicTrue()
)
If(Self.range.is_null, LogicTrue(), Entity.range.sub_equation)
)


Expand Down Expand Up @@ -22521,14 +22487,22 @@ class RangeSpec(AdaNode):
range = Field(type=Expr)

xref_stop_resolution = Property(Self.parent.is_a(ComponentClause))
xref_equation = Property(Entity.range.xref_equation & If(
xref_equation = Property(Entity.range.xref_equation & Cond(
# Ada RM says that for component clauses and signed int type
# definitions, the expected type is any integer type.
Self.parent.is_a(ComponentClause, SignedIntTypeDef),

Self.universal_int_bind(Self.range.expected_type_var)
& Entity.range.matches_expected_type,

# In the following cases, expressions from the range specification are
# expected to be of any real type, the types need not be the same.
Self.parent.is_a(DeltaConstraint, DigitsConstraint,
OrdinaryFixedPointDef, DecimalFixedPointDef),

Self.universal_real_bind(Self.range.expected_type_var)
& Entity.range.matches_expected_type,

LogicTrue()
))

Expand Down

0 comments on commit 1deda72

Please sign in to comment.