0
Fork 0
mirror of https://codeberg.org/ziglang/zig synced 2026-11-18 07:05:05 +00:00
zig/lib/std
Andrew Kelley 482b995a49 stage2: blaze the trail for std lib integration
This branch adds "builtin" and "std" to the import table when using the
self-hosted backend.

"builtin" gains one additional item:

```
pub const zig_is_stage2 = true; // false when using stage1 backend
```

This allows the std lib to do conditional compilation based on detecting
which backend is being used. This will be removed from builtin as soon
as self-hosted catches up to feature parity with stage1.
Keep a sharp eye out - people are going to be tempted to abuse this.
The general rule of thumb is do not use `builtin.zig_is_stage2`. However
this commit breaks the rule so that we can gain limited start.zig support
as we incrementally improve the self-hosted compiler.

This commit also implements `fullyQualifiedNameHash` and related
functionality, which effectively puts all Decls in their proper
namespaces. `fullyQualifiedName` is not yet implemented.

Stop printing "todo" log messages for test decls unless we are in test
mode.

Add "previous definition here" error notes for Decl name collisions.

This commit does not bring us yet to a newly passing test case.

Here's what I'm working towards:

```zig
const std = @import("std");

export fn main() c_int {
    const a = std.fs.base64_alphabet[0];
    return a - 'A';
}
```

Current output:

```
$ ./zig-cache/bin/zig build-exe test.zig
test.zig:3:1: error: TODO implement more analyze elemptr
zig-cache/lib/zig/std/start.zig:38:46: error: TODO implement structInitExpr ty
```

So the next steps are clear:
 * Sema: improve elemptr
 * AstGen: implement structInitExpr
History 2021-04-08 19:05:05 -07:00
..
atomic std: Swap arguments in Thread.spawn 2021-02-28 14:03:19 +01:00
build Merge pull request #7763 from kivikakk/zig-elf-parse 2021-03-04 11:56:31 -08:00
c netbsd: minor fixes to allow stage1 to build 2021-04-07 16:26:21 -07:00
compress Convert inline fn to callconv(.Inline) everywhere 2021-02-10 20:06:12 -07:00
crypto std/crypto/chacha20: add round-reduced versions & cleanup internals 2021-03-17 11:25:51 -07:00
event std: Swap arguments in Thread.spawn 2021-02-28 14:03:19 +01:00
fmt Reject bare +/- input when parsing floats 2021-03-05 13:11:20 +01:00
fs Fixed error types for GetSeekPosError 2021-04-04 17:04:46 -07:00
hash Specify type in autoHash error message 2021-03-21 23:07:02 +02:00
heap std.GeneralPurposeAllocator: logging improvements 2021-01-30 20:15:26 -07:00
io Fixed error types for GetSeekPosError 2021-04-04 17:04:46 -07:00
json Tidy-up in json test module (#8431) 2021-04-04 19:27:47 -04:00
math Compile error for signed integer math 2021-04-03 13:09:20 +02:00
mem std: Clear old memory on free 2021-02-25 22:20:30 +02:00
meta Add some enum utilities 2021-03-18 14:05:01 -07:00
net std: Swap arguments in Thread.spawn 2021-02-28 14:03:19 +01:00
os netbsd: minor fixes to allow stage1 to build 2021-04-07 16:26:21 -07:00
rand Add tests for the fill functions of the Isaac64, Pcg, Sfc64, and Xoroshiro128 PRNGs 2021-03-29 09:22:06 +02:00
special std docs: enhance search browser history UX 2021-04-04 16:25:47 -07:00
target target: map zig ppc32 → llvm ppc 2021-02-04 14:22:38 -08:00
testing Year++ 2020-12-31 15:45:24 -08:00
Thread std: Swap arguments in Thread.spawn 2021-02-28 14:03:19 +01:00
time Year++ 2020-12-31 15:45:24 -08:00
unicode Reduce use of deprecated IO types 2021-01-07 23:48:58 -08:00
valgrind Year++ 2020-12-31 15:45:24 -08:00
zig std: modernize zig parser perf test 2021-04-06 22:34:48 -07:00
array_hash_map.zig array_hash_map: decrement entries slice len after popping from entries in pop() to prevent oob 2021-03-28 11:02:37 +02:00
array_list.zig Remove deprecated stream aliases 2021-01-08 16:54:56 -05:00
ascii.zig std.ascii: add lessThanIgnoreCase and orderIgnoreCase 2021-02-27 01:21:01 -07:00
atomic.zig Year++ 2020-12-31 15:45:24 -08:00
base64.zig Remove the base64 unsafe decoder 2021-03-28 14:32:34 +02:00
bit_set.zig Add some enum utilities 2021-03-18 14:05:01 -07:00
buf_map.zig Year++ 2020-12-31 15:45:24 -08:00
buf_set.zig HashMap.put returns !void, not a !bool 2021-02-27 13:11:47 +02:00
build.zig std/build: fix ?[:0]const u8 build options 2021-04-06 11:09:54 -07:00
builtin.zig stage1: switch from inline fn to callconv(.Inline) 2021-02-10 20:06:13 -07:00
c.zig std: support optional getaddrinfo arguments 2021-03-16 01:10:32 +01:00
child_process.zig Reduce use of deprecated IO types 2021-01-07 23:48:58 -08:00
coff.zig zig fmt the std lib 2021-02-24 21:29:23 -07:00
compress.zig std: Update test "" to test where it makes sense 2021-01-22 15:46:58 +01:00
comptime_string_map.zig Year++ 2020-12-31 15:45:24 -08:00
crypto.zig std/crypto/chacha20: add round-reduced versions & cleanup internals 2021-03-17 11:25:51 -07:00
cstr.zig Year++ 2020-12-31 15:45:24 -08:00
debug.zig zld: use zld when linking aarch64 by default and cross-comp 2021-03-18 00:37:13 +01:00
dwarf.zig zig fmt the std lib 2021-02-24 21:29:23 -07:00
dwarf_bits.zig Year++ 2020-12-31 15:45:24 -08:00
dynamic_library.zig Year++ 2020-12-31 15:45:24 -08:00
elf.zig elf: make EM non-exhaustive 2021-03-11 10:09:51 +11:00
enums.zig stage2: make zir.Inst.Ref a non-exhaustive enum 2021-03-24 19:11:44 +01:00
event.zig Year++ 2020-12-31 15:45:24 -08:00
fifo.zig std.fifo.LinearFifo - Expose reader and writer type. 2021-02-22 00:22:46 +02:00
fmt.zig Add a test & fix for std.fmt.fmtDuration 2021-03-28 15:44:15 +02:00
fs.zig std/base64: cleanups & support url-safe and other non-padded variants 2021-03-28 14:32:34 +02:00
hash.zig Year++ 2020-12-31 15:45:24 -08:00
hash_map.zig stage2 cbe: non pointer optionals 2021-03-08 00:33:56 +02:00
heap.zig Year++ 2020-12-31 15:45:24 -08:00
io.zig std: remove io.AutoIndentingStream 2021-02-16 23:20:46 +01:00
json.zig Switch std.json to use an ordered hashmap 2021-04-04 10:16:59 +02:00
leb128.zig Year++ 2020-12-31 15:45:24 -08:00
linked_list.zig Fix off-by-one error in SinglyLinkedList.len() and add associated tests 2021-01-04 14:03:21 -08:00
log.zig zig fmt the std lib 2021-02-24 21:29:23 -07:00
macho.zig zld: fix GOT loads and indirection on x86_64 2021-03-17 19:59:57 +01:00
math.zig zig fmt the std lib 2021-03-01 20:04:28 -07:00
mem.zig std: Add reset to TokenIterator 2021-03-20 22:01:09 -07:00
meta.zig translate-c: fix meta.cast to ?*c_void 2021-04-08 08:33:26 +03:00
multi_array_list.zig std: Handle empty MultiArrayList in items() 2021-03-12 00:17:35 +01:00
net.zig replace ArrayList.shrinkAndFree by ArrayList.shrinkRetainingCapacity 2021-02-21 11:56:14 +02:00
once.zig std: Swap arguments in Thread.spawn 2021-02-28 14:03:19 +01:00
os.zig os/linux: return error on EALREADY for connect() and getsockoptError() 2021-04-06 11:30:20 +02:00
packed_int_array.zig Add workaround in PackedIntArray .initAllTo for #7635 2021-01-02 01:10:47 +11:00
pdb.zig Don't read more bytes than exist in MsfStream (#7839) 2021-02-01 15:27:39 -05:00
priority_dequeue.zig Change compareFn to fn (a: T, b: T) std.math.Order 2021-01-18 19:02:11 +00:00
priority_queue.zig Merge pull request #7792 from zanderxyz/zanderxyz/priority-dequeue 2021-04-02 10:52:23 -07:00
process.zig initial support for haiku continue clean up 2021-02-25 16:41:42 -07:00
Progress.zig std: Use more common escape sequences in Progress 2021-03-12 19:31:59 -05:00
rand.zig std: Update test "" to test where it makes sense 2021-01-22 15:46:58 +01:00
SemanticVersion.zig Move fmt.testFmt to testing.expectFmt 2021-01-12 18:13:29 -08:00
sort.zig Fix example code in comments for asc and desc 2021-01-06 15:53:53 -08:00
start.zig stage2: blaze the trail for std lib integration 2021-04-08 19:05:05 -07:00
start_windows_tls.zig Year++ 2020-12-31 15:45:24 -08:00
std.zig stage2: blaze the trail for std lib integration 2021-04-08 19:05:05 -07:00
target.zig stage2: Default AVR generic cpu to avr2 2021-04-06 10:18:11 -07:00
testing.zig std/base64: cleanups & support url-safe and other non-padded variants 2021-03-28 14:32:34 +02:00
Thread.zig make std.c.getErrno() return same type as _errno() aka c_int 2021-03-12 15:04:36 +01:00
time.zig test: fix std.time timing tests to skip on failure 2021-04-07 08:33:32 -04:00
unicode.zig Year++ 2020-12-31 15:45:24 -08:00
valgrind.zig std: Update test "" to test where it makes sense 2021-01-22 15:46:58 +01:00
wasm.zig std/wasm: add buildOpcode to help construction of Opcodes 2021-04-05 14:44:00 +08:00
zig.zig stage2: blaze the trail for std lib integration 2021-04-08 19:05:05 -07:00