src/basilisp/lang/compiler/generator.py
def _local_sym_to_py_ast(
    ctx: GeneratorContext, node: Local, is_assigning: bool = False
) -> GeneratedPyAST:
    """Generate a Python AST node for accessing a locally defined Python variable."""
    assert node.op == NodeOp.LOCAL

    sym_entry = ctx.symbol_table.find_symbol(sym.symbol(node.name))
    assert sym_entry is not None

    if node.local == LocalType.FIELD:
        this_entry = ctx.symbol_table.find_symbol(ctx.current_this)
        assert this_entry is not None, "Field type local must have this"

        return GeneratedPyAST(
            node=_load_attr(
                f"{this_entry.munged}.{sym_entry.munged}",
                ctx=ast.Store() if is_assigning else ast.Load(),
            )
        )
    else:
        return GeneratedPyAST(
            node=ast.Name(
                id=sym_entry.munged, ctx=ast.Store() if is_assigning else ast.Load()
            )
        )
def _local_sym_to_py_ast(
    ctx: GeneratorContext, node: Local, is_assigning: bool = False
) -> GeneratedPyAST:
    assert node.op == NodeOp.LOCAL

    sym_entry = ctx.symbol_table.find_symbol(sym.symbol(node.name))
    assert sym_entry is not None

    if node.local == LocalType.FIELD:
        this_entry = ctx.symbol_table.find_symbol(ctx.current_this)
        assert this_entry is not None, "Field type local must have this"

        return GeneratedPyAST(
            node=_load_attr(
                f"{this_entry.munged}.{sym_entry.munged}",
                ctx=ast.Store() if is_assigning else ast.Load(),
            )
        )
    else:
        return GeneratedPyAST(
            node=ast.Name(
                id=sym_entry.munged, ctx=ast.Store() if is_assigning else ast.Load()
            )
        )
def _local_sym_to_py_ast ( ctx : GeneratorContext , node : Local , is_assigning : bool = False ) -> GeneratedPyAST : assert node . op == NodeOp . LOCAL sym_entry = ctx . symbol_table . find_symbol ( sym . symbol ( node . name ) ) assert sym_entry is not None if node . local == LocalType . FIELD : this_entry = ctx . symbol_table . find_symbol ( ctx . current_this ) assert this_entry is not None , "Field type local must have this" return GeneratedPyAST ( node = _load_attr ( f"{this_entry.munged}.{sym_entry.munged}" , ctx = ast . Store ( ) if is_assigning else ast . Load ( ) , ) ) else : return GeneratedPyAST ( node = ast . Name ( id = sym_entry . munged , ctx = ast . Store ( ) if is_assigning else ast . Load ( ) ) )
Generate a Python AST node for accessing a locally defined Python variable.
Generate a Python AST node for accessing a locally defined Python variable .