From 4ca3b74621c3608de42a91730a71892d9d7c27b5 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 1 Aug 2019 20:36:51 +0200 Subject: Remove nullable... it's bad to have magic. Static analysis can do it instead --- src/ssa/ssa.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/ssa') diff --git a/src/ssa/ssa.c b/src/ssa/ssa.c index 405d8e4..707ccd0 100644 --- a/src/ssa/ssa.c +++ b/src/ssa/ssa.c @@ -342,8 +342,8 @@ static CHECK_RESULT SsaRegister lhsexpr_generate_ssa(Ast *self, SsaCompilerConte if(lhs_expr->is_extern) return lhsexpr_extern_generate_ssa(lhs_expr, context); - if(is_not_null(lhs_expr->rhs_expr)) { - Ast *rhs_expr = nullable_unwrap(lhs_expr->rhs_expr); + if(lhs_expr->rhs_expr) { + Ast *rhs_expr = lhs_expr->rhs_expr; SsaRegister rhs_reg; rhs_reg = ast_generate_ssa(rhs_expr, context); /* @@ -433,7 +433,7 @@ static CHECK_RESULT SsaRegister funccall_generate_ssa(Ast *self, SsaCompilerCont throw_if_error(ssa_ins_push(context->ssa, arg_reg)); } - assert((is_not_null(self->resolve_data.type->rhs_expr) && nullable_unwrap(self->resolve_data.type->rhs_expr)->type == AST_FUNCTION_DECL) || + assert((self->resolve_data.type->rhs_expr && self->resolve_data.type->rhs_expr->type == AST_FUNCTION_DECL) || self->resolve_data.type->type.type == VARIABLE_TYPE_SIGNATURE); if(self->resolve_data.type->is_extern) { amal_log_error("TODO: Implement extern function call (extern function %.*s was called)", func_call->func.name.size, func_call->func.name.data); @@ -442,7 +442,7 @@ static CHECK_RESULT SsaRegister funccall_generate_ssa(Ast *self, SsaCompilerCont } else { FunctionDecl *func_to_call; /* rhs wont be null here because only extern variable can't have rhs */ - func_to_call = nullable_unwrap(self->resolve_data.type->rhs_expr)->value.func_decl; + func_to_call = self->resolve_data.type->rhs_expr->value.func_decl; amal_log_debug("SSA funccall %.*s, func index ptr: %p", func_call->func.name.size, func_call->func.name.data, func_to_call); throw_if_error(ssa_ins_call(context->ssa, func_to_call, ®)); } -- cgit v1.2.3