[pypy-svn] r48058 - pypy/dist/pypy/lang/smalltalk

tverwaes at codespeak.net tverwaes at codespeak.net
Fri Oct 26 14:58:26 CEST 2007


Author: tverwaes
Date: Fri Oct 26 14:58:25 2007
New Revision: 48058

Modified:
   pypy/dist/pypy/lang/smalltalk/interpreter.py
   pypy/dist/pypy/lang/smalltalk/model.py
   pypy/dist/pypy/lang/smalltalk/primitives.py
Log:
fixing fallback for stream primitives


Modified: pypy/dist/pypy/lang/smalltalk/interpreter.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/interpreter.py	(original)
+++ pypy/dist/pypy/lang/smalltalk/interpreter.py	Fri Oct 26 14:58:25 2007
@@ -375,13 +375,13 @@
         self.callPrimitiveAndPush(primitives.SIZE, "size", 0, interp)
 
     def bytecodePrimNext(self, interp):
-        raise MissingBytecode("bytecodePrimNext")
+        self.callPrimitiveAndPush(primitives.NEXT, "next", 0, interp)
 
     def bytecodePrimNextPut(self, interp):
-        raise MissingBytecode("bytecodePrimNextPut")
+        self.callPrimitiveAndPush(primitives.NEXT_PUT, "nextPut:", 1, interp)
 
     def bytecodePrimAtEnd(self, interp):
-        raise MissingBytecode("bytecodePrimAtEnd")
+        self.callPrimitiveAndPush(primitives.AT_END, "atEnd", 0, interp)
 
     def bytecodePrimEquivalent(self, interp):
         raise MissingBytecode("bytecodePrimEquivalent")

Modified: pypy/dist/pypy/lang/smalltalk/model.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/model.py	(original)
+++ pypy/dist/pypy/lang/smalltalk/model.py	Fri Oct 26 14:58:25 2007
@@ -116,6 +116,9 @@
         W_AbstractObjectWithClassReference.__init__(self, w_class)
         self._vars = [None] * size
 
+    def at(self, index0):
+        return self.fetch(index0)
+       
     def fetch(self, n0):
         return self._vars[n0]
         
@@ -152,7 +155,11 @@
     def __init__(self, w_class, size):
         W_AbstractObjectWithClassReference.__init__(self, w_class)
         self.bytes = ['\x00'] * size
-        
+
+    def at(self, index0):
+        from pypy.lang.smalltalk import objtable
+        return objtable.wrap_chr(self.getbyte(index0))
+       
     def getbyte(self, n):
         return ord(self.bytes[n])
         
@@ -184,6 +191,10 @@
         W_AbstractObjectWithClassReference.__init__(self, w_class)
         self.words = [0] * size
         
+    def at(self, index0):
+        from pypy.lang.smalltalk import objtable
+        return objtable.wrap_int(self.getword(index0))
+
     def getword(self, n):
         return self.words[n]
         

Modified: pypy/dist/pypy/lang/smalltalk/primitives.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/primitives.py	(original)
+++ pypy/dist/pypy/lang/smalltalk/primitives.py	Fri Oct 26 14:58:25 2007
@@ -337,6 +337,13 @@
     return w_val
 
 # ___________________________________________________________________________
+# Stream Primitives
+
+NEXT = 65
+NEXT_PUT = 66
+AT_END = 67
+
+# ___________________________________________________________________________
 # Storage Management Primitives
 
 OBJECT_AT = 68



More information about the Pypy-commit mailing list