Add if statements
This commit is contained in:
@@ -192,7 +192,6 @@ resolve_type_pair(Token *pos, Ast_Resolved_Type *a, Ast_Resolved_Type *b){
|
||||
function void eval_decl(Ast *ast);
|
||||
function void
|
||||
eval_stmt(Ast *ast, Ast_Resolved_Type *ret){
|
||||
|
||||
switch(ast->kind){
|
||||
Ast_Begin(AST_RETURN, Ast_Return){ // @todo: need to check if all paths return a value
|
||||
Operand op = {};
|
||||
@@ -213,6 +212,15 @@ eval_stmt(Ast *ast, Ast_Resolved_Type *ret){
|
||||
Ast_End();
|
||||
}
|
||||
|
||||
Ast_Begin(AST_IF, Ast_If){
|
||||
For(node->ifs){
|
||||
if(it[0]->expr) eval_expr(it[0]->expr);
|
||||
For_It(it[0]->block->stmts, jt){
|
||||
eval_stmt(jt[0], ret);
|
||||
}
|
||||
}
|
||||
Ast_End();
|
||||
}
|
||||
|
||||
invalid_default_case;
|
||||
}
|
||||
@@ -409,7 +417,7 @@ eval_expr(Ast_Expr *ast, Ast_Resolved_Type *expected_type){
|
||||
invalid_default_case;
|
||||
}
|
||||
}
|
||||
else parsing_error(node->pos, "Arithmetic on type [TODO] is not supported");
|
||||
else parsing_error(node->pos, "Arithmetic on type [%s] is not supported", type_names[result.type->kind]);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user