rustleaf/eval/structs/
eval_ref.rs1use crate::core::{ImportItems, ParameterKind, Value};
3
4#[derive(Debug, Clone)]
5pub struct ClassMethod {
6 pub name: String,
7 pub params: Vec<String>,
8 pub body: Value,
9 pub is_static: bool,
10}
11
12#[derive(Debug, Clone)]
13pub struct ClassDeclData {
14 pub name: String,
15 pub field_names: Vec<String>,
16 pub field_defaults: Vec<Option<Value>>,
17 pub methods: Vec<ClassMethod>,
18}
19
20#[derive(Debug, Clone, PartialEq)]
21pub struct ImportData {
22 pub module: String,
23 pub items: ImportItems,
24}
25
26#[derive(Debug, Clone)]
27pub struct MatchData {
28 pub expr: Value,
29 pub cases: Vec<EvalMatchCase>,
30}
31
32#[derive(Debug, Clone)]
33pub struct MacroData {
34 pub macro_fn: Value, pub target: Value, pub args: Vec<Value>, }
38
39#[derive(Debug, Clone)]
40pub struct FunctionData {
41 pub name: String,
42 pub params: Vec<(String, Option<Value>, ParameterKind)>,
43 pub body: Value,
44}
45
46#[derive(Debug, Clone)]
47pub struct LambdaData {
48 pub params: Vec<String>,
49 pub body: Value,
50}
51
52#[derive(Debug, Clone)]
53pub struct WithData {
54 pub resources: Vec<(String, Value)>,
55 pub body: Value,
56}
57
58#[derive(Debug, Clone, PartialEq)]
59pub enum EvalPattern {
60 Variable(String),
61 List(Vec<EvalPattern>),
62 ListRest(Vec<EvalPattern>, Option<String>),
63 Dict(Vec<EvalDictPattern>),
64}
65
66#[derive(Debug, Clone, PartialEq)]
67pub struct EvalDictPattern {
68 pub key: String,
69 pub alias: Option<String>,
70}
71
72#[derive(Debug, Clone)]
73pub struct EvalMatchCase {
74 pub pattern: EvalMatchPattern,
75 pub guard: Option<Value>,
76 pub body: Value,
77}
78
79#[derive(Debug, Clone, PartialEq)]
80pub enum EvalMatchPattern {
81 Literal(Value),
82 Variable(String),
83 Wildcard,
84}