Lichen

Changeset

830:fc7f612df68d
2018-06-24 Paul Boddie raw files shortlog changelog graph Made use of available reference information in order to determine the nature of invocations and to avoid generic __invoke calls.
translator.py (file)
     1.1 --- a/translator.py	Sun Jun 24 00:57:47 2018 +0200
     1.2 +++ b/translator.py	Sun Jun 24 18:43:39 2018 +0200
     1.3 @@ -1141,18 +1141,22 @@
     1.4                  attrnames = location.attrnames
     1.5                  attrname = attrnames and attrnames.rsplit(".", 1)[-1]
     1.6  
     1.7 -                # Determine any common aspects of any attribute.
     1.8 -
     1.9 -                if attrname:
    1.10 +                # Determine common aspects of any identifiable targets.
    1.11 +
    1.12 +                if attrname or refs:
    1.13                      all_params = set()
    1.14                      all_defaults = set()
    1.15                      min_params = set()
    1.16                      max_params = set()
    1.17 -                    refs = set()
    1.18 +
    1.19 +                    # Employ references from the expression or find all
    1.20 +                    # possible attributes for the given attribute name.
    1.21 +
    1.22 +                    refs = refs or self.get_attributes_for_attrname(attrname)
    1.23  
    1.24                      # Obtain parameters and defaults for each possible target.
    1.25  
    1.26 -                    for ref in self.get_attributes_for_attrname(attrname):
    1.27 +                    for ref in refs:
    1.28                          origin = ref.get_origin()
    1.29                          params = self.importer.function_parameters.get(origin)
    1.30  
    1.31 @@ -1164,7 +1168,6 @@
    1.32                              all_params.add(tuple(params))
    1.33                              min_params.add(len(params) - (defaults and len(defaults) or 0))
    1.34                              max_params.add(len(params))
    1.35 -                            refs.add(ref)
    1.36                          else:
    1.37                              refs = set()
    1.38                              break