[pypy-svn] r24970 - pypy/branch/explicit-exceptions/translator/c

cfbolz at codespeak.net cfbolz at codespeak.net
Fri Mar 24 16:48:38 CET 2006


Author: cfbolz
Date: Fri Mar 24 16:48:32 2006
New Revision: 24970

Modified:
   pypy/branch/explicit-exceptions/translator/c/exceptiontransform.py
Log:
some cosmetics


Modified: pypy/branch/explicit-exceptions/translator/c/exceptiontransform.py
==============================================================================
--- pypy/branch/explicit-exceptions/translator/c/exceptiontransform.py	(original)
+++ pypy/branch/explicit-exceptions/translator/c/exceptiontransform.py	Fri Mar 24 16:48:32 2006
@@ -5,6 +5,7 @@
     c_last_exception, SpaceOperation, checkgraph, FunctionGraph
 from pypy.rpython.lltypesystem import lltype, llmemory
 from pypy.rpython.memory.lladdress import NULL
+from pypy.rpython.memory.gctransform import varoftype
 from pypy.rpython import rclass
 from pypy.rpython.rarithmetic import r_uint, r_longlong, r_ulonglong
 from pypy.annotation import model as annmodel
@@ -32,7 +33,9 @@
     def __init__(self, translator):
         self.translator = translator
         self.raise_analyzer = canraise.RaiseAnalyzer(translator)
-        self.exc_data = translator.rtyper.getexceptiondata()
+        edata = translator.rtyper.getexceptiondata()
+        self.lltype_of_exception_value = edata.lltype_of_exception_value
+        self.lltype_of_exception_type = edata.lltype_of_exception_type
         mixlevelannotator = MixLevelHelperAnnotator(translator.rtyper)
         l2a = annmodel.lltype_to_annotation
 
@@ -42,8 +45,8 @@
             #exc_value = lltype.nullptr(self.exc_data.lltype_of_exception_value.TO)
 
         exc_data = ExcData()
-        null_type = lltype.nullptr(self.exc_data.lltype_of_exception_type.TO)
-        null_value = lltype.nullptr(self.exc_data.lltype_of_exception_value.TO)
+        null_type = lltype.nullptr(self.lltype_of_exception_type.TO)
+        null_value = lltype.nullptr(self.lltype_of_exception_value.TO)
         
         def rpyexc_occured():
             return exc_data.exc_type is not null_type
@@ -71,19 +74,19 @@
             graph=rpyexc_occured_graph),
             lltype.Ptr(RPYEXC_OCCURED_TYPE))
         
-        RPYEXC_FETCH_TYPE_TYPE = lltype.FuncType([], self.exc_data.lltype_of_exception_type)
+        RPYEXC_FETCH_TYPE_TYPE = lltype.FuncType([], self.lltype_of_exception_type)
         rpyexc_fetch_type_graph = mixlevelannotator.getgraph(
             rpyexc_fetch_type, [],
-            l2a(self.exc_data.lltype_of_exception_type))
+            l2a(self.lltype_of_exception_type))
         self.rpyexc_fetch_type_ptr = Constant(lltype.functionptr(
             RPYEXC_FETCH_TYPE_TYPE, "RPyFetchExceptionType",
             graph=rpyexc_fetch_type_graph),
             lltype.Ptr(RPYEXC_FETCH_TYPE_TYPE))
         
-        RPYEXC_FETCH_VALUE_TYPE = lltype.FuncType([], self.exc_data.lltype_of_exception_value)
+        RPYEXC_FETCH_VALUE_TYPE = lltype.FuncType([], self.lltype_of_exception_value)
         rpyexc_fetch_value_graph = mixlevelannotator.getgraph(
             rpyexc_fetch_value, [],
-            l2a(self.exc_data.lltype_of_exception_value))
+            l2a(self.lltype_of_exception_value))
         self.rpyexc_fetch_value_ptr = Constant(lltype.functionptr(
             RPYEXC_FETCH_VALUE_TYPE, "RPyFetchExceptionValue",
             graph=rpyexc_fetch_value_graph),
@@ -97,12 +100,12 @@
             graph=rpyexc_clear_graph),
             lltype.Ptr(RPYEXC_CLEAR))
 
-        RPYEXC_RAISE = lltype.FuncType([self.exc_data.lltype_of_exception_type,
-                                        self.exc_data.lltype_of_exception_value],
+        RPYEXC_RAISE = lltype.FuncType([self.lltype_of_exception_type,
+                                        self.lltype_of_exception_value],
                                         lltype.Void)
         rpyexc_raise_graph = mixlevelannotator.getgraph(
-            rpyexc_raise, [l2a(self.exc_data.lltype_of_exception_type),
-                           l2a(self.exc_data.lltype_of_exception_value)],
+            rpyexc_raise, [l2a(self.lltype_of_exception_type),
+                           l2a(self.lltype_of_exception_value)],
             l2a(lltype.Void))
         self.rpyexc_raise_ptr = Constant(lltype.functionptr(
             RPYEXC_RAISE, "RPyRaiseException",
@@ -211,36 +214,29 @@
         startblock = Block(inputargs)
         startblock.operations.append(newop) 
         newgraph = FunctionGraph("dummy_exc1", startblock)
-        # XXX this is makes stackless happier, for very bad reasons.
-        # XXX do something about this.
-        newgraph.func = None
         startblock.closeblock(Link([result], newgraph.returnblock))
         startblock.exits = list(startblock.exits)
         newgraph.returnblock.inputargs[0].concretetype = op.result.concretetype
         self.gen_exc_check(startblock, newgraph.returnblock)
         startblock.exits[0].exitcase = startblock.exits[0].llexitcase = False
         excblock = Block([])
-        var_value = Variable()
-        var_value.concretetype = self.exc_data.lltype_of_exception_value
-        var_type = Variable()
-        var_type.concretetype = self.exc_data.lltype_of_exception_type
-        var_void = Variable()
-        var_void.concretetype = lltype.Void
+        var_value = varoftype(self.lltype_of_exception_value)
+        var_type = varoftype(self.lltype_of_exception_type)
+        var_void = varoftype(lltype.Void)
         excblock.operations.append(SpaceOperation(
             "direct_call", [self.rpyexc_fetch_value_ptr], var_value))
         excblock.operations.append(SpaceOperation(
             "direct_call", [self.rpyexc_fetch_type_ptr], var_type))
         excblock.operations.append(SpaceOperation(
             "direct_call", [self.rpyexc_clear_ptr], var_void))
-        newgraph.exceptblock.inputargs[0].concretetype = self.exc_data.lltype_of_exception_type
-        newgraph.exceptblock.inputargs[1].concretetype = self.exc_data.lltype_of_exception_value
+        newgraph.exceptblock.inputargs[0].concretetype = self.lltype_of_exception_type
+        newgraph.exceptblock.inputargs[1].concretetype = self.lltype_of_exception_value
         excblock.closeblock(Link([var_type, var_value], newgraph.exceptblock))
         startblock.exits[True].target = excblock
         startblock.exits[True].args = []
         FUNCTYPE = lltype.FuncType(ARGTYPES, op.result.concretetype)
         fptr = Constant(lltype.functionptr(FUNCTYPE, "dummy_exc2", graph=newgraph),
                         lltype.Ptr(FUNCTYPE))
-        self.translator.graphs.append(newgraph)
         return newgraph, SpaceOperation("direct_call", [fptr] + callargs, op.result) 
 
     def gen_exc_check(self, block, returnblock):



More information about the Pypy-commit mailing list