TritonVM / tasm-lang

Writing tasm with Rust syntax
15 stars 2 forks source link

Add support for blocks that can return values #42

Closed Sword-Smith closed 9 months ago

Sword-Smith commented 10 months ago

We want to be able to write

let a: u32 = {
    let c: u32 = 100;
    c
}

Supporting blocks that can return values would be a good way to prevent memory spilling, as the stack is cleared after the block. And we also need those expressions for a proper if/else expression implementation.

Sword-Smith commented 10 months ago

That means, we probably want to change the BlockStmt to

BlockExpr {
    pub stmts: Vec<Stmt<T>>,
    pub return_expr: Option<<Expr<T>>
}

and then use this for while loops, blocks, if/else expressions, if/else statements etc.

Sword-Smith commented 9 months ago

Closed by 4877f00f6a8020af63fdde17387dc1a853138140