Skip to main content

Module macros

Module macros 

Source
Expand description

Support module referenced by #[harn_builtin]-emitted code.

The proc-macro emits paths like crate::stdlib::macros::VmBuiltinDef, crate::stdlib::macros::BuiltinSignature, etc. This module re-exports everything those expansions need so any harn-vm/src/stdlib/*.rs file can apply #[harn_builtin] to a fn without extra imports.

Re-exports§

pub use crate::value::VmError;
pub use crate::value::VmValue;

Modules§

shapes
Shared structural-record Ty::Shape aliases reused across builtin signatures.

Structs§

BuiltinDef
A complete description of one builtin: its signature, its aliases, the runtime handler (typed by the consumer via H), and optional metadata.
BuiltinSignature
A complete, static description of one builtin: identifier, arity range, per-parameter types, generic type parameters, return type, and any where-clause bounds the type checker should enforce on call.
Param
One parameter slot inside a BuiltinSignature.
ShapeFieldDescriptor

Enums§

Ty
const-friendly type IR used in builtin descriptors. Mirrors the runtime TypeExpr from harn-parser but is constructable in const position with no allocation. Convert to TypeExpr at the boundary via the parser-side Ty::to_type_expr helper.
VmBuiltinHandler
Runtime handler attached to a VmBuiltinDef. None covers parser-only builtins (method-dispatched at runtime, but the parser still wants a signature for typo suggestion + return-type inference).

Constants§

TY_ANY
TY_BOOL
TY_BYTES
TY_BYTES_OR_NIL
bytes | nil.
TY_CLOSURE
TY_DICT
TY_DICT_OR_NIL
dict | nil.
TY_DURATION
TY_FLOAT
TY_INT
TY_INT_OR_NIL
int | nil.
TY_LIST
TY_NEVER
TY_NIL
TY_NUMBER
int | float.
TY_STRING
TY_STRING_OR_NIL
string | nil.

Statics§

ALL_BUILTIN_DEFS
Workspace-global registry of #[harn_builtin]-emitted definitions. Each annotated fn contributes one entry via #[linkme::distributed_slice(ALL_BUILTIN_DEFS)], so there is no per-module MODULE_BUILTINS slice to maintain. The CLI / LSP / lint / serve / dap binaries force-link harn-vm to defeat rlib dead-code stripping (linkme issue #36) so every static lands in this slice at link time.

Functions§

register_builtin_defs
Eager-registration helper: install every entry (name + aliases) on vm using the macro-emitted handler. Each module’s register_*_builtins(vm) calls this with its MODULE_BUILTINS slice so the call ordering between modules stays deterministic (e.g. clock overrides process::timestamp).

Type Aliases§

AsyncBuiltinFuture
Pinned future returned by async builtin handlers.
AsyncHandler
Async builtin handler signature. Receives an explicit crate::vm::AsyncBuiltinCtx handle so handlers thread the context they were given through async helper calls.
SyncHandler
Sync builtin handler signature (matches crate::vm::dispatch’s register_builtin shape).
VmBuiltinDef
BuiltinDef specialized to the VM’s handler type.

Attribute Macros§

distributed_slice
harn_builtin
Marks a Rust function as the runtime handler for a Harn builtin. Emits a sibling static <NAME>_DEF: harn_vm::stdlib::macros::VmBuiltinDef = ... containing the signature, aliases, handler pointer, and metadata.