Fix builds.
This commit is contained in:
parent
c9184db4d2
commit
8b773aa15e
@ -286,6 +286,7 @@ impl GlobalRuntimeState<'_> {
|
|||||||
/// Get the current source.
|
/// Get the current source.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
#[allow(dead_code)]
|
||||||
pub(crate) const fn source_raw(&self) -> Option<&ImmutableString> {
|
pub(crate) const fn source_raw(&self) -> Option<&ImmutableString> {
|
||||||
self.source.as_ref()
|
self.source.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,11 @@ use crate::engine::{
|
|||||||
KEYWORD_IS_DEF_VAR, KEYWORD_PRINT, KEYWORD_TYPE_OF,
|
KEYWORD_IS_DEF_VAR, KEYWORD_PRINT, KEYWORD_TYPE_OF,
|
||||||
};
|
};
|
||||||
use crate::eval::{Caches, FnResolutionCacheEntry, GlobalRuntimeState};
|
use crate::eval::{Caches, FnResolutionCacheEntry, GlobalRuntimeState};
|
||||||
use crate::tokenizer::Token;
|
use crate::tokenizer::{is_valid_function_name, Token};
|
||||||
use crate::{
|
use crate::{
|
||||||
calc_fn_hash, calc_fn_params_hash, combine_hashes, is_valid_function_name, Dynamic, Engine,
|
calc_fn_hash, calc_fn_params_hash, combine_hashes, Dynamic, Engine, FnArgsVec, FnPtr,
|
||||||
FnArgsVec, FnPtr, ImmutableString, Module, OptimizationLevel, Position, RhaiError, RhaiResult,
|
ImmutableString, Module, OptimizationLevel, Position, RhaiError, RhaiResult, RhaiResultOf,
|
||||||
RhaiResultOf, Scope, ERR,
|
Scope, ERR,
|
||||||
};
|
};
|
||||||
#[cfg(feature = "no_std")]
|
#[cfg(feature = "no_std")]
|
||||||
use hashbrown::hash_map::Entry;
|
use hashbrown::hash_map::Entry;
|
||||||
@ -808,11 +808,17 @@ impl Engine {
|
|||||||
KEYWORD_FN_PTR_CALL if target.is::<FnPtr>() => {
|
KEYWORD_FN_PTR_CALL if target.is::<FnPtr>() => {
|
||||||
// FnPtr call
|
// FnPtr call
|
||||||
let fn_ptr = target.read_lock::<FnPtr>().expect("`FnPtr`");
|
let fn_ptr = target.read_lock::<FnPtr>().expect("`FnPtr`");
|
||||||
|
|
||||||
|
#[cfg(not(feature = "no_function"))]
|
||||||
|
let is_anon = fn_ptr.is_anonymous();
|
||||||
|
#[cfg(feature = "no_function")]
|
||||||
|
let is_anon = false;
|
||||||
|
|
||||||
// Redirect function name
|
// Redirect function name
|
||||||
let fn_name = fn_ptr.fn_name();
|
let fn_name = fn_ptr.fn_name();
|
||||||
// Recalculate hashes
|
// Recalculate hashes
|
||||||
let args_len = call_args.len() + fn_ptr.curry().len();
|
let args_len = call_args.len() + fn_ptr.curry().len();
|
||||||
let new_hash = if !fn_ptr.is_anonymous() && !is_valid_function_name(fn_name) {
|
let new_hash = if !is_anon && !is_valid_function_name(fn_name) {
|
||||||
FnCallHashes::from_native(calc_fn_hash(None, fn_name, args_len))
|
FnCallHashes::from_native(calc_fn_hash(None, fn_name, args_len))
|
||||||
} else {
|
} else {
|
||||||
calc_fn_hash(None, fn_name, args_len).into()
|
calc_fn_hash(None, fn_name, args_len).into()
|
||||||
@ -850,7 +856,12 @@ impl Engine {
|
|||||||
|
|
||||||
// FnPtr call on object
|
// FnPtr call on object
|
||||||
let fn_ptr = mem::take(&mut call_args[0]).cast::<FnPtr>();
|
let fn_ptr = mem::take(&mut call_args[0]).cast::<FnPtr>();
|
||||||
|
|
||||||
|
#[cfg(not(feature = "no_function"))]
|
||||||
let is_anon = fn_ptr.is_anonymous();
|
let is_anon = fn_ptr.is_anonymous();
|
||||||
|
#[cfg(feature = "no_function")]
|
||||||
|
let is_anon = false;
|
||||||
|
|
||||||
call_args = &mut call_args[1..];
|
call_args = &mut call_args[1..];
|
||||||
|
|
||||||
// Redirect function name
|
// Redirect function name
|
||||||
@ -934,6 +945,11 @@ impl Engine {
|
|||||||
if let Some(map) = target.read_lock::<crate::Map>() {
|
if let Some(map) = target.read_lock::<crate::Map>() {
|
||||||
if let Some(val) = map.get(fn_name) {
|
if let Some(val) = map.get(fn_name) {
|
||||||
if let Some(fn_ptr) = val.read_lock::<FnPtr>() {
|
if let Some(fn_ptr) = val.read_lock::<FnPtr>() {
|
||||||
|
#[cfg(not(feature = "no_function"))]
|
||||||
|
let is_anon = fn_ptr.is_anonymous();
|
||||||
|
#[cfg(feature = "no_function")]
|
||||||
|
let is_anon = false;
|
||||||
|
|
||||||
// Remap the function name
|
// Remap the function name
|
||||||
_redirected = fn_ptr.fn_name_raw().clone();
|
_redirected = fn_ptr.fn_name_raw().clone();
|
||||||
fn_name = &_redirected;
|
fn_name = &_redirected;
|
||||||
@ -948,7 +964,7 @@ impl Engine {
|
|||||||
call_args = &mut _arg_values;
|
call_args = &mut _arg_values;
|
||||||
}
|
}
|
||||||
// Recalculate the hash based on the new function name and new arguments
|
// Recalculate the hash based on the new function name and new arguments
|
||||||
hash = if !fn_ptr.is_anonymous() && !is_valid_function_name(&fn_name) {
|
hash = if !is_anon && !is_valid_function_name(&fn_name) {
|
||||||
FnCallHashes::from_native(calc_fn_hash(
|
FnCallHashes::from_native(calc_fn_hash(
|
||||||
None,
|
None,
|
||||||
fn_name,
|
fn_name,
|
||||||
@ -1034,7 +1050,12 @@ impl Engine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let fn_ptr = arg_value.cast::<FnPtr>();
|
let fn_ptr = arg_value.cast::<FnPtr>();
|
||||||
|
|
||||||
|
#[cfg(not(feature = "no_function"))]
|
||||||
let is_anon = fn_ptr.is_anonymous();
|
let is_anon = fn_ptr.is_anonymous();
|
||||||
|
#[cfg(feature = "no_function")]
|
||||||
|
let is_anon = false;
|
||||||
|
|
||||||
let (fn_name, fn_curry) = fn_ptr.take_data();
|
let (fn_name, fn_curry) = fn_ptr.take_data();
|
||||||
curry.extend(fn_curry.into_iter());
|
curry.extend(fn_curry.into_iter());
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
//! The `FnPtr` type.
|
//! The `FnPtr` type.
|
||||||
|
|
||||||
|
use crate::tokenizer::is_valid_function_name;
|
||||||
use crate::types::dynamic::Variant;
|
use crate::types::dynamic::Variant;
|
||||||
use crate::{
|
use crate::{
|
||||||
is_valid_function_name, Dynamic, Engine, FuncArgs, ImmutableString, Module, NativeCallContext,
|
Dynamic, Engine, FuncArgs, ImmutableString, Module, NativeCallContext, Position, RhaiError,
|
||||||
Position, RhaiError, RhaiResult, RhaiResultOf, StaticVec, AST, ERR,
|
RhaiResult, RhaiResultOf, StaticVec, AST, ERR,
|
||||||
};
|
};
|
||||||
#[cfg(feature = "no_std")]
|
#[cfg(feature = "no_std")]
|
||||||
use std::prelude::v1::*;
|
use std::prelude::v1::*;
|
||||||
|
Loading…
Reference in New Issue
Block a user