| ... | @@ -62,6 +62,8 @@ pub const Node = extern union { | ... | @@ -62,6 +62,8 @@ pub const Node = extern union { |
| 62 | var_decl, | 62 | var_decl, |
| 63 | /// const name = struct { init } | 63 | /// const name = struct { init } |
| 64 | static_local_var, | 64 | static_local_var, |
| | 65 | /// var name = init.* |
| | 66 | mut_str, |
| 65 | func, | 67 | func, |
| 66 | warning, | 68 | warning, |
| 67 | @"struct", | 69 | @"struct", |
| ... | @@ -361,7 +363,7 @@ pub const Node = extern union { | ... | @@ -361,7 +363,7 @@ pub const Node = extern union { |
| 361 | .array_type, .null_sentinel_array_type => Payload.Array, | 363 | .array_type, .null_sentinel_array_type => Payload.Array, |
| 362 | .arg_redecl, .alias, .fail_decl => Payload.ArgRedecl, | 364 | .arg_redecl, .alias, .fail_decl => Payload.ArgRedecl, |
| 363 | .log2_int_type => Payload.Log2IntType, | 365 | .log2_int_type => Payload.Log2IntType, |
| 364 | .var_simple, .pub_var_simple, .static_local_var => Payload.SimpleVarDecl, | 366 | .var_simple, .pub_var_simple, .static_local_var, .mut_str => Payload.SimpleVarDecl, |
| 365 | .enum_constant => Payload.EnumConstant, | 367 | .enum_constant => Payload.EnumConstant, |
| 366 | .array_filler => Payload.ArrayFiller, | 368 | .array_filler => Payload.ArrayFiller, |
| 367 | .pub_inline_fn => Payload.PubInlineFn, | 369 | .pub_inline_fn => Payload.PubInlineFn, |
| ... | @@ -1230,6 +1232,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex { | ... | @@ -1230,6 +1232,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex { |
| 1230 | }, | 1232 | }, |
| 1231 | }); | 1233 | }); |
| 1232 | _ = try c.addToken(.r_brace, "}"); | 1234 | _ = try c.addToken(.r_brace, "}"); |
| | 1235 | _ = try c.addToken(.semicolon, ";"); |
| 1233 | | 1236 | |
| 1234 | return c.addNode(.{ | 1237 | return c.addNode(.{ |
| 1235 | .tag = .simple_var_decl, | 1238 | .tag = .simple_var_decl, |
| ... | @@ -1240,6 +1243,29 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex { | ... | @@ -1240,6 +1243,29 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex { |
| 1240 | }, | 1243 | }, |
| 1241 | }); | 1244 | }); |
| 1242 | }, | 1245 | }, |
| | 1246 | .mut_str => { |
| | 1247 | const payload = node.castTag(.mut_str).?.data; |
| | 1248 | |
| | 1249 | const var_tok = try c.addToken(.keyword_var, "var"); |
| | 1250 | _ = try c.addIdentifier(payload.name); |
| | 1251 | _ = try c.addToken(.equal, "="); |
| | 1252 | |
| | 1253 | const deref = try c.addNode(.{ |
| | 1254 | .tag = .deref, |
| | 1255 | .data = .{ |
| | 1256 | .lhs = try renderNodeGrouped(c, payload.init), |
| | 1257 | .rhs = undefined, |
| | 1258 | }, |
| | 1259 | .main_token = try c.addToken(.period_asterisk, ".*"), |
| | 1260 | }); |
| | 1261 | _ = try c.addToken(.semicolon, ";"); |
| | 1262 | |
| | 1263 | return c.addNode(.{ |
| | 1264 | .tag = .simple_var_decl, |
| | 1265 | .main_token = var_tok, |
| | 1266 | .data = .{ .lhs = 0, .rhs = deref }, |
| | 1267 | }); |
| | 1268 | }, |
| 1243 | .var_decl => return renderVar(c, node), | 1269 | .var_decl => return renderVar(c, node), |
| 1244 | .arg_redecl, .alias => { | 1270 | .arg_redecl, .alias => { |
| 1245 | const payload = @fieldParentPtr(Payload.ArgRedecl, "base", node.ptr_otherwise).data; | 1271 | const payload = @fieldParentPtr(Payload.ArgRedecl, "base", node.ptr_otherwise).data; |
| ... | @@ -2145,7 +2171,7 @@ fn renderNullSentinelArrayType(c: *Context, len: usize, elem_type: Node) !NodeIn | ... | @@ -2145,7 +2171,7 @@ fn renderNullSentinelArrayType(c: *Context, len: usize, elem_type: Node) !NodeIn |
| 2145 | fn addSemicolonIfNeeded(c: *Context, node: Node) !void { | 2171 | fn addSemicolonIfNeeded(c: *Context, node: Node) !void { |
| 2146 | switch (node.tag()) { | 2172 | switch (node.tag()) { |
| 2147 | .warning => unreachable, | 2173 | .warning => unreachable, |
| 2148 | .var_decl, .var_simple, .arg_redecl, .alias, .block, .empty_block, .block_single, .@"switch" => {}, | 2174 | .var_decl, .var_simple, .arg_redecl, .alias, .block, .empty_block, .block_single, .@"switch", .static_local_var, .mut_str => {}, |
| 2149 | .while_true => { | 2175 | .while_true => { |
| 2150 | const payload = node.castTag(.while_true).?.data; | 2176 | const payload = node.castTag(.while_true).?.data; |
| 2151 | return addSemicolonIfNotBlock(c, payload); | 2177 | return addSemicolonIfNotBlock(c, payload); |
| ... | @@ -2240,6 +2266,7 @@ fn renderNodeGrouped(c: *Context, node: Node) !NodeIndex { | ... | @@ -2240,6 +2266,7 @@ fn renderNodeGrouped(c: *Context, node: Node) !NodeIndex { |
| 2240 | .offset_of, | 2266 | .offset_of, |
| 2241 | .shuffle, | 2267 | .shuffle, |
| 2242 | .static_local_var, | 2268 | .static_local_var, |
| | 2269 | .mut_str, |
| 2243 | => { | 2270 | => { |
| 2244 | // no grouping needed | 2271 | // no grouping needed |
| 2245 | return renderNode(c, node); | 2272 | return renderNode(c, node); |