Refactor use.
This commit is contained in:
parent
d50d48f26f
commit
272c8505b8
37
src/ast.rs
37
src/ast.rs
@ -1,23 +1,7 @@
|
|||||||
//! Module defining the AST (abstract syntax tree).
|
//! Module defining the AST (abstract syntax tree).
|
||||||
|
|
||||||
use crate::dynamic::{Dynamic, Union};
|
use crate::dynamic::Union;
|
||||||
use crate::fn_native::{FnPtr, Shared};
|
use crate::module::NamespaceRef;
|
||||||
use crate::module::{Module, NamespaceRef};
|
|
||||||
use crate::syntax::FnCustomSyntaxEval;
|
|
||||||
use crate::token::{Position, Token, NO_POS};
|
|
||||||
use crate::utils::{ImmutableString, StraightHasherBuilder};
|
|
||||||
use crate::StaticVec;
|
|
||||||
use crate::INT;
|
|
||||||
|
|
||||||
#[cfg(not(feature = "no_float"))]
|
|
||||||
use crate::FLOAT;
|
|
||||||
|
|
||||||
#[cfg(not(feature = "no_index"))]
|
|
||||||
use crate::Array;
|
|
||||||
|
|
||||||
#[cfg(not(feature = "no_object"))]
|
|
||||||
use crate::Map;
|
|
||||||
|
|
||||||
use crate::stdlib::{
|
use crate::stdlib::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
boxed::Box,
|
boxed::Box,
|
||||||
@ -30,6 +14,19 @@ use crate::stdlib::{
|
|||||||
vec,
|
vec,
|
||||||
vec::Vec,
|
vec::Vec,
|
||||||
};
|
};
|
||||||
|
use crate::syntax::FnCustomSyntaxEval;
|
||||||
|
use crate::token::Token;
|
||||||
|
use crate::utils::StraightHasherBuilder;
|
||||||
|
use crate::{Dynamic, FnPtr, ImmutableString, Module, Position, Shared, StaticVec, INT, NO_POS};
|
||||||
|
|
||||||
|
#[cfg(not(feature = "no_float"))]
|
||||||
|
use crate::FLOAT;
|
||||||
|
|
||||||
|
#[cfg(not(feature = "no_index"))]
|
||||||
|
use crate::Array;
|
||||||
|
|
||||||
|
#[cfg(not(feature = "no_object"))]
|
||||||
|
use crate::Map;
|
||||||
|
|
||||||
/// A type representing the access mode of a scripted function.
|
/// A type representing the access mode of a scripted function.
|
||||||
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
|
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
|
||||||
@ -55,16 +52,16 @@ impl FnAccess {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn is_private(self) -> bool {
|
pub fn is_private(self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Self::Public => false,
|
|
||||||
Self::Private => true,
|
Self::Private => true,
|
||||||
|
Self::Public => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// Is this access mode public?
|
/// Is this access mode public?
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn is_public(self) -> bool {
|
pub fn is_public(self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Self::Public => true,
|
|
||||||
Self::Private => false,
|
Self::Private => false,
|
||||||
|
Self::Public => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,7 @@
|
|||||||
//! Helper module which defines the `Any` trait to to allow dynamic value handling.
|
//! Helper module which defines the `Any` trait to to allow dynamic value handling.
|
||||||
|
|
||||||
use crate::fn_native::{FnPtr, SendSync};
|
use crate::fn_native::SendSync;
|
||||||
use crate::r#unsafe::{unsafe_cast_box, unsafe_try_cast};
|
use crate::r#unsafe::{unsafe_cast_box, unsafe_try_cast};
|
||||||
use crate::utils::ImmutableString;
|
|
||||||
use crate::INT;
|
|
||||||
|
|
||||||
#[cfg(not(feature = "no_float"))]
|
|
||||||
use crate::FLOAT;
|
|
||||||
|
|
||||||
#[cfg(not(feature = "no_index"))]
|
|
||||||
use crate::Array;
|
|
||||||
|
|
||||||
#[cfg(not(feature = "no_object"))]
|
|
||||||
use crate::Map;
|
|
||||||
|
|
||||||
use crate::stdlib::{
|
use crate::stdlib::{
|
||||||
any::{type_name, Any, TypeId},
|
any::{type_name, Any, TypeId},
|
||||||
boxed::Box,
|
boxed::Box,
|
||||||
@ -23,6 +11,16 @@ use crate::stdlib::{
|
|||||||
ops::{Deref, DerefMut},
|
ops::{Deref, DerefMut},
|
||||||
string::{String, ToString},
|
string::{String, ToString},
|
||||||
};
|
};
|
||||||
|
use crate::{FnPtr, ImmutableString, INT};
|
||||||
|
|
||||||
|
#[cfg(not(feature = "no_float"))]
|
||||||
|
use crate::FLOAT;
|
||||||
|
|
||||||
|
#[cfg(not(feature = "no_index"))]
|
||||||
|
use crate::Array;
|
||||||
|
|
||||||
|
#[cfg(not(feature = "no_object"))]
|
||||||
|
use crate::Map;
|
||||||
|
|
||||||
#[cfg(not(feature = "no_std"))]
|
#[cfg(not(feature = "no_std"))]
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
@ -1,20 +1,13 @@
|
|||||||
//! Main module defining the script evaluation `Engine`.
|
//! Main module defining the script evaluation `Engine`.
|
||||||
|
|
||||||
use crate::ast::{Expr, FnCallExpr, Ident, IdentX, ReturnType, Stmt};
|
use crate::ast::{Expr, FnCallExpr, Ident, IdentX, ReturnType, Stmt};
|
||||||
use crate::dynamic::{map_std_type_name, Dynamic, Union, Variant};
|
use crate::dynamic::{map_std_type_name, Union, Variant};
|
||||||
use crate::fn_call::run_builtin_op_assignment;
|
use crate::fn_call::run_builtin_op_assignment;
|
||||||
use crate::fn_native::{CallableFunction, Callback, FnPtr, IteratorFn, OnVarCallback, Shared};
|
use crate::fn_native::{CallableFunction, Callback, IteratorFn, OnVarCallback};
|
||||||
use crate::module::{Module, NamespaceRef};
|
use crate::module::NamespaceRef;
|
||||||
use crate::optimize::OptimizationLevel;
|
|
||||||
use crate::packages::{Package, PackagesCollection, StandardPackage};
|
use crate::packages::{Package, PackagesCollection, StandardPackage};
|
||||||
use crate::r#unsafe::unsafe_cast_var_name_to_lifetime;
|
use crate::r#unsafe::unsafe_cast_var_name_to_lifetime;
|
||||||
use crate::result::EvalAltResult;
|
use crate::scope::EntryType as ScopeEntryType;
|
||||||
use crate::scope::{EntryType as ScopeEntryType, Scope};
|
|
||||||
use crate::syntax::CustomSyntax;
|
|
||||||
use crate::token::{Position, NO_POS};
|
|
||||||
use crate::utils::{get_hasher, ImmutableString};
|
|
||||||
use crate::{calc_native_fn_hash, StaticVec};
|
|
||||||
|
|
||||||
use crate::stdlib::{
|
use crate::stdlib::{
|
||||||
any::{type_name, TypeId},
|
any::{type_name, TypeId},
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
@ -27,6 +20,12 @@ use crate::stdlib::{
|
|||||||
ops::DerefMut,
|
ops::DerefMut,
|
||||||
string::{String, ToString},
|
string::{String, ToString},
|
||||||
};
|
};
|
||||||
|
use crate::syntax::CustomSyntax;
|
||||||
|
use crate::utils::get_hasher;
|
||||||
|
use crate::{
|
||||||
|
calc_native_fn_hash, Dynamic, EvalAltResult, FnPtr, ImmutableString, Module, OptimizationLevel,
|
||||||
|
Position, Scope, Shared, StaticVec, NO_POS,
|
||||||
|
};
|
||||||
|
|
||||||
#[cfg(not(feature = "no_index"))]
|
#[cfg(not(feature = "no_index"))]
|
||||||
use crate::Array;
|
use crate::Array;
|
||||||
|
@ -1,32 +1,25 @@
|
|||||||
//! Module that defines the extern API of `Engine`.
|
//! Module that defines the extern API of `Engine`.
|
||||||
|
|
||||||
use crate::ast::AST;
|
use crate::dynamic::Variant;
|
||||||
use crate::dynamic::{Dynamic, Variant};
|
use crate::engine::{EvalContext, Imports};
|
||||||
use crate::engine::{Engine, EvalContext, Imports};
|
use crate::fn_native::{FnCallArgs, SendSync};
|
||||||
use crate::fn_native::{FnCallArgs, NativeCallContext, SendSync};
|
|
||||||
use crate::optimize::OptimizationLevel;
|
|
||||||
use crate::parse_error::ParseError;
|
|
||||||
use crate::result::EvalAltResult;
|
|
||||||
use crate::scope::Scope;
|
|
||||||
use crate::token::NO_POS;
|
|
||||||
use crate::utils::get_hasher;
|
|
||||||
|
|
||||||
#[cfg(not(feature = "no_index"))]
|
|
||||||
use crate::Array;
|
|
||||||
|
|
||||||
#[cfg(not(feature = "no_object"))]
|
|
||||||
use crate::Map;
|
|
||||||
|
|
||||||
use crate::stdlib::{
|
use crate::stdlib::{
|
||||||
any::{type_name, TypeId},
|
any::{type_name, TypeId},
|
||||||
boxed::Box,
|
boxed::Box,
|
||||||
hash::{Hash, Hasher},
|
hash::{Hash, Hasher},
|
||||||
string::String,
|
string::String,
|
||||||
};
|
};
|
||||||
|
use crate::utils::get_hasher;
|
||||||
|
use crate::{
|
||||||
|
scope::Scope, Dynamic, Engine, EvalAltResult, NativeCallContext, OptimizationLevel, ParseError,
|
||||||
|
AST, NO_POS,
|
||||||
|
};
|
||||||
|
|
||||||
#[cfg(not(feature = "no_std"))]
|
#[cfg(not(feature = "no_index"))]
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
use crate::Array;
|
||||||
use crate::stdlib::{fs::File, io::prelude::*, path::PathBuf};
|
|
||||||
|
#[cfg(not(feature = "no_object"))]
|
||||||
|
use crate::Map;
|
||||||
|
|
||||||
/// Calculate a unique hash for a script.
|
/// Calculate a unique hash for a script.
|
||||||
fn calc_hash_for_scripts<'a>(scripts: impl IntoIterator<Item = &'a &'a str>) -> u64 {
|
fn calc_hash_for_scripts<'a>(scripts: impl IntoIterator<Item = &'a &'a str>) -> u64 {
|
||||||
@ -204,15 +197,11 @@ impl Engine {
|
|||||||
/// ```
|
/// ```
|
||||||
#[cfg(not(feature = "no_object"))]
|
#[cfg(not(feature = "no_object"))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn register_get<T, U>(
|
pub fn register_get<T: Variant + Clone, U: Variant + Clone>(
|
||||||
&mut self,
|
&mut self,
|
||||||
name: &str,
|
name: &str,
|
||||||
callback: impl Fn(&mut T) -> U + SendSync + 'static,
|
callback: impl Fn(&mut T) -> U + SendSync + 'static,
|
||||||
) -> &mut Self
|
) -> &mut Self {
|
||||||
where
|
|
||||||
T: Variant + Clone,
|
|
||||||
U: Variant + Clone,
|
|
||||||
{
|
|
||||||
crate::RegisterFn::register_fn(self, &crate::engine::make_getter(name), callback)
|
crate::RegisterFn::register_fn(self, &crate::engine::make_getter(name), callback)
|
||||||
}
|
}
|
||||||
/// Register a getter function for a member of a registered type with the `Engine`.
|
/// Register a getter function for a member of a registered type with the `Engine`.
|
||||||
@ -304,15 +293,11 @@ impl Engine {
|
|||||||
/// ```
|
/// ```
|
||||||
#[cfg(not(feature = "no_object"))]
|
#[cfg(not(feature = "no_object"))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn register_set<T, U>(
|
pub fn register_set<T: Variant + Clone, U: Variant + Clone>(
|
||||||
&mut self,
|
&mut self,
|
||||||
name: &str,
|
name: &str,
|
||||||
callback: impl Fn(&mut T, U) + SendSync + 'static,
|
callback: impl Fn(&mut T, U) + SendSync + 'static,
|
||||||
) -> &mut Self
|
) -> &mut Self {
|
||||||
where
|
|
||||||
T: Variant + Clone,
|
|
||||||
U: Variant + Clone,
|
|
||||||
{
|
|
||||||
crate::RegisterFn::register_fn(self, &crate::engine::make_setter(name), callback)
|
crate::RegisterFn::register_fn(self, &crate::engine::make_setter(name), callback)
|
||||||
}
|
}
|
||||||
/// Register a setter function for a member of a registered type with the `Engine`.
|
/// Register a setter function for a member of a registered type with the `Engine`.
|
||||||
@ -357,15 +342,11 @@ impl Engine {
|
|||||||
/// ```
|
/// ```
|
||||||
#[cfg(not(feature = "no_object"))]
|
#[cfg(not(feature = "no_object"))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn register_set_result<T, U>(
|
pub fn register_set_result<T: Variant + Clone, U: Variant + Clone>(
|
||||||
&mut self,
|
&mut self,
|
||||||
name: &str,
|
name: &str,
|
||||||
callback: impl Fn(&mut T, U) -> Result<(), Box<EvalAltResult>> + SendSync + 'static,
|
callback: impl Fn(&mut T, U) -> Result<(), Box<EvalAltResult>> + SendSync + 'static,
|
||||||
) -> &mut Self
|
) -> &mut Self {
|
||||||
where
|
|
||||||
T: Variant + Clone,
|
|
||||||
U: Variant + Clone,
|
|
||||||
{
|
|
||||||
crate::RegisterResultFn::register_result_fn(
|
crate::RegisterResultFn::register_result_fn(
|
||||||
self,
|
self,
|
||||||
&crate::engine::make_setter(name),
|
&crate::engine::make_setter(name),
|
||||||
@ -412,16 +393,12 @@ impl Engine {
|
|||||||
/// ```
|
/// ```
|
||||||
#[cfg(not(feature = "no_object"))]
|
#[cfg(not(feature = "no_object"))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn register_get_set<T, U>(
|
pub fn register_get_set<T: Variant + Clone, U: Variant + Clone>(
|
||||||
&mut self,
|
&mut self,
|
||||||
name: &str,
|
name: &str,
|
||||||
get_fn: impl Fn(&mut T) -> U + SendSync + 'static,
|
get_fn: impl Fn(&mut T) -> U + SendSync + 'static,
|
||||||
set_fn: impl Fn(&mut T, U) + SendSync + 'static,
|
set_fn: impl Fn(&mut T, U) + SendSync + 'static,
|
||||||
) -> &mut Self
|
) -> &mut Self {
|
||||||
where
|
|
||||||
T: Variant + Clone,
|
|
||||||
U: Variant + Clone,
|
|
||||||
{
|
|
||||||
self.register_get(name, get_fn).register_set(name, set_fn)
|
self.register_get(name, get_fn).register_set(name, set_fn)
|
||||||
}
|
}
|
||||||
/// Register an index getter for a custom type with the `Engine`.
|
/// Register an index getter for a custom type with the `Engine`.
|
||||||
@ -467,15 +444,10 @@ impl Engine {
|
|||||||
/// ```
|
/// ```
|
||||||
#[cfg(not(feature = "no_index"))]
|
#[cfg(not(feature = "no_index"))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn register_indexer_get<T, X, U>(
|
pub fn register_indexer_get<T: Variant + Clone, X: Variant + Clone, U: Variant + Clone>(
|
||||||
&mut self,
|
&mut self,
|
||||||
callback: impl Fn(&mut T, X) -> U + SendSync + 'static,
|
callback: impl Fn(&mut T, X) -> U + SendSync + 'static,
|
||||||
) -> &mut Self
|
) -> &mut Self {
|
||||||
where
|
|
||||||
T: Variant + Clone,
|
|
||||||
U: Variant + Clone,
|
|
||||||
X: Variant + Clone,
|
|
||||||
{
|
|
||||||
if TypeId::of::<T>() == TypeId::of::<Array>() {
|
if TypeId::of::<T>() == TypeId::of::<Array>() {
|
||||||
panic!("Cannot register indexer for arrays.");
|
panic!("Cannot register indexer for arrays.");
|
||||||
}
|
}
|
||||||
@ -538,14 +510,10 @@ impl Engine {
|
|||||||
/// ```
|
/// ```
|
||||||
#[cfg(not(feature = "no_index"))]
|
#[cfg(not(feature = "no_index"))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn register_indexer_get_result<T, X>(
|
pub fn register_indexer_get_result<T: Variant + Clone, X: Variant + Clone>(
|
||||||
&mut self,
|
&mut self,
|
||||||
callback: impl Fn(&mut T, X) -> Result<Dynamic, Box<EvalAltResult>> + SendSync + 'static,
|
callback: impl Fn(&mut T, X) -> Result<Dynamic, Box<EvalAltResult>> + SendSync + 'static,
|
||||||
) -> &mut Self
|
) -> &mut Self {
|
||||||
where
|
|
||||||
T: Variant + Clone,
|
|
||||||
X: Variant + Clone,
|
|
||||||
{
|
|
||||||
if TypeId::of::<T>() == TypeId::of::<Array>() {
|
if TypeId::of::<T>() == TypeId::of::<Array>() {
|
||||||
panic!("Cannot register indexer for arrays.");
|
panic!("Cannot register indexer for arrays.");
|
||||||
}
|
}
|
||||||
@ -605,15 +573,10 @@ impl Engine {
|
|||||||
/// ```
|
/// ```
|
||||||
#[cfg(not(feature = "no_index"))]
|
#[cfg(not(feature = "no_index"))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn register_indexer_set<T, X, U>(
|
pub fn register_indexer_set<T: Variant + Clone, X: Variant + Clone, U: Variant + Clone>(
|
||||||
&mut self,
|
&mut self,
|
||||||
callback: impl Fn(&mut T, X, U) + SendSync + 'static,
|
callback: impl Fn(&mut T, X, U) + SendSync + 'static,
|
||||||
) -> &mut Self
|
) -> &mut Self {
|
||||||
where
|
|
||||||
T: Variant + Clone,
|
|
||||||
U: Variant + Clone,
|
|
||||||
X: Variant + Clone,
|
|
||||||
{
|
|
||||||
if TypeId::of::<T>() == TypeId::of::<Array>() {
|
if TypeId::of::<T>() == TypeId::of::<Array>() {
|
||||||
panic!("Cannot register indexer for arrays.");
|
panic!("Cannot register indexer for arrays.");
|
||||||
}
|
}
|
||||||
@ -677,15 +640,14 @@ impl Engine {
|
|||||||
/// ```
|
/// ```
|
||||||
#[cfg(not(feature = "no_index"))]
|
#[cfg(not(feature = "no_index"))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn register_indexer_set_result<T, X, U>(
|
pub fn register_indexer_set_result<
|
||||||
|
T: Variant + Clone,
|
||||||
|
X: Variant + Clone,
|
||||||
|
U: Variant + Clone,
|
||||||
|
>(
|
||||||
&mut self,
|
&mut self,
|
||||||
callback: impl Fn(&mut T, X, U) -> Result<(), Box<EvalAltResult>> + SendSync + 'static,
|
callback: impl Fn(&mut T, X, U) -> Result<(), Box<EvalAltResult>> + SendSync + 'static,
|
||||||
) -> &mut Self
|
) -> &mut Self {
|
||||||
where
|
|
||||||
T: Variant + Clone,
|
|
||||||
U: Variant + Clone,
|
|
||||||
X: Variant + Clone,
|
|
||||||
{
|
|
||||||
if TypeId::of::<T>() == TypeId::of::<Array>() {
|
if TypeId::of::<T>() == TypeId::of::<Array>() {
|
||||||
panic!("Cannot register indexer for arrays.");
|
panic!("Cannot register indexer for arrays.");
|
||||||
}
|
}
|
||||||
@ -748,16 +710,11 @@ impl Engine {
|
|||||||
/// ```
|
/// ```
|
||||||
#[cfg(not(feature = "no_index"))]
|
#[cfg(not(feature = "no_index"))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn register_indexer_get_set<T, X, U>(
|
pub fn register_indexer_get_set<T: Variant + Clone, X: Variant + Clone, U: Variant + Clone>(
|
||||||
&mut self,
|
&mut self,
|
||||||
getter: impl Fn(&mut T, X) -> U + SendSync + 'static,
|
getter: impl Fn(&mut T, X) -> U + SendSync + 'static,
|
||||||
setter: impl Fn(&mut T, X, U) -> () + SendSync + 'static,
|
setter: impl Fn(&mut T, X, U) -> () + SendSync + 'static,
|
||||||
) -> &mut Self
|
) -> &mut Self {
|
||||||
where
|
|
||||||
T: Variant + Clone,
|
|
||||||
U: Variant + Clone,
|
|
||||||
X: Variant + Clone,
|
|
||||||
{
|
|
||||||
self.register_indexer_get(getter)
|
self.register_indexer_get(getter)
|
||||||
.register_indexer_set(setter)
|
.register_indexer_set(setter)
|
||||||
}
|
}
|
||||||
@ -935,8 +892,10 @@ impl Engine {
|
|||||||
#[cfg(not(feature = "no_std"))]
|
#[cfg(not(feature = "no_std"))]
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_file(path: PathBuf) -> Result<String, Box<EvalAltResult>> {
|
fn read_file(path: crate::stdlib::path::PathBuf) -> Result<String, Box<EvalAltResult>> {
|
||||||
let mut f = File::open(path.clone()).map_err(|err| {
|
use crate::stdlib::io::Read;
|
||||||
|
|
||||||
|
let mut f = crate::stdlib::fs::File::open(path.clone()).map_err(|err| {
|
||||||
EvalAltResult::ErrorSystem(
|
EvalAltResult::ErrorSystem(
|
||||||
format!("Cannot open script file '{}'", path.to_string_lossy()),
|
format!("Cannot open script file '{}'", path.to_string_lossy()),
|
||||||
err.into(),
|
err.into(),
|
||||||
@ -977,7 +936,10 @@ impl Engine {
|
|||||||
#[cfg(not(feature = "no_std"))]
|
#[cfg(not(feature = "no_std"))]
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn compile_file(&self, path: PathBuf) -> Result<AST, Box<EvalAltResult>> {
|
pub fn compile_file(
|
||||||
|
&self,
|
||||||
|
path: crate::stdlib::path::PathBuf,
|
||||||
|
) -> Result<AST, Box<EvalAltResult>> {
|
||||||
self.compile_file_with_scope(&Default::default(), path)
|
self.compile_file_with_scope(&Default::default(), path)
|
||||||
}
|
}
|
||||||
/// Compile a script file into an `AST` using own scope, which can be used later for evaluation.
|
/// Compile a script file into an `AST` using own scope, which can be used later for evaluation.
|
||||||
@ -1017,7 +979,7 @@ impl Engine {
|
|||||||
pub fn compile_file_with_scope(
|
pub fn compile_file_with_scope(
|
||||||
&self,
|
&self,
|
||||||
scope: &Scope,
|
scope: &Scope,
|
||||||
path: PathBuf,
|
path: crate::stdlib::path::PathBuf,
|
||||||
) -> Result<AST, Box<EvalAltResult>> {
|
) -> Result<AST, Box<EvalAltResult>> {
|
||||||
Self::read_file(path).and_then(|contents| Ok(self.compile_with_scope(scope, &contents)?))
|
Self::read_file(path).and_then(|contents| Ok(self.compile_with_scope(scope, &contents)?))
|
||||||
}
|
}
|
||||||
@ -1201,7 +1163,10 @@ impl Engine {
|
|||||||
#[cfg(not(feature = "no_std"))]
|
#[cfg(not(feature = "no_std"))]
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn eval_file<T: Variant + Clone>(&self, path: PathBuf) -> Result<T, Box<EvalAltResult>> {
|
pub fn eval_file<T: Variant + Clone>(
|
||||||
|
&self,
|
||||||
|
path: crate::stdlib::path::PathBuf,
|
||||||
|
) -> Result<T, Box<EvalAltResult>> {
|
||||||
Self::read_file(path).and_then(|contents| self.eval::<T>(&contents))
|
Self::read_file(path).and_then(|contents| self.eval::<T>(&contents))
|
||||||
}
|
}
|
||||||
/// Evaluate a script file with own scope.
|
/// Evaluate a script file with own scope.
|
||||||
@ -1229,7 +1194,7 @@ impl Engine {
|
|||||||
pub fn eval_file_with_scope<T: Variant + Clone>(
|
pub fn eval_file_with_scope<T: Variant + Clone>(
|
||||||
&self,
|
&self,
|
||||||
scope: &mut Scope,
|
scope: &mut Scope,
|
||||||
path: PathBuf,
|
path: crate::stdlib::path::PathBuf,
|
||||||
) -> Result<T, Box<EvalAltResult>> {
|
) -> Result<T, Box<EvalAltResult>> {
|
||||||
Self::read_file(path).and_then(|contents| self.eval_with_scope::<T>(scope, &contents))
|
Self::read_file(path).and_then(|contents| self.eval_with_scope::<T>(scope, &contents))
|
||||||
}
|
}
|
||||||
@ -1428,7 +1393,10 @@ impl Engine {
|
|||||||
#[cfg(not(feature = "no_std"))]
|
#[cfg(not(feature = "no_std"))]
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn consume_file(&self, path: PathBuf) -> Result<(), Box<EvalAltResult>> {
|
pub fn consume_file(
|
||||||
|
&self,
|
||||||
|
path: crate::stdlib::path::PathBuf,
|
||||||
|
) -> Result<(), Box<EvalAltResult>> {
|
||||||
Self::read_file(path).and_then(|contents| self.consume(&contents))
|
Self::read_file(path).and_then(|contents| self.consume(&contents))
|
||||||
}
|
}
|
||||||
/// Evaluate a file with own scope, but throw away the result and only return error (if any).
|
/// Evaluate a file with own scope, but throw away the result and only return error (if any).
|
||||||
@ -1439,7 +1407,7 @@ impl Engine {
|
|||||||
pub fn consume_file_with_scope(
|
pub fn consume_file_with_scope(
|
||||||
&self,
|
&self,
|
||||||
scope: &mut Scope,
|
scope: &mut Scope,
|
||||||
path: PathBuf,
|
path: crate::stdlib::path::PathBuf,
|
||||||
) -> Result<(), Box<EvalAltResult>> {
|
) -> Result<(), Box<EvalAltResult>> {
|
||||||
Self::read_file(path).and_then(|contents| self.consume_with_scope(scope, &contents))
|
Self::read_file(path).and_then(|contents| self.consume_with_scope(scope, &contents))
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
//! Configuration settings for `Engine`.
|
//! Configuration settings for `Engine`.
|
||||||
|
|
||||||
use crate::engine::Engine;
|
|
||||||
use crate::packages::PackageLibrary;
|
use crate::packages::PackageLibrary;
|
||||||
use crate::token::{is_valid_identifier, Token};
|
|
||||||
|
|
||||||
use crate::stdlib::{format, string::String};
|
use crate::stdlib::{format, string::String};
|
||||||
|
use crate::token::{is_valid_identifier, Token};
|
||||||
|
use crate::Engine;
|
||||||
|
|
||||||
#[cfg(not(feature = "no_module"))]
|
#[cfg(not(feature = "no_module"))]
|
||||||
use crate::stdlib::boxed::Box;
|
use crate::stdlib::boxed::Box;
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
use crate::dynamic::{Dynamic, Variant};
|
use crate::dynamic::Variant;
|
||||||
use crate::StaticVec;
|
use crate::{Dynamic, StaticVec};
|
||||||
|
|
||||||
/// Trait that represents arguments to a function call.
|
/// Trait that represents arguments to a function call.
|
||||||
/// Any data type that can be converted into a `Vec<Dynamic>` can be used
|
/// Any data type that can be converted into a `Vec<Dynamic>` can be used
|
||||||
|
@ -1,29 +1,14 @@
|
|||||||
//! Implement function-calling mechanism for `Engine`.
|
//! Implement function-calling mechanism for `Engine`.
|
||||||
|
|
||||||
use crate::ast::{Expr, Stmt};
|
use crate::ast::{Expr, Stmt};
|
||||||
use crate::dynamic::Dynamic;
|
|
||||||
use crate::engine::{
|
use crate::engine::{
|
||||||
search_imports, Engine, Imports, State, KEYWORD_DEBUG, KEYWORD_EVAL, KEYWORD_FN_PTR,
|
search_imports, Imports, State, KEYWORD_DEBUG, KEYWORD_EVAL, KEYWORD_FN_PTR,
|
||||||
KEYWORD_FN_PTR_CALL, KEYWORD_FN_PTR_CURRY, KEYWORD_IS_DEF_FN, KEYWORD_IS_DEF_VAR,
|
KEYWORD_FN_PTR_CALL, KEYWORD_FN_PTR_CURRY, KEYWORD_IS_DEF_FN, KEYWORD_IS_DEF_VAR,
|
||||||
KEYWORD_PRINT, KEYWORD_TYPE_OF,
|
KEYWORD_PRINT, KEYWORD_TYPE_OF,
|
||||||
};
|
};
|
||||||
use crate::fn_native::{FnCallArgs, FnPtr};
|
use crate::fn_native::FnCallArgs;
|
||||||
use crate::module::{Module, NamespaceRef};
|
use crate::module::NamespaceRef;
|
||||||
use crate::optimize::OptimizationLevel;
|
use crate::scope::EntryType as ScopeEntryType;
|
||||||
use crate::parse_error::ParseErrorType;
|
|
||||||
use crate::result::EvalAltResult;
|
|
||||||
use crate::scope::{EntryType as ScopeEntryType, Scope};
|
|
||||||
use crate::stdlib::ops::Deref;
|
|
||||||
use crate::token::NO_POS;
|
|
||||||
use crate::utils::ImmutableString;
|
|
||||||
use crate::{calc_native_fn_hash, calc_script_fn_hash, StaticVec, INT};
|
|
||||||
|
|
||||||
#[cfg(not(feature = "no_float"))]
|
|
||||||
use crate::FLOAT;
|
|
||||||
|
|
||||||
#[cfg(not(feature = "no_object"))]
|
|
||||||
use crate::Map;
|
|
||||||
|
|
||||||
use crate::stdlib::{
|
use crate::stdlib::{
|
||||||
any::{type_name, TypeId},
|
any::{type_name, TypeId},
|
||||||
boxed::Box,
|
boxed::Box,
|
||||||
@ -31,9 +16,20 @@ use crate::stdlib::{
|
|||||||
format,
|
format,
|
||||||
iter::{empty, once},
|
iter::{empty, once},
|
||||||
mem,
|
mem,
|
||||||
|
ops::Deref,
|
||||||
string::ToString,
|
string::ToString,
|
||||||
vec::Vec,
|
vec::Vec,
|
||||||
};
|
};
|
||||||
|
use crate::{
|
||||||
|
calc_native_fn_hash, calc_script_fn_hash, Dynamic, Engine, EvalAltResult, FnPtr,
|
||||||
|
ImmutableString, Module, OptimizationLevel, ParseErrorType, Scope, StaticVec, INT, NO_POS,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[cfg(not(feature = "no_float"))]
|
||||||
|
use crate::FLOAT;
|
||||||
|
|
||||||
|
#[cfg(not(feature = "no_object"))]
|
||||||
|
use crate::Map;
|
||||||
|
|
||||||
#[cfg(feature = "no_std")]
|
#[cfg(feature = "no_std")]
|
||||||
#[cfg(not(feature = "no_float"))]
|
#[cfg(not(feature = "no_float"))]
|
||||||
|
@ -3,13 +3,8 @@
|
|||||||
#![cfg(not(feature = "no_function"))]
|
#![cfg(not(feature = "no_function"))]
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
use crate::ast::AST;
|
|
||||||
use crate::dynamic::Variant;
|
use crate::dynamic::Variant;
|
||||||
use crate::engine::Engine;
|
use crate::{Engine, EvalAltResult, ParseError, Scope, AST};
|
||||||
use crate::parse_error::ParseError;
|
|
||||||
use crate::result::EvalAltResult;
|
|
||||||
use crate::scope::Scope;
|
|
||||||
|
|
||||||
use crate::stdlib::{boxed::Box, string::ToString};
|
use crate::stdlib::{boxed::Box, string::ToString};
|
||||||
|
|
||||||
/// Trait to create a Rust closure from a script.
|
/// Trait to create a Rust closure from a script.
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
//! Module defining interfaces to native-Rust functions.
|
//! Module defining interfaces to native-Rust functions.
|
||||||
|
|
||||||
use crate::ast::{FnAccess, ScriptFnDef};
|
use crate::ast::ScriptFnDef;
|
||||||
use crate::dynamic::Dynamic;
|
use crate::engine::Imports;
|
||||||
use crate::engine::{Engine, EvalContext, Imports};
|
|
||||||
use crate::module::Module;
|
|
||||||
use crate::plugin::PluginFunction;
|
use crate::plugin::PluginFunction;
|
||||||
use crate::result::EvalAltResult;
|
|
||||||
use crate::token::{is_valid_identifier, NO_POS};
|
|
||||||
use crate::utils::ImmutableString;
|
|
||||||
use crate::{calc_script_fn_hash, StaticVec};
|
|
||||||
|
|
||||||
use crate::stdlib::{boxed::Box, convert::TryFrom, fmt, iter::empty, mem, string::String};
|
use crate::stdlib::{boxed::Box, convert::TryFrom, fmt, iter::empty, mem, string::String};
|
||||||
|
use crate::token::is_valid_identifier;
|
||||||
|
use crate::{
|
||||||
|
calc_script_fn_hash, Dynamic, Engine, EvalAltResult, EvalContext, FnAccess, ImmutableString,
|
||||||
|
Module, StaticVec, NO_POS,
|
||||||
|
};
|
||||||
|
|
||||||
#[cfg(not(feature = "sync"))]
|
#[cfg(not(feature = "sync"))]
|
||||||
use crate::stdlib::rc::Rc;
|
use crate::stdlib::rc::Rc;
|
||||||
|
@ -2,15 +2,11 @@
|
|||||||
|
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
use crate::ast::FnAccess;
|
use crate::dynamic::{DynamicWriteLock, Variant};
|
||||||
use crate::dynamic::{Dynamic, DynamicWriteLock, Variant};
|
use crate::fn_native::{CallableFunction, FnAny, FnCallArgs, SendSync};
|
||||||
use crate::engine::Engine;
|
|
||||||
use crate::fn_native::{CallableFunction, FnAny, FnCallArgs, NativeCallContext, SendSync};
|
|
||||||
use crate::r#unsafe::unsafe_cast_box;
|
use crate::r#unsafe::unsafe_cast_box;
|
||||||
use crate::result::EvalAltResult;
|
|
||||||
use crate::utils::ImmutableString;
|
|
||||||
|
|
||||||
use crate::stdlib::{any::TypeId, boxed::Box, mem, string::String};
|
use crate::stdlib::{any::TypeId, boxed::Box, mem, string::String};
|
||||||
|
use crate::{Dynamic, Engine, EvalAltResult, FnAccess, ImmutableString, NativeCallContext};
|
||||||
|
|
||||||
/// Trait to register custom functions with the `Engine`.
|
/// Trait to register custom functions with the `Engine`.
|
||||||
pub trait RegisterFn<FN, ARGS, RET> {
|
pub trait RegisterFn<FN, ARGS, RET> {
|
||||||
|
@ -1,24 +1,11 @@
|
|||||||
//! Module defining external-loaded modules for Rhai.
|
//! Module defining external-loaded modules for Rhai.
|
||||||
|
|
||||||
use crate::ast::{FnAccess, IdentX};
|
use crate::ast::IdentX;
|
||||||
use crate::dynamic::{Dynamic, Variant};
|
use crate::dynamic::Variant;
|
||||||
use crate::fn_native::{
|
use crate::fn_native::{
|
||||||
shared_make_mut, shared_take_or_clone, CallableFunction, FnCallArgs, IteratorFn,
|
shared_make_mut, shared_take_or_clone, CallableFunction, FnCallArgs, IteratorFn, SendSync,
|
||||||
NativeCallContext, SendSync, Shared,
|
|
||||||
};
|
};
|
||||||
use crate::fn_register::by_value as cast_arg;
|
use crate::fn_register::by_value as cast_arg;
|
||||||
use crate::result::EvalAltResult;
|
|
||||||
use crate::token::{Token, NO_POS};
|
|
||||||
use crate::utils::{ImmutableString, StraightHasherBuilder};
|
|
||||||
use crate::StaticVec;
|
|
||||||
|
|
||||||
#[cfg(not(feature = "no_index"))]
|
|
||||||
use crate::Array;
|
|
||||||
|
|
||||||
#[cfg(not(feature = "no_index"))]
|
|
||||||
#[cfg(not(feature = "no_object"))]
|
|
||||||
use crate::Map;
|
|
||||||
|
|
||||||
use crate::stdlib::{
|
use crate::stdlib::{
|
||||||
any::TypeId,
|
any::TypeId,
|
||||||
boxed::Box,
|
boxed::Box,
|
||||||
@ -30,6 +17,18 @@ use crate::stdlib::{
|
|||||||
string::{String, ToString},
|
string::{String, ToString},
|
||||||
vec::Vec,
|
vec::Vec,
|
||||||
};
|
};
|
||||||
|
use crate::token::Token;
|
||||||
|
use crate::utils::StraightHasherBuilder;
|
||||||
|
use crate::{
|
||||||
|
Dynamic, EvalAltResult, FnAccess, ImmutableString, NativeCallContext, Shared, StaticVec, NO_POS,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[cfg(not(feature = "no_index"))]
|
||||||
|
use crate::Array;
|
||||||
|
|
||||||
|
#[cfg(not(feature = "no_index"))]
|
||||||
|
#[cfg(not(feature = "no_object"))]
|
||||||
|
use crate::Map;
|
||||||
|
|
||||||
/// Data structure containing a single registered function.
|
/// Data structure containing a single registered function.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
use crate::engine::Engine;
|
|
||||||
use crate::fn_native::Shared;
|
|
||||||
use crate::module::{Module, ModuleResolver};
|
|
||||||
use crate::result::EvalAltResult;
|
|
||||||
use crate::token::Position;
|
|
||||||
|
|
||||||
use crate::stdlib::{boxed::Box, ops::AddAssign, vec::Vec};
|
use crate::stdlib::{boxed::Box, ops::AddAssign, vec::Vec};
|
||||||
|
use crate::{Engine, EvalAltResult, Module, ModuleResolver, Position, Shared};
|
||||||
|
|
||||||
/// Module resolution service that holds a collection of module resolves,
|
/// Module resolution service that holds a collection of module resolves,
|
||||||
/// to be searched in sequential order.
|
/// to be searched in sequential order.
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
use crate::engine::Engine;
|
|
||||||
use crate::fn_native::{Locked, Shared};
|
|
||||||
use crate::module::{Module, ModuleResolver};
|
|
||||||
use crate::result::EvalAltResult;
|
|
||||||
use crate::token::Position;
|
|
||||||
|
|
||||||
use crate::stdlib::{
|
use crate::stdlib::{
|
||||||
boxed::Box, collections::HashMap, io::Error as IoError, path::PathBuf, string::String,
|
boxed::Box, collections::HashMap, io::Error as IoError, path::PathBuf, string::String,
|
||||||
};
|
};
|
||||||
|
use crate::{Engine, EvalAltResult, Locked, Module, ModuleResolver, Position, Shared};
|
||||||
|
|
||||||
/// Module resolution service that loads module script files from the file system.
|
/// Module resolution service that loads module script files from the file system.
|
||||||
///
|
///
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
use crate::engine::Engine;
|
use crate::fn_native::SendSync;
|
||||||
use crate::fn_native::{SendSync, Shared};
|
|
||||||
use crate::module::Module;
|
|
||||||
use crate::result::EvalAltResult;
|
|
||||||
use crate::token::Position;
|
|
||||||
|
|
||||||
use crate::stdlib::boxed::Box;
|
use crate::stdlib::boxed::Box;
|
||||||
|
use crate::{Engine, EvalAltResult, Module, Position, Shared};
|
||||||
|
|
||||||
mod collection;
|
mod collection;
|
||||||
pub use collection::ModuleResolversCollection;
|
pub use collection::ModuleResolversCollection;
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
use crate::engine::Engine;
|
|
||||||
use crate::fn_native::Shared;
|
|
||||||
use crate::module::{Module, ModuleResolver};
|
|
||||||
use crate::result::EvalAltResult;
|
|
||||||
use crate::token::Position;
|
|
||||||
|
|
||||||
use crate::stdlib::{boxed::Box, collections::HashMap, ops::AddAssign, string::String};
|
use crate::stdlib::{boxed::Box, collections::HashMap, ops::AddAssign, string::String};
|
||||||
|
use crate::{Engine, EvalAltResult, Module, ModuleResolver, Position, Shared};
|
||||||
|
|
||||||
/// Module resolution service that serves modules added into it.
|
/// Module resolution service that serves modules added into it.
|
||||||
///
|
///
|
||||||
|
@ -1,19 +1,12 @@
|
|||||||
//! Module implementing the AST optimizer.
|
//! Module implementing the AST optimizer.
|
||||||
|
|
||||||
use crate::ast::{Expr, ScriptFnDef, Stmt, AST};
|
use crate::ast::{Expr, ScriptFnDef, Stmt};
|
||||||
use crate::dynamic::Dynamic;
|
|
||||||
use crate::engine::{
|
use crate::engine::{
|
||||||
Engine, KEYWORD_DEBUG, KEYWORD_EVAL, KEYWORD_IS_DEF_FN, KEYWORD_IS_DEF_VAR, KEYWORD_PRINT,
|
KEYWORD_DEBUG, KEYWORD_EVAL, KEYWORD_IS_DEF_FN, KEYWORD_IS_DEF_VAR, KEYWORD_PRINT,
|
||||||
KEYWORD_TYPE_OF,
|
KEYWORD_TYPE_OF,
|
||||||
};
|
};
|
||||||
use crate::fn_call::run_builtin_binary_op;
|
use crate::fn_call::run_builtin_binary_op;
|
||||||
use crate::module::Module;
|
|
||||||
use crate::parser::map_dynamic_to_expr;
|
use crate::parser::map_dynamic_to_expr;
|
||||||
use crate::scope::Scope;
|
|
||||||
use crate::token::{is_valid_identifier, Position, NO_POS};
|
|
||||||
use crate::utils::get_hasher;
|
|
||||||
use crate::{calc_native_fn_hash, StaticVec};
|
|
||||||
|
|
||||||
use crate::stdlib::{
|
use crate::stdlib::{
|
||||||
boxed::Box,
|
boxed::Box,
|
||||||
hash::{Hash, Hasher},
|
hash::{Hash, Hasher},
|
||||||
@ -23,6 +16,11 @@ use crate::stdlib::{
|
|||||||
vec,
|
vec,
|
||||||
vec::Vec,
|
vec::Vec,
|
||||||
};
|
};
|
||||||
|
use crate::token::is_valid_identifier;
|
||||||
|
use crate::utils::get_hasher;
|
||||||
|
use crate::{
|
||||||
|
calc_native_fn_hash, Dynamic, Engine, Module, Position, Scope, StaticVec, AST, NO_POS,
|
||||||
|
};
|
||||||
|
|
||||||
/// Level of optimization performed.
|
/// Level of optimization performed.
|
||||||
///
|
///
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
use crate::def_package;
|
|
||||||
use crate::plugin::*;
|
use crate::plugin::*;
|
||||||
use crate::INT;
|
use crate::stdlib::{format, string::String};
|
||||||
|
use crate::{def_package, EvalAltResult, INT, NO_POS};
|
||||||
use crate::{result::EvalAltResult, token::NO_POS};
|
|
||||||
|
|
||||||
#[cfg(not(feature = "no_float"))]
|
#[cfg(not(feature = "no_float"))]
|
||||||
use crate::FLOAT;
|
use crate::FLOAT;
|
||||||
@ -13,8 +11,6 @@ use crate::FLOAT;
|
|||||||
#[cfg(not(feature = "no_float"))]
|
#[cfg(not(feature = "no_float"))]
|
||||||
use num_traits::float::Float;
|
use num_traits::float::Float;
|
||||||
|
|
||||||
use crate::stdlib::{format, string::String};
|
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn make_err(msg: impl Into<String>) -> Box<EvalAltResult> {
|
pub fn make_err(msg: impl Into<String>) -> Box<EvalAltResult> {
|
||||||
EvalAltResult::ErrorArithmetic(msg.into(), NO_POS).into()
|
EvalAltResult::ErrorArithmetic(msg.into(), NO_POS).into()
|
||||||
|
@ -1,21 +1,17 @@
|
|||||||
#![cfg(not(feature = "no_index"))]
|
#![cfg(not(feature = "no_index"))]
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
use crate::def_package;
|
|
||||||
use crate::dynamic::Dynamic;
|
|
||||||
use crate::engine::{OP_EQUALS, TYPICAL_ARRAY_SIZE};
|
use crate::engine::{OP_EQUALS, TYPICAL_ARRAY_SIZE};
|
||||||
use crate::fn_native::{FnPtr, NativeCallContext};
|
|
||||||
use crate::plugin::*;
|
use crate::plugin::*;
|
||||||
use crate::result::EvalAltResult;
|
use crate::stdlib::{any::TypeId, boxed::Box, cmp::max, cmp::Ordering, string::ToString};
|
||||||
use crate::token::NO_POS;
|
use crate::{
|
||||||
use crate::utils::ImmutableString;
|
def_package, Array, Dynamic, EvalAltResult, FnPtr, ImmutableString, NativeCallContext, INT,
|
||||||
use crate::{Array, INT};
|
NO_POS,
|
||||||
|
};
|
||||||
|
|
||||||
#[cfg(not(feature = "no_object"))]
|
#[cfg(not(feature = "no_object"))]
|
||||||
use crate::Map;
|
use crate::Map;
|
||||||
|
|
||||||
use crate::stdlib::{any::TypeId, boxed::Box, cmp::max, cmp::Ordering, string::ToString};
|
|
||||||
|
|
||||||
pub type Unit = ();
|
pub type Unit = ();
|
||||||
|
|
||||||
macro_rules! gen_array_functions {
|
macro_rules! gen_array_functions {
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
use crate::def_package;
|
|
||||||
use crate::dynamic::Dynamic;
|
|
||||||
use crate::plugin::*;
|
use crate::plugin::*;
|
||||||
use crate::result::EvalAltResult;
|
use crate::{def_package, Dynamic, EvalAltResult, ImmutableString};
|
||||||
use crate::utils::ImmutableString;
|
|
||||||
|
|
||||||
def_package!(crate:EvalPackage:"Disable 'eval'.", lib, {
|
def_package!(crate:EvalPackage:"Disable 'eval'.", lib, {
|
||||||
combine_with_exported_module!(lib, "eval", eval_override);
|
combine_with_exported_module!(lib, "eval", eval_override);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
use crate::def_package;
|
|
||||||
use crate::fn_native::FnPtr;
|
|
||||||
use crate::plugin::*;
|
use crate::plugin::*;
|
||||||
|
use crate::{def_package, FnPtr};
|
||||||
|
|
||||||
def_package!(crate:BasicFnPackage:"Basic Fn functions.", lib, {
|
def_package!(crate:BasicFnPackage:"Basic Fn functions.", lib, {
|
||||||
combine_with_exported_module!(lib, "FnPtr", fn_ptr_functions);
|
combine_with_exported_module!(lib, "FnPtr", fn_ptr_functions);
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
use crate::def_package;
|
|
||||||
use crate::dynamic::Variant;
|
use crate::dynamic::Variant;
|
||||||
use crate::result::EvalAltResult;
|
|
||||||
use crate::INT;
|
|
||||||
|
|
||||||
use crate::stdlib::{
|
use crate::stdlib::{
|
||||||
boxed::Box,
|
boxed::Box,
|
||||||
ops::{Add, Range},
|
ops::{Add, Range},
|
||||||
};
|
};
|
||||||
|
use crate::{def_package, EvalAltResult, INT};
|
||||||
|
|
||||||
fn get_range<T: Variant + Clone>(from: T, to: T) -> Result<Range<T>, Box<EvalAltResult>> {
|
fn get_range<T: Variant + Clone>(from: T, to: T) -> Result<Range<T>, Box<EvalAltResult>> {
|
||||||
Ok(from..to)
|
Ok(from..to)
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
#![cfg(not(feature = "no_object"))]
|
#![cfg(not(feature = "no_object"))]
|
||||||
|
|
||||||
use crate::def_package;
|
|
||||||
use crate::dynamic::Dynamic;
|
|
||||||
use crate::engine::OP_EQUALS;
|
use crate::engine::OP_EQUALS;
|
||||||
use crate::plugin::*;
|
use crate::plugin::*;
|
||||||
use crate::utils::ImmutableString;
|
use crate::{def_package, Dynamic, ImmutableString, Map, INT};
|
||||||
use crate::{Map, INT};
|
|
||||||
|
|
||||||
#[cfg(not(feature = "no_index"))]
|
#[cfg(not(feature = "no_index"))]
|
||||||
use crate::Array;
|
use crate::Array;
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
use crate::def_package;
|
|
||||||
use crate::plugin::*;
|
use crate::plugin::*;
|
||||||
use crate::token::NO_POS;
|
use crate::{def_package, INT, NO_POS};
|
||||||
use crate::INT;
|
|
||||||
|
|
||||||
#[cfg(not(feature = "no_float"))]
|
#[cfg(not(feature = "no_float"))]
|
||||||
use crate::FLOAT;
|
use crate::FLOAT;
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
//! Module containing all built-in _packages_ available to Rhai, plus facilities to define custom packages.
|
//! Module containing all built-in _packages_ available to Rhai, plus facilities to define custom packages.
|
||||||
|
|
||||||
use crate::fn_native::{CallableFunction, IteratorFn, Shared};
|
use crate::fn_native::{CallableFunction, IteratorFn};
|
||||||
use crate::module::Module;
|
|
||||||
use crate::StaticVec;
|
|
||||||
|
|
||||||
use crate::stdlib::any::TypeId;
|
use crate::stdlib::any::TypeId;
|
||||||
|
use crate::{Module, Shared, StaticVec};
|
||||||
|
|
||||||
pub(crate) mod arithmetic;
|
pub(crate) mod arithmetic;
|
||||||
mod array_basic;
|
mod array_basic;
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
use crate::def_package;
|
|
||||||
use crate::engine::{FN_TO_STRING, KEYWORD_DEBUG, KEYWORD_PRINT};
|
use crate::engine::{FN_TO_STRING, KEYWORD_DEBUG, KEYWORD_PRINT};
|
||||||
use crate::fn_native::FnPtr;
|
|
||||||
use crate::plugin::*;
|
use crate::plugin::*;
|
||||||
use crate::utils::ImmutableString;
|
use crate::stdlib::{
|
||||||
use crate::INT;
|
fmt::{Debug, Display},
|
||||||
|
format,
|
||||||
|
string::ToString,
|
||||||
|
};
|
||||||
|
use crate::{def_package, FnPtr, ImmutableString, INT};
|
||||||
|
|
||||||
#[cfg(not(feature = "no_index"))]
|
#[cfg(not(feature = "no_index"))]
|
||||||
use crate::Array;
|
use crate::Array;
|
||||||
@ -13,12 +15,6 @@ use crate::Array;
|
|||||||
#[cfg(not(feature = "no_object"))]
|
#[cfg(not(feature = "no_object"))]
|
||||||
use crate::Map;
|
use crate::Map;
|
||||||
|
|
||||||
use crate::stdlib::{
|
|
||||||
fmt::{Debug, Display},
|
|
||||||
format,
|
|
||||||
string::ToString,
|
|
||||||
};
|
|
||||||
|
|
||||||
type Unit = ();
|
type Unit = ();
|
||||||
|
|
||||||
macro_rules! gen_functions {
|
macro_rules! gen_functions {
|
||||||
|
@ -1,16 +1,10 @@
|
|||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
use crate::def_package;
|
|
||||||
use crate::dynamic::Dynamic;
|
|
||||||
use crate::fn_native::FnPtr;
|
|
||||||
use crate::plugin::*;
|
use crate::plugin::*;
|
||||||
use crate::utils::ImmutableString;
|
|
||||||
use crate::StaticVec;
|
|
||||||
use crate::INT;
|
|
||||||
|
|
||||||
use crate::stdlib::{
|
use crate::stdlib::{
|
||||||
any::TypeId, boxed::Box, format, mem, string::String, string::ToString, vec::Vec,
|
any::TypeId, boxed::Box, format, mem, string::String, string::ToString, vec::Vec,
|
||||||
};
|
};
|
||||||
|
use crate::{def_package, Dynamic, FnPtr, ImmutableString, StaticVec, INT};
|
||||||
|
|
||||||
macro_rules! gen_concat_functions {
|
macro_rules! gen_concat_functions {
|
||||||
($root:ident => $($arg_type:ident),+ ) => {
|
($root:ident => $($arg_type:ident),+ ) => {
|
||||||
|
@ -1,18 +1,13 @@
|
|||||||
#![cfg(not(feature = "no_std"))]
|
#![cfg(not(feature = "no_std"))]
|
||||||
|
|
||||||
use super::{arithmetic::make_err as make_arithmetic_err, math_basic::MAX_INT};
|
use super::{arithmetic::make_err as make_arithmetic_err, math_basic::MAX_INT};
|
||||||
|
|
||||||
use crate::def_package;
|
|
||||||
use crate::dynamic::Dynamic;
|
|
||||||
use crate::plugin::*;
|
use crate::plugin::*;
|
||||||
use crate::result::EvalAltResult;
|
use crate::stdlib::boxed::Box;
|
||||||
use crate::INT;
|
use crate::{def_package, Dynamic, EvalAltResult, INT};
|
||||||
|
|
||||||
#[cfg(not(feature = "no_float"))]
|
#[cfg(not(feature = "no_float"))]
|
||||||
use crate::FLOAT;
|
use crate::FLOAT;
|
||||||
|
|
||||||
use crate::stdlib::boxed::Box;
|
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
use crate::stdlib::time::{Duration, Instant};
|
use crate::stdlib::time::{Duration, Instant};
|
||||||
|
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
//! Module containing error definitions for the parsing process.
|
//! Module containing error definitions for the parsing process.
|
||||||
|
|
||||||
use crate::result::EvalAltResult;
|
|
||||||
use crate::token::{Position, NO_POS};
|
|
||||||
|
|
||||||
use crate::stdlib::{
|
use crate::stdlib::{
|
||||||
boxed::Box,
|
boxed::Box,
|
||||||
error::Error,
|
error::Error,
|
||||||
fmt,
|
fmt,
|
||||||
string::{String, ToString},
|
string::{String, ToString},
|
||||||
};
|
};
|
||||||
|
use crate::{EvalAltResult, Position, NO_POS};
|
||||||
|
|
||||||
/// _[INTERNALS]_ Error encountered when tokenizing the script text.
|
/// _[INTERNALS]_ Error encountered when tokenizing the script text.
|
||||||
/// Exported under the `internals` feature only.
|
/// Exported under the `internals` feature only.
|
||||||
|
@ -1,24 +1,13 @@
|
|||||||
//! Main module defining the lexer and parser.
|
//! Main module defining the lexer and parser.
|
||||||
|
|
||||||
use crate::ast::{
|
use crate::ast::{
|
||||||
BinaryExpr, CustomExpr, Expr, FnCallExpr, Ident, IdentX, ReturnType, ScriptFnDef, Stmt, AST,
|
BinaryExpr, CustomExpr, Expr, FnCallExpr, Ident, IdentX, ReturnType, ScriptFnDef, Stmt,
|
||||||
};
|
};
|
||||||
use crate::dynamic::{Dynamic, Union};
|
use crate::dynamic::Union;
|
||||||
use crate::engine::{Engine, KEYWORD_THIS, MARKER_BLOCK, MARKER_EXPR, MARKER_IDENT};
|
use crate::engine::{KEYWORD_THIS, MARKER_BLOCK, MARKER_EXPR, MARKER_IDENT};
|
||||||
use crate::module::NamespaceRef;
|
use crate::module::NamespaceRef;
|
||||||
use crate::optimize::{optimize_into_ast, OptimizationLevel};
|
use crate::optimize::optimize_into_ast;
|
||||||
use crate::parse_error::{LexError, ParseError, ParseErrorType};
|
use crate::scope::EntryType as ScopeEntryType;
|
||||||
use crate::scope::{EntryType as ScopeEntryType, Scope};
|
|
||||||
use crate::syntax::CustomSyntax;
|
|
||||||
use crate::token::{
|
|
||||||
is_keyword_function, is_valid_identifier, Position, Token, TokenStream, NO_POS,
|
|
||||||
};
|
|
||||||
use crate::utils::{get_hasher, ImmutableString, StraightHasherBuilder};
|
|
||||||
use crate::{calc_script_fn_hash, StaticVec};
|
|
||||||
|
|
||||||
#[cfg(not(feature = "no_float"))]
|
|
||||||
use crate::FLOAT;
|
|
||||||
|
|
||||||
use crate::stdlib::{
|
use crate::stdlib::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
boxed::Box,
|
boxed::Box,
|
||||||
@ -31,6 +20,16 @@ use crate::stdlib::{
|
|||||||
vec,
|
vec,
|
||||||
vec::Vec,
|
vec::Vec,
|
||||||
};
|
};
|
||||||
|
use crate::syntax::CustomSyntax;
|
||||||
|
use crate::token::{is_keyword_function, is_valid_identifier, Token, TokenStream};
|
||||||
|
use crate::utils::{get_hasher, StraightHasherBuilder};
|
||||||
|
use crate::{
|
||||||
|
calc_script_fn_hash, Dynamic, Engine, ImmutableString, LexError, OptimizationLevel, ParseError,
|
||||||
|
ParseErrorType, Position, Scope, StaticVec, AST, NO_POS,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[cfg(not(feature = "no_float"))]
|
||||||
|
use crate::FLOAT;
|
||||||
|
|
||||||
type PERR = ParseErrorType;
|
type PERR = ParseErrorType;
|
||||||
|
|
||||||
@ -148,10 +147,10 @@ impl<'e> ParseState<'e> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get an interned string, creating one if it is not yet interned.
|
/// Get an interned string, creating one if it is not yet interned.
|
||||||
pub fn get_interned_string<S>(&mut self, text: S) -> ImmutableString
|
pub fn get_interned_string<S>(
|
||||||
where
|
&mut self,
|
||||||
S: AsRef<str> + Into<ImmutableString>,
|
text: impl AsRef<str> + Into<ImmutableString>,
|
||||||
{
|
) -> ImmutableString {
|
||||||
#[allow(clippy::map_entry)]
|
#[allow(clippy::map_entry)]
|
||||||
if !self.strings.contains_key(text.as_ref()) {
|
if !self.strings.contains_key(text.as_ref()) {
|
||||||
let value: ImmutableString = text.into();
|
let value: ImmutableString = text.into();
|
||||||
|
@ -1,15 +1,11 @@
|
|||||||
//! Module defining macros for developing _plugins_.
|
//! Module defining macros for developing _plugins_.
|
||||||
|
|
||||||
pub use crate::ast::FnAccess;
|
pub use crate::fn_native::{CallableFunction, FnCallArgs};
|
||||||
pub use crate::dynamic::Dynamic;
|
|
||||||
pub use crate::engine::Engine;
|
|
||||||
pub use crate::fn_native::{CallableFunction, FnCallArgs, NativeCallContext};
|
|
||||||
pub use crate::fn_register::{RegisterFn, RegisterResultFn};
|
|
||||||
pub use crate::module::Module;
|
|
||||||
pub use crate::result::EvalAltResult;
|
|
||||||
pub use crate::utils::ImmutableString;
|
|
||||||
|
|
||||||
pub use crate::stdlib::{any::TypeId, boxed::Box, format, mem, string::ToString, vec as new_vec};
|
pub use crate::stdlib::{any::TypeId, boxed::Box, format, mem, string::ToString, vec as new_vec};
|
||||||
|
pub use crate::{
|
||||||
|
Dynamic, Engine, EvalAltResult, FnAccess, ImmutableString, Module, NativeCallContext,
|
||||||
|
RegisterFn, RegisterResultFn,
|
||||||
|
};
|
||||||
|
|
||||||
#[cfg(not(features = "no_module"))]
|
#[cfg(not(features = "no_module"))]
|
||||||
pub use rhai_codegen::*;
|
pub use rhai_codegen::*;
|
||||||
|
@ -1,17 +1,12 @@
|
|||||||
//! Module containing error definitions for the evaluation process.
|
//! Module containing error definitions for the evaluation process.
|
||||||
|
|
||||||
use crate::dynamic::Dynamic;
|
|
||||||
use crate::parse_error::ParseErrorType;
|
|
||||||
use crate::token::{Position, NO_POS};
|
|
||||||
use crate::utils::ImmutableString;
|
|
||||||
use crate::INT;
|
|
||||||
|
|
||||||
use crate::stdlib::{
|
use crate::stdlib::{
|
||||||
boxed::Box,
|
boxed::Box,
|
||||||
error::Error,
|
error::Error,
|
||||||
fmt,
|
fmt,
|
||||||
string::{String, ToString},
|
string::{String, ToString},
|
||||||
};
|
};
|
||||||
|
use crate::{Dynamic, ImmutableString, ParseErrorType, Position, INT, NO_POS};
|
||||||
|
|
||||||
/// Evaluation result.
|
/// Evaluation result.
|
||||||
///
|
///
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
//! Module that defines the `Scope` type representing a function call-stack scope.
|
//! Module that defines the `Scope` type representing a function call-stack scope.
|
||||||
|
|
||||||
use crate::dynamic::{Dynamic, Variant};
|
use crate::dynamic::Variant;
|
||||||
use crate::StaticVec;
|
|
||||||
|
|
||||||
use crate::stdlib::{borrow::Cow, boxed::Box, iter, string::String, vec::Vec};
|
use crate::stdlib::{borrow::Cow, boxed::Box, iter, string::String, vec::Vec};
|
||||||
|
use crate::{Dynamic, StaticVec};
|
||||||
|
|
||||||
/// Type of an entry in the Scope.
|
/// Type of an entry in the Scope.
|
||||||
#[derive(Debug, Eq, PartialEq, Hash, Copy, Clone)]
|
#[derive(Debug, Eq, PartialEq, Hash, Copy, Clone)]
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
//! Implement deserialization support of `Dynamic` for [`serde`](https://crates.io/crates/serde).
|
//! Implement deserialization support of `Dynamic` for [`serde`](https://crates.io/crates/serde).
|
||||||
|
|
||||||
use super::str::ImmutableStringDeserializer;
|
use super::str::ImmutableStringDeserializer;
|
||||||
use crate::dynamic::{Dynamic, Union};
|
use crate::dynamic::Union;
|
||||||
use crate::parse_error::{LexError, ParseErrorType};
|
use crate::stdlib::{any::type_name, boxed::Box, fmt, string::ToString};
|
||||||
use crate::result::EvalAltResult;
|
use crate::{Dynamic, EvalAltResult, ImmutableString, LexError, ParseErrorType, NO_POS};
|
||||||
use crate::token::NO_POS;
|
|
||||||
use crate::utils::ImmutableString;
|
|
||||||
|
|
||||||
use serde::de::{
|
use serde::de::{
|
||||||
DeserializeSeed, Deserializer, Error, IntoDeserializer, MapAccess, SeqAccess, Visitor,
|
DeserializeSeed, Deserializer, Error, IntoDeserializer, MapAccess, SeqAccess, Visitor,
|
||||||
};
|
};
|
||||||
@ -18,8 +15,6 @@ use crate::Array;
|
|||||||
#[cfg(not(feature = "no_object"))]
|
#[cfg(not(feature = "no_object"))]
|
||||||
use crate::Map;
|
use crate::Map;
|
||||||
|
|
||||||
use crate::stdlib::{any::type_name, boxed::Box, fmt, string::ToString};
|
|
||||||
|
|
||||||
/// Deserializer for `Dynamic` which is kept as a reference.
|
/// Deserializer for `Dynamic` which is kept as a reference.
|
||||||
///
|
///
|
||||||
/// The reference is necessary because the deserialized type may hold references
|
/// The reference is necessary because the deserialized type may hold references
|
||||||
|
@ -1,22 +1,18 @@
|
|||||||
//! Implement serialization support of `Dynamic` for [`serde`](https://crates.io/crates/serde).
|
//! Implement serialization support of `Dynamic` for [`serde`](https://crates.io/crates/serde).
|
||||||
|
|
||||||
use crate::dynamic::Dynamic;
|
use crate::stdlib::{boxed::Box, fmt, string::ToString};
|
||||||
use crate::result::EvalAltResult;
|
use crate::{Dynamic, EvalAltResult, NO_POS};
|
||||||
use crate::token::NO_POS;
|
|
||||||
|
|
||||||
#[cfg(not(feature = "no_index"))]
|
|
||||||
use crate::Array;
|
|
||||||
|
|
||||||
#[cfg(not(feature = "no_object"))]
|
|
||||||
use crate::Map;
|
|
||||||
|
|
||||||
use serde::ser::{
|
use serde::ser::{
|
||||||
Error, SerializeMap, SerializeSeq, SerializeStruct, SerializeTuple, SerializeTupleStruct,
|
Error, SerializeMap, SerializeSeq, SerializeStruct, SerializeTuple, SerializeTupleStruct,
|
||||||
Serializer,
|
Serializer,
|
||||||
};
|
};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use crate::stdlib::{boxed::Box, fmt, string::ToString};
|
#[cfg(not(feature = "no_index"))]
|
||||||
|
use crate::Array;
|
||||||
|
|
||||||
|
#[cfg(not(feature = "no_object"))]
|
||||||
|
use crate::Map;
|
||||||
|
|
||||||
/// Serializer for `Dynamic` which is kept as a reference.
|
/// Serializer for `Dynamic` which is kept as a reference.
|
||||||
pub struct DynamicSerializer {
|
pub struct DynamicSerializer {
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
//! Implement deserialization support of `ImmutableString` for [`serde`](https://crates.io/crates/serde).
|
//! Implement deserialization support of `ImmutableString` for [`serde`](https://crates.io/crates/serde).
|
||||||
|
|
||||||
use crate::result::EvalAltResult;
|
|
||||||
use crate::token::NO_POS;
|
|
||||||
use crate::utils::ImmutableString;
|
|
||||||
|
|
||||||
use serde::de::{Deserializer, Visitor};
|
|
||||||
|
|
||||||
use crate::stdlib::{any::type_name, boxed::Box};
|
use crate::stdlib::{any::type_name, boxed::Box};
|
||||||
|
use crate::{EvalAltResult, ImmutableString, NO_POS};
|
||||||
|
use serde::de::{Deserializer, Visitor};
|
||||||
|
|
||||||
/// Deserializer for `ImmutableString`.
|
/// Deserializer for `ImmutableString`.
|
||||||
pub struct ImmutableStringDeserializer<'a> {
|
pub struct ImmutableStringDeserializer<'a> {
|
||||||
|
@ -1,20 +1,18 @@
|
|||||||
//! Module implementing custom syntax for `Engine`.
|
//! Module implementing custom syntax for `Engine`.
|
||||||
|
|
||||||
use crate::ast::Expr;
|
use crate::ast::Expr;
|
||||||
use crate::dynamic::Dynamic;
|
use crate::engine::{EvalContext, MARKER_BLOCK, MARKER_EXPR, MARKER_IDENT};
|
||||||
use crate::engine::{Engine, EvalContext, MARKER_BLOCK, MARKER_EXPR, MARKER_IDENT};
|
use crate::fn_native::SendSync;
|
||||||
use crate::fn_native::{SendSync, Shared};
|
|
||||||
use crate::parse_error::{LexError, ParseError};
|
|
||||||
use crate::result::EvalAltResult;
|
|
||||||
use crate::token::{is_valid_identifier, Position, Token, NO_POS};
|
|
||||||
use crate::utils::ImmutableString;
|
|
||||||
use crate::StaticVec;
|
|
||||||
|
|
||||||
use crate::stdlib::{
|
use crate::stdlib::{
|
||||||
boxed::Box,
|
boxed::Box,
|
||||||
format,
|
format,
|
||||||
string::{String, ToString},
|
string::{String, ToString},
|
||||||
};
|
};
|
||||||
|
use crate::token::{is_valid_identifier, Token};
|
||||||
|
use crate::{
|
||||||
|
Dynamic, Engine, EvalAltResult, ImmutableString, LexError, ParseError, Position, Shared,
|
||||||
|
StaticVec, NO_POS,
|
||||||
|
};
|
||||||
|
|
||||||
/// A general expression evaluation trait object.
|
/// A general expression evaluation trait object.
|
||||||
#[cfg(not(feature = "sync"))]
|
#[cfg(not(feature = "sync"))]
|
||||||
|
14
src/token.rs
14
src/token.rs
@ -1,17 +1,9 @@
|
|||||||
//! Main module defining the lexer and parser.
|
//! Main module defining the lexer and parser.
|
||||||
|
|
||||||
use crate::engine::{
|
use crate::engine::{
|
||||||
Engine, KEYWORD_DEBUG, KEYWORD_EVAL, KEYWORD_FN_PTR, KEYWORD_FN_PTR_CALL, KEYWORD_FN_PTR_CURRY,
|
KEYWORD_DEBUG, KEYWORD_EVAL, KEYWORD_FN_PTR, KEYWORD_FN_PTR_CALL, KEYWORD_FN_PTR_CURRY,
|
||||||
KEYWORD_IS_DEF_FN, KEYWORD_IS_DEF_VAR, KEYWORD_PRINT, KEYWORD_THIS, KEYWORD_TYPE_OF,
|
KEYWORD_IS_DEF_FN, KEYWORD_IS_DEF_VAR, KEYWORD_PRINT, KEYWORD_THIS, KEYWORD_TYPE_OF,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::parse_error::LexError;
|
|
||||||
use crate::StaticVec;
|
|
||||||
use crate::INT;
|
|
||||||
|
|
||||||
#[cfg(not(feature = "no_float"))]
|
|
||||||
use crate::FLOAT;
|
|
||||||
|
|
||||||
use crate::stdlib::{
|
use crate::stdlib::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
boxed::Box,
|
boxed::Box,
|
||||||
@ -20,6 +12,10 @@ use crate::stdlib::{
|
|||||||
str::{Chars, FromStr},
|
str::{Chars, FromStr},
|
||||||
string::{String, ToString},
|
string::{String, ToString},
|
||||||
};
|
};
|
||||||
|
use crate::{Engine, LexError, StaticVec, INT};
|
||||||
|
|
||||||
|
#[cfg(not(feature = "no_float"))]
|
||||||
|
use crate::FLOAT;
|
||||||
|
|
||||||
type LERR = LexError;
|
type LERR = LexError;
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
//! A helper module containing unsafe utility functions.
|
//! A helper module containing unsafe utility functions.
|
||||||
|
|
||||||
use crate::dynamic::Variant;
|
use crate::dynamic::Variant;
|
||||||
|
|
||||||
use crate::stdlib::{
|
use crate::stdlib::{
|
||||||
any::{Any, TypeId},
|
any::{Any, TypeId},
|
||||||
boxed::Box,
|
boxed::Box,
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
//! Module containing various utility types and functions.
|
//! Module containing various utility types and functions.
|
||||||
|
|
||||||
use crate::fn_native::{shared_make_mut, shared_take, Shared};
|
use crate::fn_native::{shared_make_mut, shared_take};
|
||||||
|
|
||||||
use crate::stdlib::{
|
use crate::stdlib::{
|
||||||
any::TypeId,
|
any::TypeId,
|
||||||
borrow::Borrow,
|
borrow::Borrow,
|
||||||
@ -14,6 +13,7 @@ use crate::stdlib::{
|
|||||||
str::FromStr,
|
str::FromStr,
|
||||||
string::{String, ToString},
|
string::{String, ToString},
|
||||||
};
|
};
|
||||||
|
use crate::Shared;
|
||||||
|
|
||||||
/// A hasher that only takes one single `u64` and returns it as a hash key.
|
/// A hasher that only takes one single `u64` and returns it as a hash key.
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user