← All docs
count() — internals
Compiler internals for count(): lowering path, type checks, and runtime helpers.
count() — internals
Where it lives
- Signature:
src/builtins/array/count.rs - Lowering:
src/codegen/lower_inst/builtins.rs:1027 (lower_count) - Function symbol:
lower_count()
Lowering notes
- Lowers
count(array)for concrete array values by reading the runtime length header. - Called from
crate::builtins::array::count(the registry home) via a thin wrapper. - Handles Array/AssocArray (reads length directly from the runtime header), Mixed/Union
- (delegates to
__rt_mixed_count), and Countable Object (calls the object’scount - method via intrinsic or dynamic dispatch).
Runtime helpers
The following runtime helpers are referenced:
__rt_mixed_count
Signature summary
function count(array $value, int $mode = 0): int
What the type checker enforces
- Arity: takes 1–2 arguments (1 optional).
Eval interpreter (magician)
- Declaration:
crates/elephc-magician/src/interpreter/builtins/array/count.rs(eval_builtin!) - Dispatch hooks:
direct,values