From 7f524c427597cc998f243769b0e22e4f450c55cf Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 24 Apr 2019 21:22:53 +0200 Subject: Progressing on bytecode (to c), fix ssa resolving multiple times --- include/ast.h | 4 +++- include/ssa/ssa.h | 4 +++- include/std/file.h | 3 +-- 3 files changed, 7 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/ast.h b/include/ast.h index c010538..c40be22 100644 --- a/include/ast.h +++ b/include/ast.h @@ -57,7 +57,8 @@ typedef enum { typedef enum { AST_NOT_RESOLVED, AST_RESOLVING, - AST_RESOLVED + AST_RESOLVED, + AST_SSA_RESOLVED } AstResolveStatus; typedef struct { @@ -69,6 +70,7 @@ typedef struct { AstValue value; AstType type; AstResolveData resolve_data; + SsaRegister ssa_reg; } Ast; struct Scope { diff --git a/include/ssa/ssa.h b/include/ssa/ssa.h index 32d1ba6..e1e2d01 100644 --- a/include/ssa/ssa.h +++ b/include/ssa/ssa.h @@ -44,7 +44,8 @@ typedef struct { Buffer/*instruction data*/ instructions; HashMap/**/ intermediates_map; Buffer/*SsaNumber*/ intermediates; - HashMap/**/ strings; + HashMap/**/ strings_map; + Buffer/*BufferView*/ strings; SsaIntermediateIndex intermediate_counter; SsaStringIndex string_counter; SsaRegister reg_counter; @@ -77,6 +78,7 @@ SsaNumber create_ssa_integer(i64 value); SsaNumber create_ssa_float(f64 value); SsaNumber ssa_get_intermediate(Ssa *self, SsaIntermediateIndex index); +BufferView ssa_get_string(Ssa *self, SsaStringIndex index); CHECK_RESULT int ssa_init(Ssa *self, ScopedAllocator *allocator); CHECK_RESULT int ssa_get_unique_reg(Ssa *self, SsaRegister *result); diff --git a/include/std/file.h b/include/std/file.h index c6753fd..9184053 100644 --- a/include/std/file.h +++ b/include/std/file.h @@ -32,8 +32,7 @@ CHECK_RESULT int mapped_file_init(MappedFile *self, const char *filepath, Mapped CHECK_RESULT int mapped_file_deinit(MappedFile *self); #endif -/* @data will be allocated with am_malloc, should be deallocated with am_free */ -CHECK_RESULT int read_whole_file(const char *filepath, char **data, usize *size); +CHECK_RESULT int read_whole_file(const char *filepath, Buffer *result); /* @result_path will be allocated with am_malloc, should be deallocated with am_free */ CHECK_RESULT int file_get_canonical_path(const char *filepath, char **result_path, usize *result_path_size); -- cgit v1.2.3