AST_INT, AST_STR to AST_VALUE

This commit is contained in:
Krzosa Karol
2022-06-02 22:37:42 +02:00
parent 173ef843df
commit a416007bba
6 changed files with 260 additions and 238 deletions

View File

@@ -83,8 +83,7 @@ enum Ast_Kind: U32{
AST_PACKAGE,
AST_STR,
AST_INT,
AST_VALUE,
AST_CAST,
AST_IDENT,
AST_INDEX,
@@ -116,9 +115,9 @@ enum{
AST_STMT = 2,
AST_BINDING = 4,
AST_AGGREGATE = 8,
AST_ATOM = 16,
AST_AGGREGATE_CHILD = 32,
AST_ITEM_INCLUDED = 64,
AST_AGGREGATE_CHILD = 16,
AST_ITEM_INCLUDED = 32,
AST_ATOM = 64,
};
struct Ast{
@@ -140,6 +139,7 @@ union{ \
F64 f64_val; \
F32 f32_val; \
S64 int_val; \
U64 uint_val; \
Intern_String intern_val; \
Ast_Resolved_Type *type_val; \
};
@@ -282,21 +282,23 @@ struct Ast_Package:Ast{
function Ast_Atom *
ast_str(Token *pos, Intern_String string){
AST_NEW(Atom, STR, pos, AST_ATOM | AST_EXPR);
AST_NEW(Atom, VALUE, pos, AST_EXPR | AST_ATOM);
result->type = type_string; // @todo untyped
result->intern_val = string;
return result;
}
function Ast_Atom *
ast_ident(Token *pos, Intern_String string){
AST_NEW(Atom, IDENT, pos, AST_ATOM | AST_EXPR);
AST_NEW(Atom, IDENT, pos, AST_EXPR | AST_ATOM);
result->intern_val = string;
return result;
}
function Ast_Atom *
ast_int(Token *pos, S64 integer){
AST_NEW(Atom, INT, pos, AST_ATOM | AST_EXPR);
AST_NEW(Atom, VALUE, pos, AST_EXPR | AST_ATOM);
result->type = type_int; // @todo untyped
result->int_val = integer;
return result;
}