Opened 5 years ago

Last modified 4 years ago

#341 new defect

Move Cython-language utility code inclusion to code generation phase

Reported by: dagss Owned by: somebody
Priority: major Milestone: wishlist
Component: Code Generation Keywords: utility code
Cc:

Description (last modified by scoder)

Currently, utility code written in Cython is injected into the main module tree right prior to code generation, so that the code generation phase cannot add new utility code (written in Cython). Instead of merging the trees, Code.GlobalState should do the merge at the target source file block level. (Might require chaining initialization functions though.)

Change History (1)

comment:1 Changed 4 years ago by scoder

  • Description modified (diff)

Given that the code needs to get generated into a separate namespace anyway, why not do the complete Cython utility code compilation in a separate step *after* the normal module code generation, and then just generate the utility code into the same code writer?

The only real problem that I see is that utility types need to be generated before the module declared types. Maybe we could distinguish between utility types and utility functions, and generate types before the module code generation and utility functions after it? It should be acceptable to require the need for utility types to be known before code generation. Utility types are a rare requirement anyway that should usually depend on the existence of tree nodes rather than special cases that pop up during code generation.

Or maybe utility types really need to become part of the module source tree and symbol tables, just with a separate C code namespace, so that methods and attributes can be properly looked up also during analysis...

Note: See TracTickets for help on using tickets.