Streamline ScriptFnDef.
This commit is contained in:
parent
f75942715d
commit
c287a61b93
26
src/ast.rs
26
src/ast.rs
@ -83,6 +83,10 @@ impl FnAccess {
|
||||
/// This type is volatile and may change.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ScriptFnDef {
|
||||
/// Function body.
|
||||
pub body: Stmt,
|
||||
/// Encapsulated running environment, if any.
|
||||
pub lib: Option<Shared<Module>>,
|
||||
/// Function name.
|
||||
pub name: ImmutableString,
|
||||
/// Function access mode.
|
||||
@ -92,12 +96,6 @@ pub struct ScriptFnDef {
|
||||
/// Access to external variables.
|
||||
#[cfg(not(feature = "no_closure"))]
|
||||
pub externals: HashSet<String>,
|
||||
/// Function body.
|
||||
pub body: Stmt,
|
||||
/// Position of the function definition.
|
||||
pub pos: Position,
|
||||
/// Encapsulated running environment, if any.
|
||||
pub lib: Option<Shared<Module>>,
|
||||
}
|
||||
|
||||
impl fmt::Display for ScriptFnDef {
|
||||
@ -1240,3 +1238,19 @@ impl Expr {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// This test is to make sure no code changes increase the sizes of critical data structures.
|
||||
#[test]
|
||||
fn check_struct_sizes() {
|
||||
use std::mem::size_of;
|
||||
|
||||
assert_eq!(size_of::<Dynamic>(), 16);
|
||||
assert_eq!(size_of::<Option<Dynamic>>(), 16);
|
||||
assert_eq!(size_of::<Expr>(), 16);
|
||||
assert_eq!(size_of::<Stmt>(), 32);
|
||||
}
|
||||
}
|
||||
|
@ -866,7 +866,6 @@ pub fn optimize_into_ast(
|
||||
params: fn_def.params.clone(),
|
||||
#[cfg(not(feature = "no_closure"))]
|
||||
externals: fn_def.externals.clone(),
|
||||
pos: fn_def.pos,
|
||||
lib: None,
|
||||
}
|
||||
.into()
|
||||
|
@ -2485,7 +2485,6 @@ fn parse_fn(
|
||||
#[cfg(not(feature = "no_closure"))]
|
||||
externals,
|
||||
body,
|
||||
pos: settings.pos,
|
||||
lib: None,
|
||||
})
|
||||
}
|
||||
@ -2655,7 +2654,6 @@ fn parse_anon_fn(
|
||||
#[cfg(not(feature = "no_closure"))]
|
||||
externals: Default::default(),
|
||||
body,
|
||||
pos: settings.pos,
|
||||
lib: None,
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user