[pypy-svn] r66701 - pypy/branch/io-lang/pypy/lang/io

david at codespeak.net david at codespeak.net
Thu Jul 30 16:57:19 CEST 2009


Author: david
Date: Thu Jul 30 16:57:16 2009
New Revision: 66701

Modified:
   pypy/branch/io-lang/pypy/lang/io/message.py
   pypy/branch/io-lang/pypy/lang/io/model.py
   pypy/branch/io-lang/pypy/lang/io/objspace.py
Log:
add ImmutableSequence to objspace

Modified: pypy/branch/io-lang/pypy/lang/io/message.py
==============================================================================
--- pypy/branch/io-lang/pypy/lang/io/message.py	(original)
+++ pypy/branch/io-lang/pypy/lang/io/message.py	Thu Jul 30 16:57:16 2009
@@ -13,8 +13,7 @@
  
 @register_method('Message', 'name')
 def message_name(space, w_receiver, w_message, w_context):
-    # XXX TODO clone from space
-    return W_ImmutableSequence(space, w_receiver.name)
+    return space.w_immutable_sequence.clone_and_init(w_receiver.name)
 
 @register_method('Message', 'argsEvaluatedIn')
 def message_argsEvaluatedIn(space, w_target, w_message, w_context):

Modified: pypy/branch/io-lang/pypy/lang/io/model.py
==============================================================================
--- pypy/branch/io-lang/pypy/lang/io/model.py	(original)
+++ pypy/branch/io-lang/pypy/lang/io/model.py	Thu Jul 30 16:57:16 2009
@@ -160,12 +160,20 @@
     
         
 class W_ImmutableSequence(W_Object):
-    def __init__(self, space, string):
+    def __init__(self, space, string, protos=[]):
+        W_Object.__init__(self, space, protos)
         self.value = string
         
     def hash(self):
         return hash(self.value)
+        
+    def clone(self):
+        return W_ImmutableSequence(self.space, self.value, [self])
 
+    def clone_and_init(self, value):
+        ims = self.clone()
+        ims.value = value
+        return ims 
 class W_CFunction(W_Object):
     def __init__(self, space, function):
         self.function = function
@@ -281,4 +289,4 @@
         except ValueError:
             pass
     if literal.startswith('"') and literal.endswith('"'):
-        return W_ImmutableSequence(space, literal[1:-1])
\ No newline at end of file
+        return space.w_immutable_sequence.clone_and_init(literal[1:-1])
\ No newline at end of file

Modified: pypy/branch/io-lang/pypy/lang/io/objspace.py
==============================================================================
--- pypy/branch/io-lang/pypy/lang/io/objspace.py	(original)
+++ pypy/branch/io-lang/pypy/lang/io/objspace.py	Thu Jul 30 16:57:16 2009
@@ -34,6 +34,10 @@
         self.w_continue = W_Object(self, [self.w_object])
         self.w_return = W_Object(self, [self.w_object])
         self.w_eol = W_Object(self, [self.w_object])
+        
+        # XXX TODO: change this when Sequence is implemented
+        self.w_sequence = W_Object(self, [self.w_object])
+        self.w_immutable_sequence = W_ImmutableSequence(self, '', [self.w_sequence])
         # default stop state
         self.stop_status = self.w_normal
         self.w_return_value = self.w_nil
@@ -89,6 +93,7 @@
         self.w_core.protos.append(self.w_object)
         self.w_core.slots['Locals'] = self.w_locals
         self.w_core.slots['Block'] = self.w_block
+        self.w_core.slots['Coroutine'] = self.w_coroutine
         self.w_core.slots['Object'] = self.w_object
         self.w_core.slots['true'] = self.w_true
         self.w_core.slots['false'] = self.w_false
@@ -96,8 +101,10 @@
         self.w_core.slots['List'] = self.w_list
         self.w_core.slots['Call'] = self.w_call
         self.w_core.slots['Map'] = self.w_map
+        self.w_core.slots['Message'] = self.w_message
         self.w_core.slots['Number'] = self.w_number
-        self.w_core.slots['Coroutine'] = self.w_coroutine
+        self.w_core.slots['Sequence'] = self.w_sequence
+        self.w_core.slots['ImmutableSequence'] = self.w_immutable_sequence
 
     def init_w_number(self):
         self.w_number = instantiate(W_Number)



More information about the Pypy-commit mailing list