From: <fwi...@us...> - 2008-08-04 17:57:43
|
Revision: 5077 http://jython.svn.sourceforge.net/jython/?rev=5077&view=rev Author: fwierzbicki Date: 2008-08-04 17:57:34 +0000 (Mon, 04 Aug 2008) Log Message: ----------- In test_decorators.py, test_eval_order cleverly instruments a decorated call so the order of evaluation and calls can be determined. It also checks to see if the decoration works exactly the same when translated to nested function calls. Jython was evaluating the arguments before the function name, the opposite of CPython. This patch makes the order correct for both decorators and normal function calls. Also, PyObject.invoke states in its comments that it is for use from Java and shows the equivalent o.__getattr__(name).__call__(args, keywords) which is how I am constructing a call in the bytecode. I also thought that "Invoke" with a capitalized name was non-ideal, so I changed the name to invokeNoKeywords, which also allowed me to remove a comment that conveyed the same meaning. Modified Paths: -------------- branches/asm/src/org/python/compiler/CodeCompiler.java branches/asm/src/org/python/core/imp.java Modified: branches/asm/src/org/python/compiler/CodeCompiler.java =================================================================== --- branches/asm/src/org/python/compiler/CodeCompiler.java 2008-08-04 03:23:57 UTC (rev 5076) +++ branches/asm/src/org/python/compiler/CodeCompiler.java 2008-08-04 17:57:34 UTC (rev 5077) @@ -1385,29 +1385,30 @@ c.freeLocal(strings); } - public Object Invoke(Attribute node, PythonTree[] values) + public Object invokeNoKeywords(Attribute node, PythonTree[] values) throws Exception { String name = getName(node.attr); visit(node.value); code.ldc(name); + code.invokevirtual("org/python/core/PyObject", "__getattr__", "(" + $str + ")" + $pyObj); switch (values.length) { case 0: - code.invokevirtual("org/python/core/PyObject", "invoke", "(" + $str + ")" + $pyObj); + code.invokevirtual("org/python/core/PyObject", "__call__", "()" + $pyObj); break; case 1: visit(values[0]); - code.invokevirtual("org/python/core/PyObject", "invoke", "(" + $str + $pyObj + ")" + $pyObj); + code.invokevirtual("org/python/core/PyObject", "__call__", "(" + $pyObj + ")" + $pyObj); break; case 2: visit(values[0]); visit(values[1]); - code.invokevirtual("org/python/core/PyObject", "invoke", "(" + $str + $pyObj + $pyObj + ")" + $pyObj); + code.invokevirtual("org/python/core/PyObject", "__call__", "(" + $pyObj + $pyObj + ")" + $pyObj); break; default: makeArray(values); - code.invokevirtual("org/python/core/PyObject", "invoke", "(" + $str + $pyObjArr + ")" + $pyObj); + code.invokevirtual("org/python/core/PyObject", "__call__", "(" + $pyObjArr + ")" + $pyObj); break; } return null; @@ -1425,11 +1426,10 @@ values[node.args.length + i] = node.keywords[i].value; } - // Detect a method invocation with no keywords if ((node.keywords == null || node.keywords.length == 0)&& node.starargs == null && node.kwargs == null && node.func instanceof Attribute) { - return Invoke((Attribute) node.func, values); + return invokeNoKeywords((Attribute) node.func, values); } visit(node.func); Modified: branches/asm/src/org/python/core/imp.java =================================================================== --- branches/asm/src/org/python/core/imp.java 2008-08-04 03:23:57 UTC (rev 5076) +++ branches/asm/src/org/python/core/imp.java 2008-08-04 17:57:34 UTC (rev 5077) @@ -22,7 +22,7 @@ private static final String UNKNOWN_SOURCEFILE = "<unknown>"; - public static final int APIVersion = 14; + public static final int APIVersion = 15; /** A non-empty fromlist for __import__'ing sub-modules. */ private static final PyObject nonEmptyFromlist = new PyTuple(Py.newString("__doc__")); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |