#![cfg_attr(feature = "document-features", doc = document_features::document_features!(feature_label = "<span id=\"feature-{feature}\">**`{feature}`**</span>"))]
#![cfg_attr(feature = "no_std", no_std)]
#![deny(missing_docs)]
#![warn(clippy::cargo)]
#![allow(clippy::unit_arg)]
#![allow(clippy::missing_errors_doc)]
#![allow(clippy::missing_panics_doc)]
#![allow(clippy::used_underscore_binding)]
#![allow(clippy::inline_always)]
#![allow(clippy::module_name_repetitions)]
#![allow(clippy::negative_feature_names)]
#![allow(clippy::module_inception)]
#![allow(clippy::box_collection)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::upper_case_acronyms)]
#![allow(clippy::match_same_arms)]
#[cfg(feature = "no_std")]
extern crate alloc;
#[cfg(feature = "no_std")]
extern crate no_std_compat as std;
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
#[macro_use]
mod reify;
#[macro_use]
mod restore;
#[macro_use]
mod types;
mod api;
mod ast;
pub mod config;
mod engine;
mod eval;
mod func;
mod module;
mod optimizer;
pub mod packages;
mod parser;
#[cfg(feature = "serde")]
pub mod serde;
mod tests;
mod tokenizer;
type PERR = ParseErrorType;
type ERR = EvalAltResult;
type RhaiError = Box<ERR>;
type RhaiResultOf<T> = Result<T, RhaiError>;
type RhaiResult = RhaiResultOf<Dynamic>;
#[cfg(not(feature = "only_i32"))]
pub type INT = i64;
#[cfg(feature = "only_i32")]
pub type INT = i32;
#[cfg(not(feature = "only_i32"))]
#[allow(non_camel_case_types)]
type UNSIGNED_INT = u64;
#[cfg(feature = "only_i32")]
#[allow(non_camel_case_types)]
type UNSIGNED_INT = u32;
#[cfg(not(target_pointer_width = "32"))]
const MAX_USIZE_INT: INT = INT::MAX;
#[cfg(not(feature = "only_i32"))]
#[cfg(target_pointer_width = "32")]
const MAX_USIZE_INT: INT = usize::MAX as INT;
#[cfg(feature = "only_i32")]
#[cfg(target_pointer_width = "32")]
const MAX_USIZE_INT: INT = INT::MAX;
const INT_BITS: usize = std::mem::size_of::<INT>() * 8;
#[cfg(not(feature = "no_index"))]
const INT_BYTES: usize = std::mem::size_of::<INT>();
#[cfg(not(feature = "no_float"))]
#[cfg(not(feature = "f32_float"))]
pub type FLOAT = f64;
#[cfg(not(feature = "no_float"))]
#[cfg(feature = "f32_float")]
pub type FLOAT = f32;
#[cfg(not(feature = "no_float"))]
#[cfg(not(feature = "no_index"))]
const FLOAT_BYTES: usize = std::mem::size_of::<FLOAT>();
type ExclusiveRange = std::ops::Range<INT>;
type InclusiveRange = std::ops::RangeInclusive<INT>;
#[allow(deprecated)]
pub use api::build_type::{CustomType, TypeBuilder};
#[cfg(not(feature = "no_custom_syntax"))]
pub use api::custom_syntax::Expression;
#[cfg(not(feature = "no_std"))]
#[cfg(not(target_family = "wasm"))]
pub use api::files::{eval_file, run_file};
pub use api::{eval::eval, events::VarDefInfo, run::run};
pub use ast::{FnAccess, AST};
pub use engine::{Engine, OP_CONTAINS, OP_EQUALS};
pub use eval::EvalContext;
use func::{calc_fn_hash, calc_fn_hash_full, calc_var_hash};
pub use func::{plugin, FuncArgs, NativeCallContext, RegisterNativeFunction};
pub use module::{FnNamespace, Module};
use restore::RestoreOnDrop;
pub use rhai_codegen::*;
#[cfg(not(feature = "no_time"))]
pub use types::Instant;
pub use types::{
Dynamic, EvalAltResult, FnPtr, ImmutableString, LexError, ParseError, ParseErrorType, Position,
Scope,
};
#[cfg(feature = "debugging")]
pub mod debugger {
#[cfg(not(feature = "no_function"))]
pub use super::eval::CallStackFrame;
pub use super::eval::{BreakPoint, Debugger, DebuggerCommand, DebuggerEvent};
}
#[cfg(not(feature = "internals"))]
type Identifier = SmartString;
#[cfg(feature = "internals")]
pub type Identifier = SmartString;
pub use func::Shared;
pub use func::Locked;
type SharedModule = Shared<Module>;
#[cfg(not(feature = "no_function"))]
pub use func::Func;
#[cfg(not(feature = "no_function"))]
pub use ast::ScriptFnMetadata;
#[cfg(not(feature = "no_function"))]
pub use api::call_fn::CallFnOptions;
#[cfg(not(feature = "no_index"))]
pub type Array = Vec<Dynamic>;
#[cfg(not(feature = "no_index"))]
pub type Blob = Vec<u8>;
#[cfg(not(feature = "no_object"))]
pub type Map = std::collections::BTreeMap<Identifier, Dynamic>;
#[cfg(not(feature = "no_object"))]
pub use api::json::format_map_as_json;
#[cfg(not(feature = "no_module"))]
pub use module::ModuleResolver;
#[cfg(not(feature = "no_module"))]
pub use module::resolvers as module_resolvers;
#[cfg(not(feature = "no_optimize"))]
pub use optimizer::OptimizationLevel;
#[cfg(feature = "no_optimize")]
pub type OptimizationLevel = ();
#[cfg(feature = "internals")]
pub use types::dynamic::{AccessMode, DynamicReadLock, DynamicWriteLock, Variant};
#[cfg(feature = "internals")]
#[cfg(not(feature = "no_float"))]
pub use types::FloatWrapper;
#[cfg(feature = "internals")]
pub use types::{Span, StringsInterner};
#[cfg(feature = "internals")]
pub use tokenizer::{
get_next_token, is_valid_function_name, is_valid_identifier, parse_string_literal, InputStream,
MultiInputsStream, Token, TokenIterator, TokenizeState, TokenizerControl,
TokenizerControlBlock,
};
#[cfg(feature = "internals")]
pub use parser::ParseState;
#[cfg(feature = "internals")]
pub use ast::{
ASTFlags, ASTNode, BinaryExpr, ConditionalExpr, Expr, FlowControl, FnCallExpr, FnCallHashes,
Ident, OpAssignment, RangeCase, ScriptFnDef, Stmt, StmtBlock, SwitchCasesCollection,
};
#[cfg(feature = "internals")]
#[cfg(not(feature = "no_custom_syntax"))]
pub use ast::CustomExpr;
#[cfg(feature = "internals")]
#[cfg(not(feature = "no_module"))]
pub use ast::Namespace;
#[cfg(feature = "internals")]
pub use func::EncapsulatedEnviron;
#[cfg(feature = "internals")]
pub use eval::{Caches, FnResolutionCache, FnResolutionCacheEntry, GlobalRuntimeState};
#[cfg(feature = "internals")]
#[allow(deprecated)]
pub use func::{locked_read, locked_write, CallableFunction, NativeCallContextStore};
#[cfg(feature = "internals")]
#[cfg(feature = "metadata")]
pub use api::definitions::Definitions;
const STATIC_VEC_INLINE_SIZE: usize = 3;
#[cfg(not(feature = "internals"))]
type StaticVec<T> = smallvec::SmallVec<[T; STATIC_VEC_INLINE_SIZE]>;
#[cfg(feature = "internals")]
pub type StaticVec<T> = smallvec::SmallVec<[T; STATIC_VEC_INLINE_SIZE]>;
#[cfg(not(feature = "no_closure"))]
const FN_ARGS_VEC_INLINE_SIZE: usize = 5;
#[cfg(not(feature = "no_closure"))]
type FnArgsVec<T> = smallvec::SmallVec<[T; FN_ARGS_VEC_INLINE_SIZE]>;
#[cfg(feature = "no_closure")]
type FnArgsVec<T> = crate::StaticVec<T>;
type SmartString = smartstring::SmartString<smartstring::LazyCompact>;
#[cfg(feature = "no_float")]
#[cfg(feature = "f32_float")]
compile_error!("`f32_float` cannot be used with `no_float`");
#[cfg(feature = "only_i32")]
#[cfg(feature = "only_i64")]
compile_error!("`only_i32` and `only_i64` cannot be used together");
#[cfg(feature = "no_std")]
#[cfg(feature = "wasm-bindgen")]
compile_error!("`wasm-bindgen` cannot be used with `no-std`");
#[cfg(feature = "no_std")]
#[cfg(feature = "stdweb")]
compile_error!("`stdweb` cannot be used with `no-std`");
#[cfg(target_family = "wasm")]
#[cfg(feature = "no_std")]
compile_error!("`no_std` cannot be used for WASM target");
#[cfg(not(target_family = "wasm"))]
#[cfg(feature = "wasm-bindgen")]
compile_error!("`wasm-bindgen` cannot be used for non-WASM target");
#[cfg(not(target_family = "wasm"))]
#[cfg(feature = "stdweb")]
compile_error!("`stdweb` cannot be used non-WASM target");
#[cfg(feature = "wasm-bindgen")]
#[cfg(feature = "stdweb")]
compile_error!("`wasm-bindgen` and `stdweb` cannot be used together");