class NativeCodeGenerator(CodeGenerator): (source)
A code generator which renders Python types by not adding ``str()`` around output nodes.
Static Method | _default |
The default finalize function if the environment isn't configured with one. Or, if the environment has one, this is called on that function's output for constants. |
Method | _output |
Output extra source code after visiting a child of an ``Output`` node. |
Method | _output |
Output extra source code before visiting a child of an ``Output`` node. |
Method | _output |
Try to optimize a child of an ``Output`` node by trying to convert it to constant, finalized data at compile time. |
Method | _output |
Given a group of constant values converted from ``Output`` child nodes, produce a string to write to the template module source. |
Inherited from CodeGenerator
:
Method | __init__ |
Undocumented |
Method | blockvisit |
Visit a list of nodes as block in a frame. If the current frame is no buffer a dummy ``if 0: yield None`` is written automatically. |
Method | buffer |
Enable buffering for the frame from that point onwards. |
Method | choose |
Undocumented |
Method | derive |
Undocumented |
Method | dump |
Undocumented |
Method | end |
End the writing process started by `start_write`. |
Method | enter |
Undocumented |
Method | fail |
Fail with a :exc:`TemplateAssertionError`. |
Method | func |
Undocumented |
Method | get |
Undocumented |
Method | get |
Undocumented |
Method | indent |
Indent by one. |
Method | leave |
Undocumented |
Method | macro |
Dump the function def of a macro or call block. |
Method | macro |
Dump the macro definition for the def created by macro_body. |
Method | mark |
Marks a parameter in the current parameter definitions as stored. This will skip the enforced undefined checks. |
Method | newline |
Add one or more newlines before the next write. |
Method | outdent |
Outdent by step. |
Method | parameter |
Checks if a given target is an undeclared parameter. |
Method | pop |
Pops the topmost level for assignment tracking and updates the context variables if necessary. |
Method | pop |
Undocumented |
Method | pop |
Pops the current parameter definitions set. |
Method | position |
Return a human readable position for the node. |
Method | pull |
Find all filter and test names used in the template and assign them to variables in the compiled namespace. Checking that the names are registered with the environment is done when compiling the Filter and Test nodes... |
Method | push |
Pushes a new layer for assignment tracking. |
Method | push |
Undocumented |
Method | push |
Pushes all parameter targets from the given frame into a local stack that permits tracking of yet to be assigned parameters. In particular this enables the optimization from `visit_Name` to skip undefined expressions for parameters in macros as macros can reference otherwise unbound parameters. |
Method | return |
Return the buffer contents of the frame. |
Method | signature |
Writes a function call to the stream for the current node. A leading comma is added automatically. The extra keyword arguments may not include python keywords otherwise a syntax error could occur. The extra keyword arguments should be given as python dict. |
Method | simple |
Simple shortcut for start_write + write + end_write. |
Method | start |
Yield or write into the frame buffer. |
Method | temporary |
Get a new unique identifier. |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Call a block and register it for the template. |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Calls the extender. |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Visit named imports. |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Visit regular imports. |
Method | visit_ |
Undocumented |
Method | visit_ |
Handles includes. |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | visit_ |
Undocumented |
Method | write |
Write a string into the output stream. |
Method | write |
Writes a common preamble that is used by root and block functions. Primarily this sets up common local helpers and enforces a generator through a dead branch. |
Method | writeline |
Combination of newline and write. |
Class Variable | visit_ |
Undocumented |
Class Variable | visit_ |
Undocumented |
Class Variable | visit_ |
Undocumented |
Class Variable | visit_ |
Undocumented |
Class Variable | visit_ |
Undocumented |
Class Variable | visit_ |
Undocumented |
Class Variable | visit_ |
Undocumented |
Class Variable | visit_ |
Undocumented |
Class Variable | visit_ |
Undocumented |
Class Variable | visit_ |
Undocumented |
Class Variable | visit_ |
Undocumented |
Class Variable | visit_ |
Undocumented |
Instance Variable | blocks |
Undocumented |
Instance Variable | code |
Undocumented |
Instance Variable | created |
Undocumented |
Instance Variable | debug |
Undocumented |
Instance Variable | defer |
Undocumented |
Instance Variable | environment |
Undocumented |
Instance Variable | extends |
Undocumented |
Instance Variable | filename |
Undocumented |
Instance Variable | filters |
Undocumented |
Instance Variable | has |
Undocumented |
Instance Variable | import |
Undocumented |
Instance Variable | name |
Undocumented |
Instance Variable | optimizer |
Undocumented |
Instance Variable | stream |
Undocumented |
Instance Variable | tests |
Undocumented |
Property | optimized |
Undocumented |
Class | _ |
Undocumented |
Method | _filter |
Undocumented |
Method | _import |
Undocumented |
Method | _make |
Build the finalize function to be used on constants and at runtime. Cached so it's only created once for all output nodes. |
Instance Variable | _assign |
Undocumented |
Instance Variable | _context |
Undocumented |
Instance Variable | _finalize |
Undocumented |
Instance Variable | _first |
Undocumented |
Instance Variable | _indentation |
Undocumented |
Instance Variable | _last |
Undocumented |
Instance Variable | _last |
Undocumented |
Instance Variable | _new |
Undocumented |
Instance Variable | _param |
Undocumented |
Instance Variable | _write |
Undocumented |
Inherited from NodeVisitor
(via CodeGenerator
):
Method | generic |
Called if no explicit visitor function exists for a node. |
Method | get |
Return the visitor function for this node or `None` if no visitor exists for this node. In that case the generic visit function is used instead. |
Method | visit |
Visit a node. |
Output extra source code after visiting a child of an ``Output`` node.
Parameters | |
node:nodes.Expr | Undocumented |
frame:Frame | Undocumented |
finalize:CodeGenerator._FinalizeInfo | Undocumented |
Output extra source code before visiting a child of an ``Output`` node.
Parameters | |
node:nodes.Expr | Undocumented |
frame:Frame | Undocumented |
finalize:CodeGenerator._FinalizeInfo | Undocumented |
Try to optimize a child of an ``Output`` node by trying to convert it to constant, finalized data at compile time. If :exc:`Impossible` is raised, the node is not constant and will be evaluated at runtime. Any other exception will also be evaluated at runtime for easier debugging.
Parameters | |
node:nodes.Expr | Undocumented |
frame:Frame | Undocumented |
finalize:CodeGenerator._FinalizeInfo | Undocumented |
Returns | |
t.Any | Undocumented |
Given a group of constant values converted from ``Output`` child nodes, produce a string to write to the template module source.
Parameters | |
group:t.Iterable[ | Undocumented |
Returns | |
str | Undocumented |