air_script_core/
constant.rs

1use super::Identifier;
2
3// CONSTANTS
4// ================================================================================================
5
6/// Stores a constant's name and value. There are three types of constants:
7/// - Scalar: 123
8/// - Vector: \[1, 2, 3\]
9/// - Matrix: \[\[1, 2, 3\], \[4, 5, 6\]\]
10#[derive(Debug, Clone, PartialEq, Eq)]
11pub struct Constant {
12    name: Identifier,
13    value: ConstantType,
14}
15
16impl Constant {
17    /// Returns a new instance of a [Constant]
18    pub fn new(name: Identifier, value: ConstantType) -> Self {
19        Self { name, value }
20    }
21
22    /// Returns the name of the [Constant]
23    pub fn name(&self) -> &Identifier {
24        &self.name
25    }
26
27    /// Returns the value of the [Constant]
28    pub fn value(&self) -> &ConstantType {
29        &self.value
30    }
31}
32
33/// Type of constant. Constants can be of 3 types:
34/// - Scalar: 123
35/// - Vector: \[1, 2, 3\]
36/// - Matrix: \[\[1, 2, 3\], \[4, 5, 6\]\]
37#[derive(Debug, Clone, PartialEq, Eq)]
38pub enum ConstantType {
39    Scalar(u64),
40    Vector(Vec<u64>),
41    Matrix(Vec<Vec<u64>>),
42}