taichi.lang.ast.ast_transformer

Module Contents

Classes

ASTTransformer

Functions

build_stmts(ast_builder, ctx, stmts)

Attributes

build_stmt

class taichi.lang.ast.ast_transformer.ASTTransformer

Bases: taichi.lang.ast.ast_transformer_utils.Builder

static build_Name(ast_builder, ctx, node)
static build_AnnAssign(ast_builder, ctx, node)
static build_assign_annotated(ast_builder, 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(ast_builder, ctx, node)
static build_assign_unpack(ast_builder, 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(ast_builder, 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(ast_builder, ctx, node)
static is_tuple(node)
static build_Subscript(ast_builder, ctx, node)
static build_Tuple(ast_builder, ctx, node)
static build_List(ast_builder, ctx, node)
static build_Dict(ast_builder, ctx, node)
static process_listcomp(ast_builder, ctx, node, result)
static process_dictcomp(ast_builder, ctx, node, result)
static process_generators(ast_builder, ctx, node, now_comp, func, result)
static process_ifs(ast_builder, ctx, node, now_comp, now_if, func, result)
static build_comprehension(ast_builder, ctx, node)
static build_ListComp(ast_builder, ctx, node)
static build_DictComp(ast_builder, ctx, node)
static build_Index(ast_builder, ctx, node)
static build_Constant(ast_builder, ctx, node)
static build_Num(ast_builder, ctx, node)
static build_Str(ast_builder, ctx, node)
static build_Bytes(ast_builder, ctx, node)
static build_NameConstant(ast_builder, ctx, node)
static build_keyword(ast_builder, ctx, node)
static build_Starred(ast_builder, ctx, node)
static build_JoinedStr(ast_builder, ctx, node)
static build_Call(ast_builder, ctx, node)
static build_FunctionDef(ast_builder, ctx, node)
static build_Return(ast_builder, ctx, node)
static build_Module(ast_builder, ctx, node)
static build_Attribute(ast_builder, ctx, node)
static build_BinOp(ast_builder, ctx, node)
static build_AugAssign(ast_builder, ctx, node)
static build_UnaryOp(ast_builder, ctx, node)
static build_short_circuit_and(ast_builder, operands)
static build_short_circuit_or(ast_builder, operands)
static build_normal_bool_op(op)
static build_static_short_circuit_and(ast_builder, operands)
static build_static_short_circuit_or(ast_builder, operands)
static build_BoolOp(ast_builder, ctx, node)
static build_Compare(ast_builder, 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(ast_builder, ctx, node, is_grouped)
static build_range_for(ast_builder, ctx, node)
static build_ndrange_for(ast_builder, ctx, node)
static build_grouped_ndrange_for(ast_builder, ctx, node)
static build_struct_for(ast_builder, ctx, node, is_grouped)
static build_mesh_for(ast_builder, ctx, node)
static build_nested_mesh_for(ast_builder, ctx, node)
static build_For(ast_builder, ctx, node)
static build_While(ast_builder, ctx, node)
static build_If(ast_builder, ctx, node)
static build_Expr(ast_builder, ctx, node)
static build_IfExp(ast_builder, ctx, node)
static build_Assert(ast_builder, ctx, node)
static build_Break(ast_builder, ctx, node)
static build_Continue(ast_builder, ctx, node)
static build_Pass(ast_builder, ctx, node)
static build_Raise(ast_builder, ctx, node)
taichi.lang.ast.ast_transformer.build_stmt
taichi.lang.ast.ast_transformer.build_stmts(ast_builder, ctx, stmts)