From: <th...@us...> - 2008-01-15 14:08:04
|
Revision: 4034 http://jython.svn.sourceforge.net/jython/?rev=4034&view=rev Author: thobes Date: 2008-01-15 06:07:56 -0800 (Tue, 15 Jan 2008) Log Message: ----------- Fixed a bug in exception matching by slighly moveing away from the CPython contract on what is supposed to be on the stack when an exception is caught. This needs to be tested further to ensure that it doesn't break anything, and then there is some documentation to update so that it corresonds to the new contract. CPython expects: [botom of stack] ... traceback, value, type Java gives us: [botom of stack] exceptionObject The new implementation: [botom of stack] ... traceback, value, exceptionObject Also updated the README with some information about how the ant build.xml script works for this directory. Modified Paths: -------------- trunk/sandbox/pyasm/README.txt trunk/sandbox/pyasm/pyasm.py Modified: trunk/sandbox/pyasm/README.txt =================================================================== --- trunk/sandbox/pyasm/README.txt 2008-01-15 05:23:27 UTC (rev 4033) +++ trunk/sandbox/pyasm/README.txt 2008-01-15 14:07:56 UTC (rev 4034) @@ -6,12 +6,13 @@ 1. What does it do? 1.1 What it does not do - 2. Useing PyASM - 3. The parts of PyASM - 4. How PyASM works - 5. Mappings from Python Bytecode to Java Bytecode - 5.1 Explanation of python and java bytecode features, and their differences - 6. Future extensions + 2. Installation + 3. Useing PyASM + 4. The parts of PyASM + 5. How PyASM works + 6. Mappings from Python Bytecode to Java Bytecode + 6.1 Explanation of python and java bytecode features, and their differences + 7. Future extensions 1. What does it do? @@ -29,9 +30,24 @@ subclassing PyFunctionTable. - 2. Useing PyASM + 2. Installation =============== +PyASM is at the moment a separate component from Jython and therefore needs to +be installed into Jython. This is done with the included ant script +(build.xml). The default target of this ant script builds Jython and copies +the required files from pyasm to the Jython Lib directory. In order for the +ant script to find your Jython working directory the path needs to be +specified in the file 'build.properties', as the variable 'jython.dir'. + +Please note that rebuilding Jython with the standard Jython building procedure +after installing PyASM might overwrite some of the installed PyASM-files. At +the moment this is know to happen to the file 'marshal.py'. + + + 3. Useing PyASM + =============== + PyASM operates on python bytecode, and therefore depends on the C implementation of python to generate bytecode. For instructions on how to generate python bytecode from your python code, please refere to the python @@ -49,28 +65,28 @@ $ jython test.py <your_python_file_here>.py - 3. The parts of PyASM + 4. The parts of PyASM ===================== TODO - 4. How PyASM works + 5. How PyASM works ================== TODO - 5. Mappings from Python Bytecode to Java Bytecode + 6. Mappings from Python Bytecode to Java Bytecode ================================================= - 5.1 Explanation of python and java bytecode features, and their differences + 6.1 Explanation of python and java bytecode features, and their differences --------------------------------------------------------------------------- TODO - 6. Future extensions + 7. Future extensions ==================== TODO Modified: trunk/sandbox/pyasm/pyasm.py =================================================================== --- trunk/sandbox/pyasm/pyasm.py 2008-01-15 05:23:27 UTC (rev 4033) +++ trunk/sandbox/pyasm/pyasm.py 2008-01-15 14:07:56 UTC (rev 4034) @@ -482,12 +482,12 @@ nestingStackSize = property(lambda self: self.stackSize - 3) def end(self): """stack is: ... exc_traceback exc_value exc_type""" - self.asm.dupX2() - self.asm.pop() - self.asm.swap() - self.asm.invokeStatic(pyType, Method.getMethod( - "org.python.core.PyException makeException (%s)" % ", ".join([ - "org.python.core.PyObject"]*3))) + #self.asm.dupX2() + #self.asm.pop() + #self.asm.swap() + #self.asm.invokeStatic(pyType, Method.getMethod( + # "org.python.core.PyException makeException (%s)" % ", ".join([ + # "org.python.core.PyObject"]*3))) self.asm.throwException() HandlerBlock.end(self) @@ -762,12 +762,12 @@ def visitCompareOperator(self, operator): """element, element -- bool""" if operator == Operator.EXCEPTION_MATCH: - self.asm.swap() + #self.asm.swap() + #self.asm.invokeStatic(pyType, Method.getMethod( + # "org.python.core.PyException makeException (%s)"%", ".join( + # ['org.python.core.PyObject']))) + #self.asm.swap() self.asm.invokeStatic(pyType, Method.getMethod( - "org.python.core.PyException makeException (%s)"%", ".join( - ['org.python.core.PyObject']))) - self.asm.swap() - self.asm.invokeStatic(pyType, Method.getMethod( "boolean matchException (%s)" % ", ".join( ['org.python.core.PyException', 'org.python.core.PyObject']))) @@ -1420,8 +1420,7 @@ def visitRaiseVarargs(self, count): """(object, )*count -- """ if count < 0 or count > 3: - raise TypeError("RAISE_VARARGS accepts only arguments in range(4)") - self.rot(count) + raise TypeError("RAISE_VARARGS only accepts arguments in range(4)") self.asm.invokeStatic(pyType, Method.getMethod( "org.python.core.PyException makeException (%s)" % ", ".join( ["org.python.core.PyObject"]*count))) @@ -1520,7 +1519,7 @@ self.asm.getField(pyExceptionType, "value", pyObjectType) exception.load() exception.end() - self.asm.getField(pyExceptionType, "type", pyObjectType) + #self.asm.getField(pyExceptionType, "type", pyObjectType) self.scheduleCode(startExcept, code) self.asm.visitLabel(start) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |