Add using literal loading
Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
parent
8c02dbd672
commit
05c095ccfe
7 changed files with 162 additions and 1 deletions
|
|
@ -2,6 +2,8 @@ use std::collections::BTreeMap;
|
|||
|
||||
use crate::ast::TemplateAstExpr;
|
||||
use crate::input::NomoInput;
|
||||
use crate::parser::TemplateToken;
|
||||
use crate::value::NomoValue;
|
||||
|
||||
pub struct EmitMachine {
|
||||
current_index: usize,
|
||||
|
|
@ -88,6 +90,11 @@ pub enum Instruction {
|
|||
value_ident: NomoInput,
|
||||
value_slot: VariableSlot,
|
||||
},
|
||||
LoadLiteralToSlot {
|
||||
source: TemplateToken,
|
||||
value: NomoValue,
|
||||
slot: VariableSlot,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
@ -421,6 +428,13 @@ fn emit_expr_load(
|
|||
slot: emit_slot,
|
||||
});
|
||||
}
|
||||
TemplateAstExpr::Literal { source, value } => {
|
||||
eval.push(Instruction::LoadLiteralToSlot {
|
||||
source: source.clone(),
|
||||
value: value.clone(),
|
||||
slot: emit_slot,
|
||||
});
|
||||
}
|
||||
TemplateAstExpr::Invalid { .. } => eval.push(Instruction::Abort),
|
||||
TemplateAstExpr::StaticContent { .. } | TemplateAstExpr::Interpolation { .. } => {
|
||||
unreachable!("Invalid AST here")
|
||||
|
|
@ -433,7 +447,6 @@ fn emit_expr_load(
|
|||
TemplateAstExpr::For { .. } => todo!(),
|
||||
TemplateAstExpr::ForElse => todo!(),
|
||||
TemplateAstExpr::Operation { .. } => todo!(),
|
||||
TemplateAstExpr::Literal { .. } => todo!(),
|
||||
|
||||
TemplateAstExpr::IfConditional { .. } => todo!(),
|
||||
TemplateAstExpr::ConditionalContent { .. } => todo!(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue