aboutsummaryrefslogtreecommitdiff
path: root/src/ir
diff options
context:
space:
mode:
Diffstat (limited to 'src/ir')
-rw-r--r--src/ir/ir.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/ir/ir.c b/src/ir/ir.c
index a6ed931..f0c1ee2 100644
--- a/src/ir/ir.c
+++ b/src/ir/ir.c
@@ -559,8 +559,6 @@ static CHECK_RESULT IrRegister lhsexpr_export_generate_ir(LhsExpr *self, IrCompi
#endif
static CHECK_RESULT IrRegister lhsexpr_generate_ir(LhsExpr *self, AstResolveData *resolve_data, IrCompilerContext *context) {
- IrRegister reg;
-
if(LHS_EXPR_IS_EXTERN(self))
return lhsexpr_extern_generate_ir(self, context);
@@ -582,6 +580,7 @@ static CHECK_RESULT IrRegister lhsexpr_generate_ir(LhsExpr *self, AstResolveData
}
return rhs_reg;
} else {
+ IrRegister reg = 0;
/* TODO: Do not assign if we dont want default value */
if(resolve_data->type.type == RESOLVED_TYPE_LHS_EXPR) {
IrNumber number;
@@ -590,16 +589,16 @@ static CHECK_RESULT IrRegister lhsexpr_generate_ir(LhsExpr *self, AstResolveData
else if(resolve_data->type.value.lhs_expr == (LhsExpr*)context->compiler->default_types.f64)
number = create_ir_float(0.0);
else
- assert(bool_false && "TODO: assign default value to reg depending on LhsExpr type");
+ check(bool_false && "TODO: assign default value to reg depending on LhsExpr type");
throw_if_error(ir_get_unique_reg(context->ir, &reg));
throw_if_error(ir_ins_assign_inter(context->ir, reg, number));
} else if(resolve_data->type.type == RESOLVED_TYPE_FUNC_SIG) {
- assert(bool_false && "TODO: Implement this when variable can be null. Then the function pointer should be null");
+ check(bool_false && "TODO: Implement this when variable can be null. Then the function pointer should be null");
} else {
- assert(bool_false);
+ check(bool_false);
}
+ return reg;
}
- return reg;
}
static CHECK_RESULT IrRegister assignmentexpr_generate_ir(AssignmentExpr *self, IrCompilerContext *context) {
@@ -682,6 +681,7 @@ static CHECK_RESULT IrRegister funccall_generate_ir(FunctionCall *self, IrCompil
FunctionParameter *func_param_expr;
int import_index = context->import_index;
+ func_sig = NULL;
func_lhs_expr = NULL;
func_param_expr = NULL;
context->import_index = 0;
@@ -689,7 +689,8 @@ static CHECK_RESULT IrRegister funccall_generate_ir(FunctionCall *self, IrCompil
switch(self->func.resolved_var.type) {
case NAMED_OBJECT_NONE:
- assert(bool_false);
+ check(bool_false);
+ func_sig = NULL;
break;
case NAMED_OBJECT_LHS_EXPR: {
func_lhs_expr = self->func.resolved_var.value.lhs_expr;
@@ -697,22 +698,23 @@ static CHECK_RESULT IrRegister funccall_generate_ir(FunctionCall *self, IrCompil
func_sig = func_lhs_expr->type.value.signature;
} else if(func_lhs_expr->type.type == VARIABLE_TYPE_VARIABLE) {
AstResolveData *resolve_data = func_lhs_expr->type.value.variable->resolved_var.resolve_data;
- assert(resolve_data->type.type == RESOLVED_TYPE_FUNC_SIG);
+ check(resolve_data->type.type == RESOLVED_TYPE_FUNC_SIG);
func_sig = resolve_data->type.value.func_sig;
} else {
- assert(func_lhs_expr->rhs_expr && func_lhs_expr->rhs_expr->resolve_data.type.type == RESOLVED_TYPE_FUNC_SIG);
+ check(func_lhs_expr->rhs_expr && func_lhs_expr->rhs_expr->resolve_data.type.type == RESOLVED_TYPE_FUNC_SIG);
func_sig = func_lhs_expr->rhs_expr->resolve_data.type.value.func_sig;
}
break;
}
case NAMED_OBJECT_FUNC_PARAM: {
func_param_expr = self->func.resolved_var.value.func_param;
- assert(func_param_expr->type.type == VARIABLE_TYPE_SIGNATURE);
+ check(func_param_expr->type.type == VARIABLE_TYPE_SIGNATURE);
func_sig = func_param_expr->type.value.signature;
break;
}
}
+ check(func_sig);
func_decl = func_sig->func_decl;
/* Push return arguments */
@@ -952,7 +954,7 @@ static CHECK_RESULT IrRegister ast_generate_ir_resolve_data(void *ast_data, AstT
resolve_data->ir_reg = 0;/*structdecl_generate_ir(ast_data, context);*/
break;
case AST_STRUCT_FIELD:
- assert(bool_false);
+ check(bool_false);
resolve_data->ir_reg = 0;/*structfield_generate_ir(ast_data, context);*/
break;
case AST_LHS: