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

@@ -82,13 +82,11 @@ gen_expr(Ast_Expr *ast){
BREAK();
}
CASE(INT, Atom){
gen("%lld", node->int_val);
BREAK();
}
CASE(STR, Atom){
gen("LIT(\"%s\")", node->intern_val.str);
CASE(VALUE, Atom){
if(is_int(node->type)) gen("%lld", node->int_val);
else if(is_string(node->type)) gen("LIT(\"%s\")", node->intern_val.str);
else if(is_bool(node->type)) node->bool_val ? gen("true"):gen("false");
else invalid_codepath;
BREAK();
}