Update WIP with jump table for words and conditions

This commit is contained in:
Dominic Grimm 2023-04-02 12:39:35 +02:00
parent df73353bc6
commit 00bab636db
No known key found for this signature in database
GPG key ID: 12EFFCAEA9E620BF
10 changed files with 234 additions and 116 deletions

View file

@ -166,14 +166,14 @@ impl Compiler {
.collect::<Result<Vec<_>>>()?
.into_iter()
.flatten()
.collect(),
.collect::<Vec<_>>(),
c.else_instructions
.iter()
.map(|ins| ins.compile(self))
.collect::<Result<Vec<_>>>()?
.into_iter()
.flatten()
.collect(),
.collect::<Vec<_>>(),
),
})
})

View file

@ -1228,10 +1228,7 @@ impl compiler::Compilable<compiler::Compiler, hence::parser::ast::Body> for Inst
if w.times_used > 1 {
Ok(vec![hence::parser::ast::Node::MacroCall {
name: "call_stack_jump".to_string(),
args: vec![
hence::arg::Arg::Variable(format!("words_{}", w.id)),
hence::arg::Arg::Variable("OFFSET".to_string()),
],
args: vec![hence::arg::Arg::Variable(format!("words_{}", w.id))],
}])
} else {
Ok(w.instructions
@ -1252,10 +1249,7 @@ impl compiler::Compilable<compiler::Compiler, hence::parser::ast::Body> for Inst
Some(cond) => Ok(vec![if cond.only_if() {
hence::parser::ast::Node::MacroCall {
name: "call_stack_jump_cond_if".to_string(),
args: vec![
hence::arg::Arg::Variable(format!("conditions_if_{}", x)),
hence::arg::Arg::Variable("OFFSET".to_string()),
],
args: vec![hence::arg::Arg::Variable(format!("conditions_if_{}", x))],
}
} else {
hence::parser::ast::Node::MacroCall {
@ -1263,7 +1257,6 @@ impl compiler::Compilable<compiler::Compiler, hence::parser::ast::Body> for Inst
args: vec![
hence::arg::Arg::Variable(format!("conditions_if_{}", x)),
hence::arg::Arg::Variable(format!("conditions_else_{}", x)),
hence::arg::Arg::Variable("OFFSET".to_string()),
],
}
}]),