[pypy-svn] r29540 - pypy/dist/pypy/translator/cli
antocuni at codespeak.net
antocuni at codespeak.net
Fri Jun 30 22:03:33 CEST 2006
Author: antocuni
Date: Fri Jun 30 22:03:27 2006
New Revision: 29540
Modified:
pypy/dist/pypy/translator/cli/database.py
pypy/dist/pypy/translator/cli/function.py
pypy/dist/pypy/translator/cli/record.py
Log:
Don't store the _name attribute in the record, because it breaks the
cached hash. For now we recalc the name every time, in future we might
consider to cache it somewhere.
The work-around for the broken hash issue is no longer needed.
Modified: pypy/dist/pypy/translator/cli/database.py
==============================================================================
--- pypy/dist/pypy/translator/cli/database.py (original)
+++ pypy/dist/pypy/translator/cli/database.py Fri Jun 30 22:03:27 2006
@@ -30,7 +30,6 @@
self.delegates = {} # StaticMethod --> type_name
self.const_names = set()
self.name_count = 0
- self._recorded_records = [] # XXX: temporary hack
def next_count(self):
self.name_count += 1
@@ -44,9 +43,7 @@
def pending_record(self, record):
r = Record(self, record)
- if r not in self._recorded_records: # XXX: temporary hack
- self._recorded_records.append(r)
- self.pending_node(r)
+ self.pending_node(r)
return r.get_name()
def pending_node(self, node):
@@ -67,6 +64,10 @@
def class_name(self, classdef):
return self.classes.get(classdef, None)
+ def get_record_name(self, RECORD):
+ r = Record(self, RECORD)
+ return r.get_name() # TODO: cache the result?
+
def record_const(self, value):
if value in self.consts:
const = self.consts[value]
Modified: pypy/dist/pypy/translator/cli/function.py
==============================================================================
--- pypy/dist/pypy/translator/cli/function.py (original)
+++ pypy/dist/pypy/translator/cli/function.py Fri Jun 30 22:03:27 2006
@@ -285,8 +285,11 @@
def function_signature(self, graph):
return self.cts.graph_to_signature(graph, False)
- def class_name(self, ooinstance):
- return ooinstance._name
+ def class_name(self, TYPE):
+ if isinstance(TYPE, ootype.Instance):
+ return TYPE._name
+ elif isinstance(TYPE, ootype.Record):
+ return self.db.get_record_name(TYPE)
def emit(self, instr, *args):
self.ilasm.opcode(instr, *args)
Modified: pypy/dist/pypy/translator/cli/record.py
==============================================================================
--- pypy/dist/pypy/translator/cli/record.py (original)
+++ pypy/dist/pypy/translator/cli/record.py Fri Jun 30 22:03:27 2006
@@ -20,7 +20,6 @@
self.name = '__'.join(name)
assert ':' not in self.name
- record._name = self.name
def __hash__(self):
return hash(self.record)
More information about the Pypy-commit
mailing list