Cleanup, There is no decl anymore, Ast_Named
This commit is contained in:
@@ -28,7 +28,7 @@ struct Operand{
|
||||
};
|
||||
};
|
||||
|
||||
global Ast_Decl empty_decl = {};
|
||||
global Ast_Named empty_decl = {};
|
||||
|
||||
function void
|
||||
sym_insert(Sym *sym){
|
||||
@@ -202,12 +202,12 @@ eval_stmt(Ast *ast, Ast_Resolved_Type *ret){
|
||||
Ast_End();
|
||||
}
|
||||
|
||||
Ast_Begin(AST_VAR, Ast_Decl){
|
||||
Ast_Begin(AST_VAR, Ast_Var){
|
||||
eval_decl(node);
|
||||
Ast_End();
|
||||
}
|
||||
|
||||
Ast_Begin(AST_CONST, Ast_Decl){
|
||||
Ast_Begin(AST_CONST, Ast_Const){
|
||||
eval_decl(node);
|
||||
Ast_End();
|
||||
}
|
||||
@@ -226,8 +226,8 @@ eval_stmt(Ast *ast, Ast_Resolved_Type *ret){
|
||||
|
||||
Ast_Begin(AST_IF, Ast_If){
|
||||
For(node->ifs){
|
||||
if(it[0]->expr) eval_expr(it[0]->expr);
|
||||
if(it[0]->init) eval_stmt(it[0]->init, ret);
|
||||
if(it[0]->expr) eval_expr(it[0]->expr);
|
||||
S64 scope_index = scope_push();
|
||||
For_It(it[0]->block->stmts, jt){
|
||||
eval_stmt(jt[0], ret);
|
||||
@@ -454,9 +454,9 @@ eval_decl(Ast *ast){
|
||||
Ast_End();
|
||||
}
|
||||
|
||||
Ast_Begin(AST_VAR, Ast_Decl){
|
||||
Ast_Resolved_Type *type = eval_typespec(node->var.typespec);
|
||||
Operand expr = node->var.expr ? eval_expr(node->var.expr, type) : Operand{};
|
||||
Ast_Begin(AST_VAR, Ast_Var){
|
||||
Ast_Resolved_Type *type = eval_typespec(node->typespec);
|
||||
Operand expr = node->expr ? eval_expr(node->expr, type) : Operand{};
|
||||
Ast_Resolved_Type *resolved_type = resolve_type_pair(node->pos, type, expr.type);
|
||||
|
||||
Sym *sym = sym_new(SYM_Var, node->name, resolved_type, node);
|
||||
@@ -464,13 +464,11 @@ eval_decl(Ast *ast){
|
||||
Ast_End();
|
||||
}
|
||||
|
||||
Ast_Begin(AST_CONST, Ast_Decl){
|
||||
Ast_Resolved_Type *type = eval_typespec(node->var.typespec);
|
||||
if(type && type->kind == TYPE_Pointer) parsing_error(node->pos, "Const cant be a pointer");
|
||||
Operand expr = eval_expr(node->var.expr);
|
||||
Ast_Begin(AST_CONST, Ast_Const){
|
||||
Operand expr = eval_expr(node->expr);
|
||||
if(!expr.type) parsing_error(node->pos, "Constant value without expression");
|
||||
if(!expr.is_const) parsing_error(node->pos, "Value of constant variable is not a constant expression");
|
||||
Ast_Resolved_Type *resolved_type = resolve_type_pair(node->pos, type, expr.type);
|
||||
Ast_Resolved_Type *resolved_type = expr.type;
|
||||
|
||||
Sym *sym = sym_new(SYM_Const, node->name, resolved_type, node);
|
||||
if(resolved_type == type_int) sym->int_val = expr.int_val;
|
||||
|
||||
Reference in New Issue
Block a user