[pypy-svn] r34383 - pypy/dist/pypy/translator/jvm
niko at codespeak.net
niko at codespeak.net
Wed Nov 8 17:50:37 CET 2006
Author: niko
Date: Wed Nov 8 17:50:35 2006
New Revision: 34383
Modified:
pypy/dist/pypy/translator/jvm/database.py
pypy/dist/pypy/translator/jvm/generator.py
pypy/dist/pypy/translator/jvm/genjvm.py
Log:
fix a remarkable number of tests by removing code which
walked the directory to find the set of jasmin files to
compile and replacing it with code that tracks which .j
files we create, and then just iterates over this list.
this prevents one bad test from leaving an uncompilable
.j file and thus breaking the following tests.
Modified: pypy/dist/pypy/translator/jvm/database.py
==============================================================================
--- pypy/dist/pypy/translator/jvm/database.py (original)
+++ pypy/dist/pypy/translator/jvm/database.py Wed Nov 8 17:50:35 2006
@@ -26,6 +26,7 @@
OODatabase.__init__(self, genoo)
# Private attributes:
+ self._jasmin_files = [] # list of strings --- .j files we made
self._classes = {} # Maps ootype class objects to node.Class objects,
# and JvmType objects as well
self._functions = {} # graph -> jvmgen.Method
@@ -59,6 +60,14 @@
assert isinstance(jtype, jvmtype.JvmClassType)
return jtype.name
+ def add_jasmin_file(self, jfile):
+ """ Adds to the list of files we need to run jasmin on """
+ self._jasmin_files.append(jfile)
+
+ def jasmin_files(self):
+ """ Returns list of files we need to run jasmin on """
+ return self._jasmin_files
+
# _________________________________________________________________
# Node Creation
#
Modified: pypy/dist/pypy/translator/jvm/generator.py
==============================================================================
--- pypy/dist/pypy/translator/jvm/generator.py (original)
+++ pypy/dist/pypy/translator/jvm/generator.py Wed Nov 8 17:50:35 2006
@@ -961,6 +961,7 @@
os.makedirs(jdir)
except OSError: pass
self.curclass.file = open(jfile, 'w')
+ self.db.add_jasmin_file(jfile)
# Write the JasminXT header
self.curclass.out(".class public %s\n" % iclassnm)
Modified: pypy/dist/pypy/translator/jvm/genjvm.py
==============================================================================
--- pypy/dist/pypy/translator/jvm/genjvm.py (original)
+++ pypy/dist/pypy/translator/jvm/genjvm.py Wed Nov 8 17:50:35 2006
@@ -67,12 +67,14 @@
'tmpdir' --- the base directory where the sources are located
'package' --- the package the sources are in; if package is pypy.jvm,
then we expect to find the sources in $tmpdir/pypy/jvm
+ 'jfiles' --- list of files we need to run jasmin on
"""
self.tmpdir = tmpdir
self.package = package
self.compiled = False
+ self.jasmin_files = None
- # Compute directory where .java files are
+ # Compute directory where .j files are
self.javadir = self.tmpdir
for subpkg in package.split('.'):
self.javadir = self.javadir.join(subpkg)
@@ -80,6 +82,9 @@
# Compute directory where .class files should go
self.classdir = self.javadir
+ def set_jasmin_files(self, jfiles):
+ self.jasmin_files = jfiles
+
def _invoke(self, args, allow_stderr):
subp = subprocess.Popen(
args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@@ -93,24 +98,22 @@
"""
Compiles the .java sources into .class files, ready for execution.
"""
- javacmd = [getoption('jasmin'), '-d', str(self.javadir)]
- pypydir = self.javadir.join("pypy") # HACK; should do recursive
- javafiles = [str(f) for f in pypydir.listdir()
- if str(f).endswith('.j')]
-
- for javafile in javafiles:
- print "Invoking jasmin on %s" % javafile
- self._invoke(javacmd+[javafile], False)
+ jascmd = [getoption('jasmin'), '-d', str(self.javadir)]
+ for jasfile in self.jasmin_files:
+ print "Invoking jasmin on %s" % jasfile
+ self._invoke(jascmd+[jasfile], False)
# HACK: compile the Java helper class. Should eventually
# use rte.py
- sl = __file__.rindex('/')
- javasrc = __file__[:sl]+"/src/PyPy.java"
- self._invoke([getoption('javac'),
- '-nowarn',
- '-d', str(self.javadir),
- javasrc],
- True)
+ pypycls = self.classdir.join('PyPy.class')
+ if not os.path.exists(str(pypycls)):
+ sl = __file__.rindex('/')
+ javasrc = __file__[:sl]+"/src/PyPy.java"
+ self._invoke([getoption('javac'),
+ '-nowarn',
+ '-d', str(self.classdir),
+ javasrc],
+ True)
self.compiled = True
@@ -190,6 +193,7 @@
""" Creates the sources, and returns a JvmGeneratedSource object
for manipulating them """
GenOO.generate_source(self)
+ self.jvmsrc.set_jasmin_files(self.db.jasmin_files())
return self.jvmsrc
def create_assembler(self):
More information about the Pypy-commit
mailing list