authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2019-12-21 14:40:47+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2019-12-29 11:04:58+02:00
log3f7bab73734ce19615e131bd5ec3146ac30a9a85
tree5fe2370fe6c454552c1ee26f40c7f61d9a3008b9
parentfceda07f94c9e4181f97ecacc1bdc1b9a0b7ab16
signature Commit is signed but in an unrecognized format.

fix translate-c taking ages


2 files changed, 4 insertions(+), 0 deletions(-)

lib/std/zig/ast.zig+3
...@@ -13,6 +13,7 @@ pub const Tree = struct {...@@ -13,6 +13,7 @@ pub const Tree = struct {
13 root_node: *Node.Root,13 root_node: *Node.Root,
14 arena_allocator: std.heap.ArenaAllocator,14 arena_allocator: std.heap.ArenaAllocator,
15 errors: ErrorList,15 errors: ErrorList,
16 generated: bool = false,
1617
17 pub const TokenList = SegmentedList(Token, 64);18 pub const TokenList = SegmentedList(Token, 64);
18 pub const ErrorList = SegmentedList(Error, 0);19 pub const ErrorList = SegmentedList(Error, 0);
...@@ -58,6 +59,8 @@ pub const Tree = struct {...@@ -58,6 +59,8 @@ pub const Tree = struct {
58 .line_start = start_index,59 .line_start = start_index,
59 .line_end = self.source.len,60 .line_end = self.source.len,
60 };61 };
62 if (self.generated)
63 return loc;
61 const token_start = token.start;64 const token_start = token.start;
62 for (self.source[start_index..]) |c, i| {65 for (self.source[start_index..]) |c, i| {
63 if (i + start_index == token_start) {66 if (i + start_index == token_start) {
src-self-hosted/translate_c.zig+1
...@@ -249,6 +249,7 @@ pub fn translate(...@@ -249,6 +249,7 @@ pub fn translate(
249 .arena_allocator = tree_arena,249 .arena_allocator = tree_arena,
250 .tokens = undefined, // can't reference the allocator yet250 .tokens = undefined, // can't reference the allocator yet
251 .errors = undefined, // can't reference the allocator yet251 .errors = undefined, // can't reference the allocator yet
252 .generated = true,
252 };253 };
253 break :blk tree;254 break :blk tree;
254 };255 };