1.1 --- a/lib/builtins.py Sun Feb 20 19:31:50 2011 +0100
1.2 +++ b/lib/builtins.py Fri Feb 25 01:45:02 2011 +0100
1.3 @@ -618,14 +618,16 @@
1.4
1.5 function
1.6 AttributeError
1.7 +#IndexError
1.8 +NoneType
1.9 +NotImplementedType
1.10 #StopIteration
1.11 TypeError
1.12 -#IndexError
1.13
1.14 +#bool
1.15 +#ellipsis
1.16 #list
1.17 tuple
1.18 #xrange
1.19 -#ellipsis
1.20 -#bool
1.21
1.22 # vim: tabstop=4 expandtab shiftwidth=4
2.1 --- a/micropython/data.py Sun Feb 20 19:31:50 2011 +0100
2.2 +++ b/micropython/data.py Fri Feb 25 01:45:02 2011 +0100
2.3 @@ -1108,7 +1108,10 @@
2.4 return hash(self.value)
2.5
2.6 def value_type_name(self):
2.7 - return "__builtins__." + self.value.__class__.__name__
2.8 + return ".".join(self.value_type_name_parts())
2.9 +
2.10 + def value_type_name_parts(self):
2.11 + return "__builtins__", self.value.__class__.__name__
2.12
2.13 class Class(NamespaceDict, Naming, Constant):
2.14
3.1 --- a/micropython/rsvp.py Sun Feb 20 19:31:50 2011 +0100
3.2 +++ b/micropython/rsvp.py Fri Feb 25 01:45:02 2011 +0100
3.3 @@ -158,6 +158,10 @@
3.4 item = self.item
3.5 classcode = objtable.as_list().get_code(item.value_type_name())
3.6 attrcode = objtable.get_index(item.value_type_name())
3.7 + name_parts = item.value_type_name_parts()
3.8 + attr = objtable.access(*name_parts)
3.9 + cls = attr.get_value()
3.10 +
3.11 return [
3.12 DataObject(
3.13 classcode,
3.14 @@ -171,7 +175,7 @@
3.15
3.16 DataValue(
3.17 PlaceholderContext,
3.18 - item.location
3.19 + cls.location
3.20 )
3.21
3.22 # NOTE: The RSVP library needs changing if more attributes are added
3.23 @@ -202,23 +206,27 @@
3.24 if not self.is_generated(with_builtins):
3.25 item.code_location = item.full_name()
3.26
3.27 - # Skip any defaults for static functions.
3.28 + # Skip __class__ plus any defaults for static functions.
3.29
3.30 elif not item.is_dynamic():
3.31 - item.code_location = location + len(item.defaults)
3.32 + item.code_location = location + 1 + len(item.defaults)
3.33
3.34 - # Skip any defaults for dynamic functions.
3.35 + # Skip __class__ plus any defaults for dynamic functions.
3.36
3.37 else:
3.38 - item.code_location = location
3.39 + item.code_location = location + 1
3.40
3.41 - return location
3.42 + # Include the __class__ attribute.
3.43 +
3.44 + return location + 1
3.45
3.46 def finalise_location(self, with_builtins):
3.47 self._finalise_location(with_builtins)
3.48
3.49 def as_raw(self, objtable, paramtable, with_builtins):
3.50 item = self.item
3.51 + attr = objtable.access("__builtins__", "function")
3.52 + cls = attr.get_value()
3.53 # NOTE: Need class and parameter details! Should arguably be an instance of types.FunctionType.
3.54 return [
3.55 DataObject(
3.56 @@ -228,6 +236,13 @@
3.57 "__builtins__.function",
3.58 len(item.defaults) + 1, # size (not accurate for lambda functions before instantiation)
3.59 paramtable.as_list().get_code(item.full_name()) # funccode
3.60 + ),
3.61 +
3.62 + # The __class__ attribute for functions.
3.63 +
3.64 + DataValue(
3.65 + PlaceholderContext,
3.66 + cls.location
3.67 )
3.68 ]
3.69
4.1 --- a/micropython/trans.py Sun Feb 20 19:31:50 2011 +0100
4.2 +++ b/micropython/trans.py Fri Feb 25 01:45:02 2011 +0100
4.3 @@ -49,7 +49,7 @@
4.4
4.5 "Make an exception of the given 'name' using 'node'."
4.6
4.7 - # NOTE: Reserving only one attribute.
4.8 + # NOTE: Reserving an attribute plus __class__.
4.9
4.10 self.make_instance(self.get_builtin_class(name, node), 1)
4.11
4.12 @@ -1414,7 +1414,7 @@
4.13 self.make_instance(self.get_builtin_class("list", node), 2)
4.14 list_temp = self.get_temp()
4.15 self.new_op(list_temp)
4.16 - self.new_op(StoreAttr(Attr(0, None, None)))
4.17 + self.new_op(StoreAttr(Attr(1, None, None)))
4.18 self.set_source()
4.19 self.discard_value()
4.20
5.1 --- a/rsvp.py Sun Feb 20 19:31:50 2011 +0100
5.2 +++ b/rsvp.py Fri Feb 25 01:45:02 2011 +0100
5.3 @@ -174,8 +174,8 @@
5.4 print "Result", self.result
5.5 print "Exception", self.exception
5.6
5.7 - def show(self):
5.8 - self.show_memory(self.memory, self.coverage, 0)
5.9 + def show(self, start=None, end=None):
5.10 + self.show_memory(self.memory[start:end], self.coverage[start:end], start or 0)
5.11
5.12 def show_pc(self, run_in=10):
5.13 start = max(0, self.pc - run_in)
5.14 @@ -204,6 +204,15 @@
5.15 def set_break(self, location):
5.16 self.breakpoints.add(location)
5.17
5.18 + def up(self):
5.19 + retaddr = self.pc_stack[-1]
5.20 + new_breakpoint = retaddr not in self.breakpoints
5.21 + if new_breakpoint:
5.22 + self.set_break(retaddr)
5.23 + self.run()
5.24 + if new_breakpoint:
5.25 + self.breakpoints.remove(retaddr)
5.26 +
5.27 # Internal operations.
5.28
5.29 def load(self, address):
5.30 @@ -271,7 +280,7 @@
5.31 print "Execution terminated",
5.32 if self.exception is not None:
5.33 ref = self.exception
5.34 - addr = self.load(ref + 1)
5.35 + addr = self.load(ref + Library.instance_data_offset)
5.36 print "with exception:", self.load(ref)
5.37 print "At address %d: %r" % (addr, self.load(addr))
5.38 elif breakpoint:
5.39 @@ -497,7 +506,7 @@
5.40 self.value = self.load(value.ref + offset)
5.41 return
5.42
5.43 - self.exception = self._MakeObject(2, self.attr_error_instance)
5.44 + self.exception = self._MakeObject(Library.instance_size, self.attr_error_instance)
5.45 return self.RaiseException()
5.46
5.47 # LoadAttrIndexContext not defined.
5.48 @@ -520,7 +529,7 @@
5.49 self.value = self.load(inst_value.ref + offset)
5.50 return
5.51
5.52 - self.exception = self._MakeObject(2, self.attr_error_instance)
5.53 + self.exception = self._MakeObject(Library.instance_size, self.attr_error_instance)
5.54 return self.RaiseException()
5.55
5.56 def StoreAttrIndex(self):
5.57 @@ -532,13 +541,13 @@
5.58 attr_index, static_attr, offset = element
5.59 if attr_index == self.operand:
5.60 if static_attr:
5.61 - self.exception = self._MakeObject(2, self.type_error_instance)
5.62 + self.exception = self._MakeObject(Library.instance_size, self.type_error_instance)
5.63 return self.RaiseException()
5.64 else:
5.65 self.save(value.ref + offset, self.source)
5.66 return
5.67
5.68 - self.exception = self._MakeObject(2, self.attr_error_instance)
5.69 + self.exception = self._MakeObject(Library.instance_size, self.attr_error_instance)
5.70 return self.RaiseException()
5.71
5.72 # NOTE: LoadAttrIndexContext is a possibility if a particular attribute can always be overridden.
5.73 @@ -569,7 +578,7 @@
5.74 self.frame_stack[frame + offset] = self.source
5.75 return
5.76
5.77 - self.exception = self._MakeObject(2, self.type_error_instance)
5.78 + self.exception = self._MakeObject(Library.instance_size, self.type_error_instance)
5.79 return self.RaiseException()
5.80
5.81 def LoadCallable(self):
5.82 @@ -618,7 +627,7 @@
5.83
5.84 if not ((nargs - ndefaults) <= nlocals):
5.85 raise Exception, "CheckFrame %r (%r <= %r <= %r)" % (self.operand, nargs - ndefaults, nlocals, nargs)
5.86 - self.exception = self._MakeObject(2, self.type_error_instance)
5.87 + self.exception = self._MakeObject(Library.instance_size, self.type_error_instance)
5.88 return self.RaiseException()
5.89
5.90 def CheckExtra(self):
5.91 @@ -742,8 +751,8 @@
5.92 self.exception = None
5.93
5.94 def RaiseException(self):
5.95 - # NOTE: Adding the program counter as the first attribute.
5.96 - self.save(self.exception + 1, self.pc)
5.97 + # NOTE: Adding the program counter as the first attribute after __class__.
5.98 + self.save(self.exception + 2, self.pc)
5.99 # Jumping to the current handler.
5.100 if self.abort_upon_exception:
5.101 raise Exception
6.1 --- a/rsvplib.py Sun Feb 20 19:31:50 2011 +0100
6.2 +++ b/rsvplib.py Fri Feb 25 01:45:02 2011 +0100
6.3 @@ -300,7 +300,7 @@
6.4
6.5 # Get the item itself.
6.6
6.7 - self.machine.result = self.machine.load(fragment.ref + self.instance_data_offset + item_pos)
6.8 + self.machine.result = self.machine.load(fragment.ref + 1 + item_pos)
6.9
6.10 def builtins_list_len(self):
6.11 frame = self.local_sp_stack[-1]