diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/bootstrap/main.src | 2 | ||||
| -rw-r--r-- | src/bootstrap/tokenizer.src | 8 | ||||
| -rw-r--r-- | src/codegen.zig | 3 |
3 files changed, 6 insertions, 7 deletions
diff --git a/src/bootstrap/main.src b/src/bootstrap/main.src index 192869b..bb840b5 100644 --- a/src/bootstrap/main.src +++ b/src/bootstrap/main.src @@ -13,7 +13,7 @@ let main = (argc: i64, argv: **i8) => i64 { println("%s", filename); - let alloc = arena_init(9999999999); + let alloc = arena_init(999999999); tokenizer_init(alloc, filename); tokenizer_deinit(); diff --git a/src/bootstrap/tokenizer.src b/src/bootstrap/tokenizer.src index 91b5c51..246b5cc 100644 --- a/src/bootstrap/tokenizer.src +++ b/src/bootstrap/tokenizer.src @@ -138,7 +138,7 @@ let print_tokens = (t: *tokenizer) => i64 { printf("Identifier: %s\n", cast(*i8, to.data)); }; if (to.type == TOKEN_NUMBER) { - printf("Number: %d\n", cast(i64, to.data)); + printf("Number: %d\n", *cast(*i64, to.data)); }; if (to.type == TOKEN_BOOLEAN) { printf("Boolean: %d\n", cast(i1, to.data)); @@ -309,7 +309,7 @@ let tokenizer_accept_int_type = (t: *tokenizer) => *i64 { if strlen(string) == 0 { return cast(*i64, null); }; - let x = cast(*i64, arena_alloc((*t).arena, 8)); + let x = cast(*i64, arena_alloc((*t).arena, sizeof(i64))); *x = atoi(string); return x; }; @@ -368,7 +368,6 @@ let tokenizer_next = (t: *tokenizer) => *token { tokenizer_skip_whitespace(t); if (*t).offset >= (*t).file_size { - println("FILE EXCEED"); return cast(*token, null); }; @@ -533,7 +532,7 @@ let tokenizer_next = (t: *tokenizer) => *token { let tokenizer_init = (alloc: *arena, filename: *i8) => i64 { let t = cast(*tokenizer, arena_alloc(alloc, sizeof(tokenizer))); (*t).arena = alloc; - (*t).tokens = cast(*i8, arena_alloc((*t).arena, 100)); + (*t).tokens = cast(*token, arena_alloc((*t).arena, sizeof(token) * 1000)); /* why does it not care about type here */ (*t).tokens_len = 0; (*t).offset = 0; @@ -546,7 +545,6 @@ let tokenizer_init = (alloc: *arena, filename: *i8) => i64 { while true { let tk = tokenizer_next(t); if tk == cast(*token, null) { - println("NULL TOKEN!"); break; }; add_token(t, tk); diff --git a/src/codegen.zig b/src/codegen.zig index 152572f..30ef293 100644 --- a/src/codegen.zig +++ b/src/codegen.zig @@ -248,7 +248,7 @@ pub const CodeGen = struct { for (0.., function_call_statement.arguments) |i, argument| { const arg = try self.generate_expression_value(argument, null); - const expected_type = function.node_type.TYPE.FUNCTION_TYPE.parameters[i]; + const expected_type = function.node_type.TYPE.FUNCTION_TYPE.parameters[i]; //TODO: If varargs we shouldnt do this std.debug.print("2 TYP {s}: {any} vs {any}\n", .{ function_call_statement.expression.PRIMARY_EXPRESSION.IDENTIFIER.name, expected_type.TYPE, arg.node_type.TYPE }); std.debug.assert(self.compare_types(expected_type, arg.node_type, false)); try arguments.append(arg.value); @@ -1066,6 +1066,7 @@ const Environment = struct { } fn add_variable(self: *Environment, name: []const u8, variable: *Variable) !void { + // TODO: Dont allow shadowing if value != value or type != type (across things) try self.scope_stack.getLast().variables.put(name, variable); } |