# HG changeset patch # User paulb@localhost.localdomain # Date 1185748554 -7200 # Node ID aa1175e4af84b14502c799558fd332c38886c11b # Parent 1b5d0e034a6e14333e868a2fc5b3d6a5f0f4d207 Further attribute access fixes to avoid getattr and hasattr. diff -r 1b5d0e034a6e -r aa1175e4af84 simplify/fixinstances.py --- a/simplify/fixinstances.py Sun Jul 29 23:29:19 2007 +0200 +++ b/simplify/fixinstances.py Mon Jul 30 00:35:54 2007 +0200 @@ -83,7 +83,7 @@ # Internal subprograms are skipped here and processed specially via # Invoke nodes. - if not getattr(subprogram, "internal", 0): + if not subprogram.internal: for specialised in subprogram.active(): self.process_node(specialised) diff -r 1b5d0e034a6e -r aa1175e4af84 simplify/fixnames.py --- a/simplify/fixnames.py Sun Jul 29 23:29:19 2007 +0200 +++ b/simplify/fixnames.py Mon Jul 30 00:35:54 2007 +0200 @@ -127,7 +127,7 @@ # Internal subprograms are skipped here and processed specially via # Invoke nodes. - if not getattr(subprogram, "internal", 0): + if not subprogram.internal: self.subprograms.add(self.process_node(subprogram)) # Ultimately, we redefine the list of subprograms on the visitor. @@ -149,7 +149,7 @@ # Obtain a namespace either based on locals or on a structure. - structure = structure=getattr(node, "structure", None) + structure = node.structure # If passed some namespace, use that as the current namespace. @@ -167,29 +167,29 @@ # NOTE: subprogram within itself. Do not define the name of the function # NOTE: within a method definition. - if isinstance(node, Subprogram) and getattr(node, "name", None) is not None and not getattr(node, "is_method", 0): + if isinstance(node, Subprogram) and node.name is not None and not node.is_method: self.namespace.store(node.name) # Register the names of parameters in the namespace. - if hasattr(node, "params"): + if node.params: new_params = [] for param, default in node.params: new_params.append((param, self.dispatch(default))) self.namespace.store(param) node.params = new_params - if getattr(node, "star", None): + if node.star: param, default = node.star self.namespace.store(param) node.star = param, self.dispatch(default) - if getattr(node, "dstar", None): + if node.dstar: param, default = node.dstar self.namespace.store(param) node.dstar = param, self.dispatch(default) # Add namespace details to any structure involved. - if hasattr(node, "structure") and node.structure is not None: + if node.structure is not None: # Initialise bases where appropriate. diff -r 1b5d0e034a6e -r aa1175e4af84 simplify/simplified/program.py --- a/simplify/simplified/program.py Sun Jul 29 23:29:19 2007 +0200 +++ b/simplify/simplified/program.py Mon Jul 30 00:35:54 2007 +0200 @@ -452,6 +452,9 @@ def __init__(self, *args, **kw): Node.__init__(self, *args, **kw) self.structure = None + self.params = [] + self.star = None + self.dstar = None def full_name(self): return "module %s" % self.name