Lichen

Change of inspector.py

794:7dd8e4815848
inspector.py
     1.1 --- a/inspector.py	Fri Mar 31 18:42:27 2017 +0200
     1.2 +++ b/inspector.py	Fri Mar 31 23:26:47 2017 +0200
     1.3 @@ -27,7 +27,8 @@
     1.4  from referencing import Reference
     1.5  from resolving import NameResolving
     1.6  from results import AccessRef, InstanceRef, InvocationRef, LiteralSequenceRef, \
     1.7 -                    LocalNameRef, NameRef, ResolvedNameRef, VariableRef
     1.8 +                    LocalNameRef, MultipleRef, NameRef, ResolvedNameRef, \
     1.9 +                    Result, VariableRef
    1.10  import compiler
    1.11  import sys
    1.12  
    1.13 @@ -800,7 +801,7 @@
    1.14  
    1.15          "Process the given operator node 'n'."
    1.16  
    1.17 -        self.process_operator_chain(n.nodes, self.process_structure_node)
    1.18 +        return self.process_operator_chain(n.nodes)
    1.19  
    1.20      def process_name_node(self, n):
    1.21  
    1.22 @@ -915,20 +916,24 @@
    1.23                                                self.in_invocation)
    1.24          return None
    1.25  
    1.26 -    def process_operator_chain(self, nodes, fn):
    1.27 +    def process_operator_chain(self, nodes):
    1.28  
    1.29          """
    1.30 -        Process the given chain of 'nodes', applying 'fn' to each node or item.
    1.31 +        Process the given chain of 'nodes', processing each node or item.
    1.32          Each node starts a new conditional region, effectively making a deeply-
    1.33          nested collection of if-like statements.
    1.34          """
    1.35  
    1.36 +        results = []
    1.37 +
    1.38          tracker = self.trackers[-1]
    1.39  
    1.40          for item in nodes:
    1.41              tracker.new_branchpoint()
    1.42              tracker.new_branch()
    1.43 -            fn(item)
    1.44 +            result = self.process_structure_node(item)
    1.45 +            if result:
    1.46 +                results.append(result)
    1.47  
    1.48          for item in nodes[:-1]:
    1.49              tracker.shelve_branch()
    1.50 @@ -939,6 +944,8 @@
    1.51          tracker.shelve_branch()
    1.52          tracker.merge_branches()
    1.53  
    1.54 +        return MultipleRef(results)
    1.55 +
    1.56      def process_try_node(self, n):
    1.57  
    1.58          """
    1.59 @@ -1322,22 +1329,8 @@
    1.60  
    1.61          "Return a suitable initialiser reference for 'value'."
    1.62  
    1.63 -        # Includes LiteralSequenceRef, ResolvedNameRef...
    1.64 -
    1.65 -        if isinstance(value, (NameRef, AccessRef, InstanceRef)):
    1.66 +        if isinstance(value, Result):
    1.67              return value.reference()
    1.68 -
    1.69 -        # In general, invocations do not produce known results. However, the
    1.70 -        # name initialisers are resolved once a module has been inspected.
    1.71 -
    1.72 -        elif isinstance(value, InvocationRef):
    1.73 -            return value.reference()
    1.74 -
    1.75 -        # Variable references are unknown results.
    1.76 -
    1.77 -        elif isinstance(value, VariableRef):
    1.78 -            return value.reference()
    1.79 -
    1.80          else:
    1.81              return value
    1.82