2024-08-27 20:43:14 +02:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
|
|
pub enum SystemFnArity {
|
|
|
|
Unary,
|
|
|
|
Binary,
|
|
|
|
Nary,
|
|
|
|
}
|
|
|
|
|
2025-06-16 18:52:52 +02:00
|
|
|
pub fn resolve(arity: SystemFnArity, name: &str) -> Option<u8> {
|
|
|
|
use SystemFnArity::*;
|
|
|
|
|
|
|
|
// NOTE: The indices here must match those defined in system.zig.
|
|
|
|
Some(match (arity, name) {
|
|
|
|
(Binary, "+") => 0x00,
|
|
|
|
(Binary, "-") => 0x01,
|
|
|
|
(Binary, "*") => 0x02,
|
|
|
|
(Binary, "/") => 0x03,
|
|
|
|
(Unary, "-") => 0x04,
|
|
|
|
|
|
|
|
(Nary, "floor") => 0x10,
|
|
|
|
(Nary, "ceil") => 0x11,
|
|
|
|
(Nary, "round") => 0x12,
|
|
|
|
(Nary, "abs") => 0x13,
|
|
|
|
(Nary, "mod") => 0x14,
|
|
|
|
(Nary, "pow") => 0x15,
|
|
|
|
(Nary, "sqrt") => 0x16,
|
|
|
|
(Nary, "cbrt") => 0x17,
|
|
|
|
(Nary, "exp") => 0x18,
|
|
|
|
(Nary, "exp2") => 0x19,
|
|
|
|
(Nary, "ln") => 0x1a,
|
|
|
|
(Nary, "log2") => 0x1b,
|
|
|
|
(Nary, "log10") => 0x1c,
|
|
|
|
(Nary, "hypot") => 0x1d,
|
|
|
|
(Nary, "sin") => 0x1e,
|
|
|
|
(Nary, "cos") => 0x1f,
|
|
|
|
(Nary, "tan") => 0x20,
|
|
|
|
(Nary, "asin") => 0x21,
|
|
|
|
(Nary, "acos") => 0x22,
|
|
|
|
(Nary, "atan") => 0x23,
|
|
|
|
(Nary, "atan2") => 0x24,
|
|
|
|
(Nary, "expMinus1") => 0x25,
|
|
|
|
(Nary, "ln1Plus") => 0x26,
|
|
|
|
(Nary, "sinh") => 0x27,
|
|
|
|
(Nary, "cosh") => 0x28,
|
|
|
|
(Nary, "tanh") => 0x29,
|
|
|
|
(Nary, "asinh") => 0x2a,
|
|
|
|
(Nary, "acosh") => 0x2b,
|
|
|
|
(Nary, "atanh") => 0x2c,
|
|
|
|
(Nary, "min") => 0x2d,
|
|
|
|
(Nary, "max") => 0x2e,
|
|
|
|
(Nary, "lerp") => 0x30,
|
|
|
|
|
|
|
|
(Unary, "!") => 0x40,
|
|
|
|
(Binary, "==") => 0x41,
|
|
|
|
(Binary, "!=") => 0x42,
|
|
|
|
(Binary, "<") => 0x43,
|
|
|
|
(Binary, "<=") => 0x44,
|
|
|
|
(Binary, ">") => 0x45,
|
|
|
|
(Binary, ">=") => 0x46,
|
|
|
|
|
|
|
|
(Nary, "vec") => 0x80,
|
|
|
|
(Nary, "vecX") => 0x81,
|
|
|
|
(Nary, "vecY") => 0x82,
|
|
|
|
(Nary, "vecZ") => 0x83,
|
|
|
|
(Nary, "vecW") => 0x84,
|
|
|
|
|
|
|
|
(Nary, "rgba") => 0x85,
|
|
|
|
(Nary, "rgbaR") => 0x86,
|
|
|
|
(Nary, "rgbaG") => 0x87,
|
|
|
|
(Nary, "rgbaB") => 0x88,
|
|
|
|
(Nary, "rgbaA") => 0x89,
|
|
|
|
|
|
|
|
(Nary, "len") => 0x90,
|
|
|
|
(Nary, "index") => 0x91,
|
|
|
|
(Nary, "range") => 0x92,
|
|
|
|
(Nary, "map") => 0x93,
|
|
|
|
(Nary, "filter") => 0x94,
|
|
|
|
(Nary, "reduce") => 0x95,
|
|
|
|
(Nary, "flatten") => 0x96,
|
|
|
|
|
|
|
|
(Nary, "stroke") => 0xe0,
|
|
|
|
|
|
|
|
(Nary, "withDotter") => 0xf0,
|
|
|
|
|
|
|
|
_ => return None,
|
|
|
|
})
|
2024-08-10 23:10:03 +02:00
|
|
|
}
|