| ... | ... | @@ -209,7 +209,7 @@ const Scope = struct { |
| 209 | 209 | |
| 210 | 210 | pub const Context = struct { |
| 211 | 211 | tree: *ast.Tree, |
| 212 | | source_buffer: *std.Buffer, |
| 212 | source_buffer: *std.ArrayList(u8), |
| 213 | 213 | err: Error, |
| 214 | 214 | source_manager: *ZigClangSourceManager, |
| 215 | 215 | decl_table: DeclTable, |
| ... | ... | @@ -296,7 +296,8 @@ pub fn translate( |
| 296 | 296 | .eof_token = undefined, |
| 297 | 297 | }; |
| 298 | 298 | |
| 299 | | var source_buffer = try std.Buffer.initSize(arena, 0); |
| 299 | var source_buffer = std.ArrayList(u8).init(arena); |
| 300 | errdefer source_buffer.deinit(); |
| 300 | 301 | |
| 301 | 302 | var context = Context{ |
| 302 | 303 | .tree = tree, |
| ... | ... | @@ -4309,7 +4310,7 @@ fn makeRestorePoint(c: *Context) RestorePoint { |
| 4309 | 4310 | return RestorePoint{ |
| 4310 | 4311 | .c = c, |
| 4311 | 4312 | .token_index = c.tree.tokens.len, |
| 4312 | | .src_buf_index = c.source_buffer.len(), |
| 4313 | .src_buf_index = c.source_buffer.len, |
| 4313 | 4314 | }; |
| 4314 | 4315 | } |
| 4315 | 4316 | |
| ... | ... | @@ -4771,11 +4772,11 @@ fn appendToken(c: *Context, token_id: Token.Id, bytes: []const u8) !ast.TokenInd |
| 4771 | 4772 | |
| 4772 | 4773 | fn appendTokenFmt(c: *Context, token_id: Token.Id, comptime format: []const u8, args: var) !ast.TokenIndex { |
| 4773 | 4774 | assert(token_id != .Invalid); |
| 4774 | | const start_index = c.source_buffer.len(); |
| 4775 | const start_index = c.source_buffer.len; |
| 4775 | 4776 | errdefer c.source_buffer.shrink(start_index); |
| 4776 | 4777 | |
| 4777 | 4778 | try c.source_buffer.outStream().print(format, args); |
| 4778 | | const end_index = c.source_buffer.len(); |
| 4779 | const end_index = c.source_buffer.len; |
| 4779 | 4780 | const token_index = c.tree.tokens.len; |
| 4780 | 4781 | const new_token = try c.tree.tokens.addOne(); |
| 4781 | 4782 | errdefer c.tree.tokens.shrink(token_index); |
| ... | ... | @@ -4785,7 +4786,7 @@ fn appendTokenFmt(c: *Context, token_id: Token.Id, comptime format: []const u8, |
| 4785 | 4786 | .start = start_index, |
| 4786 | 4787 | .end = end_index, |
| 4787 | 4788 | }; |
| 4788 | | try c.source_buffer.appendByte(' '); |
| 4789 | try c.source_buffer.append(' '); |
| 4789 | 4790 | |
| 4790 | 4791 | return token_index; |
| 4791 | 4792 | } |