[pypy-svn] r51761 - in pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk: . test

tverwaes at codespeak.net tverwaes at codespeak.net
Thu Feb 21 21:59:14 CET 2008


Author: tverwaes
Date: Thu Feb 21 21:59:13 2008
New Revision: 51761

Modified:
   pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/classtable.py
   pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/constants.py
   pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/interpreter.py
   pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/model.py
   pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/objtable.py
   pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/primitives.py
   pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/shadow.py
   pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/squeakimage.py
   pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_interpreter.py
   pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_miniimage.py
   pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_primitives.py
Log:
adding initial shadows for contexts and making original contexts + tests
compatible with new format.


Modified: pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/classtable.py
==============================================================================
--- pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/classtable.py	(original)
+++ pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/classtable.py	Thu Feb 21 21:59:13 2008
@@ -75,9 +75,12 @@
 create_classtable()
 
 def copy_in_globals_classes_known_to_the_vm():
-    for name in constants.classes_needed_boot_vm:
+    for name in constants.classes_in_special_object_table.keys():
         name = 'w_' + name
-        globals()[name] = classtable[name]
+        try:
+            globals()[name] = classtable[name]
+        except KeyError:
+            globals()[name] = None
 
 # ___________________________________________________________________________
 # Other classes

Modified: pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/constants.py
==============================================================================
--- pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/constants.py	(original)
+++ pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/constants.py	Thu Feb 21 21:59:13 2008
@@ -112,47 +112,29 @@
 SO_FINALIZATION_SEMPAHORE = 41
 SO_LARGENEGATIVEINTEGER_CLASS = 42
 
-classes_needed_boot_vm = [
-    "SmallInteger",
-    "String",
-    "Array",
-    "Float",
-    "MethodContext",
-    "BlockContext",
-    "CompiledMethod",
-    "Character",
-    "ByteArray",
-]
-
 # XXX more missing?
 classes_in_special_object_table = {
-    "Bitmap" : SO_BITMAP_CLASS,
+#    "Bitmap" : SO_BITMAP_CLASS,
     "SmallInteger" : SO_SMALLINTEGER_CLASS,
     "String" : SO_STRING_CLASS,
     "Array" : SO_ARRAY_CLASS,
     "Float" : SO_FLOAT_CLASS,
     "MethodContext" : SO_METHODCONTEXT_CLASS,
     "BlockContext" : SO_BLOCKCONTEXT_CLASS,
-    "Point" : SO_POINT_CLASS,
-    "LargePositiveInteger" : SO_LARGEPOSITIVEINTEGER_CLASS,
-    "Display" : SO_DISPLAY_CLASS,
-    "Message" : SO_MESSAGE_CLASS,
+#    "Point" : SO_POINT_CLASS,
+#    "LargePositiveInteger" : SO_LARGEPOSITIVEINTEGER_CLASS,
+#    "Display" : SO_DISPLAY_CLASS,
+#    "Message" : SO_MESSAGE_CLASS,
     "CompiledMethod" : SO_COMPILEDMETHOD_CLASS,
-    "Semaphore" : SO_SEMAPHORE_CLASS,
+#    "Semaphore" : SO_SEMAPHORE_CLASS,
     "Character" : SO_CHARACTER_CLASS,
     "ByteArray" : SO_BYTEARRAY_CLASS,
-    "Process" : SO_PROCESS_CLASS,
-    "PseudoContext" : SO_PSEUDOCONTEXT_CLASS,
-    "TranslatedMethod" : SO_TRANSLATEDMETHOD_CLASS,
+#    "Process" : SO_PROCESS_CLASS,
+#    "PseudoContext" : SO_PSEUDOCONTEXT_CLASS,
+#    "TranslatedMethod" : SO_TRANSLATEDMETHOD_CLASS,
     # "LargeNegativeInteger" : SO_LARGENEGATIVEINTEGER_CLASS, # Not available in mini.image
 }
 
-objects_needed_boot_vm = [
-    "nil",
-    "true",
-    "false",
-]
-
 objects_in_special_object_table = {
     "nil": SO_NIL,
     "true": SO_TRUE,

Modified: pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/interpreter.py
==============================================================================
--- pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/interpreter.py	(original)
+++ pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/interpreter.py	Thu Feb 21 21:59:13 2008
@@ -25,10 +25,10 @@
     ONE = objtable.w_one
     TWO = objtable.w_two
 
-    _w_last_active_context = None
+    _s_last_active_context = None
     
     def __init__(self):
-        self.w_active_context = None
+        self.s_active_context = None
         self.cnt = 0
 
     def interpret(self):
@@ -42,30 +42,30 @@
         return (not objectmodel.we_are_translated()) and option.bc_trace
 
     def step(self):
-        next = self.w_active_context.getNextBytecode()
+        next = self.s_active_context.getNextBytecode()
         # we_are_translated returns false on top of CPython and true when
         # translating the interpreter
         if not objectmodel.we_are_translated():
             bytecodeimpl = BYTECODE_TABLE[next]
-            if self._w_last_active_context != self.w_active_context:
+            if self._s_last_active_context != self.s_active_context:
                 cnt = 0
-                p = self.w_active_context
+                p = self.s_active_context
                 # AK make method
                 while p is not None:
                     cnt += 1
-                    p = p.w_sender
+                    p = p.s_sender()
                 self._last_indent = "  " * cnt
-                self._w_last_active_context = self.w_active_context
+                self._s_last_active_context = self.s_active_context
             if self.should_trace():
                 
                 print "%sStack=%s" % (
                     self._last_indent,
-                    repr(self.w_active_context.stack),)
+                    repr(self.s_active_context.stack),)
                 print "%sBytecode at %d (%d:%s):" % (
                     self._last_indent,
-                    self.w_active_context.pc,
+                    self.s_active_context.pc(),
                     next, bytecodeimpl.__name__,)
-            bytecodeimpl(self.w_active_context, self)
+            bytecodeimpl(self.s_active_context, self)
         else:
             # this is a performance optimization: when translating the
             # interpreter, the bytecode dispatching is not implemented as a
@@ -73,7 +73,7 @@
             # below produces the switch (by being unrolled).
             for code, bytecodeimpl in unrolling_bytecode_table:
                 if code == next:
-                    bytecodeimpl(self.w_active_context, self)
+                    bytecodeimpl(self.s_active_context, self)
                     break
 
         
@@ -91,7 +91,7 @@
     # push bytecodes
     def pushReceiverVariableBytecode(self, interp):
         index = self.currentBytecode & 15
-        self.push(self.receiver().fetch(index))
+        self.push(self.w_receiver().fetch(index))
 
     def pushTemporaryVariableBytecode(self, interp):
         index = self.currentBytecode & 15
@@ -113,7 +113,7 @@
 
     def storeAndPopReceiverVariableBytecode(self, interp):
         index = self.currentBytecode & 7
-        self.receiver().store(index, self.pop())
+        self.w_receiver().store(index, self.pop())
 
     def storeAndPopTemporaryVariableBytecode(self, interp):
         index = self.currentBytecode & 7
@@ -121,7 +121,7 @@
 
     # push bytecodes
     def pushReceiverBytecode(self, interp):
-        self.push(self.receiver())
+        self.push(self.w_receiver())
 
     def pushConstantTrueBytecode(self, interp):
         self.push(interp.TRUE)
@@ -163,7 +163,7 @@
 
     def _sendSuperSelector(self, selector, argcount, interp):
         s_compiledin = self.w_method().compiledin().as_class_get_shadow()
-        self._sendSelector(selector, argcount, interp, self.receiver(),
+        self._sendSelector(selector, argcount, interp, self.w_receiver(),
                            s_compiledin.s_superclass)
 
     def _sendSelector(self, selector, argcount, interp,
@@ -203,33 +203,33 @@
         start = len(self.stack) - argcount
         assert start >= 0  # XXX check in the Blue Book what to do in this case
         arguments = self.stack[start:]
-        interp.w_active_context = method.create_frame(receiver, arguments, self) 
+        interp.s_active_context = method.create_frame(receiver, arguments, self) 
         self.pop_n(argcount + 1) 
 
-    def _return(self, object, interp, w_return_to):
+    def _return(self, object, interp, s_return_to):
         # for tests, when returning from the top-level context
-        if w_return_to is None:
+        if s_return_to is None:
             raise ReturnFromTopLevel(object)
-        w_return_to.push(object)
-        interp.w_active_context = w_return_to
+        s_return_to.push(object)
+        interp.s_active_context = s_return_to
 
     def returnReceiver(self, interp):
-        self._return(self.receiver(), interp, self.w_home.w_sender)
+        self._return(self.w_receiver(), interp, self.s_home().s_sender())
 
     def returnTrue(self, interp):
-        self._return(interp.TRUE, interp, self.w_home.w_sender)
+        self._return(interp.TRUE, interp, self.s_home().s_sender())
 
     def returnFalse(self, interp):
-        self._return(interp.FALSE, interp, self.w_home.w_sender)
+        self._return(interp.FALSE, interp, self.s_home().s_sender())
 
     def returnNil(self, interp):
-        self._return(interp.NIL, interp, self.w_home.w_sender)
+        self._return(interp.NIL, interp, self.s_home().s_sender())
 
     def returnTopFromMethod(self, interp):
-        self._return(self.top(), interp, self.w_home.w_sender)
+        self._return(self.top(), interp, self.s_home().s_sender())
 
     def returnTopFromBlock(self, interp):
-        self._return(self.top(), interp, self.w_sender)
+        self._return(self.top(), interp, self.s_sender())
 
     def unknownBytecode(self, interp):
         raise MissingBytecode("unknownBytecode")
@@ -242,7 +242,7 @@
     def extendedPushBytecode(self, interp):
         variableType, variableIndex = self.extendedVariableTypeAndIndex()
         if variableType == 0:
-            self.push(self.receiver().fetch(variableIndex))
+            self.push(self.w_receiver().fetch(variableIndex))
         elif variableType == 1:
             self.push(self.gettemp(variableIndex))
         elif variableType == 2:
@@ -257,7 +257,7 @@
     def extendedStoreBytecode(self, interp):
         variableType, variableIndex = self.extendedVariableTypeAndIndex()
         if variableType == 0:
-            self.receiver().store(variableIndex, self.top())
+            self.w_receiver().store(variableIndex, self.top())
         elif variableType == 1:
             self.settemp(variableIndex, self.top())
         elif variableType == 2:
@@ -294,7 +294,7 @@
                                     second & 31, interp)
         elif opType == 2:
             # pushReceiver
-            self.push(self.receiver().fetch(third))
+            self.push(self.w_receiver().fetch(third))
         elif opType == 3:
             # pushLiteralConstant
             self.push(self.w_method().getliteral(third))
@@ -304,9 +304,9 @@
             assert isinstance(association, model.W_PointersObject)
             self.push(association.fetch(constants.ASSOCIATION_VALUE_INDEX))
         elif opType == 5:
-            self.receiver().store(third, self.top())
+            self.w_receiver().store(third, self.top())
         elif opType == 6:
-            self.receiver().store(third, self.pop())
+            self.w_receiver().store(third, self.pop())
         elif opType == 7:
             association = self.w_method().getliteral(third)
             assert isinstance(association, model.W_PointersObject)
@@ -329,7 +329,7 @@
         raise MissingBytecode("experimentalBytecode")
 
     def jump(self,offset):
-        self.pc = self.pc + offset
+        self.store_pc(self.pc() + offset)
 
     def jumpConditional(self,bool,position):
         if self.top() == bool:

Modified: pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/model.py
==============================================================================
--- pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/model.py	(original)
+++ pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/model.py	Thu Feb 21 21:59:13 2008
@@ -196,19 +196,14 @@
 
     def as_semaphore_get_shadow(self):
         from pypy.lang.smalltalk.shadow import SemaphoreShadow
-        from pypy.lang.smalltalk import classtable
-        assert self.getclass() == classtable.classtable["w_Semaphore"]
         return self.as_special_get_shadow(SemaphoreShadow)
 
     def as_linkedlist_get_shadow(self):
         from pypy.lang.smalltalk.shadow import LinkedListShadow
-        from pypy.lang.smalltalk import classtable
         return self.as_special_get_shadow(LinkedListShadow)
 
     def as_process_get_shadow(self):
         from pypy.lang.smalltalk.shadow import ProcessShadow
-        from pypy.lang.smalltalk import classtable
-        assert self.getclass() == classtable.classtable["w_Process"]
         return self.as_special_get_shadow(ProcessShadow)
 
     def as_scheduler_get_shadow(self):
@@ -219,6 +214,24 @@
         from pypy.lang.smalltalk.shadow import AssociationShadow
         return self.as_special_get_shadow(AssociationShadow)
 
+    def as_blockcontext_get_shadow(self):
+        from pypy.lang.smalltalk.shadow import BlockContextShadow
+        return self.as_special_get_shadow(BlockContextShadow)
+
+    def as_methodcontext_get_shadow(self):
+        from pypy.lang.smalltalk.shadow import MethodContextShadow
+        return self.as_special_get_shadow(MethodContextShadow)
+
+    def as_context_get_shadow(self):
+        from pypy.lang.smalltalk import classtable
+        if self.getclass() == classtable.w_MethodContext:
+            self.as_methodcontext_get_shadow()
+        elif self.getclass() == classtable.w_BlockContext:
+            self.as_blockcontext_get_shadow()
+        else:
+            # Should not happen...
+            raise Exception()
+
     def equals(self, other):
         if not isinstance(other, W_PointersObject):
             return False
@@ -461,30 +474,55 @@
 
     __metaclass__ = extendabletype
     
-    def __init__(self, w_home, w_sender):
+    def __init__(self, s_home, s_sender):
         self.stack = []
-        self.pc = 0
-        assert isinstance(w_home, W_MethodContext)
-        self.w_home = w_home
-        assert w_sender is None or isinstance(w_sender, W_ContextPart)
-        self.w_sender = w_sender
+        self._pc = 0
+        #assert isinstance(s_home, W_MethodContext)
+        self._s_home = s_home
+        #assert w_sender is None or isinstance(w_sender, W_ContextPart)
+        self._s_sender = s_sender
+
+    def as_context_get_shadow(self):
+        # Backward compatibility
+        return self
+
+    def w_self(self):
+        # Backward compatibility
+        return self
 
-    def receiver(self):
+    def pc(self):
+        return self._pc
+
+    def store_pc(self, pc):
+        self._pc = pc
+
+    def w_receiver(self):
         " Return self of the method, or the method that contains the block "
-        return self.w_home.w_receiver
-    
+        return self.s_home().w_receiver()
+
+    def s_home(self):
+        return self._s_home
+
+    def s_sender(self):
+        if self._s_sender:
+            return self._s_sender    
+
+    def store_s_sender(self, s_sender):
+        self._s_sender = s_sender
+
     # ______________________________________________________________________
     # Imitate the primitive accessors
     
     def fetch(self, index):
         from pypy.lang.smalltalk import utility, objtable
         if index == constants.CTXPART_SENDER_INDEX:
-            if self.w_sender:
-                return self.w_sender
-            else:
+            sender = self.s_sender()
+            if sender is None:
                 return objtable.w_nil
+            else:
+                return sender.w_self()
         elif index == constants.CTXPART_PC_INDEX:
-            return utility.wrap_int(self.pc)
+            return utility.wrap_int(self.pc())
         elif index == constants.CTXPART_STACKP_INDEX:
             return utility.wrap_int(len(self.stack))
         
@@ -496,25 +534,32 @@
 
         from pypy.lang.smalltalk import utility, objtable
         if index == constants.CTXPART_SENDER_INDEX:
-            self.w_sender = w_value
+            if w_value != objtable.w_nil:
+                self._s_sender = w_value.as_context_get_shadow()
         elif index == constants.CTXPART_PC_INDEX:
-            self.pc = utility.unwrap_int(w_value)
+            self._pc = utility.unwrap_int(w_value)
         elif index == constants.CTXPART_STACKP_INDEX:
-            self.stack = [objtable.w_nil] * utility.unwrap_int(w_value)
+            size = utility.unwrap_int(w_value)
+            size = size - self.stackstart()
+            self.stack = [objtable.w_nil] * size
         else:
             # Invalid!
             raise IndexError
 
+    def stackstart(self):
+        return self.w_method().argsize + self.w_method().tempsize + constants.MTHDCTX_TEMP_FRAME_START
+
     # ______________________________________________________________________
     # Method that contains the bytecode for this method/block context
 
     def w_method(self):
-        return self.w_home._w_method
+        return self.s_home().w_method()
 
     def getbytecode(self):
-        bytecode = self.w_method().bytes[self.pc]
+        pc = self.pc()
+        bytecode = self.w_method().bytes[pc]
         currentBytecode = ord(bytecode)
-        self.pc = self.pc + 1
+        self.store_pc(pc + 1)
         return currentBytecode
 
     def getNextBytecode(self):
@@ -527,10 +572,10 @@
     # Are always fetched relative to the home method context.
     
     def gettemp(self, index):
-        return self.w_home.temps[index]
+        return self.s_home().gettemp(index)
 
     def settemp(self, index, w_value):
-        self.w_home.temps[index] = w_value
+        self.s_home().settemp(index, w_value)
 
     # ______________________________________________________________________
     # Stack Manipulation
@@ -569,10 +614,13 @@
     
 class W_BlockContext(W_ContextPart):
 
-    def __init__(self, w_home, w_sender, argcnt, initialip):
-        W_ContextPart.__init__(self, w_home, w_sender)
+    def __init__(self, s_home, s_sender, argcnt, initialip):
+        W_ContextPart.__init__(self, s_home, s_sender)
         self.argcnt = argcnt
-        self.initialip = initialip
+        self._initialip = initialip
+
+    def initialip(self):
+        return self._initialip
 
     def expected_argument_count(self):
         return self.argcnt
@@ -580,6 +628,10 @@
     def getclass(self):
         from pypy.lang.smalltalk.classtable import w_BlockContext
         return w_BlockContext
+
+    def as_blockcontext_get_shadow(self):
+        # Backwards compatibility
+        return self
     
     def fetch(self, index):
         from pypy.lang.smalltalk import utility
@@ -588,7 +640,7 @@
         elif index == constants.BLKCTX_INITIAL_IP_INDEX:
             return utility.wrap_int(self.initialip)
         elif index == constants.BLKCTX_HOME_INDEX:
-            return self.w_home
+            return self.s_home()
         elif index >= constants.BLKCTX_TEMP_FRAME_START:
             stack_index = len(self.stack) - index - 1
             return self.stack[stack_index]
@@ -604,8 +656,7 @@
         elif index == constants.BLKCTX_INITIAL_IP_INDEX:
             self.pc = utility.unwrap_int(value)
         elif index == constants.BLKCTX_HOME_INDEX:
-            assert isinstance(value, W_MethodContext)
-            self.w_home = value
+            self._s_home = value.as_methodcontext_get_shadow()
         elif index >= constants.BLKCTX_TEMP_FRAME_START:
             stack_index = len(self.stack) - index - 1
             self.stack[stack_index] = value
@@ -614,23 +665,33 @@
 
 class W_MethodContext(W_ContextPart):
     def __init__(self, w_method, w_receiver,
-                 arguments, w_sender=None):
-        W_ContextPart.__init__(self, self, w_sender)
+                 arguments, s_sender=None):
+        W_ContextPart.__init__(self, self, s_sender)
         self._w_method = w_method
-        self.w_receiver = w_receiver
+        self._w_receiver = w_receiver
         self.temps = arguments + [w_nil] * w_method.tempsize
 
+    def as_methodcontext_get_shadow(self):
+        # Backwards compatibility
+        return self
+
     def getclass(self):
         from pypy.lang.smalltalk.classtable import w_MethodContext
         return w_MethodContext
 
+    def w_receiver(self):
+        return self._w_receiver
+
+    def store_w_receiver(self, w_receiver):
+        self._w_receiver = w_receiver
+
     def fetch(self, index):
         if index == constants.MTHDCTX_METHOD:
             return self.w_method()
         elif index == constants.MTHDCTX_RECEIVER_MAP: # what is this thing?
             return w_nil
         elif index == constants.MTHDCTX_RECEIVER:
-            return self.w_receiver
+            return self._w_receiver
         elif index >= constants.MTHDCTX_TEMP_FRAME_START:
             # First set of indices are temporary variables:
             offset = index - constants.MTHDCTX_TEMP_FRAME_START
@@ -650,7 +711,7 @@
         elif index == constants.MTHDCTX_RECEIVER_MAP: # what is this thing?
             pass
         elif index == constants.MTHDCTX_RECEIVER:
-            self.w_receiver = w_object
+            self._w_receiver = w_object
         elif index >= constants.MTHDCTX_TEMP_FRAME_START:
             # First set of indices are temporary variables:
             offset = index - constants.MTHDCTX_TEMP_FRAME_START
@@ -664,6 +725,15 @@
         else:
             W_ContextPart.store(self, index, w_object)
 
+    def gettemp(self, idx):
+        return self.temps[idx]
+
+    def settemp(self, idx, w_value):
+        self.temps[idx] = w_value
+
+    def w_method(self):
+        return self._w_method
+
 
 # Use black magic to create w_nil without running the constructor,
 # thus allowing it to be used even in the constructor of its own

Modified: pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/objtable.py
==============================================================================
--- pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/objtable.py	(original)
+++ pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/objtable.py	Thu Feb 21 21:59:13 2008
@@ -30,5 +30,8 @@
 
 objtable = {}
 
-for name in constants.objects_needed_boot_vm:
-    objtable["w_" + name] = globals()["w_" + name]
+for name in constants.objects_in_special_object_table:
+    try:
+        objtable["w_" + name] = globals()["w_" + name]
+    except KeyError, e:
+        objtable["w_" + name ] = None

Modified: pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/primitives.py
==============================================================================
--- pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/primitives.py	(original)
+++ pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/primitives.py	Thu Feb 21 21:59:13 2008
@@ -68,7 +68,7 @@
                 w_result = func(interp, argument_count_m1)
                 if not no_result:
                     assert w_result is not None
-                    interp.w_active_context.push(w_result)
+                    interp.s_active_context.push(w_result)
                 return w_result
         else:
             len_unwrap_spec = len(unwrap_spec)
@@ -77,7 +77,7 @@
             unrolling_unwrap_spec = unrolling_iterable(enumerate(unwrap_spec))
             def wrapped(interp, argument_count_m1):
                 argument_count = argument_count_m1 + 1 # to account for the rcvr
-                frame = interp.w_active_context
+                frame = interp.s_active_context
                 assert argument_count == len_unwrap_spec
                 if len(frame.stack) < len_unwrap_spec:
                     raise PrimitiveFailedError()
@@ -104,7 +104,7 @@
                 frame.pop_n(len_unwrap_spec)   # only if no exception occurs!
                 if not no_result:
                     assert w_result is not None
-                    interp.w_active_context.push(w_result)
+                    interp.s_active_context.push(w_result)
         wrapped.func_name = "wrap_prim_" + name
         prim_table[code] = wrapped
         prim_table_implemented_only.append((code, wrapped))
@@ -611,7 +611,7 @@
 
 @expose_primitive(PRIMITIVE_BLOCK_COPY, unwrap_spec=[object, int])
 def func(interp, w_context, argcnt):
-    frame = interp.w_active_context
+    frame = interp.s_active_context
 
     # From B.B.: If receiver is a MethodContext, then it becomes
     # the new BlockContext's home context.  Otherwise, the home
@@ -619,20 +619,20 @@
     # Note that in our impl, MethodContext.w_home == self
     if not isinstance(w_context, model.W_ContextPart):
         raise PrimitiveFailedError()
-    w_method_context = w_context.w_home
+    s_method_context = w_context.as_context_get_shadow().s_home()
 
     # The block bytecodes are stored inline: so we skip past the
     # byteodes to invoke this primitive to find them (hence +2)
-    initialip = frame.pc + 2
-    w_new_context = model.W_BlockContext(
-        w_method_context, None, argcnt, initialip)
-    return w_new_context
+    initialip = frame.pc() + 2
+    s_new_context = model.W_BlockContext(
+        s_method_context, None, argcnt, initialip)
+    return s_new_context.w_self()
 
-def finalize_block_ctx(interp, w_block_ctx, frame):
+def finalize_block_ctx(interp, s_block_ctx, frame):
     # Set some fields
-    w_block_ctx.pc = w_block_ctx.initialip
-    w_block_ctx.w_sender = frame
-    interp.w_active_context = w_block_ctx
+    s_block_ctx.store_pc(s_block_ctx.initialip())
+    s_block_ctx.store_s_sender(frame)
+    interp.s_active_context = s_block_ctx
     
 @expose_primitive(PRIMITIVE_VALUE, no_result=True)
 def func(interp, argument_count):
@@ -642,31 +642,31 @@
     #  Rcvr | Arg 0 | Arg1 | Arg 2
     #
     
-    frame = interp.w_active_context
+    frame = interp.s_active_context
     
     # Validate that we have a block on the stack and that it received
     # the proper number of arguments:
     w_block_ctx = frame.peek(argument_count)
-    if not isinstance(w_block_ctx, model.W_BlockContext):
+    if w_block_ctx.getclass() != classtable.w_BlockContext:
         raise PrimitiveFailedError()
-    exp_arg_cnt = w_block_ctx.expected_argument_count()
+    s_block_ctx = w_block_ctx.as_blockcontext_get_shadow()
+    exp_arg_cnt = s_block_ctx.expected_argument_count()
     if argument_count != exp_arg_cnt: # exp_arg_cnt doesn't count self
         raise PrimitiveFailedError()
 
     # Initialize the block stack with the arguments that were
     # pushed.  Also pop the receiver.
     block_args = frame.pop_and_return_n(exp_arg_cnt)
-    w_block_ctx.push_all(block_args)
+    s_block_ctx.push_all(block_args)
 
     frame.pop()
-    finalize_block_ctx(interp, w_block_ctx, frame)
+    finalize_block_ctx(interp, s_block_ctx, frame)
     
 @expose_primitive(PRIMITIVE_VALUE_WITH_ARGS, unwrap_spec=[object, object],
                   no_result=True)
 def func(interp, w_block_ctx, w_args):
-    if not isinstance(w_block_ctx, model.W_BlockContext):
-        raise PrimitiveFailedError()
-    exp_arg_cnt = w_block_ctx.expected_argument_count()
+    s_block_ctx = w_block_ctx.as_blockcontext_get_shadow()
+    exp_arg_cnt = s_block_ctx.expected_argument_count()
 
     # Check that our arguments have pointers format and the right size:
     if w_args.getclass() != classtable.w_Array:
@@ -676,12 +676,12 @@
     
     # Push all the items from the array
     for i in range(exp_arg_cnt):
-        w_block_ctx.push(w_args.fetchvarpointer(i))
+        s_block_ctx.push(w_args.fetchvarpointer(i))
 
     # XXX Check original logic. Image does not test this anyway
     # because falls back to value + internal implementation
 
-    finalize_block_ctx(interp, w_block_ctx, interp.w_active_context)
+    finalize_block_ctx(interp, s_block_ctx, interp.s_active_context)
 
 @expose_primitive(PRIMITIVE_PERFORM)
 def func(interp, argcount):
@@ -694,11 +694,11 @@
     w_method = w_rcvr.shadow_of_my_class().lookup(sel)
     assert w_method
 
-    w_frame = w_method.create_frame(w_rcvr,
+    s_frame = w_method.create_frame(w_rcvr,
         [w_args.fetch(i) for i in range(w_args.size())])
 
-    w_frame.w_sender = interp.w_active_context
-    interp.w_active_context = w_frame
+    s_frame.store_s_sender(interp.s_active_context)
+    interp.s_active_context = s_frame
 
 
 @expose_primitive(PRIMITIVE_SIGNAL, unwrap_spec=[object])

Modified: pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/shadow.py
==============================================================================
--- pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/shadow.py	(original)
+++ pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/shadow.py	Thu Feb 21 21:59:13 2008
@@ -9,6 +9,9 @@
         """XXX This should get called whenever the base Smalltalk
         object changes."""
 
+    def w_self(self):
+        return self._w_self
+
 # ____________________________________________________________ 
 
 POINTERS = 0
@@ -29,7 +32,7 @@
     (i.e. used as the class of another Smalltalk object).
     """
     def __init__(self, w_self):
-        self.w_self = w_self
+        self._w_self = w_self
         self.invalidate()
 
     def invalidate(self):
@@ -47,7 +50,7 @@
 
         "Update the ClassShadow with data from the w_self class."
 
-        w_self = self.w_self
+        w_self = self._w_self
         # read and painfully decode the format
         classformat = utility.unwrap_int(
             w_self.fetch(constants.CLASS_FORMAT_INDEX))
@@ -126,7 +129,7 @@
 
     def new(self, extrasize=0):
         from pypy.lang.smalltalk import classtable
-        w_cls = self.w_self
+        w_cls = self._w_self
         
         if w_cls == classtable.w_BlockContext:
             return model.W_BlockContext(None, None, 0, 0)
@@ -212,23 +215,23 @@
         "NOT_RPYTHON"     # this is only for testing.
         assert isinstance(method, model.W_CompiledMethod)
         self.methoddict[selector] = method
-        method.w_compiledin = self.w_self
+        method.w_compiledin = self._w_self
 
 class LinkedListShadow(AbstractShadow):
     def __init__(self, w_self):
-        self.w_self = w_self
+        self._w_self = w_self
 
     def firstlink(self):
-        return self.w_self.at0(constants.FIRST_LINK_INDEX)
+        return self._w_self.at0(constants.FIRST_LINK_INDEX)
 
     def store_firstlink(self, w_object):
-        return self.w_self.atput0(constants.FIRST_LINK_INDEX, w_object)
+        return self._w_self.atput0(constants.FIRST_LINK_INDEX, w_object)
 
     def lastlink(self):
-        return self.w_self.at0(constants.LAST_LINK_INDEX)
+        return self._w_self.at0(constants.LAST_LINK_INDEX)
 
     def store_lastlink(self, w_object):
-        return self.w_self.atput0(constants.LAST_LINK_INDEX, w_object)
+        return self._w_self.atput0(constants.LAST_LINK_INDEX, w_object)
 
     def is_empty_list(self):
         from pypy.lang.smalltalk import objtable
@@ -259,14 +262,14 @@
     """A shadow for Smalltalk objects that are semaphores
     """
     def __init__(self, w_self):
-        self.w_self = w_self
+        self._w_self = w_self
 
     def put_to_sleep(self, s_process):
         priority = s_process.priority()
         s_scheduler = self.scheduler()
         w_process_lists = s_scheduler.process_lists()
         w_process_list = w_process_lists.at0(priority)
-        w_process_list.as_linkedlist_get_shadow().add_last_link(s_process.w_self)
+        w_process_list.as_linkedlist_get_shadow().add_last_link(s_process._w_self)
         s_process.store_my_list(w_process_list)
         
     def transfer_to(self, s_process, interp):
@@ -274,9 +277,9 @@
         s_scheduler = self.scheduler()
         s_old_process = s_scheduler.active_process()
         s_scheduler.store_active_process(s_process)
-        s_old_process.store_suspended_context(interp.w_active_context)
-        interp.w_active_context = s_process.suspended_context()
-        s_process.store_suspended_context(objtable.w_nil)
+        s_old_process.store_w_suspended_context(interp.s_active_context.w_self())
+        interp.s_active_context = s_process.s_suspended_context()
+        s_process.store_w_suspended_context(objtable.w_nil)
         #reclaimableContextCount := 0
 
     def scheduler(self):
@@ -300,62 +303,202 @@
     def synchronous_signal(self, interp):
         print "SYNCHRONOUS SIGNAL"
         if self.is_empty_list():
-            w_value = self.w_self.at0(constants.EXCESS_SIGNALS_INDEX)
+            w_value = self._w_self.at0(constants.EXCESS_SIGNALS_INDEX)
             w_value = utility.wrap_int(utility.unwrap_int(w_value) + 1)
-            self.w_self.atput0(constants.EXCESS_SIGNALS_INDEX, w_value)
+            self._w_self.atput0(constants.EXCESS_SIGNALS_INDEX, w_value)
         else:
             self.resume(self.remove_first_link_of_list(), interp)
 
 class LinkShadow(AbstractShadow):
     def __init__(self, w_self):
-        self.w_self = self
+        self._w_self = self
 
     def next(self):
-        return self.w_self.at0(constants.NEXT_LINK_INDEX)
+        return self._w_self.at0(constants.NEXT_LINK_INDEX)
 
     def store_next(self, w_object):
-        self.w_self.atput0(constants.NEXT_LINK_INDEX, w_object)
+        self._w_self.atput0(constants.NEXT_LINK_INDEX, w_object)
 
 class ProcessShadow(LinkShadow):
     """A shadow for Smalltalk objects that are processes
     """
     def __init__(self, w_self):
-        self.w_self = w_self
+        self._w_self = w_self
 
     def priority(self):
-        return utility.unwrap_int(self.w_self.at0(constants.PROCESS_PRIORITY_INDEX))
+        return utility.unwrap_int(self._w_self.at0(constants.PROCESS_PRIORITY_INDEX))
 
     def my_list(self):
-        return self.w_self.at0(constants.PROCESS_MY_LIST_INDEX)
+        return self._w_self.at0(constants.PROCESS_MY_LIST_INDEX)
 
     def store_my_list(self, w_object):
-        self.w_self.atput0(constants.PROCESS_MY_LIST_INDEX, w_object)
+        self._w_self.atput0(constants.PROCESS_MY_LIST_INDEX, w_object)
 
-    def suspended_context(self):
-        return self.w_self.at0(constants.PROCESS_SUSPENDED_CONTEXT_INDEX)
+    def s_suspended_context(self):
+        return self._w_self.fetch(constants.PROCESS_SUSPENDED_CONTEXT_INDEX).as_context_get_shadow()
 
-    def store_suspended_context(self, w_object):
-        self.w_self.atput0(constants.PROCESS_SUSPENDED_CONTEXT_INDEX, w_object)
+    def store_w_suspended_context(self, w_object):
+        self._w_self.atput0(constants.PROCESS_SUSPENDED_CONTEXT_INDEX, w_object)
 
 class AssociationShadow(AbstractShadow):
     def __init__(self, w_self):
-        self.w_self = w_self
+        self._w_self = w_self
 
     def key(self):
-        return self.w_self.at0(constants.ASSOCIATION_KEY_INDEX)
+        return self._w_self.at0(constants.ASSOCIATION_KEY_INDEX)
 
     def value(self):
-        return self.w_self.at0(constants.ASSOCIATION_VALUE_INDEX)
+        return self._w_self.at0(constants.ASSOCIATION_VALUE_INDEX)
 
 class SchedulerShadow(AbstractShadow):
     def __init__(self, w_self):
-        self.w_self = w_self
+        self._w_self = w_self
 
     def active_process(self):
-        return self.w_self.at0(constants.SCHEDULER_ACTIVE_PROCESS_INDEX).as_process_get_shadow()
+        return self._w_self.at0(constants.SCHEDULER_ACTIVE_PROCESS_INDEX).as_process_get_shadow()
 
     def store_active_process(self, w_object):
-        self.w_self.atput0(constants.SCHEDULER_ACTIVE_PROCESS_INDEX, w_object)
+        self._w_self.atput0(constants.SCHEDULER_ACTIVE_PROCESS_INDEX, w_object)
     
     def process_lists(self):
-        return self.w_self.at0(constants.SCHEDULER_PROCESS_LISTS_INDEX)
+        return self._w_self.at0(constants.SCHEDULER_PROCESS_LISTS_INDEX)
+
+class ContextPartShadow(AbstractShadow):
+
+    #__metaclass__ = extendabletype
+    
+    def __init__(self, w_self):
+        self._w_self = w_self
+
+    def s_home(self):
+        raise NotImplementedError()
+
+    def w_receiver(self):
+        " Return self of the method, or the method that contains the block "
+        return self.s_home().w_receiver()
+
+    def s_sender(self):
+        return self._w_self.fetch(constants.CTXPART_SENDER_INDEX).as_context_get_shadow()
+
+    def store_s_sender(self, s_sender):
+        self._w_self.store(constants.CTXPART_SENDER_INDEX, s_sender._w_self())
+
+    def pc(self):
+        return utility.unwrap_int(self._w_self.fetch(constants.CTXPART_PC_INDEX))
+
+    def store_pc(self, newpc):
+        self._w_self.store(constants.CTXPART_PC_INDEX, utility.wrap_int(newpc))
+
+    def stackpointer(self):
+        return utility.unwrap_int(self._w_self.fetch(constants.CTXPART_SENDER_STACKP_INDEX))
+
+    def store_stackpointer(self, pointer):
+        self._w_self.store(constants.CTXPART_SENDER_STACKP_INDEX,
+                          utility.wrap_int(pointer))
+
+    # ______________________________________________________________________
+    # Method that contains the bytecode for this method/block context
+
+    def w_method(self):
+        return self.s_home().w_method()
+
+    def getbytecode(self):
+        pc = self.pc()
+        bytecode = self.w_method().bytes[pc]
+        currentBytecode = ord(bytecode)
+        self.store_pc(pc + 1)
+        return currentBytecode
+
+    def getNextBytecode(self):
+        self.currentBytecode = self.getbytecode()
+        return self.currentBytecode
+
+    # ______________________________________________________________________
+    # Temporary Variables
+    #
+    # Are always fetched relative to the home method context.
+    
+    def gettemp(self, index):
+        return self.s_home().gettemp(index)
+
+    def settemp(self, index, w_value):
+        self.s_home().settemp(index, w_value)
+
+    # ______________________________________________________________________
+    # Stack Manipulation
+    def pop(self):
+        idx = self.stackpointer()
+        w_v = self._w_self.fetch(idx)
+        self.store_stackpointer(idx - 1)
+        return w_v
+
+    def push(self, w_v):
+        idx = self.stackpointer() + 1
+        self._w_self.store(idx, w_v)
+        self.store_stackpointer(idx)
+
+    def push_all(self, lst):
+        for x in lst:
+            self.push(x)
+
+    def top(self):
+        return self.peek(0)
+        
+    def peek(self, idx):
+        return self._w_self.fetch(self.stackpointer()-idx)
+
+    def pop_n(self, n):
+        assert n >= 0
+        assert n > (self.stackpointer() - self.stackstart())
+        self.store_stackpointer(self.stackpointer() - n)
+
+    def pop_and_return_n(self, n):
+        self.pop_n(n)
+        start = self.stackpointer() + 1
+        return [self._w_self.fetch(i) for i in range(start, start+n)]
+    
+class BlockContextShadow(ContextPartShadow):
+
+    def __init__(self, w_self):
+        self._w_self = w_self
+
+    def expected_argument_count(self):
+        return utility.unwrap_int(self._w_self.fetch(constants.BLKCTX_BLOCK_ARGUMENT_COUNT_INDEX))
+
+    def store_expected_argument_count(self, argc):
+        return self._w_self.store(constants.BLKCTX_BLOCK_ARGUMENT_COUNT_INDEX,
+                                 utility.wrap_int(argc))
+
+    def initialip(self):
+        return utility.unwrap_int(self._w_self.fetch(constants.BLKCTX_INITIAL_IP_INDEX))
+        
+    def s_home(self):
+        return self._w_self.fetch(constants.BLKCTX_HOME_INDEX).as_methodcontext_get_shadow()
+
+    def stackstart(self):
+        return constants.BLKCTX_TEMP_FRAME_START
+
+class MethodContextShadow(ContextPartShadow):
+    def __init__(self, w_self):
+        self._w_self = w_self
+
+    def w_method(self):
+        return self._w_self.fetch(constants.MTHDCTX_METHOD)
+
+    def w_receiver(self):
+        return self._w_self.fetch(constants.MTHDCTX_RECEIVER)
+
+    def store_w_receiver(self, w_receiver):
+        self._w_self.store(constants.MTHDCTX_RECEIVER, w_receiver)
+
+    def gettemp(self, index):
+        return self._w_self.fetch(constants.MTHDCTX_TEMP_FRAME_START + index)
+
+    def settemp(self, index, w_value):
+        self._w_self.store(constants.MTHDCTX_TEMP_FRAME_START + index, w_value) 
+
+    def s_home(self):
+        return self
+
+    def stackstart(self):
+        return self.w_method().argsize + self.w_method().tempsize + constants.MTHDCTX_TEMP_FRAME_START

Modified: pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/squeakimage.py
==============================================================================
--- pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/squeakimage.py	(original)
+++ pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/squeakimage.py	Thu Feb 21 21:59:13 2008
@@ -123,25 +123,15 @@
         for chunk in self.chunks.itervalues():
             chunk.g_object.init_w_object()
 
-    def class_indxs(self):
-        from pypy.lang.smalltalk import constants
-        return map(lambda key: (key, constants.classes_in_special_object_table[key]),
-                                     constants.classes_needed_boot_vm)
-
-    def object_indxs(self):
-        from pypy.lang.smalltalk import constants
-        return map(lambda key: (key, constants.objects_in_special_object_table[key]),
-                                     constants.objects_needed_boot_vm)
-
     def assign_prebuilt_constants(self):
         from pypy.lang.smalltalk import classtable, constants, objtable
         # assign w_objects for objects that are already in classtable
-        for name, so_index in self.class_indxs():
+        for name, so_index in constants.classes_in_special_object_table.items():
             # w_object = getattr(classtable, "w_" + name)
             w_object = classtable.classtable["w_" + name]
             self.special_object(so_index).w_object = w_object
         # assign w_objects for objects that are already in objtable
-        for name, so_index in self.object_indxs():
+        for name, so_index in constants.objects_in_special_object_table.items():
             # w_object = getattr(objtable, "w_" + name)
             w_object = objtable.objtable["w_" + name]
             self.special_object(so_index).w_object = w_object
@@ -211,14 +201,8 @@
         self.special_objects = [g_object.w_object for g_object in
                                 reader.chunks[reader.specialobjectspointer]
                                 .g_object.pointers]
-        # After loading we know of more classes than before. Copy back.
-        for name, so_index in constants.classes_in_special_object_table.items():
-            classtable.classtable["w_" + name] = self.special(so_index)
 
-        # After loading we know of more objects than before. Copy back.
         self.objects = [chunk.g_object.w_object for chunk in reader.chunklist]
-        for name, so_index in constants.objects_in_special_object_table.items():
-            objtable.objtable["w_" + name] = self.special(so_index)
 
     def special(self, index):
         return self.special_objects[index]

Modified: pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_interpreter.py
==============================================================================
--- pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_interpreter.py	(original)
+++ pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_interpreter.py	Thu Feb 21 21:59:13 2008
@@ -74,7 +74,7 @@
     w_method.tempsize=1
     w_frame = w_method.create_frame(receiver, ["foo", "bar"])
     interp = interpreter.Interpreter()
-    interp.w_active_context = w_frame
+    interp.s_active_context = w_frame.as_methodcontext_get_shadow()
     return interp
 
 def test_create_frame():
@@ -83,7 +83,7 @@
     w_method.argsize=2
     w_method.tempsize=1
     w_frame = w_method.create_frame("receiver", ["foo", "bar"])
-    assert w_frame.w_receiver == "receiver"
+    assert w_frame.w_receiver() == "receiver"
     assert w_frame.gettemp(0) == "foo"
     assert w_frame.gettemp(1) == "bar"
     assert w_frame.gettemp(2) is objtable.w_nil
@@ -95,7 +95,7 @@
 
 def test_push_pop():
     interp = new_interpreter("")
-    frame = interp.w_active_context
+    frame = interp.s_active_context
     frame.push(12)
     frame.push(34)
     frame.push(56)
@@ -116,7 +116,7 @@
 def test_pushReceiverBytecode():
     interp = new_interpreter(pushReceiverBytecode)
     interp.step()
-    assert interp.w_active_context.top() == interp.w_active_context.w_receiver
+    assert interp.s_active_context.top() == interp.s_active_context.w_receiver()
 
 def test_pushReceiverVariableBytecode(bytecode = (pushReceiverVariableBytecode(0) +
                                                   pushReceiverVariableBytecode(1) +
@@ -129,27 +129,27 @@
     interp.step()
     interp.step()
     interp.step()
-    assert interp.w_active_context.stack == ["egg", "bar", "baz"]
+    assert interp.s_active_context.stack == ["egg", "bar", "baz"]
 
 def test_pushTemporaryVariableBytecode(bytecode=(pushTemporaryVariableBytecode(0) +
                                                  pushTemporaryVariableBytecode(1) +
                                                  pushTemporaryVariableBytecode(2))):
     interp = new_interpreter(bytecode)
-    interp.w_active_context.settemp(2, "temp")
+    interp.s_active_context.settemp(2, "temp")
     interp.step()
     interp.step()
     interp.step()
-    assert interp.w_active_context.stack == ["foo", "bar", "temp"]
+    assert interp.s_active_context.stack == ["foo", "bar", "temp"]
 
 def test_pushLiteralConstantBytecode(bytecode=pushLiteralConstantBytecode(0) +
                                               pushLiteralConstantBytecode(1) +
                                               pushLiteralConstantBytecode(2)):
     interp = new_interpreter(bytecode)
-    interp.w_active_context.w_method().literals = fakeliterals("a", "b", "c")
+    interp.s_active_context.w_method().literals = fakeliterals("a", "b", "c")
     interp.step()
     interp.step()
     interp.step()
-    assert interp.w_active_context.stack == [fakesymbol("a"),
+    assert interp.s_active_context.stack == [fakesymbol("a"),
                                              fakesymbol("b"),
                                              fakesymbol("c")]
 
@@ -158,9 +158,9 @@
     w_association.store(0, "mykey")
     w_association.store(1, "myvalue")
     interp = new_interpreter(bytecode)
-    interp.w_active_context.w_method().literals = fakeliterals(w_association)
+    interp.s_active_context.w_method().literals = fakeliterals(w_association)
     interp.step()
-    assert interp.w_active_context.stack == ["myvalue"]
+    assert interp.s_active_context.stack == ["myvalue"]
 
 def test_storeAndPopReceiverVariableBytecode(bytecode=storeAndPopReceiverVariableBytecode,
                                              popped=True):
@@ -168,13 +168,13 @@
     for index in range(8):
         w_object = shadow.new()
         interp = new_interpreter(pushConstantTrueBytecode + bytecode(index))
-        interp.w_active_context.w_receiver = w_object
+        interp.s_active_context.store_w_receiver(w_object)
         interp.step()
         interp.step()
         if popped:
-            assert interp.w_active_context.stack == []
+            assert interp.s_active_context.stack == []
         else:
-            assert interp.w_active_context.stack == [interp.TRUE]
+            assert interp.s_active_context.stack == [interp.TRUE]
 
         for test_index in range(8):
             if test_index == index:
@@ -185,167 +185,167 @@
 def test_storeAndPopTemporaryVariableBytecode(bytecode=storeAndPopTemporaryVariableBytecode):
     for index in range(8):
         interp = new_interpreter(pushConstantTrueBytecode + bytecode(index))
-        interp.w_active_context.temps = [None] * 8
+        interp.s_active_context.temps = [None] * 8
         interp.step()
         interp.step()
-        assert interp.w_active_context.stack == []
+        assert interp.s_active_context.stack == []
         for test_index in range(8):
             if test_index == index:
-                assert interp.w_active_context.temps[test_index] == interp.TRUE
+                assert interp.s_active_context.temps[test_index] == interp.TRUE
             else:
-                assert interp.w_active_context.temps[test_index] == None
+                assert interp.s_active_context.temps[test_index] == None
 
 def test_pushConstantTrueBytecode():
     interp = new_interpreter(pushConstantTrueBytecode)
     interp.step()
-    assert interp.w_active_context.pop() == interp.TRUE
-    assert interp.w_active_context.stack == []
+    assert interp.s_active_context.pop() == interp.TRUE
+    assert interp.s_active_context.stack == []
 
 def test_pushConstantFalseBytecode():
     interp = new_interpreter(pushConstantFalseBytecode)
     interp.step()
-    assert interp.w_active_context.pop() == interp.FALSE
-    assert interp.w_active_context.stack == []
+    assert interp.s_active_context.pop() == interp.FALSE
+    assert interp.s_active_context.stack == []
 
 def test_pushConstantNilBytecode():
     interp = new_interpreter(pushConstantNilBytecode)
     interp.step()
-    assert interp.w_active_context.pop() == interp.NIL
-    assert interp.w_active_context.stack == []
+    assert interp.s_active_context.pop() == interp.NIL
+    assert interp.s_active_context.stack == []
 
 def test_pushConstantMinusOneBytecode():
     interp = new_interpreter(pushConstantMinusOneBytecode)
     interp.step()
-    assert interp.w_active_context.pop() == interp.MINUS_ONE
-    assert interp.w_active_context.stack == []
+    assert interp.s_active_context.pop() == interp.MINUS_ONE
+    assert interp.s_active_context.stack == []
 
 def test_pushConstantZeroBytecode():
     interp = new_interpreter(pushConstantZeroBytecode)
     interp.step()
-    assert interp.w_active_context.pop() == interp.ZERO
-    assert interp.w_active_context.stack == []
+    assert interp.s_active_context.pop() == interp.ZERO
+    assert interp.s_active_context.stack == []
     
 def test_pushConstantOneBytecode():
     interp = new_interpreter(pushConstantOneBytecode)
     interp.step()
-    assert interp.w_active_context.pop() == interp.ONE
-    assert interp.w_active_context.stack == []
+    assert interp.s_active_context.pop() == interp.ONE
+    assert interp.s_active_context.stack == []
 
 def test_pushConstantTwoBytecode():
     interp = new_interpreter(pushConstantTwoBytecode)
     interp.step()
-    assert interp.w_active_context.pop() == interp.TWO
-    assert interp.w_active_context.stack == []
+    assert interp.s_active_context.pop() == interp.TWO
+    assert interp.s_active_context.stack == []
 
 def test_pushActiveContextBytecode():
     interp = new_interpreter(pushActiveContextBytecode)
     interp.step()
-    assert interp.w_active_context.pop() == interp.w_active_context
-    assert interp.w_active_context.stack == []
+    assert interp.s_active_context.pop() == interp.s_active_context.w_self()
+    assert interp.s_active_context.stack == []
     
 def test_duplicateTopBytecode():
     interp = new_interpreter(pushConstantZeroBytecode + duplicateTopBytecode)
     interp.step()
     interp.step()
-    assert interp.w_active_context.stack == [interp.ZERO, interp.ZERO]
+    assert interp.s_active_context.stack == [interp.ZERO, interp.ZERO]
     
 def test_bytecodePrimBitAnd():
     interp = new_interpreter(pushConstantOneBytecode + pushConstantTwoBytecode + bytecodePrimBitAnd)
     interp.step()
     interp.step()
     interp.step()
-    assert interp.w_active_context.pop().value == 0
-    assert interp.w_active_context.stack == []
+    assert interp.s_active_context.pop().value == 0
+    assert interp.s_active_context.stack == []
     
 def test_bytecodePrimBitOr():
     interp = new_interpreter(pushConstantOneBytecode + pushConstantTwoBytecode + bytecodePrimBitOr)
     interp.step()
     interp.step()
     interp.step()
-    assert interp.w_active_context.pop().value == 3
-    assert interp.w_active_context.stack == []
+    assert interp.s_active_context.pop().value == 3
+    assert interp.s_active_context.stack == []
 
 def test_bytecodePrimBitShift():
     interp = new_interpreter(pushConstantOneBytecode + pushConstantTwoBytecode + bytecodePrimBitShift)
     interp.step()
     interp.step()
     interp.step()
-    assert interp.w_active_context.pop().value == 4
-    assert interp.w_active_context.stack == []
+    assert interp.s_active_context.pop().value == 4
+    assert interp.s_active_context.stack == []
     
 def test_bytecodePrimClass():
     interp = new_interpreter(pushConstantOneBytecode + bytecodePrimClass)
     interp.step()
     interp.step()
-    assert interp.w_active_context.pop() == classtable.w_SmallInteger
-    assert interp.w_active_context.stack == []
+    assert interp.s_active_context.pop() == classtable.w_SmallInteger
+    assert interp.s_active_context.stack == []
     
 def test_bytecodePrimSubtract():
     interp = new_interpreter(pushConstantOneBytecode + pushConstantTwoBytecode + bytecodePrimSubtract)
     interp.step()
     interp.step()
     interp.step()
-    assert interp.w_active_context.pop().value == -1
-    assert interp.w_active_context.stack == []
+    assert interp.s_active_context.pop().value == -1
+    assert interp.s_active_context.stack == []
 
 def test_bytecodePrimMultiply():
     interp = new_interpreter(pushConstantMinusOneBytecode + pushConstantTwoBytecode + bytecodePrimMultiply)
     interp.step()
     interp.step()
     interp.step()
-    assert interp.w_active_context.pop().value == -2
-    assert interp.w_active_context.stack == []
+    assert interp.s_active_context.pop().value == -2
+    assert interp.s_active_context.stack == []
     
 def test_bytecodePrimDivide():
     interp = new_interpreter(pushConstantTwoBytecode + pushConstantMinusOneBytecode + bytecodePrimDivide)
     interp.step()
     interp.step()
     interp.step()
-    assert interp.w_active_context.pop().value == -2    
-    assert interp.w_active_context.stack == []
+    assert interp.s_active_context.pop().value == -2    
+    assert interp.s_active_context.stack == []
     
 def test_bytecodePrimDiv():
     interp = new_interpreter(pushConstantTwoBytecode + pushConstantMinusOneBytecode + bytecodePrimDiv)
     interp.step()
     interp.step()
     interp.step()
-    assert interp.w_active_context.pop().value == -2
-    assert interp.w_active_context.stack == []
+    assert interp.s_active_context.pop().value == -2
+    assert interp.s_active_context.stack == []
 
 def test_bytecodePrimMod():
     interp = new_interpreter(pushConstantTwoBytecode + pushConstantMinusOneBytecode + bytecodePrimMod)
     interp.step()
     interp.step()
     interp.step()
-    assert interp.w_active_context.pop().value == 0
-    assert interp.w_active_context.stack == []
+    assert interp.s_active_context.pop().value == 0
+    assert interp.s_active_context.stack == []
 
 def test_bytecodePrimEquivalent():
     interp = new_interpreter(pushConstantTwoBytecode + pushConstantMinusOneBytecode + bytecodePrimEquivalent)
     interp.step()
     interp.step()
     interp.step()
-    assert interp.w_active_context.pop() == interpreter.Interpreter.FALSE
-    assert interp.w_active_context.stack == []
+    assert interp.s_active_context.pop() == interpreter.Interpreter.FALSE
+    assert interp.s_active_context.stack == []
     
     interp = new_interpreter(pushConstantOneBytecode + pushConstantOneBytecode + bytecodePrimEquivalent)
     interp.step()
     interp.step()
     interp.step()
-    assert interp.w_active_context.pop() == interpreter.Interpreter.TRUE
-    assert interp.w_active_context.stack == []
+    assert interp.s_active_context.pop() == interpreter.Interpreter.TRUE
+    assert interp.s_active_context.stack == []
     
 def test_bytecodePrimNew():
     w_fakeclassclass = mockclass(10, name='fakeclassclass')
     w_fakeclass = mockclass(1, name='fakeclass', varsized=False,
                             w_metaclass=w_fakeclassclass)
     interp = new_interpreter(bytecodePrimNew)
-    interp.w_active_context.push(w_fakeclass)
+    interp.s_active_context.push(w_fakeclass)
     run_with_faked_methods(
         [[w_fakeclassclass, primitives.NEW, 0, "new"]],
         interp.step)
-    w_fakeinst = interp.w_active_context.pop()
-    assert interp.w_active_context.stack == []
+    w_fakeinst = interp.s_active_context.pop()
+    assert interp.s_active_context.stack == []
     assert w_fakeinst.getclass() == w_fakeclass
     assert w_fakeinst.size() == 1
     
@@ -354,13 +354,13 @@
     w_fakeclass = mockclass(1, name='fakeclass', varsized=True,
                             w_metaclass=w_fakeclassclass)
     interp = new_interpreter(bytecodePrimNewWithArg)
-    interp.w_active_context.push(w_fakeclass)
-    interp.w_active_context.push(interpreter.Interpreter.TWO)
+    interp.s_active_context.push(w_fakeclass)
+    interp.s_active_context.push(interpreter.Interpreter.TWO)
     run_with_faked_methods(
         [[w_fakeclassclass, primitives.NEW_WITH_ARG, 1, "new:"]],
         interp.step)
-    w_fakeinst = interp.w_active_context.pop()
-    assert interp.w_active_context.stack == []
+    w_fakeinst = interp.s_active_context.pop()
+    assert interp.s_active_context.stack == []
     assert w_fakeinst.getclass() == w_fakeclass
     assert w_fakeinst.size() == 3
  
@@ -368,12 +368,12 @@
     w_fakeclass = mockclass(2, name='fakeclass', varsized=True)
     w_fakeinst = w_fakeclass.as_class_get_shadow().new(5)
     interp = new_interpreter(bytecodePrimSize)
-    interp.w_active_context.push(w_fakeinst)
+    interp.s_active_context.push(w_fakeinst)
     run_with_faked_methods(
         [[w_fakeclass, primitives.SIZE, 0, "size"]],
         interp.step)
-    assert interp.w_active_context.pop().value == 5
-    assert interp.w_active_context.stack == []
+    assert interp.s_active_context.pop().value == 5
+    assert interp.s_active_context.stack == []
 
 # w_class - the class from which the method is going to be called
 # (and on which it is going to be installed)
@@ -390,19 +390,19 @@
         w_method.bytes = pushConstantOneBytecode + bytecode
         shadow.installmethod("foo", w_method)
         interp = new_interpreter(bytecodes)
-        interp.w_active_context.w_method().literals = fakeliterals("foo")
-        interp.w_active_context.push(w_object)
-        callerContext = interp.w_active_context
-        interp.step()
-        assert interp.w_active_context.w_sender == callerContext
-        assert interp.w_active_context.stack == []
-        assert interp.w_active_context.w_receiver == w_object
-        assert interp.w_active_context.w_method() == shadow.methoddict["foo"]
+        interp.s_active_context.w_method().literals = fakeliterals("foo")
+        interp.s_active_context.push(w_object)
+        callerContext = interp.s_active_context
+        interp.step()
+        assert interp.s_active_context.s_sender() == callerContext
+        assert interp.s_active_context.stack == []
+        assert interp.s_active_context.w_receiver() == w_object
+        assert interp.s_active_context.w_method() == shadow.methoddict["foo"]
         assert callerContext.stack == []
         interp.step()
         interp.step()
-        assert interp.w_active_context == callerContext
-        assert interp.w_active_context.stack == [result]
+        assert interp.s_active_context == callerContext
+        assert interp.s_active_context.stack == [result]
 
 def test_sendLiteralSelectorBytecode():
     w_class = mockclass(0)
@@ -420,9 +420,9 @@
     shadow.installmethod("fib:", method)
     w_object = shadow.new()
     interp = new_interpreter(sendLiteralSelectorBytecode(16) + returnTopFromMethod)
-    interp.w_active_context.w_method().literals = fakeliterals("fib:")
-    interp.w_active_context.push(w_object)
-    interp.w_active_context.push(wrap_int(8))
+    interp.s_active_context.w_method().literals = fakeliterals("fib:")
+    interp.s_active_context.push(w_object)
+    interp.s_active_context.push(wrap_int(8))
     result = interp.interpret()
     assert unwrap_int(result) == 34
 
@@ -430,14 +430,14 @@
 
     def test():
         interp = new_interpreter(sendLiteralSelectorBytecode(1 + 16))
-        interp.w_active_context.w_method().literals = fakeliterals("foo", "sub")
-        interp.w_active_context.push(wrap_int(50))
-        interp.w_active_context.push(wrap_int(8))
-        callerContext = interp.w_active_context
-        interp.step()
-        assert interp.w_active_context is callerContext
-        assert len(interp.w_active_context.stack) == 1
-        w_result = interp.w_active_context.pop()
+        interp.s_active_context.w_method().literals = fakeliterals("foo", "sub")
+        interp.s_active_context.push(wrap_int(50))
+        interp.s_active_context.push(wrap_int(8))
+        callerContext = interp.s_active_context
+        interp.step()
+        assert interp.s_active_context is callerContext
+        assert len(interp.s_active_context.stack) == 1
+        w_result = interp.s_active_context.pop()
         assert unwrap_int(w_result) == 42
         
     run_with_faked_methods(
@@ -447,58 +447,58 @@
 
 def test_longJumpIfTrue():
     interp = new_interpreter(longJumpIfTrue(0) + chr(15) + longJumpIfTrue(0) + chr(15))
-    interp.w_active_context.push(interp.FALSE)
-    pc = interp.w_active_context.pc + 2
+    interp.s_active_context.push(interp.FALSE)
+    pc = interp.s_active_context.pc() + 2
     interp.step()
-    assert interp.w_active_context.pc == pc
-    interp.w_active_context.push(interp.TRUE)
-    pc = interp.w_active_context.pc + 2
+    assert interp.s_active_context.pc() == pc
+    interp.s_active_context.push(interp.TRUE)
+    pc = interp.s_active_context.pc() + 2
     interp.step()
-    assert interp.w_active_context.pc == pc + 15
+    assert interp.s_active_context.pc() == pc + 15
 
 def test_longJumpIfFalse():
     interp = new_interpreter(pushConstantTrueBytecode + longJumpIfFalse(0) + chr(15) +
                              pushConstantFalseBytecode + longJumpIfFalse(0) + chr(15))
     interp.step()
-    pc = interp.w_active_context.pc + 2
+    pc = interp.s_active_context.pc() + 2
     interp.step()
-    assert interp.w_active_context.pc == pc
+    assert interp.s_active_context.pc() == pc
     interp.step()
-    pc = interp.w_active_context.pc + 2
+    pc = interp.s_active_context.pc() + 2
     interp.step()
-    assert interp.w_active_context.pc == pc + 15
+    assert interp.s_active_context.pc() == pc + 15
 
 def test_longUnconditionalJump():
     interp = new_interpreter(longUnconditionalJump(4) + chr(15))
-    pc = interp.w_active_context.pc + 2
+    pc = interp.s_active_context.pc() + 2
     interp.step()
-    assert interp.w_active_context.pc == pc + 15
+    assert interp.s_active_context.pc() == pc + 15
 
 def test_shortUnconditionalJump():
     interp = new_interpreter(chr(145))
-    pc = interp.w_active_context.pc + 1
+    pc = interp.s_active_context.pc() + 1
     interp.step()
-    assert interp.w_active_context.pc == pc + 2
+    assert interp.s_active_context.pc() == pc + 2
 
 def test_shortConditionalJump():
     interp = new_interpreter(pushConstantTrueBytecode + shortConditionalJump(3) +
                              pushConstantFalseBytecode + shortConditionalJump(3))
     interp.step()
-    pc = interp.w_active_context.pc + 1
+    pc = interp.s_active_context.pc() + 1
     interp.step()
-    assert interp.w_active_context.pc == pc
+    assert interp.s_active_context.pc() == pc
     interp.step()
-    pc = interp.w_active_context.pc + 1
+    pc = interp.s_active_context.pc() + 1
     interp.step()
-    assert interp.w_active_context.pc == pc + 4
+    assert interp.s_active_context.pc() == pc + 4
 
 def test_popStackBytecode():
     interp = new_interpreter(pushConstantTrueBytecode +
                              popStackBytecode)
     interp.step()
-    assert interp.w_active_context.stack == [interp.TRUE]
+    assert interp.s_active_context.stack == [interp.TRUE]
     interp.step()
-    assert interp.w_active_context.stack == []
+    assert interp.s_active_context.stack == []
 
 def test_extendedPushBytecode():
     test_pushReceiverVariableBytecode(extendedPushBytecode + chr((0<<6) + 0) +
@@ -520,7 +520,7 @@
     w_association.store(0, "mykey")
     w_association.store(1, "myvalue")
     interp = new_interpreter(pushConstantOneBytecode + bytecode)
-    interp.w_active_context.w_method().literals = fakeliterals(w_association)
+    interp.s_active_context.w_method().literals = fakeliterals(w_association)
     interp.step()
     interp.step()
     assert w_association.fetch(1) == interp.ONE
@@ -545,13 +545,13 @@
     shadow.installmethod("+", w_method) 
     
     w_object = shadow.new()
-    interp.w_active_context.push(w_object)
-    interp.w_active_context.push(interp.ONE)
+    interp.s_active_context.push(w_object)
+    interp.s_active_context.push(interp.ONE)
     interp.step()
-    assert interp.w_active_context.w_method() == shadow.methoddict["+"]
-    assert interp.w_active_context.w_receiver is w_object
-    assert interp.w_active_context.gettemp(0) == interp.ONE
-    assert interp.w_active_context.stack == []
+    assert interp.s_active_context.w_method() == shadow.methoddict["+"]
+    assert interp.s_active_context.w_receiver() is w_object
+    assert interp.s_active_context.gettemp(0) == interp.ONE
+    assert interp.s_active_context.stack == []
 
 def test_bytecodePrimBool():
     interp = new_interpreter(bytecodePrimLessThan +
@@ -561,10 +561,10 @@
                              bytecodePrimEqual +
                              bytecodePrimNotEqual)
     for i in range(6):
-        interp.w_active_context.push(interp.ONE)
-        interp.w_active_context.push(interp.TWO)
+        interp.s_active_context.push(interp.ONE)
+        interp.s_active_context.push(interp.TWO)
         interp.step()
-    assert interp.w_active_context.stack == [interp.TRUE, interp.FALSE,
+    assert interp.s_active_context.stack == [interp.TRUE, interp.FALSE,
                                           interp.TRUE, interp.FALSE,
                                           interp.FALSE, interp.TRUE]
 
@@ -593,18 +593,18 @@
     meth1.literals = fakeliterals("foo")
     meth2.literals = fakeliterals("foo")
     interp = new_interpreter(bytecodes)
-    interp.w_active_context.w_method().literals = fakeliterals("foo")
-    interp.w_active_context.push(w_object)
+    interp.s_active_context.w_method().literals = fakeliterals("foo")
+    interp.s_active_context.push(w_object)
     interp.step()
     for w_specificclass in [w_super, w_supersuper]:
-        callerContext = interp.w_active_context
+        callerContext = interp.s_active_context
         interp.step()
         interp.step()
-        assert interp.w_active_context.w_sender == callerContext
-        assert interp.w_active_context.stack == []
-        assert interp.w_active_context.w_receiver == w_object
+        assert interp.s_active_context.s_sender() == callerContext
+        assert interp.s_active_context.stack == []
+        assert interp.s_active_context.w_receiver() == w_object
         meth = w_specificclass.as_class_get_shadow().methoddict["foo"]
-        assert interp.w_active_context.w_method() == meth
+        assert interp.s_active_context.w_method() == meth
         assert callerContext.stack == []
 
 def test_secondExtendedSendBytecode():
@@ -639,7 +639,7 @@
 def interpret_bc(bcodes, literals, receiver=objtable.w_nil):
     bcode = "".join([chr(x) for x in bcodes])
     interp = new_interpreter(bcode, receiver=receiver)
-    interp.w_active_context.w_method().literals = literals
+    interp.s_active_context.w_method().literals = literals
     return interp.interpret()
 
 # tests: bytecodePrimValue & bytecodePrimValueWithArg

Modified: pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_miniimage.py
==============================================================================
--- pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_miniimage.py	(original)
+++ pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_miniimage.py	Thu Feb 21 21:59:13 2008
@@ -200,15 +200,15 @@
     w_method = s_class.lookup("abs")
 
     assert w_method
-    w_frame = w_method.create_frame(w_object, [])
-    interp.w_active_context = w_frame
+    s_frame = w_method.create_frame(w_object, [])
+    interp.s_active_context = s_frame
 
     print w_method
 
     while True:
         try:
             interp.step()
-            print interp.w_active_context.stack
+            print interp.s_active_context.stack
         except interpreter.ReturnFromTopLevel, e:
             assert e.object.value == abs(int)
             return
@@ -258,12 +258,12 @@
     s_class = w_receiver.shadow_of_my_class()
     w_method = s_class.lookup(selector)
     assert w_method
-    w_frame = w_method.create_frame(w_receiver, list(arguments_w))
-    interp.w_active_context = w_frame
+    s_frame = w_method.create_frame(w_receiver, list(arguments_w))
+    interp.s_active_context = s_frame
     while True:
         try:
             interp.step()
-            #print interp.w_active_context.stack
+            #print interp.s_active_context.stack
         except interpreter.ReturnFromTopLevel, e:
             return e.object.value
         

Modified: pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_primitives.py
==============================================================================
--- pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_primitives.py	(original)
+++ pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_primitives.py	Thu Feb 21 21:59:13 2008
@@ -25,24 +25,24 @@
     mapped_stack = [wrap(x) for x in stack]
     frame = MockFrame(mapped_stack)
     interp = interpreter.Interpreter()
-    interp.w_active_context = frame
+    interp.s_active_context = frame
     return (interp, len(stack))
 
 def prim(code, stack):
     interp, argument_count = mock(stack)
     prim_table[code](interp, argument_count-1)
-    res = interp.w_active_context.pop()
-    assert not len(interp.w_active_context.stack) # check args are consumed
+    res = interp.s_active_context.pop()
+    assert not len(interp.s_active_context.stack) # check args are consumed
     return res
 
 def prim_fails(code, stack):
     interp, argument_count = mock(stack)
-    orig_stack = list(interp.w_active_context.stack)
+    orig_stack = list(interp.s_active_context.stack)
     try:
         prim_table[code](interp, argument_count-1)
         py.test.fail("Expected PrimitiveFailedError")
     except PrimitiveFailedError:
-        assert interp.w_active_context.stack == orig_stack
+        assert interp.s_active_context.stack == orig_stack
         
 # smallinteger tests
 def test_small_int_add():



More information about the Pypy-commit mailing list