runmat_ignition/
functions.rs

1use crate::instr::Instr;
2use runmat_builtins::Value;
3use runmat_hir::{HirStmt, VarId};
4use serde::{Deserialize, Serialize};
5use std::collections::HashMap;
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct UserFunction {
9    pub name: String,
10    pub params: Vec<VarId>,
11    pub outputs: Vec<VarId>,
12    pub body: Vec<HirStmt>,
13    pub local_var_count: usize,
14    pub has_varargin: bool,
15    pub has_varargout: bool,
16}
17
18/// Represents a call frame in the call stack
19#[derive(Debug, Clone)]
20pub struct CallFrame {
21    pub function_name: String,
22    pub return_address: usize,
23    pub locals_start: usize,
24    pub locals_count: usize,
25    pub expected_outputs: usize,
26}
27
28/// Runtime execution context with call stack
29#[derive(Debug)]
30pub struct ExecutionContext {
31    pub call_stack: Vec<CallFrame>,
32    pub locals: Vec<Value>,
33    pub instruction_pointer: usize,
34    pub functions: std::collections::HashMap<String, UserFunction>,
35}
36
37#[derive(Debug, Clone, Serialize, Deserialize)]
38pub struct Bytecode {
39    pub instructions: Vec<Instr>,
40    pub var_count: usize,
41    pub functions: HashMap<String, UserFunction>,
42}