Basic type conversion when assigning, added + - unary

This commit is contained in:
Krzosa Karol
2022-06-03 10:48:07 +02:00
parent e2e684294e
commit 081e559520
7 changed files with 95 additions and 20 deletions

View File

@@ -76,6 +76,8 @@ gen_expr(Ast_Expr *ast){
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 if(node->type == type_f32) gen("%f", node->f32_val);
else if(is_float(node->type)) gen("%f", node->f64_val);
else invalid_codepath;
BREAK();
}
@@ -310,16 +312,16 @@ gen_ast(Ast *ast){
gen(";");
}
}
else if(sym->type == type_f64){
else if(sym->type == untyped_float){
gen("// constant F64 %s = %f;", node->name.str, sym->f64_val);
}
else if(sym->type == type_int){
else if(sym->type == untyped_int){
gen("// constant Int %s = %lld;", node->name.str, sym->int_val);
}
else if(sym->type == type_string){
else if(sym->type == untyped_string){
gen("// const String %s = LIT(\"%s\");", node->name.str, sym->intern_val.str);
}
else if(sym->type == type_bool){
else if(sym->type == untyped_bool){
gen("// const Bool %s = %d;", node->name.str, sym->bool_val);
}
else if(sym->type == type_type){