For loop iterate through arrays and slices

This commit is contained in:
Krzosa Karol
2022-06-19 22:31:59 +02:00
parent 367562f0a8
commit aa5741203f
6 changed files with 67 additions and 14 deletions

View File

@@ -163,6 +163,10 @@ struct Ast_For: Ast{
Ast_Expr *cond;
Ast_Expr *iter;
Ast_Scope *scope;
Ast_Decl *array_traversal_var;
bool is_array_traversal;
bool is_also_slice_traversal;
};
struct Ast_Lambda : Ast_Expr {
@@ -266,9 +270,9 @@ struct Ast_Decl: Ast{
result->pos = ipos; \
result->di = ++pctx->unique_ids
#define MAKE_AST(T,kind,pos,flags) (T *)ast_new(sizeof(T), kind, pos, flags)
#define new_ast(T,kind,pos,flags) (T *)_new_ast(sizeof(T), kind, pos, flags)
function Ast *
ast_new(SizeU size, Ast_Kind kind, Token *pos, Ast_Flag flags = 0){
_new_ast(SizeU size, Ast_Kind kind, Token *pos, Ast_Flag flags = 0){
Ast *result = (Ast *)exp_alloc(pctx->perm, size, AF_ZeroMemory);
result->flags = flags;
result->kind = kind;