Expand description
gdscript-hir — the semantic / type layer.
Lowers the AST to a HIR (an ItemTree of signatures + per-function Body), runs name resolution
(local → class member → inherited → global), gradual type inference (Variant by default,
:=/annotations, member lookup over the engine inheritance table, is/as narrowing), and the
GDScript warning checks. Single-file in Phase 2; project-wide + scene-aware later.
Phase 2 builds this out bottom-up: the type model (ty), then the item tree, body, name
resolution, and inference. Must build for wasm32.
Modules§
- body
- Body lowering (Playbook §3.1/§3.4): a function body (or a class-level initializer
expression) lowered from the CST into a flat arena of
Expr/Stmtaddressed byExprId/StmtId, plus aBodySourceMapmapping everyExprIdback to its byte range. Every IDE feature (hover, inlay, completion) maps a cursor offset →ExprIdthrough this source map, then reads the inferred type fromcrate::infer. - def
- Canonical symbol identity + cursor classification (Playbook §3.M5) — the basis of cross-file navigation (find-references, rename, goto-definition).
- flow
- Per-body control-flow narrowing (Phase-6 Workstream 2).
- infer
- Gradual type inference (Playbook §3.3–§3.6 + §5): a single forward, bottom-up,
bidirectional walk over a lowered
Body. No unification variables — types flow forward from annotations, literals, and the engine API (rust-analyzer’s structure, Pyright’s gradual semantics). - item_
tree - The item tree (Playbook §3.1): a signature-level view of one
.gdfile — itsclass_name,extendstarget, and class members (funcs/vars/consts/signals/enums/inner classes) — lowered from the CST without reading any function body. - project
project.godotautoload parsing (Playbook §3.M4).- queries
- The salsa-tracked entry points for the semantic layer, layered on
gdscript-db’sparsequery. - resolve
- Name & type resolution (Playbook §3.2/§3.5): the
resolve_externalPhase-3 seam, the GDScript source-annotation →Tyresolver, base-class resolution, the per-classClassScope(the class-member tier of the binder), and global resolution. - ty
- The Phase-2 type model (Playbook §2/§3.5): the gradual
Tylattice overVariant, the hard/softTypeSource, the portedis_assignablecompatibility check, andTyRef→Tyresolution against the engine API. - warnings
- The Godot warning catalog + the emit-then-gate seam (Phase-6 Workstream 1).
Structs§
- AstPtr
- A reparse-stable pointer to a syntax node — its
SyntaxKindplus byteTextRange(rust-analyzer’sSyntaxNodePtr). Because it is plainCopydata keyed on text position, identical source re-parses to the identical pointer, which is what lets thecrate::item_tree::ItemTreestayEqwhile still being able to recover the CST node for deferred body lowering / initializer inference.