| ... | ... | @@ -4,25 +4,36 @@ const mem = std.mem; |
| 4 | 4 | const json = std.json; |
| 5 | 5 | const assert = std.debug.assert; |
| 6 | 6 | |
| 7 | // All references to other features are based on "zig name" as the key. |
| 8 | |
| 7 | 9 | const FeatureOverride = struct { |
| 8 | 10 | llvm_name: []const u8, |
| 9 | 11 | omit: bool = false, |
| 10 | 12 | zig_name: ?[]const u8 = null, |
| 11 | 13 | desc: ?[]const u8 = null, |
| 14 | extra_deps: []const []const u8 = &.{}, |
| 12 | 15 | }; |
| 13 | 16 | |
| 14 | | const ExtraCpu = struct { |
| 17 | const Cpu = struct { |
| 15 | 18 | llvm_name: ?[]const u8, |
| 16 | 19 | zig_name: []const u8, |
| 17 | 20 | features: []const []const u8, |
| 18 | 21 | }; |
| 19 | 22 | |
| 23 | const Feature = struct { |
| 24 | llvm_name: ?[]const u8 = null, |
| 25 | zig_name: []const u8, |
| 26 | desc: []const u8, |
| 27 | deps: []const []const u8, |
| 28 | }; |
| 29 | |
| 20 | 30 | const LlvmTarget = struct { |
| 21 | 31 | zig_name: []const u8, |
| 22 | 32 | llvm_name: []const u8, |
| 23 | 33 | td_name: []const u8, |
| 24 | 34 | feature_overrides: []const FeatureOverride = &.{}, |
| 25 | | extra_cpus: []const ExtraCpu = &.{}, |
| 35 | extra_cpus: []const Cpu = &.{}, |
| 36 | extra_features: []const Feature = &.{}, |
| 26 | 37 | branch_quota: ?usize = null, |
| 27 | 38 | }; |
| 28 | 39 | |
| ... | ... | @@ -54,6 +65,25 @@ const llvm_targets = [_]LlvmTarget{ |
| 54 | 65 | .llvm_name = "neoversev1", |
| 55 | 66 | .zig_name = "neoverse_v1", |
| 56 | 67 | }, |
| 68 | .{ |
| 69 | .llvm_name = "exynosm3", |
| 70 | .zig_name = "exynos_m3", |
| 71 | }, |
| 72 | .{ |
| 73 | .llvm_name = "exynosm4", |
| 74 | .zig_name = "exynos_m4", |
| 75 | }, |
| 76 | .{ |
| 77 | .llvm_name = "v8.1a", |
| 78 | .extra_deps = &.{"v8a"}, |
| 79 | }, |
| 80 | }, |
| 81 | .extra_features = &.{ |
| 82 | .{ |
| 83 | .zig_name = "v8a", |
| 84 | .desc = "Support ARM v8a instructions", |
| 85 | .deps = &.{ "fp_armv8", "neon" }, |
| 86 | }, |
| 57 | 87 | }, |
| 58 | 88 | }, |
| 59 | 89 | .{ |
| ... | ... | @@ -331,8 +361,9 @@ fn processOneTarget(job: Job) anyerror!void { |
| 331 | 361 | render_progress.activate(); |
| 332 | 362 | |
| 333 | 363 | const root_map = &tree.root.Object; |
| 334 | | var all_features = std.ArrayList(*json.ObjectMap).init(arena); |
| 335 | | var all_cpus = std.ArrayList(*json.ObjectMap).init(arena); |
| 364 | var features_table = std.StringHashMap(Feature).init(arena); |
| 365 | var all_features = std.ArrayList(Feature).init(arena); |
| 366 | var all_cpus = std.ArrayList(Cpu).init(arena); |
| 336 | 367 | { |
| 337 | 368 | var it = root_map.iterator(); |
| 338 | 369 | root_it: while (it.next()) |kv| { |
| ... | ... | @@ -342,23 +373,101 @@ fn processOneTarget(job: Job) anyerror!void { |
| 342 | 373 | if (hasSuperclass(&kv.value.Object, "SubtargetFeature")) { |
| 343 | 374 | const llvm_name = kv.value.Object.get("Name").?.String; |
| 344 | 375 | if (llvm_name.len == 0) continue; |
| 376 | |
| 377 | var zig_name = (try llvmNameToZigName(arena, llvm_target, llvm_name)) orelse |
| 378 | continue :root_it; |
| 379 | var desc = kv.value.Object.get("Desc").?.String; |
| 380 | var deps = std.ArrayList([]const u8).init(arena); |
| 381 | const implies = kv.value.Object.get("Implies").?.Array; |
| 382 | for (implies.items) |imply| { |
| 383 | const other_key = imply.Object.get("def").?.String; |
| 384 | const other_obj = &root_map.getEntry(other_key).?.value.Object; |
| 385 | const other_llvm_name = other_obj.get("Name").?.String; |
| 386 | const other_zig_name = (try llvmNameToZigName(arena, llvm_target, other_llvm_name)) orelse continue; |
| 387 | try deps.append(other_zig_name); |
| 388 | } |
| 345 | 389 | for (llvm_target.feature_overrides) |feature_override| { |
| 346 | 390 | if (mem.eql(u8, llvm_name, feature_override.llvm_name)) { |
| 347 | 391 | if (feature_override.omit) { |
| 348 | 392 | continue :root_it; |
| 349 | 393 | } |
| 394 | if (feature_override.zig_name) |override_name| { |
| 395 | zig_name = override_name; |
| 396 | } |
| 397 | if (feature_override.desc) |override_desc| { |
| 398 | desc = override_desc; |
| 399 | } |
| 400 | for (feature_override.extra_deps) |extra_dep| { |
| 401 | try deps.append(extra_dep); |
| 402 | } |
| 403 | break; |
| 350 | 404 | } |
| 351 | 405 | } |
| 352 | | |
| 353 | | try all_features.append(&kv.value.Object); |
| 406 | const feature: Feature = .{ |
| 407 | .llvm_name = llvm_name, |
| 408 | .zig_name = zig_name, |
| 409 | .desc = desc, |
| 410 | .deps = deps.items, |
| 411 | }; |
| 412 | try features_table.put(zig_name, feature); |
| 413 | try all_features.append(feature); |
| 354 | 414 | } |
| 355 | 415 | if (hasSuperclass(&kv.value.Object, "Processor")) { |
| 356 | | try all_cpus.append(&kv.value.Object); |
| 416 | const llvm_name = kv.value.Object.get("Name").?.String; |
| 417 | if (llvm_name.len == 0) continue; |
| 418 | |
| 419 | var zig_name = (try llvmNameToZigName(arena, llvm_target, llvm_name)) orelse |
| 420 | continue :root_it; |
| 421 | var deps = std.ArrayList([]const u8).init(arena); |
| 422 | const features = kv.value.Object.get("Features").?.Array; |
| 423 | for (features.items) |feature| { |
| 424 | const feature_key = feature.Object.get("def").?.String; |
| 425 | const feature_obj = &root_map.getEntry(feature_key).?.value.Object; |
| 426 | const feature_llvm_name = feature_obj.get("Name").?.String; |
| 427 | if (feature_llvm_name.len == 0) continue; |
| 428 | const feature_zig_name = (try llvmNameToZigName(arena, llvm_target, feature_llvm_name)) orelse continue; |
| 429 | try deps.append(feature_zig_name); |
| 430 | } |
| 431 | const tune_features = kv.value.Object.get("TuneFeatures").?.Array; |
| 432 | for (tune_features.items) |feature| { |
| 433 | const feature_key = feature.Object.get("def").?.String; |
| 434 | const feature_obj = &root_map.getEntry(feature_key).?.value.Object; |
| 435 | const feature_llvm_name = feature_obj.get("Name").?.String; |
| 436 | if (feature_llvm_name.len == 0) continue; |
| 437 | const feature_zig_name = (try llvmNameToZigName(arena, llvm_target, feature_llvm_name)) orelse continue; |
| 438 | try deps.append(feature_zig_name); |
| 439 | } |
| 440 | for (llvm_target.feature_overrides) |feature_override| { |
| 441 | if (mem.eql(u8, llvm_name, feature_override.llvm_name)) { |
| 442 | if (feature_override.omit) { |
| 443 | continue :root_it; |
| 444 | } |
| 445 | if (feature_override.zig_name) |override_name| { |
| 446 | zig_name = override_name; |
| 447 | } |
| 448 | for (feature_override.extra_deps) |extra_dep| { |
| 449 | try deps.append(extra_dep); |
| 450 | } |
| 451 | break; |
| 452 | } |
| 453 | } |
| 454 | try all_cpus.append(.{ |
| 455 | .llvm_name = llvm_name, |
| 456 | .zig_name = zig_name, |
| 457 | .features = deps.items, |
| 458 | }); |
| 357 | 459 | } |
| 358 | 460 | } |
| 359 | 461 | } |
| 360 | | std.sort.sort(*json.ObjectMap, all_features.items, {}, objectLessThan); |
| 361 | | std.sort.sort(*json.ObjectMap, all_cpus.items, {}, objectLessThan); |
| 462 | for (llvm_target.extra_features) |extra_feature| { |
| 463 | try features_table.put(extra_feature.zig_name, extra_feature); |
| 464 | try all_features.append(extra_feature); |
| 465 | } |
| 466 | for (llvm_target.extra_cpus) |extra_cpu| { |
| 467 | try all_cpus.append(extra_cpu); |
| 468 | } |
| 469 | std.sort.sort(Feature, all_features.items, {}, featureLessThan); |
| 470 | std.sort.sort(Cpu, all_cpus.items, {}, cpuLessThan); |
| 362 | 471 | |
| 363 | 472 | const target_sub_path = try fs.path.join(arena, &.{ "lib", "std", "target" }); |
| 364 | 473 | var target_dir = try job.zig_src_dir.makeOpenPath(target_sub_path, .{}); |
| ... | ... | @@ -389,10 +498,8 @@ fn processOneTarget(job: Job) anyerror!void { |
| 389 | 498 | \\ |
| 390 | 499 | ); |
| 391 | 500 | |
| 392 | | for (all_features.items) |obj| { |
| 393 | | const llvm_name = obj.get("Name").?.String; |
| 394 | | const zig_name = try llvmNameToZigName(arena, llvm_target, llvm_name); |
| 395 | | try w.print(" {},\n", .{std.zig.fmtId(zig_name)}); |
| 501 | for (all_features.items) |feature| { |
| 502 | try w.print(" {},\n", .{std.zig.fmtId(feature.zig_name)}); |
| 396 | 503 | } |
| 397 | 504 | |
| 398 | 505 | try w.writeAll( |
| ... | ... | @@ -413,45 +520,46 @@ fn processOneTarget(job: Job) anyerror!void { |
| 413 | 520 | \\ |
| 414 | 521 | ); |
| 415 | 522 | |
| 416 | | for (all_features.items) |obj| { |
| 417 | | const llvm_name = obj.get("Name").?.String; |
| 418 | | const llvm_description = obj.get("Desc").?.String; |
| 419 | | const description = for (llvm_target.feature_overrides) |feature_override| { |
| 420 | | if (mem.eql(u8, llvm_name, feature_override.llvm_name)) { |
| 421 | | if (feature_override.desc) |desc| { |
| 422 | | break desc; |
| 423 | | } |
| 424 | | } |
| 425 | | } else llvm_description; |
| 426 | | const zig_name = try llvmNameToZigName(arena, llvm_target, llvm_name); |
| 427 | | try w.print( |
| 428 | | \\ result[@enumToInt(Feature.{})] = .{{ |
| 429 | | \\ .llvm_name = "{}", |
| 430 | | \\ .description = "{}", |
| 431 | | \\ .dependencies = featureSet(&[_]Feature{{ |
| 432 | | , |
| 433 | | .{ |
| 434 | | std.zig.fmtId(zig_name), |
| 435 | | std.zig.fmtEscapes(llvm_name), |
| 436 | | std.zig.fmtEscapes(description), |
| 437 | | }, |
| 438 | | ); |
| 439 | | const implies = obj.get("Implies").?.Array; |
| 523 | for (all_features.items) |feature| { |
| 524 | if (feature.llvm_name) |llvm_name| { |
| 525 | try w.print( |
| 526 | \\ result[@enumToInt(Feature.{})] = .{{ |
| 527 | \\ .llvm_name = "{}", |
| 528 | \\ .description = "{}", |
| 529 | \\ .dependencies = featureSet(&[_]Feature{{ |
| 530 | , |
| 531 | .{ |
| 532 | std.zig.fmtId(feature.zig_name), |
| 533 | std.zig.fmtEscapes(llvm_name), |
| 534 | std.zig.fmtEscapes(feature.desc), |
| 535 | }, |
| 536 | ); |
| 537 | } else { |
| 538 | try w.print( |
| 539 | \\ result[@enumToInt(Feature.{})] = .{{ |
| 540 | \\ .llvm_name = null, |
| 541 | \\ .description = "{}", |
| 542 | \\ .dependencies = featureSet(&[_]Feature{{ |
| 543 | , |
| 544 | .{ |
| 545 | std.zig.fmtId(feature.zig_name), |
| 546 | std.zig.fmtEscapes(feature.desc), |
| 547 | }, |
| 548 | ); |
| 549 | } |
| 440 | 550 | var deps_set = std.StringHashMap(void).init(arena); |
| 441 | | for (implies.items) |imply| { |
| 442 | | const other_key = imply.Object.get("def").?.String; |
| 443 | | try deps_set.put(other_key, {}); |
| 551 | for (feature.deps) |dep| { |
| 552 | try deps_set.put(dep, {}); |
| 444 | 553 | } |
| 445 | | try pruneFeatures(arena, root_map, &deps_set); |
| 446 | | var dependencies = std.ArrayList(*json.ObjectMap).init(arena); |
| 554 | try pruneFeatures(arena, features_table, &deps_set); |
| 555 | var dependencies = std.ArrayList([]const u8).init(arena); |
| 447 | 556 | { |
| 448 | 557 | var it = deps_set.iterator(); |
| 449 | 558 | while (it.next()) |entry| { |
| 450 | | const other_obj = &root_map.getEntry(entry.key).?.value.Object; |
| 451 | | try dependencies.append(other_obj); |
| 559 | try dependencies.append(entry.key); |
| 452 | 560 | } |
| 453 | 561 | } |
| 454 | | std.sort.sort(*json.ObjectMap, dependencies.items, {}, objectLessThan); |
| 562 | std.sort.sort([]const u8, dependencies.items, {}, asciiLessThan); |
| 455 | 563 | |
| 456 | 564 | if (dependencies.items.len == 0) { |
| 457 | 565 | try w.writeAll( |
| ... | ... | @@ -462,9 +570,7 @@ fn processOneTarget(job: Job) anyerror!void { |
| 462 | 570 | } else { |
| 463 | 571 | try w.writeAll("\n"); |
| 464 | 572 | for (dependencies.items) |dep| { |
| 465 | | const other_llvm_name = dep.get("Name").?.String; |
| 466 | | const other_zig_name = try llvmNameToZigName(arena, llvm_target, other_llvm_name); |
| 467 | | try w.print(" .{},\n", .{std.zig.fmtId(other_zig_name)}); |
| 573 | try w.print(" .{},\n", .{std.zig.fmtId(dep)}); |
| 468 | 574 | } |
| 469 | 575 | try w.writeAll( |
| 470 | 576 | \\ }), |
| ... | ... | @@ -485,81 +591,42 @@ fn processOneTarget(job: Job) anyerror!void { |
| 485 | 591 | \\pub const cpu = struct { |
| 486 | 592 | \\ |
| 487 | 593 | ); |
| 488 | | for (llvm_target.extra_cpus) |extra_cpu| { |
| 489 | | try w.print( |
| 490 | | \\ pub const {} = CpuModel{{ |
| 491 | | \\ .name = "{}", |
| 492 | | \\ |
| 493 | | , .{ |
| 494 | | std.zig.fmtId(extra_cpu.zig_name), |
| 495 | | std.zig.fmtEscapes(extra_cpu.zig_name), |
| 496 | | }); |
| 497 | | if (extra_cpu.llvm_name) |llvm_name| { |
| 498 | | try w.print( |
| 499 | | \\ .llvm_name = "{}", |
| 500 | | \\ .features = featureSet(&[_]Feature{{ |
| 501 | | , .{std.zig.fmtEscapes(llvm_name)}); |
| 502 | | } else { |
| 503 | | try w.writeAll( |
| 504 | | \\ .llvm_name = null, |
| 505 | | \\ .features = featureSet(&[_]Feature{ |
| 506 | | ); |
| 507 | | } |
| 508 | | if (extra_cpu.features.len == 0) { |
| 509 | | try w.writeAll( |
| 510 | | \\}), |
| 511 | | \\ }; |
| 512 | | \\ |
| 513 | | ); |
| 514 | | } else { |
| 515 | | try w.writeAll("\n"); |
| 516 | | for (extra_cpu.features) |feature_zig_name| { |
| 517 | | try w.print(" .{},\n", .{std.zig.fmtId(feature_zig_name)}); |
| 518 | | } |
| 519 | | try w.writeAll( |
| 520 | | \\ }), |
| 521 | | \\ }; |
| 522 | | \\ |
| 523 | | ); |
| 524 | | } |
| 525 | | } |
| 526 | | for (all_cpus.items) |obj| { |
| 527 | | const llvm_name = obj.get("Name").?.String; |
| 594 | for (all_cpus.items) |cpu| { |
| 528 | 595 | var deps_set = std.StringHashMap(void).init(arena); |
| 529 | | |
| 530 | | const features = obj.get("Features").?.Array; |
| 531 | | for (features.items) |feature| { |
| 532 | | const feature_key = feature.Object.get("def").?.String; |
| 533 | | try deps_set.put(feature_key, {}); |
| 596 | for (cpu.features) |feature_zig_name| { |
| 597 | try deps_set.put(feature_zig_name, {}); |
| 534 | 598 | } |
| 535 | | const tune_features = obj.get("TuneFeatures").?.Array; |
| 536 | | for (tune_features.items) |feature| { |
| 537 | | const feature_key = feature.Object.get("def").?.String; |
| 538 | | try deps_set.put(feature_key, {}); |
| 539 | | } |
| 540 | | try pruneFeatures(arena, root_map, &deps_set); |
| 541 | | var cpu_features = std.ArrayList(*json.ObjectMap).init(arena); |
| 599 | try pruneFeatures(arena, features_table, &deps_set); |
| 600 | var cpu_features = std.ArrayList([]const u8).init(arena); |
| 542 | 601 | { |
| 543 | 602 | var it = deps_set.iterator(); |
| 544 | 603 | while (it.next()) |entry| { |
| 545 | | const feature_obj = &root_map.getEntry(entry.key).?.value.Object; |
| 546 | | const feature_llvm_name = feature_obj.get("Name").?.String; |
| 547 | | if (feature_llvm_name.len == 0) continue; |
| 548 | | try cpu_features.append(feature_obj); |
| 604 | try cpu_features.append(entry.key); |
| 549 | 605 | } |
| 550 | 606 | } |
| 551 | | std.sort.sort(*json.ObjectMap, cpu_features.items, {}, objectLessThan); |
| 552 | | const zig_cpu_name = try llvmNameToZigName(arena, llvm_target, llvm_name); |
| 553 | | try w.print( |
| 554 | | \\ pub const {} = CpuModel{{ |
| 555 | | \\ .name = "{}", |
| 556 | | \\ .llvm_name = "{}", |
| 557 | | \\ .features = featureSet(&[_]Feature{{ |
| 558 | | , .{ |
| 559 | | std.zig.fmtId(zig_cpu_name), |
| 560 | | std.zig.fmtEscapes(zig_cpu_name), |
| 561 | | std.zig.fmtEscapes(llvm_name), |
| 562 | | }); |
| 607 | std.sort.sort([]const u8, cpu_features.items, {}, asciiLessThan); |
| 608 | if (cpu.llvm_name) |llvm_name| { |
| 609 | try w.print( |
| 610 | \\ pub const {} = CpuModel{{ |
| 611 | \\ .name = "{}", |
| 612 | \\ .llvm_name = "{}", |
| 613 | \\ .features = featureSet(&[_]Feature{{ |
| 614 | , .{ |
| 615 | std.zig.fmtId(cpu.zig_name), |
| 616 | std.zig.fmtEscapes(cpu.zig_name), |
| 617 | std.zig.fmtEscapes(llvm_name), |
| 618 | }); |
| 619 | } else { |
| 620 | try w.print( |
| 621 | \\ pub const {} = CpuModel{{ |
| 622 | \\ .name = "{}", |
| 623 | \\ .llvm_name = null, |
| 624 | \\ .features = featureSet(&[_]Feature{{ |
| 625 | , .{ |
| 626 | std.zig.fmtId(cpu.zig_name), |
| 627 | std.zig.fmtEscapes(cpu.zig_name), |
| 628 | }); |
| 629 | } |
| 563 | 630 | if (cpu_features.items.len == 0) { |
| 564 | 631 | try w.writeAll( |
| 565 | 632 | \\}), |
| ... | ... | @@ -568,9 +635,7 @@ fn processOneTarget(job: Job) anyerror!void { |
| 568 | 635 | ); |
| 569 | 636 | } else { |
| 570 | 637 | try w.writeAll("\n"); |
| 571 | | for (cpu_features.items) |feature_obj| { |
| 572 | | const feature_llvm_name = feature_obj.get("Name").?.String; |
| 573 | | const feature_zig_name = try llvmNameToZigName(arena, llvm_target, feature_llvm_name); |
| 638 | for (cpu_features.items) |feature_zig_name| { |
| 574 | 639 | try w.print(" .{},\n", .{std.zig.fmtId(feature_zig_name)}); |
| 575 | 640 | } |
| 576 | 641 | try w.writeAll( |
| ... | ... | @@ -602,20 +667,26 @@ fn usageAndExit(file: fs.File, arg0: []const u8, code: u8) noreturn { |
| 602 | 667 | std.process.exit(code); |
| 603 | 668 | } |
| 604 | 669 | |
| 605 | | fn objectLessThan(context: void, a: *json.ObjectMap, b: *json.ObjectMap) bool { |
| 606 | | const a_key = a.get("Name").?.String; |
| 607 | | const b_key = b.get("Name").?.String; |
| 608 | | return std.ascii.lessThanIgnoreCase(a_key, b_key); |
| 670 | fn featureLessThan(context: void, a: Feature, b: Feature) bool { |
| 671 | return std.ascii.lessThanIgnoreCase(a.zig_name, b.zig_name); |
| 672 | } |
| 673 | |
| 674 | fn cpuLessThan(context: void, a: Cpu, b: Cpu) bool { |
| 675 | return std.ascii.lessThanIgnoreCase(a.zig_name, b.zig_name); |
| 676 | } |
| 677 | |
| 678 | fn asciiLessThan(context: void, a: []const u8, b: []const u8) bool { |
| 679 | return std.ascii.lessThanIgnoreCase(a, b); |
| 609 | 680 | } |
| 610 | 681 | |
| 611 | 682 | fn llvmNameToZigName( |
| 612 | 683 | arena: *mem.Allocator, |
| 613 | 684 | llvm_target: LlvmTarget, |
| 614 | 685 | llvm_name: []const u8, |
| 615 | | ) ![]const u8 { |
| 686 | ) !?[]const u8 { |
| 616 | 687 | for (llvm_target.feature_overrides) |feature_override| { |
| 617 | 688 | if (mem.eql(u8, feature_override.llvm_name, llvm_name)) { |
| 618 | | assert(!feature_override.omit); |
| 689 | if (feature_override.omit) return null; |
| 619 | 690 | return feature_override.zig_name orelse break; |
| 620 | 691 | } |
| 621 | 692 | } |
| ... | ... | @@ -640,7 +711,7 @@ fn hasSuperclass(obj: *json.ObjectMap, class_name: []const u8) bool { |
| 640 | 711 | |
| 641 | 712 | fn pruneFeatures( |
| 642 | 713 | arena: *mem.Allocator, |
| 643 | | root_map: *const json.ObjectMap, |
| 714 | features_table: std.StringHashMap(Feature), |
| 644 | 715 | deps_set: *std.StringHashMap(void), |
| 645 | 716 | ) !void { |
| 646 | 717 | // For each element, recursively iterate over the dependencies and add |
| ... | ... | @@ -650,8 +721,8 @@ fn pruneFeatures( |
| 650 | 721 | { |
| 651 | 722 | var it = deps_set.iterator(); |
| 652 | 723 | while (it.next()) |entry| { |
| 653 | | const other_obj = &root_map.getEntry(entry.key).?.value.Object; |
| 654 | | try walkFeatures(root_map, &deletion_set, other_obj); |
| 724 | const feature = features_table.get(entry.key).?; |
| 725 | try walkFeatures(features_table, &deletion_set, feature); |
| 655 | 726 | } |
| 656 | 727 | } |
| 657 | 728 | { |
| ... | ... | @@ -663,15 +734,13 @@ fn pruneFeatures( |
| 663 | 734 | } |
| 664 | 735 | |
| 665 | 736 | fn walkFeatures( |
| 666 | | root_map: *const json.ObjectMap, |
| 737 | features_table: std.StringHashMap(Feature), |
| 667 | 738 | deletion_set: *std.StringHashMap(void), |
| 668 | | feature: *json.ObjectMap, |
| 739 | feature: Feature, |
| 669 | 740 | ) error{OutOfMemory}!void { |
| 670 | | const implies = feature.get("Implies").?.Array; |
| 671 | | for (implies.items) |imply| { |
| 672 | | const other_key = imply.Object.get("def").?.String; |
| 673 | | try deletion_set.put(other_key, {}); |
| 674 | | const other_obj = &root_map.getEntry(other_key).?.value.Object; |
| 675 | | try walkFeatures(root_map, deletion_set, other_obj); |
| 741 | for (feature.deps) |dep| { |
| 742 | try deletion_set.put(dep, {}); |
| 743 | const other_feature = features_table.get(dep).?; |
| 744 | try walkFeatures(features_table, deletion_set, other_feature); |
| 676 | 745 | } |
| 677 | 746 | } |