1use core::mem;
4use string_interner::Symbol;
5use crate::language::{IntType, FloatType, InternSymbol};
6use crate::runtime::errors::ErrorKind;
7
8pub type ConstID = u16;
9pub type StringID = usize;
10
11
12#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
15pub enum Constant {
16 Integer(IntType),
17 Float([u8; mem::size_of::<FloatType>()]), String(StringID),
19 Error { error: ErrorKind, message: StringID },
20}
21
22impl From<IntType> for Constant {
23 fn from(value: IntType) -> Self { Self::Integer(value) }
24}
25
26impl From<FloatType> for Constant {
27 fn from(value: FloatType) -> Self { Self::Float(value.to_le_bytes()) }
28}
29
30impl From<InternSymbol> for Constant {
31 fn from(symbol: InternSymbol) -> Self { Self::String(symbol.to_usize()) }
32}