1.1 --- a/translator.py Sun Feb 19 22:24:36 2017 +0100
1.2 +++ b/translator.py Mon Feb 20 00:35:33 2017 +0100
1.3 @@ -91,8 +91,8 @@
1.4
1.5 "A reference to a name in the translation."
1.6
1.7 - def __init__(self, name, ref, expr=None, parameter=None, location=None):
1.8 - results.ResolvedNameRef.__init__(self, name, ref, expr)
1.9 + def __init__(self, name, ref, expr=None, is_global=False, parameter=None, location=None):
1.10 + results.ResolvedNameRef.__init__(self, name, ref, expr, is_global)
1.11 self.parameter = parameter
1.12 self.location = location
1.13
1.14 @@ -730,7 +730,7 @@
1.15 # the complete access.
1.16
1.17 name_ref = attr_expr and attr_expr.is_name() and attr_expr
1.18 - name = name_ref and self.get_name_for_tracking(name_ref.name, name_ref and name_ref.reference()) or None
1.19 + name = name_ref and self.get_name_for_tracking(name_ref.name, name_ref) or None
1.20
1.21 location = self.get_access_location(name, self.attrs)
1.22 refs = self.get_referenced_attributes(location)
1.23 @@ -1549,8 +1549,23 @@
1.24 # Determine any assigned globals.
1.25
1.26 globals = self.importer.get_module(self.name).scope_globals.get(path)
1.27 +
1.28 + # Explicitly declared globals.
1.29 +
1.30 if globals and n.name in globals:
1.31 objpath = self.get_global_path(n.name)
1.32 + is_global = True
1.33 +
1.34 + # Implicitly referenced globals in functions.
1.35 +
1.36 + elif self.in_function:
1.37 + is_global = n.name not in self.importer.function_locals[path]
1.38 +
1.39 + # Implicitly referenced globals elsewhere.
1.40 +
1.41 + else:
1.42 + namespace = self.importer.identify(path)
1.43 + is_global = not self.importer.get_attributes(namespace, n.name)
1.44
1.45 # Get the static identity of the name.
1.46
1.47 @@ -1579,7 +1594,7 @@
1.48 # static namespace members. The reference should be configured to return
1.49 # such names.
1.50
1.51 - return TrResolvedNameRef(n.name, ref, expr=expr, parameter=parameter, location=location)
1.52 + return TrResolvedNameRef(n.name, ref, expr=expr, is_global=is_global, parameter=parameter, location=location)
1.53
1.54 def process_not_node(self, n):
1.55