Fix no_module builds.
This commit is contained in:
parent
a5ae002cb7
commit
dc2e824ce2
@ -717,6 +717,7 @@ impl AST {
|
|||||||
///
|
///
|
||||||
/// Not available under `no_function`.
|
/// Not available under `no_function`.
|
||||||
#[cfg(not(feature = "no_function"))]
|
#[cfg(not(feature = "no_function"))]
|
||||||
|
#[allow(dead_code)]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(crate) fn iter_fn_def(&self) -> impl Iterator<Item = &ScriptFnDef> {
|
pub(crate) fn iter_fn_def(&self) -> impl Iterator<Item = &ScriptFnDef> {
|
||||||
self.functions
|
self.functions
|
||||||
|
@ -262,6 +262,7 @@ pub const KEYWORD_IS_DEF_VAR: &str = "is_def_var";
|
|||||||
pub const KEYWORD_IS_DEF_FN: &str = "is_def_fn";
|
pub const KEYWORD_IS_DEF_FN: &str = "is_def_fn";
|
||||||
pub const KEYWORD_THIS: &str = "this";
|
pub const KEYWORD_THIS: &str = "this";
|
||||||
#[cfg(not(feature = "no_function"))]
|
#[cfg(not(feature = "no_function"))]
|
||||||
|
#[cfg(not(feature = "no_module"))]
|
||||||
pub const KEYWORD_GLOBAL: &str = "global";
|
pub const KEYWORD_GLOBAL: &str = "global";
|
||||||
#[cfg(not(feature = "no_object"))]
|
#[cfg(not(feature = "no_object"))]
|
||||||
pub const FN_GET: &str = "get$";
|
pub const FN_GET: &str = "get$";
|
||||||
@ -1178,10 +1179,11 @@ impl Engine {
|
|||||||
Expr::Variable(Some(_), _, _) => {
|
Expr::Variable(Some(_), _, _) => {
|
||||||
self.search_scope_only(scope, mods, state, lib, this_ptr, expr)
|
self.search_scope_only(scope, mods, state, lib, this_ptr, expr)
|
||||||
}
|
}
|
||||||
Expr::Variable(None, var_pos, v) => match v.as_ref() {
|
Expr::Variable(None, _var_pos, v) => match v.as_ref() {
|
||||||
// Normal variable access
|
// Normal variable access
|
||||||
(_, None, _) => self.search_scope_only(scope, mods, state, lib, this_ptr, expr),
|
(_, None, _) => self.search_scope_only(scope, mods, state, lib, this_ptr, expr),
|
||||||
// Qualified variable access
|
// Qualified variable access
|
||||||
|
#[cfg(not(feature = "no_module"))]
|
||||||
(_, Some((namespace, hash_var)), var_name) => {
|
(_, Some((namespace, hash_var)), var_name) => {
|
||||||
if let Some(module) = self.search_imports(mods, state, namespace) {
|
if let Some(module) = self.search_imports(mods, state, namespace) {
|
||||||
// foo:bar::baz::VARIABLE
|
// foo:bar::baz::VARIABLE
|
||||||
@ -1190,7 +1192,7 @@ impl Engine {
|
|||||||
let mut target = target.clone();
|
let mut target = target.clone();
|
||||||
// Module variables are constant
|
// Module variables are constant
|
||||||
target.set_access_mode(AccessMode::ReadOnly);
|
target.set_access_mode(AccessMode::ReadOnly);
|
||||||
Ok((target.into(), *var_pos))
|
Ok((target.into(), *_var_pos))
|
||||||
}
|
}
|
||||||
Err(mut err) => {
|
Err(mut err) => {
|
||||||
match *err {
|
match *err {
|
||||||
@ -1204,7 +1206,7 @@ impl Engine {
|
|||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
Err(err.fill_position(*var_pos))
|
Err(err.fill_position(*_var_pos))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if namespace.len() == 1 && namespace[0].name == KEYWORD_GLOBAL {
|
} else if namespace.len() == 1 && namespace[0].name == KEYWORD_GLOBAL {
|
||||||
@ -1213,7 +1215,7 @@ impl Engine {
|
|||||||
let mut target: Target = value.clone().into();
|
let mut target: Target = value.clone().into();
|
||||||
// Module variables are constant
|
// Module variables are constant
|
||||||
target.set_access_mode(AccessMode::ReadOnly);
|
target.set_access_mode(AccessMode::ReadOnly);
|
||||||
Ok((target.into(), *var_pos))
|
Ok((target.into(), *_var_pos))
|
||||||
} else {
|
} else {
|
||||||
Err(EvalAltResult::ErrorVariableNotFound(
|
Err(EvalAltResult::ErrorVariableNotFound(
|
||||||
format!(
|
format!(
|
||||||
@ -1234,6 +1236,8 @@ impl Engine {
|
|||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "no_module")]
|
||||||
|
(_, Some((_, _)), _) => unreachable!("no_module is active"),
|
||||||
},
|
},
|
||||||
_ => unreachable!("Expr::Variable expected, but gets {:?}", expr),
|
_ => unreachable!("Expr::Variable expected, but gets {:?}", expr),
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ use crate::parse::IdentifierBuilder;
|
|||||||
use crate::token::Token;
|
use crate::token::Token;
|
||||||
use crate::{
|
use crate::{
|
||||||
calc_fn_params_hash, calc_qualified_fn_hash, combine_hashes, Dynamic, EvalAltResult,
|
calc_fn_params_hash, calc_qualified_fn_hash, combine_hashes, Dynamic, EvalAltResult,
|
||||||
Identifier, ImmutableString, NativeCallContext, Position, Shared, StaticVec,
|
Identifier, ImmutableString, NativeCallContext, Shared, StaticVec,
|
||||||
};
|
};
|
||||||
#[cfg(feature = "no_std")]
|
#[cfg(feature = "no_std")]
|
||||||
use std::prelude::v1::*;
|
use std::prelude::v1::*;
|
||||||
@ -455,10 +455,11 @@ impl Module {
|
|||||||
|
|
||||||
/// Get a reference to a namespace-qualified variable.
|
/// Get a reference to a namespace-qualified variable.
|
||||||
/// Name and Position in [`EvalAltResult`] are [`None`] and [`NONE`][Position::NONE] and must be set afterwards.
|
/// Name and Position in [`EvalAltResult`] are [`None`] and [`NONE`][Position::NONE] and must be set afterwards.
|
||||||
|
#[cfg(not(feature = "no_module"))]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(crate) fn get_qualified_var(&self, hash_var: u64) -> Result<&Dynamic, Box<EvalAltResult>> {
|
pub(crate) fn get_qualified_var(&self, hash_var: u64) -> Result<&Dynamic, Box<EvalAltResult>> {
|
||||||
self.all_variables.get(&hash_var).ok_or_else(|| {
|
self.all_variables.get(&hash_var).ok_or_else(|| {
|
||||||
EvalAltResult::ErrorVariableNotFound(String::new(), Position::NONE).into()
|
EvalAltResult::ErrorVariableNotFound(String::new(), crate::Position::NONE).into()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1379,6 +1379,7 @@ fn parse_primary(
|
|||||||
parse_fn_call(input, state, lib, name, false, ns, settings.level_up())?
|
parse_fn_call(input, state, lib, name, false, ns, settings.level_up())?
|
||||||
}
|
}
|
||||||
// module access
|
// module access
|
||||||
|
#[cfg(not(feature = "no_module"))]
|
||||||
(Expr::Variable(_, var_pos, x), Token::DoubleColon) => {
|
(Expr::Variable(_, var_pos, x), Token::DoubleColon) => {
|
||||||
let (id2, pos2) = parse_var_name(input)?;
|
let (id2, pos2) = parse_var_name(input)?;
|
||||||
let (_, mut namespace, var_name) = *x;
|
let (_, mut namespace, var_name) = *x;
|
||||||
|
@ -1829,6 +1829,7 @@ fn get_next_token_inner(
|
|||||||
}
|
}
|
||||||
('=', _) => return Some((Token::Equals, start_pos)),
|
('=', _) => return Some((Token::Equals, start_pos)),
|
||||||
|
|
||||||
|
#[cfg(not(feature = "no_module"))]
|
||||||
(':', ':') => {
|
(':', ':') => {
|
||||||
eat_next(stream, pos);
|
eat_next(stream, pos);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user