mirror of
https://github.com/exoticorn/curlywas.git
synced 2026-01-20 19:56:42 +01:00
add support for (void) block expression
This commit is contained in:
@@ -316,6 +316,7 @@ fn collect_locals_expr<'a>(expr: &ast::Expression, locals: &mut Vec<(String, ast
|
||||
ast::Expr::Assign { value, .. } => collect_locals_expr(value, locals),
|
||||
ast::Expr::LocalTee { value, .. } => collect_locals_expr(value, locals),
|
||||
ast::Expr::Loop { block, .. } => collect_locals_expr(block, locals),
|
||||
ast::Expr::LabelBlock { block, .. } => collect_locals_expr(block, locals),
|
||||
ast::Expr::Cast { value, .. } => collect_locals_expr(value, locals),
|
||||
ast::Expr::FuncCall { params, .. } => {
|
||||
for param in params {
|
||||
@@ -610,6 +611,13 @@ fn emit_expression<'a>(ctx: &mut FunctionContext<'a>, expr: &'a ast::Expression)
|
||||
ctx.labels.pop();
|
||||
ctx.function.instruction(&Instruction::End);
|
||||
}
|
||||
ast::Expr::LabelBlock {label, block } => {
|
||||
ctx.labels.push(label.to_string());
|
||||
ctx.function.instruction(&Instruction::Block(map_block_type(block.type_)));
|
||||
emit_expression(ctx, block);
|
||||
ctx.labels.pop();
|
||||
ctx.function.instruction(&Instruction::End);
|
||||
}
|
||||
ast::Expr::Variable(name) => {
|
||||
if let Some(index) = ctx.locals.get(name) {
|
||||
if let Some((expr, let_type)) = ctx.let_values.get(name.as_str()) {
|
||||
|
||||
Reference in New Issue
Block a user