aboutsummaryrefslogtreecommitdiff
path: root/src/ssa
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-07-16 00:27:53 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-25 14:36:46 +0200
commit85c654a102701958d3748e82ecac9c1bc4dbbcba (patch)
tree61a804a3af5ca43e7608f4c5dc6ea1e292fc8a35 /src/ssa
parentabd74f22fd0c58b30f951da9cec1d1799e9b5072 (diff)
Start on real bytecode & doc parsing
Diffstat (limited to 'src/ssa')
-rw-r--r--src/ssa/ssa.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/ssa/ssa.c b/src/ssa/ssa.c
index 91ba185..34e3e3e 100644
--- a/src/ssa/ssa.c
+++ b/src/ssa/ssa.c
@@ -16,6 +16,9 @@ do { \
throw(return_if_result); \
} while(0)
+/* Max length of a string that fits in u16 */
+#define MAX_STRING_LENGTH ((2 << 16) - 1)
+
static int compare_number(const void *a, const void *b) {
const SsaNumber *lhs;
const SsaNumber *rhs;
@@ -125,6 +128,11 @@ static CHECK_RESULT int ssa_try_add_string(Ssa *self, BufferView str, SsaStringI
/* Overflow */
if(self->string_counter + 1 < self->string_counter)
return -1;
+
+ if(str.size > MAX_STRING_LENGTH) {
+ amal_log_error("String \"%.*s\" is longer than %d\n", str.size, str.data, MAX_STRING_LENGTH);
+ return -2;
+ }
*result_index = self->string_counter;
++self->string_counter;
@@ -386,6 +394,10 @@ in any order.
*/
static CHECK_RESULT SsaRegister funcdecl_generate_ssa(FunctionDecl *self, SsaCompilerContext *context) {
/* TODO: Implement */
+ /*
+ Reset reg counter in each function, because each function has a separate register context
+ that is reset after function end
+ */
SsaRegister prev_reg_counter;
prev_reg_counter = context->ssa->reg_counter;
context->ssa->reg_counter = 0;