devalang_core/core/store/
function.rs1use crate::core::parser::statement::Statement;
2use std::collections::HashMap;
3
4#[derive(Debug, Clone)]
5pub struct FunctionDef {
6 pub name: String,
7 pub parameters: Vec<String>,
8 pub body: Vec<Statement>,
9}
10
11#[derive(Debug, Clone)]
12pub struct FunctionTable {
13 pub functions: HashMap<String, FunctionDef>,
14}
15
16impl FunctionTable {
17 pub fn new() -> Self {
18 FunctionTable {
19 functions: HashMap::new(),
20 }
21 }
22
23 pub fn add_function(&mut self, function: FunctionDef) {
24 self.functions.insert(function.name.clone(), function);
25 }
26
27 pub fn get_function(&self, name: &str) -> Option<&FunctionDef> {
28 self.functions.get(name)
29 }
30
31 pub fn remove_function(&mut self, name: &str) -> Option<FunctionDef> {
32 self.functions.remove(name)
33 }
34}