taichi.lang.ast.ast_transformer

Module Contents

Classes

ASTTransformer

Functions

build_stmts(ctx, stmts)

Attributes

build_stmt

class taichi.lang.ast.ast_transformer.ASTTransformer

Bases: taichi.lang.ast.ast_transformer_utils.Builder

static build_Name(ctx, node)
static build_AnnAssign(ctx, node)
static build_assign_annotated(ctx, target, value, is_static_assign, annotation)

Build an annotated assginment like this: target: annotation = value.

Parameters
  • ctx (ast_builder_utils.BuilderContext) – The builder context.

  • target (ast.Name) – A variable name. target.id holds the name as

  • string. (a) –

  • annotation – A type we hope to assign to the target

  • value – A node representing the value.

  • is_static_assign – A boolean value indicating whether this is a static assignment

static build_Assign(ctx, node)
static build_assign_unpack(ctx, node_target, values, is_static_assign)

Build the unpack assignments like this: (target1, target2) = (value1, value2). The function should be called only if the node target is a tuple.

Parameters
  • ctx (ast_builder_utils.BuilderContext) – The builder context.

  • node_target (ast.Tuple) – A list or tuple object. node_target.elts holds a

  • elements. (list of nodes representing the) –

  • values – A node/list representing the values.

  • is_static_assign – A boolean value indicating whether this is a static assignment

static build_assign_basic(ctx, target, value, is_static_assign)

Build basic assginment like this: target = value.

Parameters
  • ctx (ast_builder_utils.BuilderContext) – The builder context.

  • target (ast.Name) – A variable name. target.id holds the name as

  • string. (a) –

  • value – A node representing the value.

  • is_static_assign – A boolean value indicating whether this is a static assignment

static build_NamedExpr(ctx, node)
static is_tuple(node)
static build_Subscript(ctx, node)
static build_Tuple(ctx, node)
static build_List(ctx, node)
static build_Dict(ctx, node)
static process_listcomp(ctx, node, result)
static process_dictcomp(ctx, node, result)
static process_generators(ctx, node, now_comp, func, result)
static process_ifs(ctx, node, now_comp, now_if, func, result)
static build_comprehension(ctx, node)
static build_ListComp(ctx, node)
static build_DictComp(ctx, node)
static build_Index(ctx, node)
static build_Constant(ctx, node)
static build_Num(ctx, node)
static build_Str(ctx, node)
static build_Bytes(ctx, node)
static build_NameConstant(ctx, node)
static build_keyword(ctx, node)
static build_Starred(ctx, node)
static build_JoinedStr(ctx, node)
static build_Call(ctx, node)
static build_FunctionDef(ctx, node)
static build_Return(ctx, node)
static build_Module(ctx, node)
static build_Attribute(ctx, node)
static build_BinOp(ctx, node)
static build_AugAssign(ctx, node)
static build_UnaryOp(ctx, node)
static build_short_circuit_and(operands)
static build_short_circuit_or(operands)
static build_normal_bool_op(op)
static build_static_short_circuit_and(operands)
static build_static_short_circuit_or(operands)
static build_BoolOp(ctx, node)
static build_Compare(ctx, node)
static get_decorator(ctx, node)
static get_for_loop_targets(node)

Returns the list of indices of the for loop |node|. See also: https://docs.python.org/3/library/ast.html#ast.For

static build_static_for(ctx, node, is_grouped)
static build_range_for(ctx, node)
static build_ndrange_for(ctx, node)
static build_grouped_ndrange_for(ctx, node)
static build_struct_for(ctx, node, is_grouped)
static build_mesh_for(ctx, node)
static build_nested_mesh_for(ctx, node)
static build_For(ctx, node)
static build_While(ctx, node)
static build_If(ctx, node)
static build_Expr(ctx, node)
static build_IfExp(ctx, node)
static build_Assert(ctx, node)
static build_Break(ctx, node)
static build_Continue(ctx, node)
static build_Pass(ctx, node)
static build_Raise(ctx, node)
taichi.lang.ast.ast_transformer.build_stmt
taichi.lang.ast.ast_transformer.build_stmts(ctx, stmts)