class documentation

class NativeCodeGenerator(CodeGenerator):

View In Hierarchy

A code generator which renders Python types by not adding str() around output nodes.
Static Method ​_default​_finalize 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​_child​_post Output extra source code after visiting a child of an Output node.
Method ​_output​_child​_pre Output extra source code before visiting a child of an Output node.
Method ​_output​_child​_to​_const Try to optimize a child of an Output node by trying to convert it to constant, finalized data at compile time.
Method ​_output​_const​_repr Given a group of constant values converted from Output child nodes, produce a string to write to the template module source.

Inherited from CodeGenerator:

Class _​Finalize​Info Undocumented
Method __init__ Undocumented
Method ​_filter​_test​_common Undocumented
Method ​_import​_common Undocumented
Method ​_make​_finalize Build the finalize function to be used on constants and at runtime. Cached so it's only created once for all output nodes.
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​_async Undocumented
Method derive​_context Undocumented
Method dump​_local​_context Undocumented
Method end​_write End the writing process started by start_write.
Method enter​_frame Undocumented
Method fail Fail with a TemplateAssertionError.
Method func Undocumented
Method get​_context​_ref Undocumented
Method get​_resolve​_func Undocumented
Method indent Indent by one.
Method leave​_frame Undocumented
Method macro​_body Dump the function def of a macro or call block.
Method macro​_def Dump the macro definition for the def created by macro_body.
Method mark​_parameter​_stored 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​_is​_undeclared Checks if a given target is an undeclared parameter.
Method pop​_assign​_tracking Pops the topmost level for assignment tracking and updates the context variables if necessary.
Method pop​_context​_reference Undocumented
Method pop​_parameter​_definitions Pops the current parameter definitions set.
Method position Return a human readable position for the node.
Method pull​_dependencies No summary
Method push​_assign​_tracking Pushes a new layer for assignment tracking.
Method push​_context​_reference Undocumented
Method push​_parameter​_definitions No summary
Method return​_buffer​_contents Return the buffer contents of the frame.
Method signature No summary
Method simple​_write Simple shortcut for start_write + write + end_write.
Method start​_write Yield or write into the frame buffer.
Method temporary​_identifier Get a new unique identifier.
Method visit_​Assign Undocumented
Method visit_​Assign​Block Undocumented
Method visit_​Block Call a block and register it for the template.
Method visit_​Break Undocumented
Method visit_​Call Undocumented
Method visit_​Call​Block Undocumented
Method visit_​Compare Undocumented
Method visit_​Concat Undocumented
Method visit_​Cond​Expr Undocumented
Method visit_​Const Undocumented
Method visit_​Context​Reference Undocumented
Method visit_​Continue Undocumented
Method visit_​Derived​Context​Reference Undocumented
Method visit_​Dict Undocumented
Method visit_​Environment​Attribute Undocumented
Method visit_​Eval​Context​Modifier Undocumented
Method visit_​Expr​Stmt Undocumented
Method visit_​Extends Calls the extender.
Method visit_​Extension​Attribute Undocumented
Method visit_​Filter Undocumented
Method visit_​Filter​Block Undocumented
Method visit_​For Undocumented
Method visit_​From​Import Visit named imports.
Method visit_​Getattr Undocumented
Method visit_​Getitem Undocumented
Method visit_​If Undocumented
Method visit_​Import Visit regular imports.
Method visit_​Imported​Name Undocumented
Method visit_​Include Handles includes.
Method visit_​Internal​Name Undocumented
Method visit_​Keyword Undocumented
Method visit_​List Undocumented
Method visit_​Macro Undocumented
Method visit_​Mark​Safe Undocumented
Method visit_​Mark​Safe​If​Autoescape Undocumented
Method visit_​Name Undocumented
Method visit_​NSRef Undocumented
Method visit_​Operand Undocumented
Method visit_​Output Undocumented
Method visit_​Overlay​Scope Undocumented
Method visit_​Scope Undocumented
Method visit_​Scoped​Eval​Context​Modifier Undocumented
Method visit_​Slice Undocumented
Method visit_​Template Undocumented
Method visit_​Template​Data Undocumented
Method visit_​Test Undocumented
Method visit_​Tuple Undocumented
Method visit_​With Undocumented
Method write Write a string into the output stream.
Method write​_commons 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_​Add Undocumented
Class Variable visit_​And Undocumented
Class Variable visit_​Div Undocumented
Class Variable visit_​Floor​Div Undocumented
Class Variable visit_​Mod Undocumented
Class Variable visit_​Mul Undocumented
Class Variable visit_​Neg Undocumented
Class Variable visit_​Not Undocumented
Class Variable visit_​Or Undocumented
Class Variable visit_​Pos Undocumented
Class Variable visit_​Pow Undocumented
Class Variable visit_​Sub Undocumented
Instance Variable ​_assign​_stack Undocumented
Instance Variable ​_context​_reference​_stack Undocumented
Instance Variable ​_finalize Undocumented
Instance Variable ​_first​_write Undocumented
Instance Variable ​_indentation Undocumented
Instance Variable ​_last​_identifier Undocumented
Instance Variable ​_last​_line Undocumented
Instance Variable ​_new​_lines Undocumented
Instance Variable ​_param​_def​_block Undocumented
Instance Variable ​_write​_debug​_info Undocumented
Instance Variable blocks Undocumented
Instance Variable code​_lineno Undocumented
Instance Variable created​_block​_context Undocumented
Instance Variable debug​_info Undocumented
Instance Variable defer​_init Undocumented
Instance Variable environment Undocumented
Instance Variable extends​_so​_far Undocumented
Instance Variable filename Undocumented
Instance Variable filters Undocumented
Instance Variable has​_known​_extends Undocumented
Instance Variable import​_aliases Undocumented
Instance Variable name Undocumented
Instance Variable optimizer Undocumented
Instance Variable stream Undocumented
Instance Variable tests Undocumented
Property optimized Undocumented

Inherited from NodeVisitor (via CodeGenerator):

Method generic​_visit Called if no explicit visitor function exists for a node.
Method get​_visitor 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.
@staticmethod
def _default_finalize(value):
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.
Parameters
value:t.AnyUndocumented
Returns
t.AnyUndocumented
def _output_child_post(self, node, frame, finalize):
Output extra source code after visiting a child of an Output node.
Parameters
node:nodes.ExprUndocumented
frame:FrameUndocumented
finalize:CodeGenerator._FinalizeInfoUndocumented
def _output_child_pre(self, node, frame, finalize):
Output extra source code before visiting a child of an Output node.
Parameters
node:nodes.ExprUndocumented
frame:FrameUndocumented
finalize:CodeGenerator._FinalizeInfoUndocumented
def _output_child_to_const(self, node, frame, finalize):

Try to optimize a child of an Output node by trying to convert it to constant, finalized data at compile time.

If 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.ExprUndocumented
frame:FrameUndocumented
finalize:CodeGenerator._FinalizeInfoUndocumented
Returns
t.AnyUndocumented
def _output_const_repr(self, group):
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[t.Any]Undocumented
Returns
strUndocumented