taichi.lang.ast

Submodules

Package Contents

Classes

ASTTransformerContext

KernelSimplicityASTChecker

A node visitor base class that walks the abstract syntax tree and calls a

Functions

transform_tree(tree, ctx: taichi.lang.ast.ast_transformer_utils.ASTTransformerContext)

class taichi.lang.ast.ASTTransformerContext(excluded_parameters=(), is_kernel=True, func=None, arg_features=None, global_vars=None, argument_data=None, file=None, src=None, start_lineno=None)
variable_scope_guard(self)
loop_scope_guard(self, is_static=False)
non_static_scope_guard(self)
current_scope(self)
current_loop_scope(self)
loop_status(self)
set_loop_status(self, status)
is_in_static_for(self)
is_in_non_static(self)
is_var_declared(self, name)
create_variable(self, name, var)
check_loop_var(self, loop_var)
get_var_by_name(self, name)
get_pos_info(self, node)
class taichi.lang.ast.KernelSimplicityASTChecker(func)

Bases: ast.NodeVisitor

A node visitor base class that walks the abstract syntax tree and calls a visitor function for every node found. This function may return a value which is forwarded by the visit method.

This class is meant to be subclassed, with the subclass adding visitor methods.

Per default the visitor functions for the nodes are 'visit_' + class name of the node. So a TryFinally node visit function would be visit_TryFinally. This behavior can be changed by overriding the visit method. If no visitor function exists for a node (return value None) the generic_visit visitor is used instead.

Don’t use the NodeVisitor if you want to apply changes to nodes during traversing. For this a special visitor exists (NodeTransformer) that allows modifications.

class ScopeGuard(checker)
property allows_for_loop(self)
property allows_more_stmt(self)
mark_no_more_for_loop(self)
mark_no_more_stmt(self)
new_scope(self)
property current_scope(self)
property top_level(self)
get_error_location(self, node)
static should_check(node)
generic_visit(self, node)

Called if no explicit visitor function exists for a node.

static visit_for(node)
taichi.lang.ast.transform_tree(tree, ctx: taichi.lang.ast.ast_transformer_utils.ASTTransformerContext)