Files
regorus/src/builtins/mod.rs
Anand Krishnamoorthi bb0ca29753 Lock down ACI tests and more OPA test folders (#54)
Borrowed from rego-cpp

Significantly (> 10 times) faster execution.

$ cargo test -r  --test aci
aci/mount_device                                  passed    9.597958ms
aci/mount_overlay                                 passed    10.159208ms
aci/scratch_mount                                 passed    8.598875ms
aci/create_container                              passed    10.237292ms
aci/shutdown_container                            passed    6.904084ms
aci/scratch_unmount                               passed    6.530875ms
aci/unmount_overlay                               passed    5.958875ms
aci/unmount_device                                passed    5.657834ms
aci/load_fragment                                 passed    6.049917ms

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
2023-12-01 08:32:11 -08:00

81 lines
1.7 KiB
Rust

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
mod aggregates;
mod arrays;
mod bitwise;
pub mod comparison;
mod conversions;
mod debugging;
pub mod deprecated;
mod encoding;
pub mod numbers;
mod objects;
mod regex;
mod semver;
pub mod sets;
mod strings;
mod time;
mod tracing;
pub mod types;
mod units;
mod utils;
use crate::ast::{Expr, Ref};
use crate::lexer::Span;
use crate::value::Value;
use std::collections::HashMap;
use anyhow::Result;
use lazy_static::lazy_static;
pub type BuiltinFcn = (fn(&Span, &[Ref<Expr>], &[Value]) -> Result<Value>, u8);
pub use deprecated::DEPRECATED;
#[rustfmt::skip]
lazy_static! {
pub static ref BUILTINS: HashMap<&'static str, BuiltinFcn> = {
let mut m : HashMap<&'static str, BuiltinFcn> = HashMap::new();
// comparison functions are directly called.
numbers::register(&mut m);
aggregates::register(&mut m);
arrays::register(&mut m);
sets::register(&mut m);
objects::register(&mut m);
strings::register(&mut m);
regex::register(&mut m);
//glob::register(&mut m);
bitwise::register(&mut m);
conversions::register(&mut m);
//units::register(&mut m);
types::register(&mut m);
encoding::register(&mut m);
//token_signing::register(&mut m);
//token_verification::register(&mut m);
time::register(&mut m);
//cryptography::register(&mut m);
//graphs::register(&mut m);
//graphql::register(&mut m);
//http::register(&mut m);
//net::register(&mut m);
//uuid::register(&mut m);
semver::register(&mut m);
//rego::register(&mut m);
//opa::register(&mut m);
debugging::register(&mut m);
tracing::register(&mut m);
units::register(&mut m);
m
};
}
pub fn must_cache(path: &str) -> Option<&'static str> {
match path {
"rand.intn" => Some("rand.intn"),
_ => None,
}
}