1.1 --- a/rsvp.py Thu Apr 23 00:52:33 2009 +0200
1.2 +++ b/rsvp.py Sun Apr 26 03:24:12 2009 +0200
1.3 @@ -129,6 +129,8 @@
1.4 cls = objlist.access("__builtins__", "int")
1.5 self.int_class_location = cls and cls.get_value() and cls.get_value().location
1.6 self.int_instance_location = cls and cls.get_value() and cls.get_value().instance_template_location
1.7 + cls = objlist.access("__builtins__", "list")
1.8 + self.list_instance_location = cls and cls.get_value() and cls.get_value().instance_template_location
1.9
1.10 # Debugging attributes.
1.11
1.12 @@ -338,7 +340,10 @@
1.13 self.frame_stack[frame + self.operand] = self.source
1.14
1.15 LoadTemp = LoadName
1.16 - StoreTemp = StoreName
1.17 +
1.18 + def StoreTemp(self):
1.19 + frame = self.local_sp_stack[-1]
1.20 + self.frame_stack[frame + self.operand] = self.value
1.21
1.22 def LoadAddress(self):
1.23 # Preserve context (potentially null).
1.24 @@ -616,10 +621,11 @@
1.25 return attr_index == data.attrcode
1.26
1.27 def _MakeObject(self, size, ref):
1.28 + # Load the template.
1.29 data = self.load(ref)
1.30 addr = self.new(size)
1.31 - # Set the header to resemble the class.
1.32 - self.save(addr, data)
1.33 + # Save the header, overriding the size.
1.34 + self.save(addr, data.with_size(size))
1.35 return addr
1.36
1.37 def _LoadAddressContextCond(self, context, ref, inst_context, inst_ref):
1.38 @@ -634,12 +640,6 @@
1.39
1.40 # Native function implementations.
1.41
1.42 - def builtins_object_init(self):
1.43 - pass
1.44 -
1.45 - def builtins_int_init(self):
1.46 - pass
1.47 -
1.48 def builtins_int_add(self):
1.49 frame = self.local_sp_stack[-1]
1.50
1.51 @@ -706,12 +706,25 @@
1.52 left_context, left = self.frame_stack[frame]
1.53 self.result = left, left
1.54
1.55 + def builtins_list_new(self):
1.56 + frame = self.local_sp_stack[-1]
1.57 +
1.58 + # NOTE: Specific copying of tuples/lists.
1.59 +
1.60 + args_context, args = self.frame_stack[frame]
1.61 + header = self.load(args)
1.62 +
1.63 + list = self._MakeObject(header.size, self.list_instance_location)
1.64 + for i in range(1, header.size):
1.65 + self.save(list + i, self.load(args + i))
1.66 +
1.67 + self.result = list, list
1.68 +
1.69 native_functions = {
1.70 - "__builtins__.object.__init__" : builtins_object_init,
1.71 - "__builtins__.int.__init__" : builtins_int_init,
1.72 "__builtins__.int.__add__" : builtins_int_add,
1.73 "__builtins__.int.__bool__" : builtins_int_bool,
1.74 "__builtins__.bool.__bool__" : builtins_bool_bool,
1.75 + "__builtins__.list" : builtins_list_new,
1.76 }
1.77
1.78 # vim: tabstop=4 expandtab shiftwidth=4