[pypy-svn] r30159 - pypy/dist/pypy/translator/cli
antocuni at codespeak.net
antocuni at codespeak.net
Tue Jul 18 14:34:21 CEST 2006
Author: antocuni
Date: Tue Jul 18 14:34:14 2006
New Revision: 30159
Modified:
pypy/dist/pypy/translator/cli/class_.py
pypy/dist/pypy/translator/cli/ilgenerator.py
Log:
Mark classes with abstract methods as abstract.
Modified: pypy/dist/pypy/translator/cli/class_.py
==============================================================================
--- pypy/dist/pypy/translator/cli/class_.py (original)
+++ pypy/dist/pypy/translator/cli/class_.py Tue Jul 18 14:34:14 2006
@@ -40,6 +40,12 @@
else:
return self.db.class_name(base_class)
+ def is_abstract(self):
+ for m_name, m_meth in self.INSTANCE._methods.iteritems():
+ if not hasattr(m_meth, 'graph'):
+ return True
+ return False
+
def render(self, ilasm):
if self.is_root(self.INSTANCE):
return
@@ -48,7 +54,7 @@
if self.namespace:
ilasm.begin_namespace(self.namespace)
- ilasm.begin_class(self.name, self.get_base_class())
+ ilasm.begin_class(self.name, self.get_base_class(), abstract=self.is_abstract())
for f_name, (f_type, f_default) in self.INSTANCE._fields.iteritems():
cts_type = self.cts.lltype_to_cts(f_type)
f_name = self.cts.escape_name(f_name)
Modified: pypy/dist/pypy/translator/cli/ilgenerator.py
==============================================================================
--- pypy/dist/pypy/translator/cli/ilgenerator.py (original)
+++ pypy/dist/pypy/translator/cli/ilgenerator.py Tue Jul 18 14:34:14 2006
@@ -53,14 +53,15 @@
def end_namespace(self):
self.code.closeblock()
- def begin_class(self, name, base=None, sealed=False, interfaces=()):
+ def begin_class(self, name, base=None, sealed=False, interfaces=(), abstract=False):
if base is None:
base = '[mscorlib]System.Object'
+ s = ''
+ if abstract:
+ s += 'abstract '
if sealed:
- s = 'sealed'
- else:
- s = ''
-
+ s += 'sealed '
+
self.code.writeline('.class public %s %s extends %s' % (s, name, base))
if interfaces:
self.code.writeline(' implements %s' % ', '.join(interfaces))
More information about the Pypy-commit
mailing list