Cleaning up parsing / typechecking of calls slightly, adding any vargs

This commit is contained in:
Krzosa Karol
2022-06-20 09:28:38 +02:00
parent aa5741203f
commit 4e288dcfab
7 changed files with 84 additions and 67 deletions

44
ast.cpp
View File

@@ -52,17 +52,17 @@ enum Ast_Kind: U32{
typedef U32 Ast_Flag;
enum{
AST_EXPR = bit_flag(1),
AST_STMT = bit_flag(2),
AST_STRICT = bit_flag(3),
AST_AGGREGATE = bit_flag(4),
AST_EXPR = bit_flag(1),
AST_STMT = bit_flag(2),
AST_STRICT = bit_flag(3),
AST_AGGREGATE = bit_flag(4),
AST_AGGREGATE_CHILD = bit_flag(5),
AST_ITEM_INCLUDED = bit_flag(6),
AST_ATOM = bit_flag(7),
AST_FOREIGN = bit_flag(8),
AST_DECL = bit_flag(9),
AST_GLOBAL = bit_flag(10),
AST_FLAG = bit_flag(11),
AST_ANY_VARGS = bit_flag(6),
AST_ATOM = bit_flag(7),
AST_FOREIGN = bit_flag(8),
AST_DECL = bit_flag(9),
AST_GLOBAL = bit_flag(10),
AST_FLAG = bit_flag(11),
};
struct Ast{
@@ -88,13 +88,23 @@ struct Ast_Atom: Ast_Expr{
INLINE_VALUE_FIELDS;
};
struct Ast_Call_Item: Ast_Expr{
Ast_Atom *name; // for calls only name, for compounds name | index
Ast_Expr *item;
Ast_Expr *index;
typedef U32 Ast_Call_Item_Flag;
enum{
CALL_INDEX = bit_flag(1),
CALL_NAME = bit_flag(2),
CALL_DOT_ANY = bit_flag(3),
CALL_INCLUDED= bit_flag(4),
};
struct Ast_Call_Item: Ast_Expr{
Ast_Call_Item_Flag call_flags;
S32 resolved_index;
Ast_Expr *item;
union {
Ast_Atom *name;
Ast_Expr *index;
};
Intern_String resolved_name;
S64 resolved_index;
};
struct Ast_Call: Ast_Expr{
@@ -270,9 +280,9 @@ struct Ast_Decl: Ast{
result->pos = ipos; \
result->di = ++pctx->unique_ids
#define new_ast(T,kind,pos,flags) (T *)_new_ast(sizeof(T), kind, pos, flags)
#define ast_new(T,kind,pos,flags) (T *)_ast_new(sizeof(T), kind, pos, flags)
function Ast *
_new_ast(SizeU size, Ast_Kind kind, Token *pos, Ast_Flag flags = 0){
_ast_new(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;