QIEC tooling¶
Shared QIEC analysis and symbol metadata for interactive tooling.
Internal module
This module is an implementation detail of the compiler and its
tooling. Its __all__ is empty, so none of the names below are
part of the public API, and they may change without notice.
qiec_tooling
¶
Shared QIEC analysis and symbol metadata for interactive tooling.
The runtime compiler and the QIEC lowerer are deliberately separate pipelines.
This module is the small adapter used by qvr check, the REPL, and the LSP:
it lowers and validates QIEC declarations, while continuing to compile the
other QVR declarations in the same source module with their compiler.
QiecToolingDiagnostic
dataclass
¶
A frontend-neutral QIEC diagnostic.
QiecBinding
dataclass
¶
QiecBinding(name: str, kind: QiecBindingKind, declaration: object, owner: Statement, scope: tuple[int, int] | None = None)
One source-level name exposed to completion and navigation.
scope
class-attribute
instance-attribute
¶
The 1-based line range the binding is visible over.
None for a module-level declaration, which is visible throughout.
A local binder carries the span of the region that may refer to it,
so a tool can offer it at a position inside that region and nowhere
else.
is_local
property
¶
Whether this binding is confined to part of one declaration.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True when the binding carries a lexical scope, which is how a caller distinguishes a name that may be offered anywhere in the module from one that may not. |
qualified_name
property
¶
Return the declaration-qualified identity of this binding.
Signature members are scoped by their owning index, family, or effect. Top-level declarations already have a module-level identity, so their qualified spelling is just their authored name.
| RETURNS | DESCRIPTION |
|---|---|
str
|
|
semantic_kind
property
¶
The token class a highlighter should give this binding.
| RETURNS | DESCRIPTION |
|---|---|
str
|
One of |
covers
¶
Whether this binding is visible at a source line.
| PARAMETER | DESCRIPTION |
|---|---|
line
|
1-based line number.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True for a module-level binding at any line, and for a local binding only inside its own span. A tool that offers a local outside its span is offering a name that does not resolve. |
Source code in src/quivers/dsl/qiec_tooling.py
ToolingAnalysis
dataclass
¶
ToolingAnalysis(compiler: Compiler, env: dict[str, Any], non_qiec_module: Module, qiec_module: QiecModule | None, qiec_diagnostics: tuple[QiecToolingDiagnostic, ...], compile_error: CompileError | None)
The two elaboration products needed by user-facing tools.
CallSite
didactic-model
¶
CallSite(*, callee: str, owner: str, line: int, col: int, static_arguments: tuple[str, ...] = (), argument_count: int = 0)
Bases: Model
One call of a named computation in a body.
| PARAMETER | DESCRIPTION |
|---|---|
callee
|
The computation called.
TYPE:
|
owner
|
The name of the declaration the call sits in.
TYPE:
|
line
|
The call's 1-based line.
TYPE:
|
col
|
The call's 0-based column, at the callee's name.
TYPE:
|
static_arguments
|
The call's static arguments in source form, in order.
TYPE:
|
argument_count
|
The number of value arguments passed.
TYPE:
|
is_qiec_statement
¶
is_qiec_statement(statement: Statement) -> bool
Return whether statement belongs to the QIEC surface.
| PARAMETER | DESCRIPTION |
|---|---|
statement
|
The parsed statement to classify.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True for a QIEC declaration. This is the split the tooling layer works from: QIEC statements go to the lowerer and everything else to the existing compiler. |
Source code in src/quivers/dsl/qiec_tooling.py
analyze_module
¶
analyze_module(module: Module, *, module_name: str, file_path: str | None = None) -> ToolingAnalysis
Run the QIEC lowerer and existing compiler without conflating them.
QIEC failures are returned as stable diagnostics. Existing compiler errors remain separately typed so callers can retain their established diagnostic code and presentation.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module, carrying both QIEC and ordinary declarations.
TYPE:
|
module_name
|
Name the QIEC lowerer derives stable identities from. Two modules of the same name produce the same identities, so this must match what the rest of the pipeline uses.
TYPE:
|
file_path
|
Path recorded on diagnostics, or None when the source has no file.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ToolingAnalysis
|
The compiler, its environment, the non-QIEC projection, the lowered QIEC module when lowering succeeded, the QIEC diagnostics, and the compiler error when one occurred. Nothing raises: a tool needs whichever half succeeded even when the other failed. |
Source code in src/quivers/dsl/qiec_tooling.py
qiec_diagnostic
¶
qiec_diagnostic(error: Exception) -> QiecToolingDiagnostic
Normalize lowerer/kernel exceptions into the public QIEC code set.
| PARAMETER | DESCRIPTION |
|---|---|
error
|
The exception raised by the lowerer or the kernel.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
QiecToolingDiagnostic
|
A diagnostic whose code is drawn from the published set. An exception carrying a recognised code keeps it; anything else is classified by its text, so a caller always receives a stable code rather than an implementation detail. |
Source code in src/quivers/dsl/qiec_tooling.py
qiec_bindings
¶
qiec_bindings(module: Module) -> tuple[QiecBinding, ...]
Return top-level and signature-member names in source order.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module to read.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[QiecBinding, ...]
|
Every module-level QIEC name, and the members each declaration
owns. These carry no scope, being visible throughout. Names local
to a body come from
|
Source code in src/quivers/dsl/qiec_tooling.py
qiec_local_bindings
¶
qiec_local_bindings(module: Module) -> tuple[QiecBinding, ...]
Every binder local to a declaration body, in source order.
These are the names a tool may offer only inside part of a file:
let bindings, a handler clause's parameters, a scoped instance, and
the names a case branch binds. Each carries the line range it is
visible over, so a caller filters with
QiecBinding.covers.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module to traverse.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[QiecBinding, ...]
|
The local bindings. A module with no QIEC computation or handler declarations yields nothing. |
Source code in src/quivers/dsl/qiec_tooling.py
qiec_binding_map
¶
qiec_binding_map(module: Module) -> dict[str, QiecBinding]
Return unambiguous source identities for QIEC bindings.
Every signature member is available through Owner.member. A bare
member spelling remains available when exactly one declaration owns that
spelling and it does not collide with a top-level declaration. This keeps
the convenient :type get form for a single effect while preventing a
later Writer.get from silently replacing Reader.get.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module to read.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, QiecBinding]
|
Spelling to binding. A member owned by two declarations appears only under its qualified spellings, so a lookup never silently resolves to one of two equally good answers. |
Source code in src/quivers/dsl/qiec_tooling.py
qiec_binding_candidates
¶
qiec_binding_candidates(module: Module, name: str) -> tuple[QiecBinding, ...]
Return every binding matching an authored or qualified spelling.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module to search.
TYPE:
|
name
|
A bare member name or a qualified
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[QiecBinding, ...]
|
Matching bindings. A qualified spelling yields at most one. A bare spelling yields every owner that declares it, which is what lets a caller report an ambiguity rather than resolve it arbitrarily. |
Source code in src/quivers/dsl/qiec_tooling.py
qiec_env_kinds
¶
qiec_env_kinds(module: Module) -> dict[str, str]
Return semantic-token classifications for QIEC names.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module to classify.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, str]
|
Spelling to token class, for the language server's semantic token legend. Only unambiguous spellings appear, since the map it is built from omits the rest. |
Source code in src/quivers/dsl/qiec_tooling.py
qiec_surface_values
¶
qiec_surface_values(module: Module) -> dict[str, object]
Expose authored QIEC declarations in the shared inspection environment.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module to expose.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, object]
|
Spelling to the authored declaration node. These are source AST nodes rather than lowered or compiled objects, so inspecting a name in the REPL shows what the user wrote. |
Source code in src/quivers/dsl/qiec_tooling.py
render_operation
¶
render_operation(operation: OperationDef) -> str
Render one operation of an effect interface as its declaration line.
| PARAMETER | DESCRIPTION |
|---|---|
operation
|
The operation.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
|
Source code in src/quivers/dsl/qiec_tooling.py
render_effect
¶
render_effect(effect: EffectDef) -> str
Render an effect interface as its declaration.
| PARAMETER | DESCRIPTION |
|---|---|
effect
|
The interface.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The |
Source code in src/quivers/dsl/qiec_tooling.py
prelude_effect
¶
prelude_effect(name: str) -> EffectDef | None
The prelude interface of a name, if the prelude declares one.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The interface's name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
EffectDef | None
|
The interface, or |
Source code in src/quivers/dsl/qiec_tooling.py
instance_effect_name
¶
instance_effect_name(module: Module, instance: str) -> str | None
The interface a module-level instance declaration instantiates.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module.
TYPE:
|
instance
|
The instance's name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str | None
|
The interface's name, or |
Source code in src/quivers/dsl/qiec_tooling.py
effect_operation_names
¶
effect_operation_names(module: Module, effect: str) -> tuple[str, ...]
The operations of an interface, declared in the module or by the prelude.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module.
TYPE:
|
effect
|
The interface's name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[str, ...]
|
The operation names in declaration order; empty for an unknown interface. A module's own declaration shadows the prelude's. |
Source code in src/quivers/dsl/qiec_tooling.py
call_sites
¶
Every call of a named computation in a module.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[CallSite, ...]
|
The calls in computation bodies, handler clause bodies, and program bodies, in source order. A recursive call is a call whose callee is its owner. |
Source code in src/quivers/dsl/qiec_tooling.py
call_site_at
¶
The call whose callee name covers a source position.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module.
TYPE:
|
line
|
The 0-based line.
TYPE:
|
col
|
The 0-based column.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
CallSite | None
|
The call, or |
Source code in src/quivers/dsl/qiec_tooling.py
instantiated_call_signature
¶
Render the signature a call instantiates its callee at.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module.
TYPE:
|
site
|
The call.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str | None
|
The callee's declaration line with each static binder replaced
by the call's argument for it, and the |
Source code in src/quivers/dsl/qiec_tooling.py
qualified_operation_signature
¶
qualified_operation_signature(module: Module, spelling: str) -> str | None
Render an operation addressed through its interface or an instance.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module.
TYPE:
|
spelling
|
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str | None
|
The operation's declaration line under the given spelling, with
an instance's static arguments substituted for the interface's
binders ( |
Source code in src/quivers/dsl/qiec_tooling.py
1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 | |
qiec_module_name
¶
Derive a deterministic source module name for editor/CLI entry points.
The name enters every stable identity the lowerer derives, so it has to depend on the path alone and not on how the path was spelled.
| PARAMETER | DESCRIPTION |
|---|---|
file_path
|
The source path, possibly a
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The path's stem, |