1.1 --- a/micropython/ast.py Sat May 10 02:32:20 2008 +0200
1.2 +++ b/micropython/ast.py Sun May 11 18:20:27 2008 +0200
1.3 @@ -19,17 +19,11 @@
1.4 this program. If not, see <http://www.gnu.org/licenses/>.
1.5 """
1.6
1.7 -import micropython.inspect
1.8 +from micropython.common import *
1.9 +from micropython.data import *
1.10 from micropython.rsvp import *
1.11 -from micropython.common import *
1.12 import compiler.ast
1.13 from compiler.visitor import ASTVisitor
1.14 -try:
1.15 - set
1.16 -except NameError:
1.17 - from sets import Set as set
1.18 -
1.19 -class TranslateError(NodeProcessingError): pass
1.20
1.21 class Label:
1.22
1.23 @@ -264,12 +258,12 @@
1.24
1.25 # Get the details of the access.
1.26
1.27 - if isinstance(last.attr, micropython.inspect.Const):
1.28 + if isinstance(last.attr, Const):
1.29 target_name = last.attr.value_type_name()
1.30 else:
1.31 target = last.attr.value
1.32
1.33 - if isinstance(target, micropython.inspect.Const):
1.34 + if isinstance(target, Const):
1.35 target_name = target.value_type_name()
1.36 else:
1.37 target_name = target.full_name()
1.38 @@ -527,11 +521,11 @@
1.39
1.40 if scope == "local":
1.41 unit = self.unit
1.42 - if isinstance(unit, micropython.inspect.Function):
1.43 + if isinstance(unit, Function):
1.44 self.new_op(NameInstruction(unit.all_locals()[name]))
1.45 - elif isinstance(unit, micropython.inspect.Class):
1.46 + elif isinstance(unit, Class):
1.47 self.new_op(AddressInstruction(unit.all_class_attributes()[name]))
1.48 - elif isinstance(unit, micropython.inspect.Module):
1.49 + elif isinstance(unit, Module):
1.50 self.new_op(AddressInstruction(unit.module_attributes()[name]))
1.51 else:
1.52 raise TranslateError(self.module.full_name(), node, "Program unit %r has no local %r." % (unit, name))
1.53 @@ -575,14 +569,14 @@
1.54 def _have_constant_input(self, n):
1.55 last = self.last_ops(n+1)
1.56 return len(last) > n and (isinstance(last[n], LoadAddress) and last[n].attr.assignments == 1 or
1.57 - isinstance(last[n], LoadConst)) # and not isinstance(last[n].attr, micropython.inspect.Instance)
1.58 + isinstance(last[n], LoadConst)) # and not isinstance(last[n].attr, Instance)
1.59
1.60 def _have_known_target(self):
1.61 return self._have_constant_input(0)
1.62
1.63 def _have_self_input(self):
1.64 last = self.last_op()
1.65 - return isinstance(self.unit, micropython.inspect.Function) and \
1.66 + return isinstance(self.unit, Function) and \
1.67 self.unit.is_method() and isinstance(last, LoadName) and \
1.68 last.attr.name == "self"
1.69
1.70 @@ -669,9 +663,9 @@
1.71
1.72 # Handle calls to classes.
1.73
1.74 - if isinstance(target, micropython.inspect.Class):
1.75 + if isinstance(target, Class):
1.76 target = target.get_instantiator()
1.77 - context = micropython.inspect.Instance()
1.78 + context = Instance()
1.79
1.80 # A special context is chosen to avoid generating unnecessary
1.81 # context loading and checking instructions.