Expand description
IR canonicalization.
Walks an Expr / Statement tree and applies two
normalising passes so downstream consumers (lineage, bindgen,
symbol cross-check) work against a single canonical shape:
- Fully-qualify names. A bare reference like
employeesin a routine declared in schemaHRis rewritten toHR.EMPLOYEES. The caller supplies aCanonicalisationContextcarrying the active schema + the package containing the reference (if any) so the resolver knows what scope to consult. - Desugar implicit cursor FOR loops. PL/SQL accepts
FOR row IN (SELECT … FROM …) LOOP …as syntactic sugar for an explicit cursor declaration. The canonicaliser rewrites this shape intoForLoopwhoserange_textcarries the SELECT and whosebody_textis the same; the side-effect is to flag the loop’s iterator as having an implicit%ROWTYPEof the select projection so the bindings layer can resolve it.
Anything outside these two passes is left untouched — the
canonicaliser is a thin layer above the IR shape ships from
expr.rs + stmt.rs.
§/oracle evidence
DATABASE-REFERENCE.mdPL/SQL Language Reference — Naming chapter governs how a bare reference resolves against the current schema; the Cursor FOR Loop section spells out the implicit-cursor desugaring rule.LOW-LEVEL-CATALOGS.mdData Dictionary View Families —ALL_OBJECTSis the server-side authority for whether a fully-qualified name actually exists; the offline canonicaliser defers that cross-check to a later stage.
Structs§
- Canonicalisation
Context - Caller-supplied state that drives canonicalization. The active schema is required; an optional active package scopes references to package-local names first.
- Canonicalisation
Stats
Functions§
- canonicalize_
expr - Canonicalize one expression against
ctx. Returns the rewrittenExprplus the stats. - canonicalize_
statements - Canonicalize a statement-body slice. Walks every statement
and applies expression canonicalization to embedded
rhs_text/cond_textslices (re-lowered throughlower_expressionfirst).