Fix no_function build.

This commit is contained in:
Stephen Chung 2020-11-08 10:56:33 +08:00
parent b3d318ef7f
commit 760f6c3678
3 changed files with 15 additions and 10 deletions

View File

@ -1658,15 +1658,16 @@ impl Engine {
mut ast: AST, mut ast: AST,
optimization_level: OptimizationLevel, optimization_level: OptimizationLevel,
) -> AST { ) -> AST {
let lib = if cfg!(not(feature = "no_function")) { #[cfg(not(feature = "no_function"))]
ast.lib() let lib = ast
.lib()
.iter_fn() .iter_fn()
.filter(|f| f.func.is_script()) .filter(|f| f.func.is_script())
.map(|f| (**f.func.get_fn_def()).clone()) .map(|f| (**f.func.get_fn_def()).clone())
.collect() .collect();
} else {
Default::default() #[cfg(feature = "no_function")]
}; let lib = Default::default();
let stmt = mem::take(ast.statements_mut()); let stmt = mem::take(ast.statements_mut());
optimize_into_ast(self, scope, stmt, lib, optimization_level) optimize_into_ast(self, scope, stmt, lib, optimization_level)

View File

@ -1265,6 +1265,7 @@ impl Module {
/// Get an iterator to the functions in the module. /// Get an iterator to the functions in the module.
#[cfg(not(feature = "no_optimize"))] #[cfg(not(feature = "no_optimize"))]
#[cfg(not(feature = "no_function"))]
#[inline(always)] #[inline(always)]
pub(crate) fn iter_fn(&self) -> impl Iterator<Item = &FuncInfo> { pub(crate) fn iter_fn(&self) -> impl Iterator<Item = &FuncInfo> {
self.functions.values() self.functions.values()

View File

@ -32,7 +32,7 @@ use crate::{
use crate::stdlib::{ use crate::stdlib::{
borrow::Cow, borrow::Cow,
boxed::Box, boxed::Box,
collections::{HashMap, HashSet}, collections::HashMap,
format, format,
hash::Hash, hash::Hash,
iter::empty, iter::empty,
@ -45,6 +45,9 @@ use crate::stdlib::{
#[cfg(not(feature = "no_function"))] #[cfg(not(feature = "no_function"))]
use crate::stdlib::hash::Hasher; use crate::stdlib::hash::Hasher;
#[cfg(not(feature = "no_closure"))]
use crate::stdlib::collections::HashSet;
#[cfg(not(feature = "no_std"))] #[cfg(not(feature = "no_std"))]
#[cfg(not(feature = "no_function"))] #[cfg(not(feature = "no_function"))]
use crate::stdlib::collections::hash_map::DefaultHasher; use crate::stdlib::collections::hash_map::DefaultHasher;