Add conditional value emitting
Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
parent
662e574588
commit
9940881e46
10 changed files with 82 additions and 11 deletions
|
|
@ -57,6 +57,7 @@ pub enum Instruction {
|
|||
LoadFromContextToSlot {
|
||||
name: NomoInput,
|
||||
slot: VariableSlot,
|
||||
fail_on_not_found: bool,
|
||||
},
|
||||
EmitFromSlot {
|
||||
slot: VariableSlot,
|
||||
|
|
@ -440,6 +441,14 @@ fn emit_expr_load(
|
|||
eval.push(Instruction::LoadFromContextToSlot {
|
||||
name: template_token.source().clone(),
|
||||
slot: emit_slot,
|
||||
fail_on_not_found: true,
|
||||
});
|
||||
}
|
||||
TemplateAstExpr::ConditionalAccess(template_token) => {
|
||||
eval.push(Instruction::LoadFromContextToSlot {
|
||||
name: template_token.source().clone(),
|
||||
slot: emit_slot,
|
||||
fail_on_not_found: false,
|
||||
});
|
||||
}
|
||||
TemplateAstExpr::Literal { source, value } => {
|
||||
|
|
@ -476,7 +485,6 @@ fn emit_expr_load(
|
|||
slot: emit_slot,
|
||||
});
|
||||
}
|
||||
TemplateAstExpr::ConditionalAccess { .. } => todo!(),
|
||||
TemplateAstExpr::Invalid { .. } => eval.push(Instruction::Abort),
|
||||
TemplateAstExpr::StaticContent { .. } | TemplateAstExpr::Interpolation { .. } => {
|
||||
unreachable!("Invalid AST here")
|
||||
|
|
@ -523,6 +531,7 @@ mod tests {
|
|||
slot: VariableSlot {
|
||||
index: 0,
|
||||
},
|
||||
fail_on_not_found: true,
|
||||
},
|
||||
EmitFromSlot {
|
||||
slot: VariableSlot {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ VMInstructions {
|
|||
slot: VariableSlot {
|
||||
index: 1,
|
||||
},
|
||||
fail_on_not_found: true,
|
||||
},
|
||||
JumpIfNotTrue {
|
||||
emit_slot: VariableSlot {
|
||||
|
|
@ -51,6 +52,7 @@ VMInstructions {
|
|||
slot: VariableSlot {
|
||||
index: 3,
|
||||
},
|
||||
fail_on_not_found: true,
|
||||
},
|
||||
JumpIfNotTrue {
|
||||
emit_slot: VariableSlot {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue