cython/cython — pull request #93 by scoder (2012-03-14 19:50:23+00:00)
Title: construct 'lnotab' byte string for code objects

The intention of this change is to eventually be able to support runtime mapping of line numbers for code objects. What CPython does is to pack a byte code offset to line number offset map into a byte string and store it in the code object. This is what this patch does as well, so that the line number could be computed by CPython by simply using ```current source line - first source line of function``` as a fake byte code offset for Cython functions when tracing or raising an exception. This will allow reuse of the code object over the whole body of a function.

A current problem is the syntax tree layout for Cython functions that have a code object. Here, the code object lives outside of the function, specifically in the fused functions object. It would be better to move it inside of the function itself, where the function code could use it. This is not entirely trivial because the fused function code currently reuses one code object for all specialisations, which doesn't work well with the idea of letting each separate function own it.

By itself, this patch isn't very interesting because Cython does not currently use byte code offsets in frame objects. But it's the first non-trivial step in that direction and should be applied at some point before refactoring the syntax tree.