Commit graph

61 commits

Author SHA1 Message Date
Jacob Young
8293ff94cf InternPool: implement and use thread-safe list for strings 2024-07-07 22:59:52 -04:00
Tristan Ross
099f3c4039
std.builtin: make container layout fields lowercase 2024-03-11 07:09:07 -07:00
Jacob Young
b60fc16b4f compiler: audit debug mode checks
* Introduce `-Ddebug-extensions` for enabling compiler debug helpers
 * Replace safety mode checks with `std.debug.runtime_safety`
 * Replace debugger helper checks with `!builtin.strip_debug_info`

Sometimes, you just have to debug optimized compilers...
2024-03-01 17:42:54 -08:00
Carl Åstholm
85869f8225 Correct expected/actual parameter order of some assertions 2024-01-03 21:20:49 +01:00
Carl Åstholm
4c1da0912a Fix compile errors from the expectEqual change 2024-01-03 21:20:48 +01:00
Jacob Young
095c4294aa x86_64: fix miscompilations
Closes #17618
2023-11-04 09:15:05 -04:00
Jacob Young
fe93332ba2 x86_64: implement enough to pass unicode tests
* implement vector comparison
 * implement reduce for bool vectors
 * fix `@memcpy` bug
 * enable passing std tests
2023-10-23 22:42:18 -04:00
Jacob Young
27fe945a00 Revert "Revert "Merge pull request #17637 from jacobly0/x86_64-test-std""
This reverts commit 6f0198cadb.
2023-10-22 15:46:43 -04:00
Andrew Kelley
6f0198cadb Revert "Merge pull request #17637 from jacobly0/x86_64-test-std"
This reverts commit 0c99ba1eab, reversing
changes made to 5f92b070bf.

This caused a CI failure when it landed in master branch due to a
128-bit `@byteSwap` in std.mem.
2023-10-22 12:16:35 -07:00
Jacob Young
2e6e39a700 x86_64: fix bugs and disable erroring tests 2023-10-21 10:55:41 -04:00
Andrew Kelley
cbb9b5d9f0 std: add unstable sorting to array hash maps
closes #17426
2023-10-08 16:54:31 -07:00
Andrew Kelley
cc69315f03 std.MultiArrayList: add test coverage for 0-bit structs
closes #10618
solved by #17172
2023-09-24 15:49:56 -07:00
Niles Salter
e395a08e60
Add more sorting functions to MultiArrayList (#16377) 2023-07-11 06:37:51 +00:00
mlugg
f26dda2117 all: migrate code to new cast builtin syntax
Most of this migration was performed automatically with `zig fmt`. There
were a few exceptions which I had to manually fix:

* `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten
* `@truncate`'s fixup is incorrect for vectors
* Test cases are not formatted, and their error locations change
2023-06-24 16:56:39 -07:00
Eric Joldasov
50339f595a all: zig fmt and rename "@XToY" to "@YFromX"
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-19 12:34:42 -07:00
mlugg
4976b58ab1
Prevent analysis of functions only referenced at comptime
The idea here is that there are two ways we can reference a function at runtime:

* Through a direct call, i.e. where the function is comptime-known
* Through a function pointer

This means we can easily perform a form of rudimentary escape analysis
on functions. If we ever see a `decl_ref` or `ref` of a function, we
have a function pointer, which could "leak" into runtime code, so we
emit the function; but for a plain `decl_val`, there's no need to.

This change means that `comptime { _ = f; }` no longer forces a function
to be emitted, which was used for some things (mainly tests). These use
sites have been replaced with `_ = &f;`, which still triggers analysis
of the function body, since you're taking a pointer to the function.

Resolves: #6256
Resolves: #15353
2023-05-29 23:06:08 +01:00
Ali Chraghi
3db3cf7790 std.sort: add pdqsort and heapsort 2023-05-23 17:55:59 -07:00
Andrew Kelley
6261c13731 update codebase to use @memset and @memcpy 2023-04-28 13:24:43 -07:00
Andrew Kelley
a5c910adb6 change semantics of @memcpy and @memset
Now they use slices or array pointers with any element type instead of
requiring byte pointers.

This is a breaking enhancement to the language.

The safety check for overlapping pointers will be implemented in a
future commit.

closes #14040
2023-04-25 11:23:40 -07:00
Bogdan Romanyuk
397649fb09 Removing duplicate word in doc 2023-04-16 22:10:48 +03:00
GethDW
2c639d6570 std.MultiArrayList: add support for tagged unions. 2023-04-10 12:15:05 -04:00
Jacob Young
0e5e001278 std.MultiArrayList: add set and get to Slice 2023-03-27 05:58:00 -04:00
Jacob Young
c29c4c6f70 tools: add lldb pretty printer for std.MultiArrayList.Slice 2023-03-06 05:58:46 -05:00
Jacob Young
a3529c2dea tools: implement more lldb pretty printers 2023-02-27 05:37:03 -05:00
Jacob Young
828ac637b2 MultiArrayList: delete pessimizing vector usage
By factoring out the comptime parts of this computation, vectors are no
longer useful in this function.
2023-02-21 00:27:12 -05:00
Andrew Kelley
aeaef8c0ff update std lib and compiler sources to new for loop syntax 2023-02-18 19:17:21 -07:00
r00ster91
aac2d6b56f std.builtin: rename Type.UnionField and Type.StructField's field_type to type 2022-12-17 14:11:33 +01:00
Andrew Kelley
50eb7983cd remove most conditional compilation based on stage1
There are still a few occurrences of "stage1" in the standard library
and self-hosted compiler source, however, these instances need a bit
more careful inspection to ensure no breakage.
2022-12-06 20:38:54 -07:00
Andrew Kelley
ceb0a632cf std.mem.Allocator: allow shrink to fail
closes #13535
2022-11-29 23:30:38 -07:00
Jacob Young
93d60d0de7 std: avoid vector usage with the C backend
Vectors are not yet implemented in the C backend, so no reason to
prevent code using the standard library from compiling in the meantime.
2022-11-01 20:38:37 -04:00
Andrew Kelley
d3d24874c9 std: remove deprecated API for the upcoming release
See #3811
2022-09-16 14:46:53 -04:00
Andrew Kelley
68f2d6cb24 std: remove workaround for fixed bug
The miscompilation in question has been fixed upstream in LLVM 13.

closes #8117
2022-09-13 18:20:18 -07:00
antlilja
ae8d26a6a0 Sema: add error for non-comptime param in comptime func
Adds error for taking a non comptime parameter in a function returning a
comptime-only type but not when that type is dependent on a parameter.

Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-08-27 11:17:48 +03:00
InKryption
609896a6e8
std.MultiArrayList: add functions addOne, pop, and popOrNull (#11553)
Update basic usage test to account for these, and by extension for addOneAssumeCapacity.
2022-04-29 22:51:53 -04:00
Andrew Kelley
b802a67562 std.MultiArrayList: check size of element, not pointer
Ever since a semi-recent language specification update, pointers to
zero-sized types still have runtime bits.
2022-03-24 19:55:12 -07:00
Robin Voetter
feb8981a95 gdb: add slice, multi array list, and array hash map printers 2022-03-16 15:50:03 +01:00
Andrew Kelley
d42d31f72f basic language features do not belong in std.meta 2022-03-14 00:11:46 -07:00
Andrew Kelley
6e49ba77f3 std: add sort method to ArrayHashMap and MultiArrayList
This also adds `std.sort.sortContext` and
`std.sort.insertionSortContext` which are more advanced methods that
allow overriding the `swap` method. The former calls the latter for now
because reworking the main sort implementation is a big task that can be
done later without any changes to the API.
2022-03-10 13:13:17 -05:00
Andrew Kelley
913d61ebb9 Revert "MultiArrayList: Fix error when struct is 0 sized"
This reverts commit 1f10cf4edf.

Re-opens #10618

I want to solve this a different way. `align(S)` where S is a 0-byte
type should work in this context.

This also caused issues such as
https://github.com/Vexu/arocc/issues/221
2022-01-24 21:29:04 -07:00
riverbl
1f10cf4edf
MultiArrayList: Fix error when struct is 0 sized
Also fixes error with ArrayHashMap when both key and value are 0 sized
2022-01-24 17:31:27 +02:00
Jakub Konka
90343d1868 libstd: add smoke test for insert methods in MultiArrayList 2022-01-17 12:26:48 +01:00
Jarred Sumner
144e36770e
Fix missing !void in std.MultiArrayList
Calling `insert` on a `std.MultiArrayList` currently fails with a compiler error due to using a `try` without the `!` annotation on the return type

```zig
this.list.insert(allocator, 0, listener);
```

```zig
/Users/jarred/Build/zig/lib/std/multi_array_list.zig:192:13: error: expected type 'void', found '@typeInfo(@typeInfo(@TypeOf(std.multi_array_list.MultiArrayList(src.javascript.jsc.node.types.Listener).ensureUnusedCapacity)).Fn.return_type.?).ErrorUnion.error_set'
            try self.ensureUnusedCapacity(gpa, 1);
```
2022-01-16 17:26:49 -08:00
Lee Cannon
85de022c56
allocgate: std Allocator interface refactor 2021-11-30 23:32:47 +00:00
Andrew Kelley
902df103c6 std lib API deprecations for the upcoming 0.9.0 release
See #3811
2021-11-30 00:13:07 -07:00
Jonathan Marler
ad5b90ab10 multi_array_list: get function take self by value 2021-10-26 18:55:02 -04:00
Ryan Liptak
59f5053bed Update all ensureCapacity calls to the relevant non-deprecated version 2021-09-19 13:52:56 +02:00
Andrew Kelley
d29871977f remove redundant license headers from zig standard library
We already have a LICENSE file that covers the Zig Standard Library. We
no longer need to remind everyone that the license is MIT in every single
file.

Previously this was introduced to clarify the situation for a fork of
Zig that made Zig's LICENSE file harder to find, and replaced it with
their own license that required annual payments to their company.
However that fork now appears to be dead. So there is no need to
reinforce the copyright notice in every single file.
2021-08-24 12:25:09 -07:00
Jacob G-W
9fffffb07b fix code broken from previous commit 2021-06-21 17:03:03 -07:00
Andrew Kelley
138afd5cbf zig fmt 2021-06-10 20:13:43 -07:00
Martin Wickham
fc9430f567 Breaking hash map changes for 0.8.0
- hash/eql functions moved into a Context object
- *Context functions pass an explicit context
- *Adapted functions pass specialized keys and contexts
- new getPtr() function returns a pointer to value
- remove functions renamed to fetchRemove
- new remove functions return bool
- removeAssertDiscard deleted, use assert(remove(...)) instead
- Keys and values are stored in separate arrays
- Entry is now {*K, *V}, the new KV is {K, V}
- BufSet/BufMap functions renamed to match other set/map types
- fixed iterating-while-modifying bug in src/link/C.zig
2021-06-03 17:02:16 -05:00