turtle/interpreter/values/
function.rs1use crate::{Environment, Expression, Symbol};
2use std::cmp::Ordering;
3
4use crate::Locker;
5
6#[derive(Debug, Clone)]
7pub struct Function {
8 pub params: Vec<Symbol>,
9 pub expressions: Vec<Expression>,
10 pub collapse_input: bool,
11 pub lexical_scope: Locker<Environment>,
12}
13
14impl PartialEq for Function {
15 fn eq(&self, other: &Self) -> bool {
16 self.params == other.params
17 && self.expressions == other.expressions
18 && self.collapse_input == other.collapse_input
19 }
20}
21
22impl PartialOrd for Function {
23 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
24 if self == other {
25 Some(Ordering::Equal)
26 } else {
27 None
28 }
29 }
30}
31
32impl Function {
33 pub fn new(
34 params: Vec<Symbol>,
35 expressions: Vec<Expression>,
36 collapse_input: bool,
37 lexical_scope: Locker<Environment>,
38 ) -> Self {
39 Self {
40 params,
41 expressions,
42 collapse_input,
43 lexical_scope,
44 }
45 }
46}