Skip to main content

factorio_ir/
statement.rs

1use crate::{expression::Expression, function::Function, structure::Struct, r#type::Type};
2
3#[derive(Debug, Clone, PartialEq)]
4pub enum Statement {
5    FunctionDecl(Function),
6    StructDecl(Struct),
7    VariableDecl {
8        name: String,
9        ty: Type,
10        source_type: Option<String>,
11        value: Expression,
12    },
13    Assignment {
14        target: Expression,
15        value: Expression,
16    },
17    Conditional {
18        condition: Expression,
19        then_block: Vec<Self>,
20        else_block: Vec<Self>,
21    },
22    Return(Option<Expression>),
23    Expr(Expression),
24    /// `for _, VAR in pairs(ITER) do BODY end` in Lua.
25    ForIn {
26        var: String,
27        iter: Expression,
28        body: Vec<Self>,
29    },
30    /// `goto __continue_N` in Lua (the label `::__continue_N::` is emitted by the enclosing `ForIn`).
31    Continue,
32}