|
ESBMC
Efficient SMT-based Context-Bounded Model Checker
|
Classes | |
| class | ImportResolverLike |
| class | JsonEmitterDeps |
| class | EmitPipelineDeps |
Functions | |
| set[str] | get_referenced_names (ast.AST node) |
| Iterable[str] | _assign_target_names (ast.expr target) |
| set[str] | _node_bound_names (ast.stmt node) |
| list[ast.stmt] | _filter_nodes_for_import (ast.Module tree, elements_to_import) |
| str | _compute_output_json_path (str python_filename, str output_dir, str|None module_qualname) |
| None | _reject_unencodable_string_constants (ast.AST tree, str source_filename) |
| generate_ast_json (ast.Module tree, str python_filename, elements_to_import, str output_dir, module_qualname=None, *, JsonEmitterDeps deps) | |
| None | emit_file_as_json (str filename, str output_dir, str|None module_qualname=None, elements_to_import=None, *, EmitPipelineDeps deps) |
| None | emit_module_json (str module_qualname, str output_dir, elements_to_import=None, *, EmitPipelineDeps deps) |
AST JSON emission helpers for parser pipeline.
|
protected |
|
protected |
|
protected |
Return the subset of ``tree.body`` selected by ``elements_to_import``. Beyond the explicitly imported names, retain every top-level definition or global *transitively* referenced by them, computed as a fixpoint over ``get_referenced_names``. An imported class whose method reads a module global — or calls a sibling helper that itself reads one — keeps that global in the emitted body, matching CPython's rule that the global resolves against its defining module at call time (GitHub #4984). The closure only ever adds nodes, so it cannot drop anything the previous one-hop scan kept.
|
protected |
Top-level binding names introduced by ``node`` (empty for non-bindings).
|
protected |
Refuse string literals that cannot cross the parser->converter JSON boundary. A surrogate code point is representable in a CPython ``str`` but has no UTF-8 encoding, and the C++ reader rejects both transportable spellings: an escaped ``\\ud800`` is invalid JSON (nlohmann requires a low surrogate to follow), and the WTF-8 byte form is ill-formed UTF-8. Python never combines a surrogate pair, so ``"\\ud83d\\ude00"`` is two unencodable code points rather than an emoji and is refused the same way. Emitting one aborts the parser mid-``json.dump``, so refuse at parse time with a located diagnostic rather than crash or emit a silently truncated string.
| None parser.json_emitter.emit_file_as_json | ( | str | filename, |
| str | output_dir, | ||
| str | None | module_qualname = None, | ||
| elements_to_import = None, | |||
| * | , | ||
| EmitPipelineDeps | deps ) |
Generate AST JSON for a source file.
| None parser.json_emitter.emit_module_json | ( | str | module_qualname, |
| str | output_dir, | ||
| elements_to_import = None, | |||
| * | , | ||
| EmitPipelineDeps | deps ) |
Resolve module to file and emit AST JSON.
| parser.json_emitter.generate_ast_json | ( | ast.Module | tree, |
| str | python_filename, | ||
| elements_to_import, | |||
| str | output_dir, | ||
| module_qualname = None, | |||
| * | , | ||
| JsonEmitterDeps | deps ) |
Generate AST JSON from the given Python AST tree.
| set[str] parser.json_emitter.get_referenced_names | ( | ast.AST | node | ) |
Collect every name *read* inside a definition (``Load`` context). This subsumes call targets (``C()``), type annotations (``-> Node``, ``x: Tile``), and — crucially — bare reads of module-level globals such as a method that reads a module constant. Capturing the last case lets a named import (``from mod import C``) carry along the globals ``C``'s methods reference, instead of dropping them and failing name resolution at the use site (GitHub #4984). Local stores and parameters are in ``Store``/``Param`` context and are intentionally excluded; only top-level definitions whose names match are ever retained by ``_filter_nodes_for_import``, so any incidental over-collection is sound (it can only keep a real sibling global, never drop one).