[pypy-svn] r47886 - pypy/dist/pypy/lang/smalltalk
lukas at codespeak.net
lukas at codespeak.net
Thu Oct 25 09:38:30 CEST 2007
Author: lukas
Date: Thu Oct 25 09:38:29 2007
New Revision: 47886
Modified:
pypy/dist/pypy/lang/smalltalk/constants.py
pypy/dist/pypy/lang/smalltalk/interpreter.py
Log:
use ASSOCIATION_VALUE_INDEX instead of magic number
Modified: pypy/dist/pypy/lang/smalltalk/constants.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/constants.py (original)
+++ pypy/dist/pypy/lang/smalltalk/constants.py Thu Oct 25 09:38:29 2007
@@ -11,12 +11,15 @@
CLASS_SUPERCLASS_INDEX = 0
CLASS_METHODDICT_INDEX = 1
-CLASS_FORMAT_INDEX = 2
-CLASS_NAME_INDEX = 6
+CLASS_FORMAT_INDEX = 2
+CLASS_NAME_INDEX = 6
METHODDICT_VALUES_INDEX = 1
METHODDICT_NAMES_INDEX = 2
+ASSOCIATION_KEY_INDEX = 0
+ASSOCIATION_VALUE_INDEX = 1
+
# ----- special objects indices -------
SO_NIL = 0
Modified: pypy/dist/pypy/lang/smalltalk/interpreter.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/interpreter.py (original)
+++ pypy/dist/pypy/lang/smalltalk/interpreter.py Thu Oct 25 09:38:29 2007
@@ -1,5 +1,5 @@
import py
-from pypy.lang.smalltalk import model, primitives
+from pypy.lang.smalltalk import model, constants, primitives
from pypy.lang.smalltalk import fakeimage
@@ -76,7 +76,7 @@
# named var (the value).
index = self.currentBytecode & 31
association = self.method.getliteral(index)
- self.push(association.fetch(1))
+ self.push(association.fetch(constants.ASSOCIATION_VALUE_INDEX))
def storeAndPopReceiverVariableBytecode(self, interp):
index = self.currentBytecode & 7
@@ -192,7 +192,7 @@
self.push(self.method.getliteral(variableIndex))
elif variableType == 3:
association = self.method.getliteral(variableIndex)
- self.push(association.fetch(1))
+ self.push(association.fetch(constants.ASSOCIATION_VALUE_INDEX))
def extendedStoreBytecode(self, interp):
variableType, variableIndex = self.extendedVariableTypeAndIndex()
@@ -204,7 +204,7 @@
raise IllegalStoreError
elif variableType == 3:
association = self.method.getliteral(variableIndex)
- association.store(1,self.top())
+ association.store(constants.ASSOCIATION_VALUE_INDEX, self.top())
def extendedStoreAndPopBytecode(self, interp):
self.extendedStoreBytecode(interp)
@@ -239,14 +239,14 @@
elif opType == 4:
# pushLiteralVariable
association = self.method.getliteral(third)
- self.push(association.fetch(1))
+ self.push(association.fetch(constants.ASSOCIATION_VALUE_INDEX))
elif opType == 5:
self.receiver.store(third, self.top())
elif opType == 6:
self.receiver.store(third, self.pop())
elif opType == 7:
association = self.method.getliteral(third)
- association.store(1,self.top())
+ association.store(constants.ASSOCIATION_VALUE_INDEX, self.top())
def singleExtendedSuperBytecode(self, interp):
selector, argcount = self.getExtendedSelectorArgcount()
More information about the Pypy-commit
mailing list