1.1 --- a/micropython/ast.py Tue Nov 06 00:16:26 2012 +0100
1.2 +++ b/micropython/ast.py Mon Nov 12 23:55:42 2012 +0100
1.3 @@ -77,6 +77,9 @@
1.4 def __repr__(self):
1.5 return "Translation(%r)" % self.module
1.6
1.7 + def get_unit(self):
1.8 + return self.unit
1.9 +
1.10 def get_module_code(self):
1.11
1.12 """
2.1 --- a/micropython/common.py Tue Nov 06 00:16:26 2012 +0100
2.2 +++ b/micropython/common.py Mon Nov 12 23:55:42 2012 +0100
2.3 @@ -53,13 +53,7 @@
2.4 except NodeProcessingError, exc:
2.5 if exc.astnode is None:
2.6 exc.astnode = node
2.7 -
2.8 - # NOTE: Should perhaps specialise the subclasses appropriately.
2.9 -
2.10 - if isinstance(self, (compiler.ast.Class, compiler.ast.Function, compiler.ast.Module)):
2.11 - exc.unit_name = self.unit.full_name()
2.12 - else:
2.13 - exc.unit_name = self.full_name()
2.14 + exc.unit_name = self.get_unit().full_name()
2.15 raise
2.16
2.17 def possible_accessor_types(self, node, defining_users=1):
2.18 @@ -210,9 +204,9 @@
2.19
2.20 # Access and slicing.
2.21
2.22 - "AssSlice" : "setslice",
2.23 + "AssSlice" : "setslice", # Python 2.7
2.24 "Slice" : "getslice",
2.25 - "AssSubscript" : "setitem",
2.26 + "AssSubscript" : "setitem", # Python 2.7
2.27 "Subscript" : "getitem",
2.28 }
2.29
3.1 --- a/micropython/inspect.py Tue Nov 06 00:16:26 2012 +0100
3.2 +++ b/micropython/inspect.py Mon Nov 12 23:55:42 2012 +0100
3.3 @@ -488,6 +488,8 @@
3.4
3.5 return (self.namespaces[-1:] or [self])[0]
3.6
3.7 + get_unit = get_namespace # compatibility method for error handling
3.8 +
3.9 def use_name(self, name, node=None, value=None, ns=None):
3.10
3.11 """
4.1 --- a/micropython/report.py Tue Nov 06 00:16:26 2012 +0100
4.2 +++ b/micropython/report.py Mon Nov 12 23:55:42 2012 +0100
4.3 @@ -635,6 +635,9 @@
4.4 self.program.unknown_target_nodes = []
4.5 self.units = []
4.6
4.7 + def get_unit(self):
4.8 + return self.units[-1]
4.9 +
4.10 def to_stream(self, stream):
4.11
4.12 "Write the annotated code to the given 'stream'."