[pypy-svn] r47844 - in pypy/dist/pypy/lang/smalltalk: . test

arigo at codespeak.net arigo at codespeak.net
Wed Oct 24 18:06:04 CEST 2007


Author: arigo
Date: Wed Oct 24 18:06:04 2007
New Revision: 47844

Modified:
   pypy/dist/pypy/lang/smalltalk/fakeimage.py
   pypy/dist/pypy/lang/smalltalk/interpreter.py
   pypy/dist/pypy/lang/smalltalk/model.py
   pypy/dist/pypy/lang/smalltalk/primitives.py
   pypy/dist/pypy/lang/smalltalk/test/test_interpreter.py
   pypy/dist/pypy/lang/smalltalk/test/test_model.py
Log:
Rename away the deprecated get/setnamedvar().


Modified: pypy/dist/pypy/lang/smalltalk/fakeimage.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/fakeimage.py	(original)
+++ pypy/dist/pypy/lang/smalltalk/fakeimage.py	Wed Oct 24 18:06:04 2007
@@ -23,7 +23,7 @@
 
 def ord_w_char(w_c):
     assert w_c.w_class is ct.w_Character
-    w_ord = w_c.getnamedvar(CHARACTER_VALUE_INDEX)
+    w_ord = w_c.fetch(CHARACTER_VALUE_INDEX)
     assert w_ord.w_class is ct.w_SmallInteger
     assert isinstance(w_ord, model.W_SmallInteger)
     return w_ord.value
@@ -51,7 +51,7 @@
     global CharacterTable
     def bld_char(i):
         w_cinst = ct.w_Character.new()
-        w_cinst.setnamedvar(CHARACTER_VALUE_INDEX, wrap_int(i))
+        w_cinst.store(CHARACTER_VALUE_INDEX, wrap_int(i))
         return w_cinst
     CharacterTable = [bld_char(i) for i in range(256)]
 wrap_char_table()

Modified: pypy/dist/pypy/lang/smalltalk/interpreter.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/interpreter.py	(original)
+++ pypy/dist/pypy/lang/smalltalk/interpreter.py	Wed Oct 24 18:06:04 2007
@@ -54,7 +54,7 @@
     # push bytecodes
     def pushReceiverVariableBytecode(self, interp):
         index = self.currentBytecode & 15
-        self.push(self.receiver.getnamedvar(index))
+        self.push(self.receiver.fetch(index))
 
     def pushTemporaryVariableBytecode(self, interp):
         index = self.currentBytecode & 15
@@ -70,11 +70,11 @@
         # named var (the value).
         index = self.currentBytecode & 31
         association = self.method.literals[index]
-        self.push(association.getnamedvar(1))
+        self.push(association.fetch(1))
 
     def storeAndPopReceiverVariableBytecode(self, interp):
         index = self.currentBytecode & 7
-        self.receiver.setnamedvar(index, self.pop())
+        self.receiver.store(index, self.pop())
 
     def storeAndPopTemporaryVariableBytecode(self, interp):
         index = self.currentBytecode & 7
@@ -179,26 +179,26 @@
     def extendedPushBytecode(self, interp):
         variableType, variableIndex = self.extendedVariableTypeAndIndex()
         if variableType == 0:
-            self.push(self.receiver.getnamedvar(variableIndex))
+            self.push(self.receiver.fetch(variableIndex))
         elif variableType == 1:
             self.push(self.gettemp(variableIndex))
         elif variableType == 2:
             self.push(self.method.literals[variableIndex])
         elif variableType == 3:
             association = self.method.literals[variableIndex]
-            self.push(association.getnamedvar(1))
+            self.push(association.fetch(1))
 
     def extendedStoreBytecode(self, interp):
         variableType, variableIndex = self.extendedVariableTypeAndIndex()
         if variableType == 0:
-            self.receiver.setnamedvar(variableIndex, self.top())
+            self.receiver.store(variableIndex, self.top())
         elif variableType == 1:
             self.settemp(variableIndex, self.top())
         elif variableType == 2:
             raise IllegalStoreError
         elif variableType == 3:
             association = self.method.literals[variableIndex]
-            association.setnamedvar(1,self.top())
+            association.store(1,self.top())
 
     def extendedStoreAndPopBytecode(self, interp):
         self.extendedStoreBytecode(interp)
@@ -226,21 +226,21 @@
                                     second & 31, interp)
         elif opType == 2:
             # pushReceiver
-            self.push(self.receiver.getnamedvar(third))
+            self.push(self.receiver.fetch(third))
         elif opType == 3:
             # pushLiteralConstant
             self.push(self.method.literals[third])
         elif opType == 4:
             # pushLiteralVariable
             association = self.method.literals[third]
-            self.push(association.getnamedvar(1))
+            self.push(association.fetch(1))
         elif opType == 5:
-            self.receiver.setnamedvar(third, self.top())
+            self.receiver.store(third, self.top())
         elif opType == 6:
-            self.receiver.setnamedvar(third, self.pop())
+            self.receiver.store(third, self.pop())
         elif opType == 7:
             association = self.method.literals[third]
-            association.setnamedvar(1,self.top())
+            association.store(1,self.top())
 
     def singleExtendedSuperBytecode(self, interp):
         selector, argcount = self.getExtendedSelectorArgcount()

Modified: pypy/dist/pypy/lang/smalltalk/model.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/model.py	(original)
+++ pypy/dist/pypy/lang/smalltalk/model.py	Wed Oct 24 18:06:04 2007
@@ -49,23 +49,9 @@
         
     def store(self, index, w_value):    
         self.vars[index] = w_value
-        
-    def getnamedvar(self, index):
-        print "deprecated"
-        return self.fetch(index)
-
-    def setnamedvar(self, index, w_value):
-        print "deprecated"
-        return self.store(index, w_value)
 
     def size(self):
         return len(self.vars)
-        
-    def getindexedvar(self, index):
-        raise NotImplementedError
-
-    def setindexedvar(self, index, w_value):
-        raise NotImplementedError
 
     def invariant(self):
         return (W_Object.invariant(self) and

Modified: pypy/dist/pypy/lang/smalltalk/primitives.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/primitives.py	(original)
+++ pypy/dist/pypy/lang/smalltalk/primitives.py	Wed Oct 24 18:06:04 2007
@@ -241,7 +241,7 @@
     [w_rcvr, w_idx] = stack
     idx = unwrap_int(w_idx)
     assert_bounds(idx, 0, w_rcvr.w_class.instvarsize)
-    return w_rcvr.getnamedvar(idx)
+    return w_rcvr.fetch(idx)
 
 @primitive(OBJECT_AT_PUT)
 @stack(3)
@@ -249,7 +249,7 @@
     [w_rcvr, w_idx, w_val] = stack
     idx = unwrap_int(w_idx)
     assert_bounds(idx, 0, w_rcvr.w_class.instvarsize)
-    w_rcvr.setnamedvar(idx, w_val)
+    w_rcvr.store(idx, w_val)
     return w_val
 
 @primitive(NEW)
@@ -284,7 +284,7 @@
     if idx < 0:
         raise PrimitiveFailedError()
     if idx < w_cls.instvarsize:
-        return w_rcvr.getnamedvar(idx)
+        return w_rcvr.fetch(idx)
     idx -= w_cls.instvarsize
     if idx < w_rcvr.size():
         return subscript(idx, w_rcvr)

Modified: pypy/dist/pypy/lang/smalltalk/test/test_interpreter.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/test/test_interpreter.py	(original)
+++ pypy/dist/pypy/lang/smalltalk/test/test_interpreter.py	Wed Oct 24 18:06:04 2007
@@ -75,9 +75,9 @@
                                                   pushReceiverVariableBytecode(2))):
     w_democlass = model.W_Class(None, None, 3)
     w_demo = w_democlass.new()
-    w_demo.setnamedvar(0, "egg")
-    w_demo.setnamedvar(1, "bar")
-    w_demo.setnamedvar(2, "baz")
+    w_demo.store(0, "egg")
+    w_demo.store(1, "bar")
+    w_demo.store(2, "baz")
     interp = new_interpreter(bytecode, receiver = w_demo)
     interp.step()
     interp.step()
@@ -107,8 +107,8 @@
 def test_pushLiteralVariableBytecode(bytecode=pushLiteralVariableBytecode(0)):
     w_associationclass = model.W_Class(None, None, 2)
     w_association = w_associationclass.new()
-    w_association.setnamedvar(0, "mykey")
-    w_association.setnamedvar(1, "myvalue")
+    w_association.store(0, "mykey")
+    w_association.store(1, "myvalue")
     interp = new_interpreter(bytecode)
     interp.activeContext.method.literals = [w_association]
     interp.step()
@@ -130,9 +130,9 @@
 
         for test_index in range(8):
             if test_index == index:
-                assert w_object.getnamedvar(test_index) == interp.TRUE
+                assert w_object.fetch(test_index) == interp.TRUE
             else:
-                assert w_object.getnamedvar(test_index) == None
+                assert w_object.fetch(test_index) == None
 
 def test_storeAndPopTemporaryVariableBytecode(bytecode=storeAndPopTemporaryVariableBytecode):
     for index in range(8):
@@ -332,13 +332,13 @@
 def storeAssociation(bytecode):
     w_associationclass = model.W_Class(None, None, 2)
     w_association = w_associationclass.new()
-    w_association.setnamedvar(0, "mykey")
-    w_association.setnamedvar(1, "myvalue")
+    w_association.store(0, "mykey")
+    w_association.store(1, "myvalue")
     interp = new_interpreter(pushConstantOneBytecode + bytecode)
     interp.activeContext.method.literals = [w_association]
     interp.step()
     interp.step()
-    assert w_association.getnamedvar(1) == interp.ONE
+    assert w_association.fetch(1) == interp.ONE
 
 def test_extendedStoreAndPopBytecode():
     test_storeAndPopReceiverVariableBytecode(lambda index: extendedStoreAndPopBytecode + chr((0<<6) + index))

Modified: pypy/dist/pypy/lang/smalltalk/test/test_model.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/test/test_model.py	(original)
+++ pypy/dist/pypy/lang/smalltalk/test/test_model.py	Wed Oct 24 18:06:04 2007
@@ -12,10 +12,10 @@
     w_myinstance = w_mycls.new()
     assert isinstance(w_myinstance, model.W_PointersObject)
     assert w_myinstance.w_class is w_mycls
-    assert w_myinstance.getnamedvar(0) is None
-    py.test.raises(IndexError, lambda: w_myinstance.getnamedvar(3))
-    w_myinstance.setnamedvar(1, w_myinstance)
-    assert w_myinstance.getnamedvar(1) is w_myinstance
+    assert w_myinstance.fetch(0) is None
+    py.test.raises(IndexError, lambda: w_myinstance.fetch(3))
+    w_myinstance.store(1, w_myinstance)
+    assert w_myinstance.fetch(1) is w_myinstance
 
 def test_bytes_object():
     w_class = model.W_Class(None, None, format=model.BYTES)



More information about the Pypy-commit mailing list