aboutsummaryrefslogtreecommitdiff
path: root/src/ssa
diff options
context:
space:
mode:
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;