[pypy-svn] r48880 - in pypy/dist/pypy/translator: . cli
antocuni at codespeak.net
antocuni at codespeak.net
Tue Nov 20 22:21:45 CET 2007
Author: antocuni
Date: Tue Nov 20 22:21:44 2007
New Revision: 48880
Modified:
pypy/dist/pypy/translator/cli/record.py
pypy/dist/pypy/translator/driver.py
Log:
automatically use ledit to start pypy-{cli,jvm} if available
Modified: pypy/dist/pypy/translator/cli/record.py
==============================================================================
--- pypy/dist/pypy/translator/cli/record.py (original)
+++ pypy/dist/pypy/translator/cli/record.py Tue Nov 20 22:21:44 2007
@@ -100,21 +100,25 @@
self.ilasm.end_function()
def _getHashCode(self):
- # return the hash of the first field. XXX: it can lead to a bad distribution
record_type = self.cts.lltype_to_cts(self.record)
self.ilasm.begin_function('GetHashCode', [], 'int32', False, 'virtual', 'instance', 'default')
gethash = 'int32 [pypylib]pypy.runtime.Utils::GetHashCode<%s>(!!0)'
+
+ self.ilasm.opcode('ldc.i4.0') # initial hash
if self.record._fields:
- f_name, (FIELD_TYPE, default) = self.record._fields.iteritems().next()
- if FIELD_TYPE is ootype.Void:
- self.ilasm.opcode('ldc.i4.0')
- else:
- f_name = self.cts.escape_name(f_name)
- f_type = self.cts.lltype_to_cts(FIELD_TYPE)
- self.ilasm.opcode('ldarg.0')
- self.ilasm.get_field((f_type, record_type.classname(), f_name))
- self.ilasm.call(gethash % f_type)
- else:
- self.ilasm.opcode('ldc.i4.0')
+ for f_name, (FIELD_TYPE, default) in self.record._fields.iteritems():
+ if FIELD_TYPE is ootype.Void:
+ continue
+ else:
+ # compute the hash for this field
+ f_name = self.cts.escape_name(f_name)
+ f_type = self.cts.lltype_to_cts(FIELD_TYPE)
+ self.ilasm.opcode('ldarg.0')
+ self.ilasm.get_field((f_type, record_type.classname(), f_name))
+ self.ilasm.call(gethash % f_type)
+
+ # xor with the previous value
+ self.ilasm.opcode('xor')
+
self.ilasm.opcode('ret')
self.ilasm.end_function()
Modified: pypy/dist/pypy/translator/driver.py
==============================================================================
--- pypy/dist/pypy/translator/driver.py (original)
+++ pypy/dist/pypy/translator/driver.py Tue Nov 20 22:21:44 2007
@@ -665,8 +665,9 @@
newexename = basename
f = file(newexename, 'w')
f.write("""#!/bin/bash
+LEDIT=`which ledit 2>/dev/null`
if [ `uname -o` = 'Cygwin' ]; then MONO=; else MONO=mono; fi
-$MONO "$(dirname $0)/$(basename $0)-data/%s" "$@" # XXX doesn't work if it's placed in PATH
+$LEDIT $MONO "$(dirname $0)/$(basename $0)-data/%s" "$@" # XXX doesn't work if it's placed in PATH
""" % main_exe_name)
f.close()
os.chmod(newexename, 0755)
@@ -734,7 +735,8 @@
newexename = basename
f = file(newexename, 'w')
f.write("""#!/bin/bash
-java -jar $0.jar "$@"
+LEDIT=`which ledit 2>/dev/null`
+$LEDIT java -jar $0.jar "$@"
""")
f.close()
os.chmod(newexename, 0755)
More information about the Pypy-commit
mailing list