[pypy-svn] r46365 - in pypy/dist/pypy/translator/jvm: . test

antocuni at codespeak.net antocuni at codespeak.net
Thu Sep 6 14:18:07 CEST 2007


Author: antocuni
Date: Thu Sep  6 14:18:05 2007
New Revision: 46365

Modified:
   pypy/dist/pypy/translator/jvm/genjvm.py
   pypy/dist/pypy/translator/jvm/metavm.py
   pypy/dist/pypy/translator/jvm/methods.py
   pypy/dist/pypy/translator/jvm/test/test_class.py
Log:
take care of void arguments



Modified: pypy/dist/pypy/translator/jvm/genjvm.py
==============================================================================
--- pypy/dist/pypy/translator/jvm/genjvm.py	(original)
+++ pypy/dist/pypy/translator/jvm/genjvm.py	Thu Sep  6 14:18:05 2007
@@ -268,7 +268,6 @@
         """ Creates and returns a Generator object according to the
         configuration.  Right now, however, there is only one kind of
         generator: JasminGenerator """
-        print "Uh...?"
         return JasminGenerator(self.db, self.jvmsrc.javadir)
         
         

Modified: pypy/dist/pypy/translator/jvm/metavm.py
==============================================================================
--- pypy/dist/pypy/translator/jvm/metavm.py	(original)
+++ pypy/dist/pypy/translator/jvm/metavm.py	Thu Sep  6 14:18:05 2007
@@ -14,6 +14,7 @@
 class _JvmCallMethod(MicroInstruction):
 
     def _invoke_method(self, gen, db, jmethod, jactargs, args, jactres, res):
+        assert len(args) == len(jactargs)
         for arg, jmthdty in zip(args, jactargs):
             # Load the argument on the stack:
             gen.load(arg)
@@ -44,11 +45,12 @@
         jactargs = jmethod.argument_types
         if jmethod.is_static():
             jactargs = jactargs[1:]
-
+            
+        args = [arg for arg in op.args[2:] if arg.concretetype is not ootype.Void]
         # Iterate through the arguments, inserting casts etc as required
         gen.load(this)
         self._invoke_method(gen, gen.db, jmethod,
-                            jactargs, op.args[2:],
+                            jactargs, args,
                             jmethod.return_type, op.result)
 JvmCallMethod = _JvmCallMethod()
 

Modified: pypy/dist/pypy/translator/jvm/methods.py
==============================================================================
--- pypy/dist/pypy/translator/jvm/methods.py	(original)
+++ pypy/dist/pypy/translator/jvm/methods.py	Thu Sep  6 14:18:05 2007
@@ -61,11 +61,8 @@
         for fieldnm, (FIELDOOTY, fielddef) in self.OOCLASS._fields.iteritems():
 
             if FIELDOOTY is ootype.Void: continue
-
             genprint('"'+fieldnm+'":')
 
-            print "fieldnm=%r fieldty=%r" % (fieldnm, FIELDOOTY)
-
             # Print the value of the field:
             self._print_field_value(fieldnm, FIELDOOTY)
 

Modified: pypy/dist/pypy/translator/jvm/test/test_class.py
==============================================================================
--- pypy/dist/pypy/translator/jvm/test/test_class.py	(original)
+++ pypy/dist/pypy/translator/jvm/test/test_class.py	Thu Sep  6 14:18:05 2007
@@ -6,5 +6,25 @@
     def test_overridden_classattr_as_defaults(self):
         py.test.skip("JVM doesn't support overridden default value yet")
 
+    def test_method_void_arg(self):
+        class Space:
+            def __init__(self):
+                self.x = 40
+            def _freeze_(self):
+                return True
+        space = Space()
+
+        class MyClass:
+            def foo(self, space, x):
+                return space.x + x
+
+        def fn(x):
+            obj = MyClass()
+            return obj.foo(space, x)
+
+        assert self.interpret(fn, [2]) == 42
+            
+        
+
 class TestJvmSpecialCase(JvmTest, BaseTestSpecialcase):
     pass



More information about the Pypy-commit mailing list