| ... | ... | @@ -63,13 +63,20 @@ const String = extern struct { |
| 63 | 63 | .start = 0, |
| 64 | 64 | .len = 0, |
| 65 | 65 | }; |
| 66 | |
| 67 | fn concat(lhs: String, rhs: String) String { |
| 68 | assert(lhs.start + lhs.len == rhs.start); |
| 69 | return .{ |
| 70 | .start = lhs.start, |
| 71 | .len = lhs.len + rhs.len, |
| 72 | }; |
| 73 | } |
| 66 | 74 | }; |
| 67 | 75 | |
| 68 | 76 | /// Per-declaration data. |
| 69 | 77 | pub const AvBlock = struct { |
| 70 | 78 | fwd_decl: String = .empty, |
| 71 | 79 | code: String = .empty, |
| 72 | | code_header: String = .empty, |
| 73 | 80 | /// Each `Decl` stores a set of used `CType`s. In `flush()`, we iterate |
| 74 | 81 | /// over each `Decl` and generate the definition for each used `CType` once. |
| 75 | 82 | ctype_pool: codegen.CType.Pool = .empty, |
| ... | ... | @@ -205,9 +212,10 @@ pub fn updateFunc( |
| 205 | 212 | .ctype_pool = mir.c.ctype_pool.move(), |
| 206 | 213 | .lazy_fns = mir.c.lazy_fns.move(), |
| 207 | 214 | }; |
| 208 | | gop.value_ptr.code = try self.addString(mir.c.code); |
| 209 | 215 | gop.value_ptr.fwd_decl = try self.addString(mir.c.fwd_decl); |
| 210 | | gop.value_ptr.code_header = try self.addString(mir.c.code_header); |
| 216 | const code_header = try self.addString(mir.c.code_header); |
| 217 | const code = try self.addString(mir.c.code); |
| 218 | gop.value_ptr.code = code_header.concat(code); |
| 211 | 219 | try self.addUavsFromCodegen(&mir.c.uavs); |
| 212 | 220 | } |
| 213 | 221 | |