Streamline ScriptFnDef.

This commit is contained in:
Stephen Chung
2020-11-04 12:34:54 +08:00
parent f75942715d
commit c287a61b93
3 changed files with 20 additions and 9 deletions

View File

@@ -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);
}
}