1.1 --- a/rsvplib.py Fri Jun 03 01:30:35 2011 +0200
1.2 +++ b/rsvplib.py Fri Jun 03 01:31:27 2011 +0200
1.3 @@ -376,14 +376,33 @@
1.4
1.5 self.machine.save(obj_value.ref + self.instance_data_offset, DataValue(None, new_fragment))
1.6
1.7 + def builtins_tuple_new(self):
1.8 + frame = self.local_sp_stack[-1]
1.9 +
1.10 + # Get the sequence address.
1.11 + # The first argument should be empty.
1.12 +
1.13 + obj_value = self.frame_stack[frame + 1]
1.14 + return self._builtins_tuple(obj_value)
1.15 +
1.16 def builtins_tuple(self):
1.17 frame = self.local_sp_stack[-1]
1.18
1.19 - # Get the list address.
1.20 + # Get the sequence address.
1.21
1.22 obj_value = self.frame_stack[frame]
1.23 + return self._builtins_tuple(obj_value)
1.24
1.25 - if not self.machine._CheckInstance(obj_value.ref, self.list_class):
1.26 + def _builtins_tuple(self, obj_value):
1.27 +
1.28 + if self.machine._CheckInstance(obj_value.ref, self.tuple_class):
1.29 + self.machine.result = obj_value
1.30 + return
1.31 +
1.32 + # Reject non-list, non-tuple types.
1.33 + # NOTE: This should probably accept any sequence.
1.34 +
1.35 + elif not self.machine._CheckInstance(obj_value.ref, self.list_class):
1.36 self.machine.exception = self.machine._MakeObject(self.instance_size, self.type_error_instance)
1.37 return self.machine.RaiseException()
1.38
1.39 @@ -529,6 +548,13 @@
1.40
1.41 # Native method implementations:
1.42
1.43 + "__builtins__.basestring.__lt__" : builtins_str_lt,
1.44 + "__builtins__.basestring.__le__" : builtins_str_le,
1.45 + "__builtins__.basestring.__gt__" : builtins_str_gt,
1.46 + "__builtins__.basestring.__ge__" : builtins_str_ge,
1.47 + "__builtins__.basestring.__eq__" : builtins_str_eq,
1.48 + "__builtins__.basestring.__ne__" : builtins_str_ne,
1.49 + "__builtins__.bool.__bool__" : builtins_bool_bool,
1.50 "__builtins__.int.__add__" : builtins_int_add,
1.51 "__builtins__.int.__radd__" : builtins_int_add, # NOTE: To be made distinct.
1.52 "__builtins__.int.__sub__" : builtins_int_sub,
1.53 @@ -546,18 +572,12 @@
1.54 "__builtins__.int.__rand__" : builtins_int_and,
1.55 "__builtins__.int.__or__" : builtins_int_or,
1.56 "__builtins__.int.__ror__" : builtins_int_or,
1.57 - "__builtins__.bool.__bool__" : builtins_bool_bool,
1.58 "__builtins__.list.__get_single_item__" : builtins_list_get_single_item,
1.59 "__builtins__.list.__len__" : builtins_list_len,
1.60 "__builtins__.list.append" : builtins_list_append,
1.61 + "__builtins__.tuple" : builtins_tuple_new,
1.62 "__builtins__.tuple.__len__" : builtins_tuple_len,
1.63 "__builtins__.tuple.__get_single_item__" : builtins_tuple_get_single_item,
1.64 - "__builtins__.basestring.__lt__" : builtins_str_lt,
1.65 - "__builtins__.basestring.__le__" : builtins_str_le,
1.66 - "__builtins__.basestring.__gt__" : builtins_str_gt,
1.67 - "__builtins__.basestring.__ge__" : builtins_str_ge,
1.68 - "__builtins__.basestring.__eq__" : builtins_str_eq,
1.69 - "__builtins__.basestring.__ne__" : builtins_str_ne,
1.70
1.71 # Native initialisers:
1.72