1.1 --- a/micropython/inspect.py Thu Mar 20 01:13:48 2008 +0100
1.2 +++ b/micropython/inspect.py Fri Mar 21 02:14:30 2008 +0100
1.3 @@ -566,6 +566,13 @@
1.4 self.name = name
1.5 self.parent = parent
1.6 self.argnames = argnames
1.7 + self.positional_names = self.argnames[:]
1.8 + if has_dstar:
1.9 + self.dstar_name = self.positional_names[-1]
1.10 + del self.positional_names[-1]
1.11 + if has_star:
1.12 + self.star_name = self.positional_names[-1]
1.13 + del self.positional_names[-1]
1.14 self.has_star = has_star
1.15 self.has_dstar = has_dstar
1.16 self.node = node
1.17 @@ -916,6 +923,13 @@
1.18 raise InspectError(self.full_name(), node,
1.19 "Base class %r for %r is not found: it may be hidden in some way." % (base, cls.full_name()))
1.20
1.21 + # NOTE: Potentially dubious measure to permit __init__ availability.
1.22 + # If no bases exist, adopt the 'object' class.
1.23 +
1.24 + if not node.bases:
1.25 + expr = self.dispatch(compiler.ast.Name("object"))
1.26 + cls.add_base(expr.value)
1.27 +
1.28 # Make a back reference from the node for code generation.
1.29
1.30 node.unit = cls
1.31 @@ -924,6 +938,8 @@
1.32
1.33 self.store(node.name, cls)
1.34
1.35 + # Process the class body.
1.36 +
1.37 self.namespaces.append(cls)
1.38 self.dispatch(node.code)
1.39 self.namespaces.pop()
1.40 @@ -1074,7 +1090,11 @@
1.41
1.42 visitInvert = NOP
1.43
1.44 - visitKeyword = NOP
1.45 + def visitKeyword(self, node):
1.46 + self.dispatch(node.expr)
1.47 + const = Const(node.name)
1.48 + self.constant_values[node.name] = const
1.49 + return None
1.50
1.51 visitLambda = NOP
1.52
1.53 @@ -1200,7 +1220,10 @@
1.54 'frozenset', 'int', # 'list',
1.55 'long', 'object', 'set', 'slice', 'str',
1.56 'tuple', 'type', 'unicode', 'xrange']:
1.57 - self.store(key, Class(key, self, self))
1.58 +
1.59 + cls = Class(key, self, self)
1.60 + cls.set("__init__", Function("__init__", cls, [], 0, 0, cls))
1.61 + self.store(key, cls)
1.62
1.63 # NOTE: Temporary measure - provide detailed built-ins.
1.64