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

cfbolz at codespeak.net cfbolz at codespeak.net
Mon Oct 29 12:06:23 CET 2007


Author: cfbolz
Date: Mon Oct 29 12:06:21 2007
New Revision: 48144

Modified:
   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/shadow.py
Log:
add some "assert 0" before nonsensical code. They don't break any 
tests (!!!), which is a bad sign, but help to get translation 
further. Also, rename getbyte on W_ContextPart to getbytecode to 
avoid confusion.


Modified: pypy/dist/pypy/lang/smalltalk/interpreter.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/interpreter.py	(original)
+++ pypy/dist/pypy/lang/smalltalk/interpreter.py	Mon Oct 29 12:06:21 2007
@@ -215,7 +215,7 @@
         raise MissingBytecode("unknownBytecode")
 
     def extendedVariableTypeAndIndex(self):
-        descriptor = self.getbyte()
+        descriptor = self.getbytecode()
         return ((descriptor >> 6) & 3), (descriptor & 63)
 
     def extendedPushBytecode(self, interp):
@@ -249,7 +249,7 @@
         self.pop()
 
     def getExtendedSelectorArgcount(self):
-        descriptor = self.getbyte()
+        descriptor = self.getbytecode()
         return ((self.w_method().getliteralsymbol(descriptor & 31)),
                 (descriptor >> 5))
 
@@ -258,8 +258,8 @@
         self._sendSelfSelector(selector, argcount, interp)
 
     def doubleExtendedDoAnythingBytecode(self, interp):
-        second = self.getbyte()
-        third = self.getbyte()
+        second = self.getbytecode()
+        third = self.getbytecode()
         opType = second >> 5
         if opType == 0:
             # selfsend
@@ -294,7 +294,7 @@
         self._sendSuperSelector(selector, argcount, interp)
 
     def secondExtendedSendBytecode(self, interp):
-        descriptor = self.getbyte()
+        descriptor = self.getbytecode()
         selector = self.w_method().getliteralsymbol(descriptor & 63)
         argcount = descriptor >> 6
         self._sendSelfSelector(selector, argcount, interp)
@@ -323,10 +323,10 @@
         self.jumpConditional(interp.FALSE,self.shortJumpPosition())
 
     def longUnconditionalJump(self, interp):
-        self.jump((((self.currentBytecode & 7) - 4) << 8) + self.getbyte())
+        self.jump((((self.currentBytecode & 7) - 4) << 8) + self.getbytecode())
 
     def longJumpPosition(self):
-        return ((self.currentBytecode & 3) << 8) + self.getbyte()
+        return ((self.currentBytecode & 3) << 8) + self.getbytecode()
 
     def longJumpIfTrue(self, interp):
         self.jumpConditional(interp.TRUE,self.longJumpPosition())

Modified: pypy/dist/pypy/lang/smalltalk/model.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/model.py	(original)
+++ pypy/dist/pypy/lang/smalltalk/model.py	Mon Oct 29 12:06:21 2007
@@ -413,14 +413,14 @@
     def w_method(self):
         return self.w_home._w_method
 
-    def getbyte(self):
+    def getbytecode(self):
         bytecode = self.w_method().bytes[self.pc]
         currentBytecode = ord(bytecode)
         self.pc = self.pc + 1
         return currentBytecode
 
     def getNextBytecode(self):
-        self.currentBytecode = self.getbyte()
+        self.currentBytecode = self.getbytecode()
         return self.currentBytecode
 
     # ______________________________________________________________________

Modified: pypy/dist/pypy/lang/smalltalk/primitives.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/primitives.py	(original)
+++ pypy/dist/pypy/lang/smalltalk/primitives.py	Mon Oct 29 12:06:21 2007
@@ -332,6 +332,10 @@
 @expose_primitive(STRING_AT, unwrap_spec=[object, index1_0])
 def func(interp, w_obj, n0):
     assert_valid_index(n0, w_obj)
+    # XXX I am not sure this is correct, but it un-breaks translation:
+    # make sure that getbyte is only performed on W_BytesObjects
+    if not isinstance(w_obj, model.W_BytesObject):
+        raise PrimitiveFailedError
     byte = w_obj.getbyte(n0)
     return objtable.CharacterTable[byte]
 
@@ -449,6 +453,8 @@
     header = unwrap_int(w_header)
     literalcount = ((header >> 10) & 255) + 1
     w_method = w_class.as_class_get_shadow().new(literalcount)
+    # XXX not sure this is correct
+    assert isinstance(w_method, model.W_MethodContext)
     w_method.literals[constants.METHOD_HEADER_INDEX] = w_header
     for i in range(0,literalcount):
         w_method.literals[i+1] = objtable.w_nil

Modified: pypy/dist/pypy/lang/smalltalk/shadow.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/shadow.py	(original)
+++ pypy/dist/pypy/lang/smalltalk/shadow.py	Mon Oct 29 12:06:21 2007
@@ -120,12 +120,11 @@
         if w_cls == classtable.w_BlockContext:
             return model.W_BlockContext(None, None, 0, 0)
         elif w_cls == classtable.w_MethodContext:
+            assert 0, "this seems nonsense"
             return model.W_MethodContext(None, None, [], extrasize)
         
         if self.instance_kind == POINTERS:
             return model.W_PointersObject(w_cls, self.instance_size+extrasize)
-        elif self.instance_kind == COMPILED_METHOD:
-            return model.W_CompiledMethod(extrasize+constants.LITERAL_START, w_compiledin = w_cls)
         elif self.instance_kind == WORDS:
             return model.W_WordsObject(w_cls, extrasize)
         elif self.instance_kind == BYTES:



More information about the Pypy-commit mailing list