diff options
author | dec05eba <dec05eba@protonmail.com> | 2019-04-24 21:22:53 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-25 14:36:46 +0200 |
commit | 7f524c427597cc998f243769b0e22e4f450c55cf (patch) | |
tree | 0dba782c2214d1ce5309ba71cfd3dddaee4a52a1 /src/parser.c | |
parent | 328a9c8310e8bab250b04e9e001ab0d890d33074 (diff) |
Progressing on bytecode (to c), fix ssa resolving multiple times
Diffstat (limited to 'src/parser.c')
-rw-r--r-- | src/parser.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/parser.c b/src/parser.c index 8e122fd..f05b31d 100644 --- a/src/parser.c +++ b/src/parser.c @@ -598,17 +598,13 @@ int parser_parse_buffer(Parser *self, BufferView code_buffer, BufferView buffer_ } int parser_parse_file(Parser *self, BufferView filepath) { - int result; - char *file_data; - usize file_size; - + Buffer file_content; + return_if_error(buffer_init(&file_content, self->allocator)); assert(!self->started && "Parser can't be reused. Create a new parser."); self->started = bool_true; assert(filepath.size > 0 && filepath.data[filepath.size] == '\0'); - result = read_whole_file(filepath.data, &file_data, &file_size); - if(result != 0) return result; - result = parser_parse_buffer(self, create_buffer_view(file_data, file_size), filepath); - return result; + return_if_error(read_whole_file(filepath.data, &file_content)); + return parser_parse_buffer(self, create_buffer_view(file_content.data, file_content.size), filepath); } static CHECK_RESULT int file_path_join(BufferView directory, BufferView file, char **result_path) { |