1.1 --- a/simplify.py Sun Jan 07 23:44:39 2007 +0100
1.2 +++ b/simplify.py Mon Jan 08 23:37:53 2007 +0100
1.3 @@ -73,6 +73,7 @@
1.4 self.constants = {} # Constants.
1.5 self.current_subprograms = [] # Current subprograms being processed.
1.6 self.current_structures = [] # Current structures being processed.
1.7 + self.within_class = 0 # Whether a class is being defined.
1.8 self.builtins = builtins # Whether the builtins are being processed.
1.9
1.10 # Convenience attributes.
1.11 @@ -434,6 +435,8 @@
1.12
1.13 structure = Class(name=class_.name, module=self.module, bases=self.dispatches(bases))
1.14 self.structures.append(structure)
1.15 + within_class = self.within_class
1.16 + self.within_class = 1
1.17
1.18 # Make a subprogram which initialises the class structure.
1.19
1.20 @@ -445,6 +448,7 @@
1.21
1.22 subprogram.code = self.dispatch(class_.code) + [ReturnFromBlock()]
1.23
1.24 + self.within_class = within_class
1.25 self.current_structures.pop()
1.26 self.current_subprograms.pop()
1.27 self.subprograms.append(subprogram); self.subnames[subprogram.full_name()] = subprogram
1.28 @@ -803,10 +807,15 @@
1.29 """
1.30
1.31 subprogram = Subprogram(name=function.name, module=self.module, structures=self.current_structures[:],
1.32 - internal=0, returns_value=1, star=None, dstar=None)
1.33 + internal=0, returns_value=1, star=None, dstar=None, is_method=self.within_class)
1.34
1.35 self.current_subprograms.append(subprogram)
1.36 + within_class = self.within_class
1.37 + self.within_class = 0
1.38 +
1.39 subprogram.code = self.dispatch(function.code) + [ReturnFromFunction()]
1.40 +
1.41 + self.within_class = within_class
1.42 self.current_subprograms.pop()
1.43 self._visitFunction(function, subprogram)
1.44