Add boolean constant words

This commit is contained in:
Dominic Grimm 2023-04-29 14:55:35 +02:00
parent 74dd36638f
commit ac72c73e99
Signed by: dergrimm
GPG Key ID: 61826A9FB3D04E59
1 changed files with 22 additions and 0 deletions

View File

@ -66,6 +66,9 @@ pub enum Instruction {
Mod,
AsmQuote(String),
True,
False,
Multiple {
instruction: Box<Self>,
count: usize,
@ -535,6 +538,14 @@ impl compiler::Compilable<compiler::Compiler, hence::parser::ast::Body> for Inst
name: "std_set".to_string(),
args: vec![hence::arg::Arg::Variable("MEM_ALLOC_PTR".to_string())],
},
hence::parser::ast::Node::Call {
name: "tsr".to_string(),
arg: Some(hence::arg::Arg::Variable("CORE_REG_A".to_string())),
},
hence::parser::ast::Node::Call {
name: "tls".to_string(),
arg: None,
},
]),
Instruction::Dot => Ok(vec![
hence::parser::ast::Node::MacroCall {
@ -1263,6 +1274,15 @@ impl compiler::Compilable<compiler::Compiler, hence::parser::ast::Body> for Inst
None => bail!("Condition by index not found: {}", x),
},
Instruction::True => Ok(vec![hence::parser::ast::Node::Call {
name: "push".to_string(),
arg: Some(hence::arg::Arg::Variable("TRUE".to_string())),
}]),
Instruction::False => Ok(vec![hence::parser::ast::Node::Call {
name: "push".to_string(),
arg: Some(hence::arg::Arg::Variable("FALSE".to_string())),
}]),
Instruction::Multiple { instruction, count } => {
if *count == 0 {
Ok(vec![])
@ -1536,6 +1556,8 @@ impl Instruction {
"*" => Some(Instruction::Times),
"/" => Some(Instruction::Divide),
"mod" => Some(Instruction::Mod),
"true" => Some(Instruction::True),
"false" => Some(Instruction::False),
_ => None,
}
}