Added Param object to Value enum

This commit is contained in:
Goren Barak 2023-11-18 08:27:30 -05:00
parent 60527bba91
commit 518ce7b3ad

View file

@ -39,13 +39,13 @@ pub struct FunDefinition<'a> {
name: &'a str, name: &'a str,
params: Vec<FunParamDef<'a>>, params: Vec<FunParamDef<'a>>,
contents: Vec<Expr<'a>>, contents: Vec<Expr<'a>>,
return_value: &'a Expr<'a>, return_value: Value<'a>,
} }
#[derive(Debug)] #[derive(Debug)]
pub struct FunParamDef<'a> { pub struct FunParamDef<'a> {
name: &'a str, name: &'a str,
number: u8, number: u64,
} }
#[derive(Debug)] #[derive(Debug)]
@ -66,15 +66,25 @@ pub struct VarReference<'a> {
pub name: &'a str, pub name: &'a str,
} }
#[derive(Debug, Copy, Clone)]
pub struct ParamReference<'a> {
pub param_number: u64,
}
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
pub enum Value<'a> { pub enum Value<'a> {
Var(VarReference<'a>), Var(VarReference<'a>),
Param(ParamReference<'a>),
Number(u64), Number(u64),
} }
impl<'a> Value<'a> { impl<'a> Value<'a> {
pub fn unwrap(&self) -> String { pub fn unwrap(&self) -> String {
match self { match self {
Value::Param(e) => {
},
Value::Number(e) => { Value::Number(e) => {
return e.to_string(); return e.to_string();
}, },