@zigc/lib 0.16.0-test.1 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +19 -0
- package/c/math.zig +135 -35
- package/c/stropts.zig +17 -0
- package/c.zig +1 -0
- package/compiler/aro/aro/Attribute/names.zig +604 -589
- package/compiler/aro/aro/Attribute.zig +202 -116
- package/compiler/aro/aro/Builtins/common.zig +874 -863
- package/compiler/aro/aro/Builtins/eval.zig +15 -7
- package/compiler/aro/aro/Builtins.zig +0 -1
- package/compiler/aro/aro/CodeGen.zig +3 -1
- package/compiler/aro/aro/Compilation.zig +120 -97
- package/compiler/aro/aro/Diagnostics.zig +21 -17
- package/compiler/aro/aro/Driver/GCCDetector.zig +635 -0
- package/compiler/aro/aro/Driver.zig +124 -50
- package/compiler/aro/aro/LangOpts.zig +12 -2
- package/compiler/aro/aro/Parser/Diagnostic.zig +79 -19
- package/compiler/aro/aro/Parser.zig +336 -142
- package/compiler/aro/aro/Preprocessor/Diagnostic.zig +21 -0
- package/compiler/aro/aro/Preprocessor.zig +127 -56
- package/compiler/aro/aro/Target.zig +17 -12
- package/compiler/aro/aro/Tokenizer.zig +31 -14
- package/compiler/aro/aro/Toolchain.zig +4 -7
- package/compiler/aro/aro/Tree.zig +178 -148
- package/compiler/aro/aro/TypeStore.zig +82 -24
- package/compiler/aro/aro/Value.zig +13 -17
- package/compiler/aro/aro/features.zig +1 -0
- package/compiler/aro/aro/pragmas/once.zig +0 -1
- package/compiler/aro/aro/record_layout.zig +3 -3
- package/compiler/aro/assembly_backend/x86_64.zig +3 -4
- package/compiler/aro/backend/Assembly.zig +1 -2
- package/compiler/aro/backend/Interner.zig +2 -2
- package/compiler/aro/backend/Ir.zig +100 -92
- package/compiler/aro/include/ptrcheck.h +49 -0
- package/compiler/aro/main.zig +26 -10
- package/compiler/build_runner.zig +1 -0
- package/compiler/objdump.zig +93 -0
- package/compiler/reduce.zig +5 -1
- package/compiler/resinator/compile.zig +2 -2
- package/compiler/resinator/main.zig +7 -1
- package/compiler/resinator/preprocess.zig +1 -3
- package/compiler/std-docs.zig +8 -1
- package/compiler/test_runner.zig +193 -61
- package/compiler/translate-c/MacroTranslator.zig +80 -11
- package/compiler/translate-c/PatternList.zig +1 -9
- package/compiler/translate-c/Scope.zig +43 -6
- package/compiler/translate-c/Translator.zig +364 -126
- package/compiler/translate-c/ast.zig +19 -11
- package/compiler/translate-c/main.zig +75 -16
- package/compiler_rt/cos.zig +141 -52
- package/compiler_rt/limb64.zig +266 -0
- package/compiler_rt/long_double.zig +37 -0
- package/compiler_rt/mulo.zig +6 -1
- package/compiler_rt/rem_pio2l.zig +173 -0
- package/compiler_rt/sin.zig +140 -55
- package/compiler_rt/sincos.zig +279 -72
- package/compiler_rt/tan.zig +118 -47
- package/compiler_rt/trig.zig +256 -6
- package/compiler_rt.zig +2 -0
- package/fuzzer.zig +855 -307
- package/libc/musl/src/math/pow.c +343 -0
- package/package.json +1 -1
- package/std/Build/Fuzz.zig +6 -19
- package/std/Build/Module.zig +1 -1
- package/std/Build/Step/CheckObject.zig +3 -3
- package/std/Build/Step/Compile.zig +18 -0
- package/std/Build/Step/ConfigHeader.zig +49 -33
- package/std/Build/Step/InstallArtifact.zig +18 -0
- package/std/Build/Step/Run.zig +536 -87
- package/std/Build/Step/TranslateC.zig +0 -6
- package/std/Build/Step.zig +8 -15
- package/std/Build/WebServer.zig +29 -17
- package/std/Build/abi.zig +47 -11
- package/std/Build.zig +17 -14
- package/std/Io/Dispatch.zig +2 -0
- package/std/Io/File/Reader.zig +3 -1
- package/std/Io/File.zig +1 -0
- package/std/Io/Kqueue.zig +2 -2
- package/std/Io/Threaded.zig +181 -143
- package/std/Io/Uring.zig +2 -1
- package/std/Io.zig +970 -2
- package/std/Target.zig +3 -2
- package/std/Thread.zig +8 -3
- package/std/array_hash_map.zig +96 -555
- package/std/array_list.zig +22 -31
- package/std/bit_set.zig +22 -6
- package/std/builtin/assembly.zig +68 -0
- package/std/c.zig +17 -17
- package/std/compress/flate/Compress.zig +3 -3
- package/std/crypto/Certificate/Bundle.zig +15 -1
- package/std/crypto/codecs/asn1.zig +33 -18
- package/std/crypto/codecs/base64_hex_ct.zig +14 -4
- package/std/debug/Dwarf.zig +29 -9
- package/std/debug/Info.zig +4 -0
- package/std/debug/MachOFile.zig +46 -8
- package/std/debug/Pdb.zig +539 -36
- package/std/debug/SelfInfo/Elf.zig +19 -18
- package/std/debug/SelfInfo/MachO.zig +18 -7
- package/std/debug/SelfInfo/Windows.zig +138 -36
- package/std/debug.zig +179 -65
- package/std/enums.zig +25 -19
- package/std/heap/ArenaAllocator.zig +145 -154
- package/std/heap/debug_allocator.zig +7 -7
- package/std/http/Client.zig +10 -6
- package/std/http.zig +11 -9
- package/std/json/Stringify.zig +3 -3
- package/std/json/dynamic.zig +4 -4
- package/std/math/big/int.zig +16 -17
- package/std/mem/Allocator.zig +4 -5
- package/std/mem.zig +48 -0
- package/std/os/emscripten.zig +1 -17
- package/std/os/linux.zig +7 -2
- package/std/os/windows.zig +2 -2
- package/std/pdb.zig +143 -4
- package/std/posix.zig +6 -12
- package/std/priority_dequeue.zig +13 -12
- package/std/priority_queue.zig +5 -4
- package/std/process/Child.zig +1 -1
- package/std/process/Environ.zig +1 -1
- package/std/start.zig +17 -4
- package/std/std.zig +19 -6
- package/std/testing/FailingAllocator.zig +4 -4
- package/std/testing/Smith.zig +37 -2
- package/std/zig/Ast/Render.zig +186 -458
- package/std/zig/Ast.zig +0 -4
- package/std/zig/AstGen.zig +44 -7
- package/std/zig/AstSmith.zig +2602 -0
- package/std/zig/Client.zig +8 -3
- package/std/zig/Parse.zig +83 -74
- package/std/zig/Server.zig +26 -0
- package/std/zig/Zir.zig +17 -0
- package/std/zig/c_translation/helpers.zig +14 -9
- package/std/zig/llvm/Builder.zig +107 -48
- package/std/zig/system.zig +20 -4
- package/std/zig/tokenizer.zig +2 -1
- package/std/zig.zig +6 -0
- package/compiler/aro/aro/Driver/Filesystem.zig +0 -241
- package/libc/mingw/complex/cabs.c +0 -48
- package/libc/mingw/complex/cabsf.c +0 -48
- package/libc/mingw/complex/cacos.c +0 -50
- package/libc/mingw/complex/cacosf.c +0 -50
- package/libc/mingw/complex/carg.c +0 -48
- package/libc/mingw/complex/cargf.c +0 -48
- package/libc/mingw/complex/casin.c +0 -50
- package/libc/mingw/complex/casinf.c +0 -50
- package/libc/mingw/complex/catan.c +0 -50
- package/libc/mingw/complex/catanf.c +0 -50
- package/libc/mingw/complex/ccos.c +0 -50
- package/libc/mingw/complex/ccosf.c +0 -50
- package/libc/mingw/complex/cexp.c +0 -48
- package/libc/mingw/complex/cexpf.c +0 -48
- package/libc/mingw/complex/cimag.c +0 -48
- package/libc/mingw/complex/cimagf.c +0 -48
- package/libc/mingw/complex/clog.c +0 -48
- package/libc/mingw/complex/clog10.c +0 -49
- package/libc/mingw/complex/clog10f.c +0 -49
- package/libc/mingw/complex/clogf.c +0 -48
- package/libc/mingw/complex/conj.c +0 -48
- package/libc/mingw/complex/conjf.c +0 -48
- package/libc/mingw/complex/cpow.c +0 -48
- package/libc/mingw/complex/cpowf.c +0 -48
- package/libc/mingw/complex/cproj.c +0 -48
- package/libc/mingw/complex/cprojf.c +0 -48
- package/libc/mingw/complex/creal.c +0 -48
- package/libc/mingw/complex/crealf.c +0 -48
- package/libc/mingw/complex/csin.c +0 -50
- package/libc/mingw/complex/csinf.c +0 -50
- package/libc/mingw/complex/csqrt.c +0 -48
- package/libc/mingw/complex/csqrtf.c +0 -48
- package/libc/mingw/complex/ctan.c +0 -50
- package/libc/mingw/complex/ctanf.c +0 -50
- package/libc/mingw/math/arm/s_rint.c +0 -86
- package/libc/mingw/math/arm/s_rintf.c +0 -51
- package/libc/mingw/math/arm/sincos.S +0 -30
- package/libc/mingw/math/arm-common/sincosl.c +0 -13
- package/libc/mingw/math/arm64/rint.c +0 -12
- package/libc/mingw/math/arm64/rintf.c +0 -12
- package/libc/mingw/math/arm64/sincos.S +0 -32
- package/libc/mingw/math/bsd_private_base.h +0 -148
- package/libc/mingw/math/frexpf.c +0 -13
- package/libc/mingw/math/frexpl.c +0 -71
- package/libc/mingw/math/x86/acosf.c +0 -29
- package/libc/mingw/math/x86/atanf.c +0 -23
- package/libc/mingw/math/x86/atanl.c +0 -18
- package/libc/mingw/math/x86/cos.def.h +0 -65
- package/libc/mingw/math/x86/cosl.c +0 -46
- package/libc/mingw/math/x86/cosl_internal.S +0 -55
- package/libc/mingw/math/x86/ldexp.c +0 -23
- package/libc/mingw/math/x86/scalbn.S +0 -41
- package/libc/mingw/math/x86/scalbnf.S +0 -40
- package/libc/mingw/math/x86/sin.def.h +0 -65
- package/libc/mingw/math/x86/sinl.c +0 -46
- package/libc/mingw/math/x86/sinl_internal.S +0 -58
- package/libc/mingw/math/x86/tanl.S +0 -62
- package/libc/mingw/misc/btowc.c +0 -28
- package/libc/mingw/misc/wcstof.c +0 -66
- package/libc/mingw/misc/wcstoimax.c +0 -132
- package/libc/mingw/misc/wcstoumax.c +0 -126
- package/libc/mingw/misc/wctob.c +0 -29
- package/libc/mingw/misc/winbs_uint64.c +0 -6
- package/libc/mingw/misc/winbs_ulong.c +0 -6
- package/libc/mingw/misc/winbs_ushort.c +0 -6
- package/libc/mingw/stdio/_Exit.c +0 -10
- package/libc/mingw/stdio/_findfirst64i32.c +0 -21
- package/libc/mingw/stdio/_findnext64i32.c +0 -21
- package/libc/mingw/stdio/_fstat64i32.c +0 -37
- package/libc/mingw/stdio/_stat64i32.c +0 -37
- package/libc/mingw/stdio/_wfindfirst64i32.c +0 -21
- package/libc/mingw/stdio/_wfindnext64i32.c +0 -21
- package/libc/mingw/stdio/_wstat64i32.c +0 -37
- package/libc/musl/src/legacy/isastream.c +0 -7
- package/libc/musl/src/legacy/valloc.c +0 -8
- package/libc/musl/src/math/__cosl.c +0 -96
- package/libc/musl/src/math/__sinl.c +0 -78
- package/libc/musl/src/math/__tanl.c +0 -143
- package/libc/musl/src/math/aarch64/lrint.c +0 -10
- package/libc/musl/src/math/aarch64/lrintf.c +0 -10
- package/libc/musl/src/math/aarch64/rintf.c +0 -7
- package/libc/musl/src/math/cosl.c +0 -39
- package/libc/musl/src/math/fdim.c +0 -10
- package/libc/musl/src/math/finite.c +0 -7
- package/libc/musl/src/math/finitef.c +0 -7
- package/libc/musl/src/math/frexp.c +0 -23
- package/libc/musl/src/math/frexpf.c +0 -23
- package/libc/musl/src/math/frexpl.c +0 -29
- package/libc/musl/src/math/i386/lrint.c +0 -8
- package/libc/musl/src/math/i386/lrintf.c +0 -8
- package/libc/musl/src/math/i386/rintf.c +0 -7
- package/libc/musl/src/math/lrint.c +0 -72
- package/libc/musl/src/math/lrintf.c +0 -8
- package/libc/musl/src/math/powerpc64/lrint.c +0 -16
- package/libc/musl/src/math/powerpc64/lrintf.c +0 -16
- package/libc/musl/src/math/rintf.c +0 -30
- package/libc/musl/src/math/s390x/rintf.c +0 -15
- package/libc/musl/src/math/sincosl.c +0 -60
- package/libc/musl/src/math/sinl.c +0 -41
- package/libc/musl/src/math/tanl.c +0 -29
- package/libc/musl/src/math/x32/lrint.s +0 -5
- package/libc/musl/src/math/x32/lrintf.s +0 -5
- package/libc/musl/src/math/x86_64/lrint.c +0 -8
- package/libc/musl/src/math/x86_64/lrintf.c +0 -8
- package/libc/wasi/libc-bottom-half/sources/reallocarray.c +0 -14
|
@@ -374,24 +374,27 @@ pub fn deinit(ir: *Ir, gpa: std.mem.Allocator) void {
|
|
|
374
374
|
ir.* = undefined;
|
|
375
375
|
}
|
|
376
376
|
|
|
377
|
-
const TYPE = std.Io.
|
|
378
|
-
const INST = std.Io.
|
|
379
|
-
const REF = std.Io.
|
|
380
|
-
const LITERAL = std.Io.
|
|
381
|
-
const ATTRIBUTE = std.Io.
|
|
377
|
+
const TYPE = std.Io.Terminal.Color.bright_magenta;
|
|
378
|
+
const INST = std.Io.Terminal.Color.bright_cyan;
|
|
379
|
+
const REF = std.Io.Terminal.Color.bright_blue;
|
|
380
|
+
const LITERAL = std.Io.Terminal.Color.bright_green;
|
|
381
|
+
const ATTRIBUTE = std.Io.Terminal.Color.bright_yellow;
|
|
382
382
|
|
|
383
383
|
const RefMap = std.AutoArrayHashMapUnmanaged(Ref, void);
|
|
384
384
|
|
|
385
|
-
pub
|
|
385
|
+
pub const DumpError = std.Io.Terminal.SetColorError || std.mem.Allocator.Error;
|
|
386
|
+
|
|
387
|
+
pub fn dump(ir: *const Ir, gpa: Allocator, term: std.Io.Terminal) DumpError!void {
|
|
386
388
|
for (ir.decls.keys(), ir.decls.values()) |name, *decl| {
|
|
387
|
-
try ir.dumpDecl(decl, gpa, name,
|
|
389
|
+
try ir.dumpDecl(decl, gpa, name, term);
|
|
388
390
|
}
|
|
389
|
-
try
|
|
391
|
+
try term.writer.flush();
|
|
390
392
|
}
|
|
391
393
|
|
|
392
|
-
fn dumpDecl(ir: *const Ir, decl: *const Decl, gpa: Allocator, name: []const u8,
|
|
394
|
+
fn dumpDecl(ir: *const Ir, decl: *const Decl, gpa: Allocator, name: []const u8, term: std.Io.Terminal) !void {
|
|
393
395
|
const tags = decl.instructions.items(.tag);
|
|
394
396
|
const data = decl.instructions.items(.data);
|
|
397
|
+
const w = term.writer;
|
|
395
398
|
|
|
396
399
|
var ref_map: RefMap = .empty;
|
|
397
400
|
defer ref_map.deinit(gpa);
|
|
@@ -402,10 +405,10 @@ fn dumpDecl(ir: *const Ir, decl: *const Decl, gpa: Allocator, name: []const u8,
|
|
|
402
405
|
const ret_inst = decl.body.items[decl.body.items.len - 1];
|
|
403
406
|
const ret_operand = data[@intFromEnum(ret_inst)].un;
|
|
404
407
|
const ret_ty = decl.instructions.items(.ty)[@intFromEnum(ret_operand)];
|
|
405
|
-
try ir.writeType(ret_ty,
|
|
406
|
-
try
|
|
408
|
+
try ir.writeType(ret_ty, term);
|
|
409
|
+
try term.setColor(REF);
|
|
407
410
|
try w.print(" @{s}", .{name});
|
|
408
|
-
try
|
|
411
|
+
try term.setColor(.reset);
|
|
409
412
|
try w.writeAll("(");
|
|
410
413
|
|
|
411
414
|
var arg_count: u32 = 0;
|
|
@@ -414,8 +417,8 @@ fn dumpDecl(ir: *const Ir, decl: *const Decl, gpa: Allocator, name: []const u8,
|
|
|
414
417
|
if (tags[@intFromEnum(ref)] != .arg) break;
|
|
415
418
|
if (arg_count != 0) try w.writeAll(", ");
|
|
416
419
|
try ref_map.put(gpa, ref, {});
|
|
417
|
-
try ir.writeRef(decl, &ref_map, ref,
|
|
418
|
-
try
|
|
420
|
+
try ir.writeRef(decl, &ref_map, ref, term);
|
|
421
|
+
try term.setColor(.reset);
|
|
419
422
|
}
|
|
420
423
|
try w.writeAll(") {\n");
|
|
421
424
|
for (decl.body.items[arg_count..]) |ref| {
|
|
@@ -432,7 +435,7 @@ fn dumpDecl(ir: *const Ir, decl: *const Decl, gpa: Allocator, name: []const u8,
|
|
|
432
435
|
.arg, .constant, .symbol => unreachable,
|
|
433
436
|
.label => {
|
|
434
437
|
const label_index = label_map.getIndex(ref).?;
|
|
435
|
-
try
|
|
438
|
+
try term.setColor(REF);
|
|
436
439
|
try w.print("{s}.{d}:\n", .{ data[i].label, label_index });
|
|
437
440
|
},
|
|
438
441
|
// .label_val => {
|
|
@@ -441,35 +444,35 @@ fn dumpDecl(ir: *const Ir, decl: *const Decl, gpa: Allocator, name: []const u8,
|
|
|
441
444
|
// },
|
|
442
445
|
.jmp => {
|
|
443
446
|
const un = data[i].un;
|
|
444
|
-
try
|
|
447
|
+
try term.setColor(INST);
|
|
445
448
|
try w.writeAll(" jmp ");
|
|
446
|
-
try writeLabel(decl, &label_map, un,
|
|
449
|
+
try writeLabel(decl, &label_map, un, term);
|
|
447
450
|
try w.writeByte('\n');
|
|
448
451
|
},
|
|
449
452
|
.branch => {
|
|
450
453
|
const br = data[i].branch;
|
|
451
|
-
try
|
|
454
|
+
try term.setColor(INST);
|
|
452
455
|
try w.writeAll(" branch ");
|
|
453
|
-
try ir.writeRef(decl, &ref_map, br.cond,
|
|
454
|
-
try
|
|
456
|
+
try ir.writeRef(decl, &ref_map, br.cond, term);
|
|
457
|
+
try term.setColor(.reset);
|
|
455
458
|
try w.writeAll(", ");
|
|
456
|
-
try writeLabel(decl, &label_map, br.then,
|
|
457
|
-
try
|
|
459
|
+
try writeLabel(decl, &label_map, br.then, term);
|
|
460
|
+
try term.setColor(.reset);
|
|
458
461
|
try w.writeAll(", ");
|
|
459
|
-
try writeLabel(decl, &label_map, br.@"else",
|
|
462
|
+
try writeLabel(decl, &label_map, br.@"else", term);
|
|
460
463
|
try w.writeByte('\n');
|
|
461
464
|
},
|
|
462
465
|
.select => {
|
|
463
466
|
const br = data[i].branch;
|
|
464
|
-
try ir.writeNewRef(gpa, decl, &ref_map, ref,
|
|
467
|
+
try ir.writeNewRef(gpa, decl, &ref_map, ref, term);
|
|
465
468
|
try w.writeAll("select ");
|
|
466
|
-
try ir.writeRef(decl, &ref_map, br.cond,
|
|
467
|
-
try
|
|
469
|
+
try ir.writeRef(decl, &ref_map, br.cond, term);
|
|
470
|
+
try term.setColor(.reset);
|
|
468
471
|
try w.writeAll(", ");
|
|
469
|
-
try ir.writeRef(decl, &ref_map, br.then,
|
|
470
|
-
try
|
|
472
|
+
try ir.writeRef(decl, &ref_map, br.then, term);
|
|
473
|
+
try term.setColor(.reset);
|
|
471
474
|
try w.writeAll(", ");
|
|
472
|
-
try ir.writeRef(decl, &ref_map, br.@"else",
|
|
475
|
+
try ir.writeRef(decl, &ref_map, br.@"else", term);
|
|
473
476
|
try w.writeByte('\n');
|
|
474
477
|
},
|
|
475
478
|
// .jmp_val => {
|
|
@@ -478,91 +481,91 @@ fn dumpDecl(ir: *const Ir, decl: *const Decl, gpa: Allocator, name: []const u8,
|
|
|
478
481
|
// },
|
|
479
482
|
.@"switch" => {
|
|
480
483
|
const @"switch" = data[i].@"switch";
|
|
481
|
-
try
|
|
484
|
+
try term.setColor(INST);
|
|
482
485
|
try w.writeAll(" switch ");
|
|
483
|
-
try ir.writeRef(decl, &ref_map, @"switch".target,
|
|
484
|
-
try
|
|
486
|
+
try ir.writeRef(decl, &ref_map, @"switch".target, term);
|
|
487
|
+
try term.setColor(.reset);
|
|
485
488
|
try w.writeAll(" {");
|
|
486
489
|
for (@"switch".case_vals[0..@"switch".cases_len], @"switch".case_labels) |val_ref, label_ref| {
|
|
487
490
|
try w.writeAll("\n ");
|
|
488
|
-
try ir.writeValue(val_ref,
|
|
489
|
-
try
|
|
491
|
+
try ir.writeValue(val_ref, term);
|
|
492
|
+
try term.setColor(.reset);
|
|
490
493
|
try w.writeAll(" => ");
|
|
491
|
-
try writeLabel(decl, &label_map, label_ref,
|
|
492
|
-
try
|
|
494
|
+
try writeLabel(decl, &label_map, label_ref, term);
|
|
495
|
+
try term.setColor(.reset);
|
|
493
496
|
}
|
|
494
|
-
try
|
|
497
|
+
try term.setColor(LITERAL);
|
|
495
498
|
try w.writeAll("\n default ");
|
|
496
|
-
try
|
|
499
|
+
try term.setColor(.reset);
|
|
497
500
|
try w.writeAll("=> ");
|
|
498
|
-
try writeLabel(decl, &label_map, @"switch".default,
|
|
499
|
-
try
|
|
501
|
+
try writeLabel(decl, &label_map, @"switch".default, term);
|
|
502
|
+
try term.setColor(.reset);
|
|
500
503
|
try w.writeAll("\n }\n");
|
|
501
504
|
},
|
|
502
505
|
.call => {
|
|
503
506
|
const call = data[i].call;
|
|
504
|
-
try ir.writeNewRef(gpa, decl, &ref_map, ref,
|
|
507
|
+
try ir.writeNewRef(gpa, decl, &ref_map, ref, term);
|
|
505
508
|
try w.writeAll("call ");
|
|
506
|
-
try ir.writeRef(decl, &ref_map, call.func,
|
|
507
|
-
try
|
|
509
|
+
try ir.writeRef(decl, &ref_map, call.func, term);
|
|
510
|
+
try term.setColor(.reset);
|
|
508
511
|
try w.writeAll("(");
|
|
509
512
|
for (call.args(), 0..) |arg, arg_i| {
|
|
510
513
|
if (arg_i != 0) try w.writeAll(", ");
|
|
511
|
-
try ir.writeRef(decl, &ref_map, arg,
|
|
512
|
-
try
|
|
514
|
+
try ir.writeRef(decl, &ref_map, arg, term);
|
|
515
|
+
try term.setColor(.reset);
|
|
513
516
|
}
|
|
514
517
|
try w.writeAll(")\n");
|
|
515
518
|
},
|
|
516
519
|
.alloc => {
|
|
517
520
|
const alloc = data[i].alloc;
|
|
518
|
-
try ir.writeNewRef(gpa, decl, &ref_map, ref,
|
|
521
|
+
try ir.writeNewRef(gpa, decl, &ref_map, ref, term);
|
|
519
522
|
try w.writeAll("alloc ");
|
|
520
|
-
try
|
|
523
|
+
try term.setColor(ATTRIBUTE);
|
|
521
524
|
try w.writeAll("size ");
|
|
522
|
-
try
|
|
525
|
+
try term.setColor(LITERAL);
|
|
523
526
|
try w.print("{d}", .{alloc.size});
|
|
524
|
-
try
|
|
527
|
+
try term.setColor(ATTRIBUTE);
|
|
525
528
|
try w.writeAll(" align ");
|
|
526
|
-
try
|
|
529
|
+
try term.setColor(LITERAL);
|
|
527
530
|
try w.print("{d}", .{alloc.@"align"});
|
|
528
531
|
try w.writeByte('\n');
|
|
529
532
|
},
|
|
530
533
|
.phi => {
|
|
531
|
-
try ir.writeNewRef(gpa, decl, &ref_map, ref,
|
|
534
|
+
try ir.writeNewRef(gpa, decl, &ref_map, ref, term);
|
|
532
535
|
try w.writeAll("phi");
|
|
533
|
-
try
|
|
536
|
+
try term.setColor(.reset);
|
|
534
537
|
try w.writeAll(" {");
|
|
535
538
|
for (data[i].phi.inputs()) |input| {
|
|
536
539
|
try w.writeAll("\n ");
|
|
537
|
-
try writeLabel(decl, &label_map, input.label,
|
|
538
|
-
try
|
|
540
|
+
try writeLabel(decl, &label_map, input.label, term);
|
|
541
|
+
try term.setColor(.reset);
|
|
539
542
|
try w.writeAll(" => ");
|
|
540
|
-
try ir.writeRef(decl, &ref_map, input.value,
|
|
541
|
-
try
|
|
543
|
+
try ir.writeRef(decl, &ref_map, input.value, term);
|
|
544
|
+
try term.setColor(.reset);
|
|
542
545
|
}
|
|
543
|
-
try
|
|
546
|
+
try term.setColor(.reset);
|
|
544
547
|
try w.writeAll("\n }\n");
|
|
545
548
|
},
|
|
546
549
|
.store => {
|
|
547
550
|
const bin = data[i].bin;
|
|
548
|
-
try
|
|
551
|
+
try term.setColor(INST);
|
|
549
552
|
try w.writeAll(" store ");
|
|
550
|
-
try ir.writeRef(decl, &ref_map, bin.lhs,
|
|
551
|
-
try
|
|
553
|
+
try ir.writeRef(decl, &ref_map, bin.lhs, term);
|
|
554
|
+
try term.setColor(.reset);
|
|
552
555
|
try w.writeAll(", ");
|
|
553
|
-
try ir.writeRef(decl, &ref_map, bin.rhs,
|
|
556
|
+
try ir.writeRef(decl, &ref_map, bin.rhs, term);
|
|
554
557
|
try w.writeByte('\n');
|
|
555
558
|
},
|
|
556
559
|
.ret => {
|
|
557
|
-
try
|
|
560
|
+
try term.setColor(INST);
|
|
558
561
|
try w.writeAll(" ret ");
|
|
559
|
-
if (data[i].un != .none) try ir.writeRef(decl, &ref_map, data[i].un,
|
|
562
|
+
if (data[i].un != .none) try ir.writeRef(decl, &ref_map, data[i].un, term);
|
|
560
563
|
try w.writeByte('\n');
|
|
561
564
|
},
|
|
562
565
|
.load => {
|
|
563
|
-
try ir.writeNewRef(gpa, decl, &ref_map, ref,
|
|
566
|
+
try ir.writeNewRef(gpa, decl, &ref_map, ref, term);
|
|
564
567
|
try w.writeAll("load ");
|
|
565
|
-
try ir.writeRef(decl, &ref_map, data[i].un,
|
|
568
|
+
try ir.writeRef(decl, &ref_map, data[i].un, term);
|
|
566
569
|
try w.writeByte('\n');
|
|
567
570
|
},
|
|
568
571
|
.bit_or,
|
|
@@ -583,12 +586,12 @@ fn dumpDecl(ir: *const Ir, decl: *const Decl, gpa: Allocator, name: []const u8,
|
|
|
583
586
|
.mod,
|
|
584
587
|
=> {
|
|
585
588
|
const bin = data[i].bin;
|
|
586
|
-
try ir.writeNewRef(gpa, decl, &ref_map, ref,
|
|
589
|
+
try ir.writeNewRef(gpa, decl, &ref_map, ref, term);
|
|
587
590
|
try w.print("{s} ", .{@tagName(tag)});
|
|
588
|
-
try ir.writeRef(decl, &ref_map, bin.lhs,
|
|
589
|
-
try
|
|
591
|
+
try ir.writeRef(decl, &ref_map, bin.lhs, term);
|
|
592
|
+
try term.setColor(.reset);
|
|
590
593
|
try w.writeAll(", ");
|
|
591
|
-
try ir.writeRef(decl, &ref_map, bin.rhs,
|
|
594
|
+
try ir.writeRef(decl, &ref_map, bin.rhs, term);
|
|
592
595
|
try w.writeByte('\n');
|
|
593
596
|
},
|
|
594
597
|
.bit_not,
|
|
@@ -598,33 +601,34 @@ fn dumpDecl(ir: *const Ir, decl: *const Decl, gpa: Allocator, name: []const u8,
|
|
|
598
601
|
.sext,
|
|
599
602
|
=> {
|
|
600
603
|
const un = data[i].un;
|
|
601
|
-
try ir.writeNewRef(gpa, decl, &ref_map, ref,
|
|
604
|
+
try ir.writeNewRef(gpa, decl, &ref_map, ref, term);
|
|
602
605
|
try w.print("{s} ", .{@tagName(tag)});
|
|
603
|
-
try ir.writeRef(decl, &ref_map, un,
|
|
606
|
+
try ir.writeRef(decl, &ref_map, un, term);
|
|
604
607
|
try w.writeByte('\n');
|
|
605
608
|
},
|
|
606
609
|
.label_addr, .jmp_val => {},
|
|
607
610
|
}
|
|
608
611
|
}
|
|
609
|
-
try
|
|
612
|
+
try term.setColor(.reset);
|
|
610
613
|
try w.writeAll("}\n\n");
|
|
611
614
|
}
|
|
612
615
|
|
|
613
|
-
fn writeType(ir: Ir, ty_ref: Interner.Ref,
|
|
616
|
+
fn writeType(ir: Ir, ty_ref: Interner.Ref, term: std.Io.Terminal) !void {
|
|
617
|
+
const w = term.writer;
|
|
614
618
|
const ty = ir.interner.get(ty_ref);
|
|
615
|
-
try
|
|
619
|
+
try term.setColor(TYPE);
|
|
616
620
|
switch (ty) {
|
|
617
621
|
.ptr_ty, .noreturn_ty, .void_ty, .func_ty => try w.writeAll(@tagName(ty)),
|
|
618
622
|
.int_ty => |bits| try w.print("i{d}", .{bits}),
|
|
619
623
|
.float_ty => |bits| try w.print("f{d}", .{bits}),
|
|
620
624
|
.array_ty => |info| {
|
|
621
625
|
try w.print("[{d} * ", .{info.len});
|
|
622
|
-
try ir.writeType(info.child, .no_color, w);
|
|
626
|
+
try ir.writeType(info.child, .{ .mode = .no_color, .writer = w });
|
|
623
627
|
try w.writeByte(']');
|
|
624
628
|
},
|
|
625
629
|
.vector_ty => |info| {
|
|
626
630
|
try w.print("<{d} * ", .{info.len});
|
|
627
|
-
try ir.writeType(info.child, .no_color, w);
|
|
631
|
+
try ir.writeType(info.child, .{ .mode = .no_color, .writer = w });
|
|
628
632
|
try w.writeByte('>');
|
|
629
633
|
},
|
|
630
634
|
.record_ty => |elems| {
|
|
@@ -632,7 +636,7 @@ fn writeType(ir: Ir, ty_ref: Interner.Ref, config: std.Io.tty.Config, w: *std.Io
|
|
|
632
636
|
try w.writeAll("{ ");
|
|
633
637
|
for (elems, 0..) |elem, i| {
|
|
634
638
|
if (i != 0) try w.writeAll(", ");
|
|
635
|
-
try ir.writeType(elem,
|
|
639
|
+
try ir.writeType(elem, .{ .mode = .no_color, .writer = w });
|
|
636
640
|
}
|
|
637
641
|
try w.writeAll(" }");
|
|
638
642
|
},
|
|
@@ -640,8 +644,9 @@ fn writeType(ir: Ir, ty_ref: Interner.Ref, config: std.Io.tty.Config, w: *std.Io
|
|
|
640
644
|
}
|
|
641
645
|
}
|
|
642
646
|
|
|
643
|
-
fn writeValue(ir: Ir, val: Interner.Ref,
|
|
644
|
-
|
|
647
|
+
fn writeValue(ir: Ir, val: Interner.Ref, term: std.Io.Terminal) !void {
|
|
648
|
+
const w = term.writer;
|
|
649
|
+
try term.setColor(LITERAL);
|
|
645
650
|
const key = ir.interner.get(val);
|
|
646
651
|
switch (key) {
|
|
647
652
|
.null => return w.writeAll("nullptr_t"),
|
|
@@ -656,43 +661,46 @@ fn writeValue(ir: Ir, val: Interner.Ref, config: std.Io.tty.Config, w: *std.Io.W
|
|
|
656
661
|
}
|
|
657
662
|
}
|
|
658
663
|
|
|
659
|
-
fn writeRef(ir: Ir, decl: *const Decl, ref_map: *RefMap, ref: Ref,
|
|
664
|
+
fn writeRef(ir: Ir, decl: *const Decl, ref_map: *RefMap, ref: Ref, term: std.Io.Terminal) !void {
|
|
665
|
+
const w = term.writer;
|
|
660
666
|
assert(ref != .none);
|
|
661
667
|
const index = @intFromEnum(ref);
|
|
662
668
|
const ty_ref = decl.instructions.items(.ty)[index];
|
|
663
669
|
if (decl.instructions.items(.tag)[index] == .constant) {
|
|
664
|
-
try ir.writeType(ty_ref,
|
|
670
|
+
try ir.writeType(ty_ref, term);
|
|
665
671
|
const v_ref = decl.instructions.items(.data)[index].constant;
|
|
666
672
|
try w.writeByte(' ');
|
|
667
|
-
try ir.writeValue(v_ref,
|
|
673
|
+
try ir.writeValue(v_ref, term);
|
|
668
674
|
return;
|
|
669
675
|
} else if (decl.instructions.items(.tag)[index] == .symbol) {
|
|
670
676
|
const name = decl.instructions.items(.data)[index].label;
|
|
671
|
-
try ir.writeType(ty_ref,
|
|
672
|
-
try
|
|
677
|
+
try ir.writeType(ty_ref, term);
|
|
678
|
+
try term.setColor(REF);
|
|
673
679
|
try w.print(" @{s}", .{name});
|
|
674
680
|
return;
|
|
675
681
|
}
|
|
676
|
-
try ir.writeType(ty_ref,
|
|
677
|
-
try
|
|
682
|
+
try ir.writeType(ty_ref, term);
|
|
683
|
+
try term.setColor(REF);
|
|
678
684
|
const ref_index = ref_map.getIndex(ref).?;
|
|
679
685
|
try w.print(" %{d}", .{ref_index});
|
|
680
686
|
}
|
|
681
687
|
|
|
682
|
-
fn writeNewRef(ir: Ir, gpa: Allocator, decl: *const Decl, ref_map: *RefMap, ref: Ref,
|
|
688
|
+
fn writeNewRef(ir: Ir, gpa: Allocator, decl: *const Decl, ref_map: *RefMap, ref: Ref, term: std.Io.Terminal) !void {
|
|
689
|
+
const w = term.writer;
|
|
683
690
|
try ref_map.put(gpa, ref, {});
|
|
684
691
|
try w.writeAll(" ");
|
|
685
|
-
try ir.writeRef(decl, ref_map, ref,
|
|
686
|
-
try
|
|
692
|
+
try ir.writeRef(decl, ref_map, ref, term);
|
|
693
|
+
try term.setColor(.reset);
|
|
687
694
|
try w.writeAll(" = ");
|
|
688
|
-
try
|
|
695
|
+
try term.setColor(INST);
|
|
689
696
|
}
|
|
690
697
|
|
|
691
|
-
fn writeLabel(decl: *const Decl, label_map: *RefMap, ref: Ref,
|
|
698
|
+
fn writeLabel(decl: *const Decl, label_map: *RefMap, ref: Ref, term: std.Io.Terminal) !void {
|
|
699
|
+
const w = term.writer;
|
|
692
700
|
assert(ref != .none);
|
|
693
701
|
const index = @intFromEnum(ref);
|
|
694
702
|
const label = decl.instructions.items(.data)[index].label;
|
|
695
|
-
try
|
|
703
|
+
try term.setColor(REF);
|
|
696
704
|
const label_index = label_map.getIndex(ref).?;
|
|
697
705
|
try w.print("{s}.{d}", .{ label, label_index });
|
|
698
706
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#if defined(__has_feature) && __has_feature(bounds_attributes)
|
|
4
|
+
#define __has_ptrcheck 1
|
|
5
|
+
#else
|
|
6
|
+
#define __has_ptrcheck 0
|
|
7
|
+
#endif
|
|
8
|
+
|
|
9
|
+
#if __has_ptrcheck
|
|
10
|
+
|
|
11
|
+
#define __single __attribute__((__single__))
|
|
12
|
+
#define __unsafe_indexable __attribute__((__unsafe_indexable__))
|
|
13
|
+
|
|
14
|
+
#else
|
|
15
|
+
|
|
16
|
+
#define __single
|
|
17
|
+
#define __unsafe_indexable
|
|
18
|
+
#define __counted_by(N)
|
|
19
|
+
#define __counted_by_or_null(N)
|
|
20
|
+
#define __sized_by(N)
|
|
21
|
+
#define __sized_by_or_null(N)
|
|
22
|
+
#define __ended_by(E)
|
|
23
|
+
|
|
24
|
+
#define __terminated_by(T)
|
|
25
|
+
#define __null_terminated
|
|
26
|
+
|
|
27
|
+
/* __ptrcheck_abi_assume_indexable and __ptrcheck_abi_assume_bidi_indexable intentionally not defined */
|
|
28
|
+
#define __ptrcheck_abi_assume_single()
|
|
29
|
+
#define __ptrcheck_abi_assume_unsafe_indexable()
|
|
30
|
+
|
|
31
|
+
#define __unsafe_forge_bidi_indexable(T, P, S) ((T)(P))
|
|
32
|
+
#define __unsafe_forge_single(T, P) ((T)(P))
|
|
33
|
+
#define __unsafe_forge_terminated_by(T, P, E) ((T)(P))
|
|
34
|
+
#define __unsafe_forge_null_terminated(T, P) ((T)(P))
|
|
35
|
+
|
|
36
|
+
#define __terminated_by_to_indexable(P) (P)
|
|
37
|
+
#define __unsafe_terminated_by_to_indexable(P) (P)
|
|
38
|
+
#define __null_terminated_to_indexable(P) (P)
|
|
39
|
+
#define __unsafe_null_terminated_to_indexable(P) (P)
|
|
40
|
+
#define __unsafe_terminated_by_from_indexable(T, P, ...) (P)
|
|
41
|
+
#define __unsafe_null_terminated_from_indexable(P, ...) (P)
|
|
42
|
+
|
|
43
|
+
#define __array_decay_dicards_count_in_parameters
|
|
44
|
+
|
|
45
|
+
#define __ptrcheck_unavailable
|
|
46
|
+
#define __ptrcheck_unavailable_r(REPLACEMENT)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
#endif
|
package/compiler/aro/main.zig
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const std = @import("std");
|
|
2
|
-
const Io = std.Io;
|
|
3
|
-
const Allocator = mem.Allocator;
|
|
4
2
|
const mem = std.mem;
|
|
5
3
|
const process = std.process;
|
|
4
|
+
const Allocator = mem.Allocator;
|
|
5
|
+
const build_options = @import("build_options");
|
|
6
|
+
|
|
6
7
|
const aro = @import("aro");
|
|
7
8
|
const Compilation = aro.Compilation;
|
|
8
9
|
const Diagnostics = aro.Diagnostics;
|
|
@@ -11,14 +12,15 @@ const Toolchain = aro.Toolchain;
|
|
|
11
12
|
const assembly_backend = @import("assembly_backend");
|
|
12
13
|
|
|
13
14
|
var debug_allocator: std.heap.DebugAllocator(.{
|
|
14
|
-
.stack_trace_frames = 0,
|
|
15
|
+
.stack_trace_frames = if (build_options.debug_allocations and std.debug.sys_can_stack_trace) 10 else 0,
|
|
16
|
+
.resize_stack_traces = build_options.debug_allocations,
|
|
15
17
|
// A unique value so that when a default-constructed
|
|
16
|
-
//
|
|
18
|
+
// GeneralPurposeAllocator is incorrectly passed to testing allocator, or
|
|
17
19
|
// vice versa, panic occurs.
|
|
18
20
|
.canary = @truncate(0xc647026dc6875134),
|
|
19
21
|
}) = .{};
|
|
20
22
|
|
|
21
|
-
pub fn main(init:
|
|
23
|
+
pub fn main(init: process.Init.Minimal) u8 {
|
|
22
24
|
const gpa = if (@import("builtin").link_libc)
|
|
23
25
|
std.heap.c_allocator
|
|
24
26
|
else
|
|
@@ -31,7 +33,10 @@ pub fn main(init: std.process.Init.Minimal) u8 {
|
|
|
31
33
|
defer arena_instance.deinit();
|
|
32
34
|
const arena = arena_instance.allocator();
|
|
33
35
|
|
|
34
|
-
var threaded: std.Io.Threaded = .init(gpa, .{
|
|
36
|
+
var threaded: std.Io.Threaded = .init(gpa, .{
|
|
37
|
+
.argv0 = .init(init.args),
|
|
38
|
+
.environ = init.environ,
|
|
39
|
+
});
|
|
35
40
|
defer threaded.deinit();
|
|
36
41
|
const io = threaded.io();
|
|
37
42
|
|
|
@@ -43,7 +48,11 @@ pub fn main(init: std.process.Init.Minimal) u8 {
|
|
|
43
48
|
return 1;
|
|
44
49
|
};
|
|
45
50
|
|
|
46
|
-
|
|
51
|
+
var environ_map = std.process.Environ.createMap(init.environ, gpa) catch |err|
|
|
52
|
+
std.process.fatal("failed to parse environment variables: {t}", .{err});
|
|
53
|
+
defer environ_map.deinit();
|
|
54
|
+
|
|
55
|
+
const aro_name = std.process.executableDirPathAlloc(io, gpa) catch {
|
|
47
56
|
std.debug.print("unable to find Aro executable path\n", .{});
|
|
48
57
|
if (fast_exit) process.exit(1);
|
|
49
58
|
return 1;
|
|
@@ -51,15 +60,21 @@ pub fn main(init: std.process.Init.Minimal) u8 {
|
|
|
51
60
|
defer gpa.free(aro_name);
|
|
52
61
|
|
|
53
62
|
var stderr_buf: [1024]u8 = undefined;
|
|
54
|
-
var stderr = Io.File.stderr().writer(&stderr_buf);
|
|
63
|
+
var stderr = std.Io.File.stderr().writer(io, &stderr_buf);
|
|
55
64
|
var diagnostics: Diagnostics = .{
|
|
56
65
|
.output = .{ .to_writer = .{
|
|
57
|
-
.
|
|
66
|
+
.mode = std.Io.Terminal.Mode.detect(io, stderr.file, false, false) catch .no_color,
|
|
58
67
|
.writer = &stderr.interface,
|
|
59
68
|
} },
|
|
60
69
|
};
|
|
61
70
|
|
|
62
|
-
var comp = Compilation.
|
|
71
|
+
var comp = Compilation.init(.{
|
|
72
|
+
.gpa = gpa,
|
|
73
|
+
.arena = arena,
|
|
74
|
+
.io = io,
|
|
75
|
+
.diagnostics = &diagnostics,
|
|
76
|
+
.environ_map = &environ_map,
|
|
77
|
+
}) catch |er| switch (er) {
|
|
63
78
|
error.OutOfMemory => {
|
|
64
79
|
std.debug.print("out of memory\n", .{});
|
|
65
80
|
if (fast_exit) process.exit(1);
|
|
@@ -85,6 +100,7 @@ pub fn main(init: std.process.Init.Minimal) u8 {
|
|
|
85
100
|
if (fast_exit) process.exit(1);
|
|
86
101
|
return 1;
|
|
87
102
|
},
|
|
103
|
+
error.Canceled => unreachable,
|
|
88
104
|
};
|
|
89
105
|
if (fast_exit) process.exit(@intFromBool(comp.diagnostics.errors != 0));
|
|
90
106
|
return @intFromBool(diagnostics.errors != 0);
|
|
@@ -424,6 +424,7 @@ pub fn main(init: process.Init.Minimal) !void {
|
|
|
424
424
|
fatal("unable to parse jobs count '{s}': {t}", .{ text, err });
|
|
425
425
|
if (n < 1) fatal("number of jobs must be at least 1", .{});
|
|
426
426
|
threaded.setAsyncLimit(.limited(n));
|
|
427
|
+
graph.max_jobs = n;
|
|
427
428
|
} else if (mem.eql(u8, arg, "--")) {
|
|
428
429
|
builder.args = argsRest(args, arg_idx);
|
|
429
430
|
break;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
const std = @import("std");
|
|
2
|
+
const Io = std.Io;
|
|
3
|
+
const fatal = std.process.fatal;
|
|
4
|
+
const mem = std.mem;
|
|
5
|
+
const assert = std.debug.assert;
|
|
6
|
+
|
|
7
|
+
var stdout_buffer: [4000]u8 = undefined;
|
|
8
|
+
|
|
9
|
+
pub fn main(init: std.process.Init) !void {
|
|
10
|
+
const io = init.io;
|
|
11
|
+
const args = try init.minimal.args.toSlice(init.arena.allocator());
|
|
12
|
+
|
|
13
|
+
var opt_input_path: ?[]const u8 = null;
|
|
14
|
+
var i: usize = 1;
|
|
15
|
+
while (i < args.len) : (i += 1) {
|
|
16
|
+
const arg = args[i];
|
|
17
|
+
if (mem.startsWith(u8, arg, "-")) {
|
|
18
|
+
if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) {
|
|
19
|
+
return Io.File.stdout().writeStreamingAll(io, usage);
|
|
20
|
+
} else {
|
|
21
|
+
fatal("unrecognized argument: {s}", .{arg});
|
|
22
|
+
}
|
|
23
|
+
} else if (opt_input_path == null) {
|
|
24
|
+
opt_input_path = arg;
|
|
25
|
+
} else {
|
|
26
|
+
fatal("unexpected positional: {s}", .{arg});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const input_path = opt_input_path orelse fatal("missing input file path positional argument", .{});
|
|
31
|
+
|
|
32
|
+
var file = std.Io.Dir.cwd().openFile(io, input_path, .{}) catch |err|
|
|
33
|
+
fatal("failed to open {s}: {t}", .{ input_path, err });
|
|
34
|
+
defer file.close(io);
|
|
35
|
+
|
|
36
|
+
var buffer: [4000]u8 = undefined;
|
|
37
|
+
var file_reader = file.reader(io, &buffer);
|
|
38
|
+
var stdout_writer = std.Io.File.stdout().writerStreaming(io, &stdout_buffer);
|
|
39
|
+
dump(&file_reader.interface, &stdout_writer.interface) catch |err| switch (err) {
|
|
40
|
+
error.ReadFailed => return file_reader.err.?,
|
|
41
|
+
error.WriteFailed => return stdout_writer.err.?,
|
|
42
|
+
error.UnknownFile => fatal("unrecognized file: {s}", .{input_path}),
|
|
43
|
+
else => |e| return e,
|
|
44
|
+
};
|
|
45
|
+
try stdout_writer.flush();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
fn dump(r: *Io.Reader, w: *Io.Writer) !void {
|
|
49
|
+
try r.fill(4);
|
|
50
|
+
elf: {
|
|
51
|
+
if (!mem.eql(u8, r.buffered()[0..4], std.elf.MAGIC)) break :elf;
|
|
52
|
+
return elf.dump(r, w);
|
|
53
|
+
}
|
|
54
|
+
macho: {
|
|
55
|
+
if (mem.readInt(u32, r.buffered()[0..4], .little) != std.macho.MH_MAGIC_64) break :macho;
|
|
56
|
+
return macho.dump(r, w);
|
|
57
|
+
}
|
|
58
|
+
wasm: {
|
|
59
|
+
comptime assert(std.wasm.magic.len == 4);
|
|
60
|
+
if (!mem.eql(u8, r.buffered()[0..4], &std.wasm.magic)) break :wasm;
|
|
61
|
+
return wasm.dump(r, w);
|
|
62
|
+
}
|
|
63
|
+
return error.UnknownFile;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const elf = struct {
|
|
67
|
+
fn dump(r: *Io.Reader, w: *Io.Writer) !void {
|
|
68
|
+
_ = r;
|
|
69
|
+
try w.writeAll("TODO dump elf file\n");
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const macho = struct {
|
|
74
|
+
fn dump(r: *Io.Reader, w: *Io.Writer) !void {
|
|
75
|
+
_ = r;
|
|
76
|
+
try w.writeAll("TODO dump macho file\n");
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const wasm = struct {
|
|
81
|
+
fn dump(r: *Io.Reader, w: *Io.Writer) !void {
|
|
82
|
+
_ = r;
|
|
83
|
+
try w.writeAll("TODO dump wasm file\n");
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const usage =
|
|
88
|
+
\\Usage: zig objdump [options] file
|
|
89
|
+
\\
|
|
90
|
+
\\Options:
|
|
91
|
+
\\ -h, --help Print this help and exit
|
|
92
|
+
\\
|
|
93
|
+
;
|
package/compiler/reduce.zig
CHANGED
|
@@ -291,7 +291,11 @@ fn termToInteresting(term: std.process.Child.Term) Interestingness {
|
|
|
291
291
|
std.debug.print("interestingness check terminated with signal {t}\n", .{sig});
|
|
292
292
|
return .boring;
|
|
293
293
|
},
|
|
294
|
-
|
|
294
|
+
.stopped => |sig| {
|
|
295
|
+
std.debug.print("interestingness check stopped with signal {t}\n", .{sig});
|
|
296
|
+
return .boring;
|
|
297
|
+
},
|
|
298
|
+
.unknown => {
|
|
295
299
|
std.debug.print("interestingness check aborted unexpectedly\n", .{});
|
|
296
300
|
return .boring;
|
|
297
301
|
},
|
|
@@ -2746,7 +2746,7 @@ pub const Compiler = struct {
|
|
|
2746
2746
|
// 1. Any permutation that does not have PRELOAD in it just uses the
|
|
2747
2747
|
// default flags.
|
|
2748
2748
|
const initial_flags = flags.*;
|
|
2749
|
-
var flags_set = std.enums.EnumSet(rc.CommonResourceAttributes).
|
|
2749
|
+
var flags_set = std.enums.EnumSet(rc.CommonResourceAttributes).empty;
|
|
2750
2750
|
for (tokens) |token| {
|
|
2751
2751
|
const attribute = rc.CommonResourceAttributes.map.get(token.slice(source)).?;
|
|
2752
2752
|
flags_set.insert(attribute);
|
|
@@ -2769,7 +2769,7 @@ pub const Compiler = struct {
|
|
|
2769
2769
|
// 3. If none of DISCARDABLE, SHARED, or PURE is specified, then PRELOAD
|
|
2770
2770
|
// implies `flags &= ~SHARED` and LOADONCALL implies `flags |= SHARED`
|
|
2771
2771
|
const shared_set = comptime blk: {
|
|
2772
|
-
var set = std.enums.EnumSet(rc.CommonResourceAttributes).
|
|
2772
|
+
var set = std.enums.EnumSet(rc.CommonResourceAttributes).empty;
|
|
2773
2773
|
set.insert(.discardable);
|
|
2774
2774
|
set.insert(.shared);
|
|
2775
2775
|
set.insert(.pure);
|