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/parser.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/parser.c') diff --git a/src/parser.c b/src/parser.c index 7d991a2..fdf34ce 100644 --- a/src/parser.c +++ b/src/parser.c @@ -62,7 +62,7 @@ int parser_init(Parser *self, amal_compiler *compiler, ArenaAllocator *allocator return_if_error(structdecl_init(&self->struct_decl, &compiler->root_scope, allocator)); self->struct_decl.body.parser = self; lhsexpr_init(&self->file_decl, bool_true, bool_true, bool_true, create_buffer_view_null()); - return_if_error(ast_create(self->allocator, &self->struct_decl, AST_STRUCT_DECL, &nullable_raw(self->file_decl.rhs_expr))); + return_if_error(ast_create(self->allocator, &self->struct_decl, AST_STRUCT_DECL, &self->file_decl.rhs_expr)); self->current_scope = &self->struct_decl.body; self->has_func_parent = bool_false; am_memset(&self->bytecode, 0, sizeof(self->bytecode)); @@ -667,21 +667,21 @@ Ast* parser_parse_body(Parser *self) { func_decl = parser_parse_closure(self); if(func_decl) { - throw_if_error(ast_create(self->allocator, func_decl, AST_FUNCTION_DECL, &nullable_raw(lhs_expr->rhs_expr))); + throw_if_error(ast_create(self->allocator, func_decl, AST_FUNCTION_DECL, &lhs_expr->rhs_expr)); return result; } struct_decl = parser_parse_struct_decl(self); if(struct_decl) { - throw_if_error(ast_create(self->allocator, struct_decl, AST_STRUCT_DECL, &nullable_raw(lhs_expr->rhs_expr))); + throw_if_error(ast_create(self->allocator, struct_decl, AST_STRUCT_DECL, &lhs_expr->rhs_expr)); return result; } import = parser_parse_import(self); if(import) { parser_queue_file(self, import->path, &import->file_scope); - throw_if_error(ast_create(self->allocator, import, AST_IMPORT, &nullable_raw(lhs_expr->rhs_expr))); - parser_parse_body_semicolon(self, nullable_unwrap(lhs_expr->rhs_expr)); + throw_if_error(ast_create(self->allocator, import, AST_IMPORT, &lhs_expr->rhs_expr)); + parser_parse_body_semicolon(self, lhs_expr->rhs_expr); return result; } } else { @@ -696,7 +696,7 @@ Ast* parser_parse_body(Parser *self) { self->error_context = ERROR_CONTEXT_NONE; /* Variable declaration with lhs and rhs */ if(lhs_expr) { - nullable_assign(lhs_expr->rhs_expr, rhs_expr); + lhs_expr->rhs_expr = rhs_expr; } else { bool match; throw_if_error(tokenizer_consume_if(&self->tokenizer, TOK_EQUALS, &match)); -- cgit v1.2.3