Add built-in identifiers
This commit is contained in:
parent
edded5043d
commit
50a7a7aca1
@ -10,22 +10,42 @@ pub fn all_built_in_identifiers() -> impl Iterator<Item = BuiltInIdentifier> {
|
|||||||
|
|
||||||
static OPTION: OnceLock<Identifier> = OnceLock::new();
|
static OPTION: OnceLock<Identifier> = OnceLock::new();
|
||||||
static NONE: OnceLock<Identifier> = OnceLock::new();
|
static NONE: OnceLock<Identifier> = OnceLock::new();
|
||||||
|
static SOME: OnceLock<Identifier> = OnceLock::new();
|
||||||
|
static RESULT: OnceLock<Identifier> = OnceLock::new();
|
||||||
|
static OK: OnceLock<Identifier> = OnceLock::new();
|
||||||
|
static ERROR: OnceLock<Identifier> = OnceLock::new();
|
||||||
|
|
||||||
#[derive(Sequence, Debug)]
|
#[derive(Sequence, Debug)]
|
||||||
pub enum BuiltInIdentifier {
|
pub enum BuiltInIdentifier {
|
||||||
Option,
|
Option,
|
||||||
None,
|
None,
|
||||||
|
Some,
|
||||||
|
Result,
|
||||||
|
Ok,
|
||||||
|
Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BuiltInIdentifier {
|
impl BuiltInIdentifier {
|
||||||
pub fn get(&self) -> Identifier {
|
pub fn get(&self) -> &Identifier {
|
||||||
match self {
|
match self {
|
||||||
BuiltInIdentifier::Option => OPTION
|
BuiltInIdentifier::Option => {
|
||||||
.get_or_init(|| Identifier::from_raw_parts(Arc::new("Option".to_string())))
|
OPTION.get_or_init(|| Identifier::from_raw_parts(Arc::new("Option".to_string())))
|
||||||
.clone(),
|
}
|
||||||
BuiltInIdentifier::None => NONE
|
BuiltInIdentifier::None => {
|
||||||
.get_or_init(|| Identifier::from_raw_parts(Arc::new("None".to_string())))
|
NONE.get_or_init(|| Identifier::from_raw_parts(Arc::new("None".to_string())))
|
||||||
.clone(),
|
}
|
||||||
|
BuiltInIdentifier::Some => {
|
||||||
|
SOME.get_or_init(|| Identifier::from_raw_parts(Arc::new("Some".to_string())))
|
||||||
|
}
|
||||||
|
BuiltInIdentifier::Result => {
|
||||||
|
RESULT.get_or_init(|| Identifier::from_raw_parts(Arc::new("Result".to_string())))
|
||||||
|
}
|
||||||
|
BuiltInIdentifier::Ok => {
|
||||||
|
OK.get_or_init(|| Identifier::from_raw_parts(Arc::new("Ok".to_string())))
|
||||||
|
}
|
||||||
|
BuiltInIdentifier::Error => {
|
||||||
|
ERROR.get_or_init(|| Identifier::from_raw_parts(Arc::new("Error".to_string())))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,16 +35,16 @@ pub mod struct_instance;
|
|||||||
/// value that can be treated as any other.
|
/// value that can be treated as any other.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum Value {
|
pub enum Value {
|
||||||
|
Boolean(bool),
|
||||||
|
Enum(EnumInstance),
|
||||||
|
Float(f64),
|
||||||
|
Function(Function),
|
||||||
|
Integer(i64),
|
||||||
List(List),
|
List(List),
|
||||||
Map(Map),
|
Map(Map),
|
||||||
Function(Function),
|
|
||||||
String(String),
|
|
||||||
Float(f64),
|
|
||||||
Integer(i64),
|
|
||||||
Boolean(bool),
|
|
||||||
Range(RangeInclusive<i64>),
|
Range(RangeInclusive<i64>),
|
||||||
|
String(String),
|
||||||
Struct(StructInstance),
|
Struct(StructInstance),
|
||||||
Enum(EnumInstance),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Value {
|
impl Value {
|
||||||
|
Loading…
Reference in New Issue
Block a user