Encapsulate FunctionsLib to hold script-defined functions.

This commit is contained in:
Stephen Chung
2020-03-26 20:26:05 +08:00
parent 8679982b4b
commit 56df5c49c8
6 changed files with 89 additions and 65 deletions

View File

@@ -11,9 +11,7 @@ use crate::optimize::optimize_into_ast;
use crate::stdlib::{
borrow::Cow,
boxed::Box,
char,
cmp::Ordering,
fmt, format,
char, fmt, format,
iter::Peekable,
str::Chars,
str::FromStr,
@@ -175,18 +173,6 @@ pub struct FnDef {
pub pos: Position,
}
impl FnDef {
/// Function to order two FnDef records, for binary search.
pub fn compare(&self, name: &str, params_len: usize) -> Ordering {
// First order by name
match self.name.as_str().cmp(name) {
// Then by number of parameters
Ordering::Equal => self.params.len().cmp(&params_len),
order => order,
}
}
}
/// `return`/`throw` statement.
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
pub enum ReturnType {