Add optimize_full pseudo feature.

This commit is contained in:
Stephen Chung 2020-03-16 12:40:42 +08:00
parent 2c90fea764
commit f36caa6dc3
2 changed files with 10 additions and 3 deletions

View File

@ -19,7 +19,7 @@ num-traits = "*"
[features] [features]
#default = ["no_function", "no_index", "no_float", "only_i32", "no_stdlib", "unchecked", "no_optimize"] #default = ["no_function", "no_index", "no_float", "only_i32", "no_stdlib", "unchecked", "no_optimize"]
default = [] default = [ "optimize_full" ]
debug_msgs = [] # print debug messages on function registrations and calls debug_msgs = [] # print debug messages on function registrations and calls
unchecked = [] # unchecked arithmetic unchecked = [] # unchecked arithmetic
no_stdlib = [] # no standard library of utility functions no_stdlib = [] # no standard library of utility functions
@ -27,6 +27,7 @@ no_index = [] # no arrays and indexing
no_float = [] # no floating-point no_float = [] # no floating-point
no_function = [] # no script-defined functions no_function = [] # no script-defined functions
no_optimize = [] # no script optimizer no_optimize = [] # no script optimizer
optimize_full = [] # set optimization level to Full (default is Simple)
only_i32 = [] # set INT=i32 (useful for 32-bit systems) only_i32 = [] # set INT=i32 (useful for 32-bit systems)
only_i64 = [] # set INT=i64 (default) and disable support for all other integer types only_i64 = [] # set INT=i64 (default) and disable support for all other integer types

View File

@ -99,14 +99,20 @@ impl Engine<'_> {
// Create the new scripting Engine // Create the new scripting Engine
let mut engine = Engine { let mut engine = Engine {
#[cfg(not(feature = "no_optimize"))]
optimization_level: OptimizationLevel::Full,
ext_functions: HashMap::new(), ext_functions: HashMap::new(),
script_functions: Vec::new(), script_functions: Vec::new(),
type_iterators: HashMap::new(), type_iterators: HashMap::new(),
type_names, type_names,
on_print: Box::new(default_print), // default print/debug implementations on_print: Box::new(default_print), // default print/debug implementations
on_debug: Box::new(default_print), on_debug: Box::new(default_print),
#[cfg(not(feature = "no_optimize"))]
#[cfg(not(feature = "optimize_full"))]
optimization_level: OptimizationLevel::Simple,
#[cfg(not(feature = "no_optimize"))]
#[cfg(feature = "optimize_full")]
optimization_level: OptimizationLevel::Full,
}; };
engine.register_core_lib(); engine.register_core_lib();