Fix builds.
This commit is contained in:
parent
4fc088a0f1
commit
9c4ed44ab8
@ -2,7 +2,6 @@
|
|||||||
#![cfg(not(feature = "no_function"))]
|
#![cfg(not(feature = "no_function"))]
|
||||||
|
|
||||||
use crate::engine::{EvalState, Imports};
|
use crate::engine::{EvalState, Imports};
|
||||||
use crate::func::call::ensure_no_data_race;
|
|
||||||
use crate::types::dynamic::Variant;
|
use crate::types::dynamic::Variant;
|
||||||
use crate::{
|
use crate::{
|
||||||
Dynamic, Engine, EvalAltResult, FuncArgs, Position, RhaiResult, Scope, StaticVec, AST,
|
Dynamic, Engine, EvalAltResult, FuncArgs, Position, RhaiResult, Scope, StaticVec, AST,
|
||||||
@ -176,7 +175,7 @@ impl Engine {
|
|||||||
|
|
||||||
// Check for data race.
|
// Check for data race.
|
||||||
#[cfg(not(feature = "no_closure"))]
|
#[cfg(not(feature = "no_closure"))]
|
||||||
ensure_no_data_race(name, &mut args, false)?;
|
crate::func::call::ensure_no_data_race(name, &mut args, false)?;
|
||||||
|
|
||||||
let result = self.call_script_fn(
|
let result = self.call_script_fn(
|
||||||
scope,
|
scope,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//! Module that defines the public compilation API of [`Engine`].
|
//! Module that defines the public compilation API of [`Engine`].
|
||||||
|
|
||||||
use crate::parser::ParseState;
|
use crate::parser::ParseState;
|
||||||
use crate::{Engine, EvalAltResult, Identifier, ParseError, Position, Scope, AST};
|
use crate::{Engine, ParseError, Scope, AST};
|
||||||
#[cfg(feature = "no_std")]
|
#[cfg(feature = "no_std")]
|
||||||
use std::prelude::v1::*;
|
use std::prelude::v1::*;
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ impl Engine {
|
|||||||
&self,
|
&self,
|
||||||
scope: &Scope,
|
scope: &Scope,
|
||||||
script: impl AsRef<str>,
|
script: impl AsRef<str>,
|
||||||
) -> Result<AST, Box<EvalAltResult>> {
|
) -> Result<AST, Box<crate::EvalAltResult>> {
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::{ASTNode, Expr, Stmt},
|
ast::{ASTNode, Expr, Stmt},
|
||||||
func::native::shared_take_or_clone,
|
func::native::shared_take_or_clone,
|
||||||
@ -102,7 +102,7 @@ impl Engine {
|
|||||||
fn collect_imports(
|
fn collect_imports(
|
||||||
ast: &AST,
|
ast: &AST,
|
||||||
resolver: &StaticModuleResolver,
|
resolver: &StaticModuleResolver,
|
||||||
imports: &mut BTreeSet<Identifier>,
|
imports: &mut BTreeSet<crate::Identifier>,
|
||||||
) {
|
) {
|
||||||
ast.walk(
|
ast.walk(
|
||||||
&mut |path| match path.last().expect("contains current node") {
|
&mut |path| match path.last().expect("contains current node") {
|
||||||
@ -130,7 +130,7 @@ impl Engine {
|
|||||||
while let Some(path) = imports.iter().next() {
|
while let Some(path) = imports.iter().next() {
|
||||||
let path = path.clone();
|
let path = path.clone();
|
||||||
|
|
||||||
match module_resolver.resolve_ast(self, None, &path, Position::NONE) {
|
match module_resolver.resolve_ast(self, None, &path, crate::Position::NONE) {
|
||||||
Some(Ok(module_ast)) => {
|
Some(Ok(module_ast)) => {
|
||||||
collect_imports(&module_ast, &resolver, &mut imports)
|
collect_imports(&module_ast, &resolver, &mut imports)
|
||||||
}
|
}
|
||||||
@ -138,7 +138,8 @@ impl Engine {
|
|||||||
None => (),
|
None => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
let module = module_resolver.resolve(self, None, &path, Position::NONE)?;
|
let module =
|
||||||
|
module_resolver.resolve(self, None, &path, crate::Position::NONE)?;
|
||||||
let module = shared_take_or_clone(module);
|
let module = shared_take_or_clone(module);
|
||||||
|
|
||||||
imports.remove(&path);
|
imports.remove(&path);
|
||||||
@ -361,14 +362,14 @@ impl Engine {
|
|||||||
&self,
|
&self,
|
||||||
json: impl AsRef<str>,
|
json: impl AsRef<str>,
|
||||||
has_null: bool,
|
has_null: bool,
|
||||||
) -> Result<Map, Box<EvalAltResult>> {
|
) -> Result<Map, Box<crate::EvalAltResult>> {
|
||||||
use crate::tokenizer::Token;
|
use crate::tokenizer::Token;
|
||||||
|
|
||||||
fn parse_json_inner(
|
fn parse_json_inner(
|
||||||
engine: &Engine,
|
engine: &Engine,
|
||||||
json: &str,
|
json: &str,
|
||||||
has_null: bool,
|
has_null: bool,
|
||||||
) -> Result<Map, Box<EvalAltResult>> {
|
) -> Result<Map, Box<crate::EvalAltResult>> {
|
||||||
let mut scope = Scope::new();
|
let mut scope = Scope::new();
|
||||||
let json_text = json.trim_start();
|
let json_text = json.trim_start();
|
||||||
let scripts = if json_text.starts_with(Token::MapStart.literal_syntax()) {
|
let scripts = if json_text.starts_with(Token::MapStart.literal_syntax()) {
|
||||||
@ -380,7 +381,10 @@ impl Engine {
|
|||||||
Token::LeftBrace.syntax().into(),
|
Token::LeftBrace.syntax().into(),
|
||||||
"to start a JSON object hash".into(),
|
"to start a JSON object hash".into(),
|
||||||
)
|
)
|
||||||
.into_err(Position::new(1, (json.len() - json_text.len() + 1) as u16))
|
.into_err(crate::Position::new(
|
||||||
|
1,
|
||||||
|
(json.len() - json_text.len() + 1) as u16,
|
||||||
|
))
|
||||||
.into());
|
.into());
|
||||||
};
|
};
|
||||||
let (stream, tokenizer_control) = engine.lex_raw(
|
let (stream, tokenizer_control) = engine.lex_raw(
|
||||||
|
@ -34,6 +34,8 @@ pub trait FuncArgs {
|
|||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// # fn main() -> Result<(), Box<rhai::EvalAltResult>> {
|
/// # fn main() -> Result<(), Box<rhai::EvalAltResult>> {
|
||||||
|
/// # #[cfg(not(feature = "no_function"))]
|
||||||
|
/// # {
|
||||||
/// let options = Options { foo: false, bar: "world".to_string(), baz: 42 };
|
/// let options = Options { foo: false, bar: "world".to_string(), baz: 42 };
|
||||||
///
|
///
|
||||||
/// let engine = Engine::new();
|
/// let engine = Engine::new();
|
||||||
@ -49,6 +51,7 @@ pub trait FuncArgs {
|
|||||||
/// let result: String = engine.call_fn(&mut scope, &ast, "hello", options)?;
|
/// let result: String = engine.call_fn(&mut scope, &ast, "hello", options)?;
|
||||||
///
|
///
|
||||||
/// assert_eq!(result, "world42");
|
/// assert_eq!(result, "world42");
|
||||||
|
/// # }
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
Loading…
Reference in New Issue
Block a user