| ... | ... | @@ -2160,19 +2160,59 @@ fn globalVarDecl( |
| 2160 | 2160 | fn comptimeDecl( |
| 2161 | 2161 | astgen: *AstGen, |
| 2162 | 2162 | gz: *GenZir, |
| 2163 | | wip_decls: *WipDecls, |
| 2163 | scope: *Scope, |
| 2164 | 2164 | node: ast.Node.Index, |
| 2165 | 2165 | ) InnerError!void { |
| 2166 | | @panic("TODO astgen comptimeDecl"); |
| 2166 | const tree = &astgen.file.tree; |
| 2167 | const node_datas = tree.nodes.items(.data); |
| 2168 | const block_expr = node_datas[node].lhs; |
| 2169 | // TODO probably we want to put these into a block and store a list of them |
| 2170 | _ = try expr(gz, scope, .none, block_expr); |
| 2167 | 2171 | } |
| 2168 | 2172 | |
| 2169 | 2173 | fn usingnamespaceDecl( |
| 2170 | 2174 | astgen: *AstGen, |
| 2171 | 2175 | gz: *GenZir, |
| 2172 | | wip_decls: *WipDecls, |
| 2176 | scope: *Scope, |
| 2173 | 2177 | node: ast.Node.Index, |
| 2174 | 2178 | ) InnerError!void { |
| 2175 | | @panic("TODO astgen usingnamespaceDecl"); |
| 2179 | const tree = &astgen.file.tree; |
| 2180 | const node_datas = tree.nodes.items(.data); |
| 2181 | |
| 2182 | const type_expr = node_datas[node].lhs; |
| 2183 | const is_pub = blk: { |
| 2184 | const main_tokens = tree.nodes.items(.main_token); |
| 2185 | const token_tags = tree.tokens.items(.tag); |
| 2186 | const main_token = main_tokens[node]; |
| 2187 | break :blk (main_token > 0 and token_tags[main_token - 1] == .keyword_pub); |
| 2188 | }; |
| 2189 | // TODO probably we want to put these into a block and store a list of them |
| 2190 | const namespace_inst = try expr(gz, scope, .{ .ty = .type_type }, type_expr); |
| 2191 | } |
| 2192 | |
| 2193 | fn testDecl( |
| 2194 | astgen: *AstGen, |
| 2195 | gz: *GenZir, |
| 2196 | scope: *Scope, |
| 2197 | node: ast.Node.Index, |
| 2198 | ) InnerError!void { |
| 2199 | const tree = &astgen.file.tree; |
| 2200 | const node_datas = tree.nodes.items(.data); |
| 2201 | const test_expr = node_datas[node].rhs; |
| 2202 | |
| 2203 | const test_name: u32 = blk: { |
| 2204 | const main_tokens = tree.nodes.items(.main_token); |
| 2205 | const token_tags = tree.tokens.items(.tag); |
| 2206 | const test_token = main_tokens[node]; |
| 2207 | const str_lit_token = test_token + 1; |
| 2208 | if (token_tags[str_lit_token] == .string_literal) { |
| 2209 | break :blk (try gz.strLitAsString(str_lit_token)).index; |
| 2210 | } |
| 2211 | break :blk 0; |
| 2212 | }; |
| 2213 | |
| 2214 | // TODO probably we want to put these into a block and store a list of them |
| 2215 | const block_inst = try expr(gz, scope, .none, test_expr); |
| 2176 | 2216 | } |
| 2177 | 2217 | |
| 2178 | 2218 | fn structDeclInner( |
| ... | ... | @@ -2289,11 +2329,15 @@ fn structDeclInner( |
| 2289 | 2329 | }, |
| 2290 | 2330 | |
| 2291 | 2331 | .@"comptime" => { |
| 2292 | | try astgen.comptimeDecl(gz, &wip_decls, member_node); |
| 2332 | try astgen.comptimeDecl(gz, scope, member_node); |
| 2293 | 2333 | continue; |
| 2294 | 2334 | }, |
| 2295 | 2335 | .@"usingnamespace" => { |
| 2296 | | try astgen.usingnamespaceDecl(gz, &wip_decls, member_node); |
| 2336 | try astgen.usingnamespaceDecl(gz, scope, member_node); |
| 2337 | continue; |
| 2338 | }, |
| 2339 | .test_decl => { |
| 2340 | try astgen.testDecl(gz, scope, member_node); |
| 2297 | 2341 | continue; |
| 2298 | 2342 | }, |
| 2299 | 2343 | else => unreachable, |