@@ -660,9 +660,11 @@ def __init__(self,
660
660
List of path for file names to include in the generated library.
661
661
"""
662
662
663
- self .logic_converter_props : Set [PropertyDef ] = set ()
663
+ self .logic_functor_props : Set [Tuple [ PropertyDef , int ] ] = set ()
664
664
"""
665
- Set of properties used as converters in logic equations.
665
+ Set of properties (and the corresponding arity for entity args) used as
666
+ converters/combiners in logic equations. We generate functors for them,
667
+ so that equations can refer to them.
666
668
"""
667
669
668
670
self .default_unit_provider = default_unit_provider
@@ -968,9 +970,10 @@ def add_with_clause(self, from_pkg, source_kind, to_pkg, use_clause=False,
968
970
(to_pkg , use_clause , is_private ))
969
971
970
972
@property
971
- def sorted_logic_converters (self ):
972
- return sorted (self .logic_converter_props ,
973
- key = lambda x : x .name .camel )
973
+ def sorted_logic_functors (self ) -> List [Tuple [PropertyDef , int ]]:
974
+ return sorted (
975
+ self .logic_functor_props , key = lambda x : x [0 ].name .camel
976
+ )
974
977
975
978
def sorted_types (self , type_set ):
976
979
"""
@@ -995,17 +998,21 @@ def sorted_exception_types(self) -> List[GeneratedException]:
995
998
return sorted (self .exception_types .values (),
996
999
key = lambda e : e .doc_entity )
997
1000
998
- def do_generate_logic_functors (self , convert_property = None ):
1001
+ def do_generate_logic_functors (self ,
1002
+ prop : Optional [PropertyDef ],
1003
+ arity : int ) -> None :
999
1004
"""
1000
- Generate a logic binder with the given conversion property.
1005
+ Generate a logic binder with the given convert/combine property.
1001
1006
1002
1007
If you call this function several times for the same property, only one
1003
- binder will be generaed .
1008
+ binder will be generated .
1004
1009
1005
- :param PropertyDef convert_property: The conversion property.
1010
+ :param prop: The convert/combine property.
1011
+ :param arity: Number of entity arguments this property takes ("Self"
1012
+ included).
1006
1013
"""
1007
- if convert_property :
1008
- self .logic_converter_props .add (convert_property )
1014
+ if prop :
1015
+ self .logic_functor_props .add (( prop , arity ) )
1009
1016
1010
1017
@staticmethod
1011
1018
def grammar_rule_api_name (rule ):
0 commit comments