Expand description
Declarative registry of Gruel’s @intrinsic set.
This crate is the single source of truth for every intrinsic the compiler
recognizes. Each intrinsic is described by an IntrinsicDef value; the
full list lives in INTRINSICS. Compiler stages (RIR astgen, Sema,
codegen) consult the registry instead of carrying their own name lists, and
the website’s intrinsic reference page is generated from the same data.
Behavior (semantic analyzers, codegen arms) still lives in the consumer
crates — the registry owns metadata and identity, not per-intrinsic logic.
Stages dispatch on the stable IntrinsicId enum rather than matching
strings.
§What earns a place in this registry
ADR-0087 commits to the rule: intrinsics carry compiler magic, not
transport. A row earns its place in IntrinsicId / INTRINSICS if it
does at least one of:
- Codegen-emitted lowering of a language feature (e.g.
@vec(...)constructs aVec(T)aggregate; pointer ops emit a typedload/store;@spawnsynthesises a@mark(c)thunk per(arg, ret, fn)triple). - Compile-time type / kind dispatch on heterogeneous arguments (e.g.
@dbg(42, true, "hi")routes per arg type;@type_info(T)). - Compile-time evaluation with no runtime presence (e.g.
@size_of,@align_of,@target_arch,@compile_error). - A row is blocked on a missing language feature that would otherwise
let it move to the prelude (ADR-0087 currently tracks four such rows —
@panicfamily,@spawn/@thread_join,@cstr_to_vec,@dbg— each with a documented prerequisite).
Rows that exist only because “there is a libc function we want to call”
and have an expressible Gruel signature today do NOT belong here. ADR-0087
migrated the original wave of those rows (@read_line, @parse_*,
@random_*, @utf8_validate, @bytes_eq, @alloc / @free /
@realloc) to prelude fns in prelude/runtime_wrappers.gruel; future
additions of similar shape should land there first.
Structs§
- Intrinsic
Def - Metadata for one intrinsic. Instances live as
constentries inINTRINSICS; nothing in this type is runtime-mutable. - Pointer
Method - One method or associated function on
Ptr(T)/MutPtr(T)(ADR-0063). - Slice
Method - One method on
Slice(T)/MutSlice(T)(ADR-0064).
Enums§
- Category
- High-level grouping used when rendering the documentation reference page.
- Intrinsic
Id - Stable identity for every intrinsic. Stages dispatch on this rather than comparing strings, so adding an intrinsic requires updating a closed match in each consumer — the compiler enforces coverage.
- Intrinsic
Kind - Whether an intrinsic takes an expression argument list (the common case)
or a type argument (
@size_of(T),@type_info(T), etc.). - Pointer
Kind - Which builtin pointer constructor an entry is defined on.
- Pointer
OpForm - Whether an entry is an instance method or an associated function.
- Slice
Kind - Which builtin slice constructor an entry is defined on.
Constants§
- INTRINSICS
- The canonical list of every intrinsic the compiler recognizes.
- POINTER_
METHODS - Closed registry of every pointer method / associated function (ADR-0063).
- SLICE_
METHODS - Closed registry of every slice method (ADR-0064).
Functions§
- by_
category - Iterate over intrinsics in a single category.
- is_
type_ intrinsic - Is this name a type intrinsic (takes a type arg, as
@size_of(T)does)? - iter
- Iterate over every registered intrinsic.
- lookup_
by_ id - Look up an intrinsic by its stable
IntrinsicId. - lookup_
by_ name - Look up an intrinsic by its source-level name (without the leading
@). - lookup_
pointer_ method - Look up a pointer method/assoc fn by
(kind, name, form). - lookup_
slice_ method - Look up a slice method by
(kind, name). - render_
reference_ markdown - Render the full intrinsics reference page as markdown.