[pypy-svn] r18527 - pypy/dist/pypy/translator/c
tismer at codespeak.net
tismer at codespeak.net
Fri Oct 14 10:37:59 CEST 2005
Author: tismer
Date: Fri Oct 14 10:37:56 2005
New Revision: 18527
Modified:
pypy/dist/pypy/translator/c/funcgen.py
pypy/dist/pypy/translator/c/gc.py
pypy/dist/pypy/translator/c/stackless.py
Log:
made the generated code a bit more readable and easier to debug.
There is now one instruction per line.
Modified: pypy/dist/pypy/translator/c/funcgen.py
==============================================================================
--- pypy/dist/pypy/translator/c/funcgen.py (original)
+++ pypy/dist/pypy/translator/c/funcgen.py Fri Oct 14 10:37:56 2005
@@ -234,7 +234,11 @@
lst.append(self.expr(op.result))
lst.append(err)
line = '%s(%s);' % (macro, ', '.join(lst))
- yield line
+ if '\n' in line:
+ for subline in line.split('\n'):
+ yield subline
+ else:
+ yield line
if line.find(err) >= 0:
reachable_err = len(to_release)
to_release.append(op.result)
@@ -404,11 +408,11 @@
# skip assignment of 'void' return value
r = self.expr(op.result)
line = '%s = %s' % (r, line)
- line = '%s %s' % (line, self.check_directcall_result(op, err))
+ line = '%s\n%s' % (line, self.check_directcall_result(op, err))
return line
def check_directcall_result(self, op, err):
- return 'if (RPyExceptionOccurred()) FAIL(%s);' % err
+ return 'if (RPyExceptionOccurred())\n\tFAIL(%s);' % err
# low-level operations
def generic_get(self, op, sourceexpr):
@@ -418,7 +422,7 @@
# need to adjust the refcount of the result only for PyObjects
if T == PyObjPtr:
result.append(self.pyobj_incref_expr(newvalue, T))
- result = '\t'.join(result)
+ result = '\n'.join(result)
if T is Void:
result = '/* %s */' % result
return result
@@ -429,7 +433,7 @@
# insert write barrier
T = self.lltypemap(op.args[2])
self.gcpolicy.write_barrier(result, newvalue, T, targetexpr)
- result = '\t'.join(result)
+ result = '\n'.join(result)
if T is Void:
result = '/* %s */' % result
return result
@@ -518,7 +522,7 @@
elength,
cdecl(itemtypename, ''))
result = self.gcpolicy.zero_malloc(TYPE, esize, eresult, err)
- result += '\t%s->%s = %s;' % (eresult, lenfld, elength)
+ result += '\n%s->%s = %s;' % (eresult, lenfld, elength)
return result
def OP_CAST_POINTER(self, op, err):
Modified: pypy/dist/pypy/translator/c/gc.py
==============================================================================
--- pypy/dist/pypy/translator/c/gc.py (original)
+++ pypy/dist/pypy/translator/c/gc.py Fri Oct 14 10:37:56 2005
@@ -107,10 +107,12 @@
if increfstmt:
result.append(increfstmt)
if decrefstmt:
- result.insert(0, '{ %s = %s;' % (
+ result.insert(0, '%s = %s;' % (
cdecl(self.db.gettype(T), 'prev'),
targetexpr))
result.append(decrefstmt)
+ result[:] = ['\t%s' % line for line in result]
+ result[0] = '{' + result[0]
result.append('}')
def generic_dealloc(self, expr, T):
@@ -348,7 +350,7 @@
is_varsize,
err)
if gcinfo and gcinfo.finalizer:
- result += ('\tGC_REGISTER_FINALIZER(%s, %s, NULL, NULL, NULL);'
+ result += ('\nGC_REGISTER_FINALIZER(%s, %s, NULL, NULL, NULL);'
% (eresult, gcinfo.finalizer))
return result
Modified: pypy/dist/pypy/translator/c/stackless.py
==============================================================================
--- pypy/dist/pypy/translator/c/stackless.py (original)
+++ pypy/dist/pypy/translator/c/stackless.py Fri Oct 14 10:37:56 2005
@@ -243,12 +243,12 @@
# add the checks for the unwinding case just after the directcall
# in the source
- unwind_check = "if (slp_frame_stack_bottom) goto %s;" % (savelabel,)
+ unwind_check = "if (slp_frame_stack_bottom)\n\tgoto %s;" % (savelabel,)
exception_check = (super(SlpFunctionCodeGenerator, self)
.check_directcall_result(op, err))
- return '%s\n %s:\n\t%s' % (unwind_check,
- resumelabel,
- exception_check)
+ return '%s\n %s:\n%s' % (unwind_check,
+ resumelabel,
+ exception_check)
def signature_type(T):
More information about the Pypy-commit
mailing list