Add internals feature.

This commit is contained in:
Stephen Chung
2020-06-23 10:43:24 +08:00
parent a9b168ba99
commit 54c5c139f9
7 changed files with 46 additions and 7 deletions

View File

@@ -65,20 +65,34 @@ impl AST {
}
/// Get the statements.
#[cfg(not(feature = "internals"))]
pub(crate) fn statements(&self) -> &Vec<Stmt> {
&self.0
}
/// Get the statements.
#[cfg(feature = "internals")]
pub fn statements(&self) -> &Vec<Stmt> {
&self.0
}
/// Get a mutable reference to the statements.
pub(crate) fn statements_mut(&mut self) -> &mut Vec<Stmt> {
&mut self.0
}
/// Get the script-defined functions.
/// Get the internal `Module` containing all script-defined functions.
#[cfg(not(feature = "internals"))]
pub(crate) fn lib(&self) -> &Module {
&self.1
}
/// Get the internal `Module` containing all script-defined functions.
#[cfg(feature = "internals")]
pub fn lib(&self) -> &Module {
&self.1
}
/// Merge two `AST` into one. Both `AST`'s are untouched and a new, merged, version
/// is returned.
///