taichi.lang.ast.symbol_resolver

Provides helpers to resolve AST nodes.

Module Contents

Classes

ASTResolver

Provides helper methods to resolve AST nodes.

class taichi.lang.ast.symbol_resolver.ASTResolver

Provides helper methods to resolve AST nodes.

static resolve_to(node, wanted, scope)

Check if symbol node resolves to wanted object.

This is only intended to check if a given AST node resolves to a symbol under some namespaces, e.g. the a.b.c.foo pattern, but not meant for more complicated expressions like (a + b).foo.

Parameters
  • node (Union[ast.Attribute, ast.Name]) – an AST node to be resolved.

  • wanted (Any) – The expected python object.

  • scope (Dict[str, Any]) – Maps from symbol names to objects, for example, globals()

Returns

The checked result.

Return type

bool