[pypy-svn] r26511 - pypy/dist/pypy/translator/cl

sanxiyn at codespeak.net sanxiyn at codespeak.net
Fri Apr 28 11:48:30 CEST 2006


Author: sanxiyn
Date: Fri Apr 28 11:48:27 2006
New Revision: 26511

Modified:
   pypy/dist/pypy/translator/cl/gencl.py
Log:
(dialtone, sanxiyn)
Exceptions work in Lisp backend! (well, in the most primitive form at least)


Modified: pypy/dist/pypy/translator/cl/gencl.py
==============================================================================
--- pypy/dist/pypy/translator/cl/gencl.py	(original)
+++ pypy/dist/pypy/translator/cl/gencl.py	Fri Apr 28 11:48:27 2006
@@ -223,7 +223,7 @@
     def declare_class(self, cls):
         # cls is Instance
         if cls in self.declarations:
-            return
+            return self.declarations[cls][0]
         name = clrepr(cls._name, symbol=True)
         field_declaration = ['('+clrepr(field, True)+')' for field in cls._fields]
         field_declaration = " ".join(field_declaration)
@@ -238,6 +238,7 @@
             methodobj = cls._methods[method]
             methodobj._method_name = method
             self.pendinggraphs.append(methodobj)
+        return name
 
     def declare_exception(self, cls):
         # cls is Instance
@@ -246,10 +247,10 @@
             return self.declarations[cls][0]
         name = clrepr(cls._name, symbol=True)
         if cls._superclass is OBJECT:
-            exception_declaration = "(define-condition %s () ())" % (name,)
+            supername = self.declare_class(OBJECT)
+            exception_declaration = "(define-condition %s (condition %s) ())" % (name, supername)
         else:
-            self.declare_exception(cls._superclass)
-            supername = clrepr(cls._superclass._name, symbol=True)
+            supername = self.declare_exception(cls._superclass)
             exception_declaration = "(define-condition %s (%s) ())" % (name, supername)
         self.declarations[cls] = (name, exception_declaration)
         return name
@@ -407,7 +408,8 @@
                 self.emit_link(body)
                 for exception in exceptions:
                     yield "(%s ()" % (exception,)
-                    self.emit_link(exceptions[exception])
+                    for line in self.emit_link(exceptions[exception]):
+                        yield line
                     yield ")"
             else:
                 # this is for the more general case.  The previous special case



More information about the Pypy-commit mailing list