Add Var Unpack

This commit is contained in:
Krzosa Karol
2022-06-16 08:56:31 +02:00
parent 185fd8975c
commit 4f0d16e632
4 changed files with 33 additions and 2 deletions

14
ast.cpp
View File

@@ -26,6 +26,7 @@ enum Ast_Kind: U32{
AST_LENGTH_OF,
AST_ALIGN_OF,
AST_VAR_UNPACK,
AST_BREAK,
AST_COMPOUND,
AST_TYPE,
@@ -102,6 +103,11 @@ struct Ast_Call: Ast_Expr{
Array<Ast_Call_Item *> exprs;
};
struct Ast_Var_Unpack: Ast_Expr{
Array<Ast_Decl *> vars;
Ast_Expr *expr;
};
struct Ast_Unary: Ast_Expr{
Token_Kind op;
Ast_Expr *expr;
@@ -554,6 +560,14 @@ ast_alignof(Token *pos, Ast_Expr *expr){
return result;
}
function Ast_Var_Unpack *
ast_var_unpack(Token *pos, Array<Ast_Decl *> vars, Ast_Expr *expr){
AST_NEW(Var_Unpack, VAR_UNPACK, pos, AST_STMT);
result->vars = vars.tight_copy(pctx->perm);
result->expr = expr;
return result;
}
//-----------------------------------------------------------------------------
// Value
//-----------------------------------------------------------------------------