Commit Graph

8464 Commits

Author SHA1 Message Date
Krzysztof Wolicki
2651363c9d
autodoc: Implement various missing expressions in ex (#17129)
Co-authored-by: Loris Cro <kappaloris@gmail.com>
2023-09-16 17:38:06 +02:00
Krzysztof Wolicki
f2026e7dd6 autodoc: Implement builtin function rendering.
Implement unary ops handling.
Fix getType in main.js
Minor cleanup of builtin function handling.
2023-09-16 17:35:11 +02:00
Krzysztof Wolicki
9a326b22d5 autodoc: Fix styling of the navbar 2023-09-16 17:31:43 +02:00
Krzysztof Wolicki
da28379d6c autodoc: Remove unnecessary Expr tag 2023-09-16 17:30:49 +02:00
Krzysztof Wolicki
8a9aa9e112 autodoc: Handle ref ZIR instruction 2023-09-16 17:30:49 +02:00
Andrew Kelley
61b70778bd
Merge pull request #17156 from mlugg/destructure
compiler: implement destructuring syntax
2023-09-15 14:51:52 -07:00
mlugg
94529ffb62 package manager: write deps in a flat format, eliminating the FQN concept
The new `@depedencies` module contains generated code like the
following (where strings like "abc123" represent hashes):

```zig
pub const root_deps = [_]struct { []const u8, []const u8 }{
    .{ "foo", "abc123" },
};

pub const packages = struct {
    pub const abc123 = struct {
        pub const build_root = "/home/mlugg/.cache/zig/blah/abc123";
        pub const build_zig = @import("abc123");
        pub const deps = [_]struct { []const u8, []const u8 }{
            .{ "bar", "abc123" },
            .{ "name", "ghi789" },
        };
    };
};
```

Each package contains a build root string, the build.zig import, and a
mapping from dependency names to package hashes. There is also such a
mapping for the root package dependencies.

In theory, we could now remove the `dep_prefix` field from `std.Build`,
since its main purpose is now handled differently. I believe this is a
desirable goal, as it doesn't really make sense to assign a single FQN
to any package (because it may appear in many different places in the
package hierarchy). This commit does not remove that field, as it's used
non-trivially in a few places in the build runner and compiler tests:
this will be a future enhancement.

Resolves: #16354
Resolves: #17135
2023-09-15 14:04:23 -07:00
mlugg
88f5315ddf compiler: implement destructuring syntax
This change implements the following syntax into the compiler:

```zig
const x: u32, var y, foo.bar = .{ 1, 2, 3 };
```

A destructure expression may only appear within a block (i.e. not at
comtainer scope). The LHS consists of a sequence of comma-separated var
decls and/or lvalue expressions. The RHS is a normal expression.

A new result location type, `destructure`, is used, which contains
result pointers for each component of the destructure. This means that
when the RHS is a more complicated expression, peer type resolution is
not used: each result value is individually destructured and written to
the result pointers. RLS is always used for destructure expressions,
meaning every `const` on the LHS of such an expression creates a true
stack allocation.

Aside from anonymous array literals, Sema is capable of destructuring
the following types:
* Tuples
* Arrays
* Vectors

A destructure may be prefixed with the `comptime` keyword, in which case
the entire destructure is evaluated at comptime: this means all `var`s
in the LHS are `comptime var`s, every lvalue expression is evaluated at
comptime, and the RHS is evaluated at comptime. If every LHS is a
`const`, this is not allowed: as with single declarations, the user
should instead mark the RHS as `comptime`.

There are a few subtleties in the grammar changes here. For one thing,
if every LHS is an lvalue expression (rather than a var decl), a
destructure is considered an expression. This makes, for instance,
`if (cond) x, y = .{ 1, 2 };` valid Zig code. A destructure is allowed
in almost every context where a standard assignment expression is
permitted. The exception is `switch` prongs, which cannot be
destructures as the comma is ambiguous with the end of the prong.

A follow-up commit will begin utilizing this syntax in the Zig compiler.

Resolves: #498
2023-09-15 11:33:53 -07:00
bfredl
1a0e6bcdb1 bpf: remove unhelpful "comptime" and fix union order
Insn.st() can be used with dynamic size just like Insn.stx(), which is
relevant in a code generation context.

using ImmOrReg caused an error as its fields were ordered differently than
Source.
2023-09-15 01:05:52 -07:00
Federico Stra
4f952c7e0e
std.math.log_int: implement integer logarithm without using float math 2023-09-14 19:33:56 +00:00
Ryan Liptak
c9613e3d5c ComptimeStringMap: Add version that takes an equality function
This will allow users to construct e.g. a ComptimeStringMap that uses case-insensitive ASCII comparison.

Note: the previous ComptimeStringMap API is unchanged (i.e. this does not break any existing code).
2023-09-14 11:03:15 -07:00
Rafael Fernández López
69982339ed std: add compile error when using std.os.getenv on the wasi target
`std.process.getEnvMap` or `std.process.getEnvVarOwned` should be used
instead, requiring allocation.
2023-09-14 20:04:35 +03:00
Ryan Liptak
742030a8f2 fs tests: Skip UNC path types in Dir.rename tests
Follow up to https://github.com/ziglang/zig/pull/17136. The `Dir.rename files` test has now also been seen to fail in CI, so now all rename tests are skipped for the UNC path type. This is a heavy handed approach to hopefully get rid of any flakiness related to rename & UNC paths. See https://github.com/ziglang/zig/issues/17134
2023-09-14 16:30:41 +03:00
Jonathan Marler
223f62acbd
std.json: add fmt function (#17055)
Adds std.json.fmt which returns a std.fmt Formatter that formats any
given value using std.json.stringify.
2023-09-13 18:24:59 -04:00
Andrew Kelley
0e2f002a7b
Merge pull request #17046 from tiehuis/improve-hash-tests
improve std/hash test coverage
2023-09-13 18:22:56 -04:00
Pascal S. de Kloe
4a44b79935 mem: explicit Allocator.Error on concat and join 2023-09-13 13:52:05 +03:00
Ryan Liptak
89ea67aee2 Disable flaky part of Dir.rename directories test on Windows
See https://github.com/ziglang/zig/issues/17134
2023-09-13 03:46:00 -04:00
Lucas Culverhouse
5b7eefce46
std.math.cbrt: fixed -0.0 evaluating to 0.0 2023-09-12 18:39:34 +00:00
Ruben Dimas
402468b210 std.math.asinh: changed unsigned int to hexadecimal 2023-09-12 22:22:07 +12:00
Ruben Dimas
a8a4f1755e std.math.asinh: fixed -0.0 evaluating to 0.0 2023-09-12 22:22:07 +12:00
Techatrix
7827265ea8
json: respect max_value_len when parsing std.json.Value (#17107) 2023-09-11 17:00:06 -04:00
Ian Johnson
d2014fe971 Autodoc: simplify search text on mobile
This prevents the placeholder text from spilling out of the search bar
on smaller screens.
2023-09-09 19:48:18 +02:00
Ian Johnson
51d7700c8c Autodoc: tweak page layout
Closes #17011
Closes #17012

This commit allows the logo to scale more freely to fit its container,
and removes some extra margins so that the content scroll bar is flush
with the right side of the viewport.
2023-09-09 19:48:18 +02:00
Ian Johnson
2f26b15995 Autodoc: fix search results navigation
Closes #17013
2023-09-09 19:47:57 +02:00
Wooster
f33bb0228b
std: clean up top-level namespaces documentation
This cleans up existing documentation, adds a bit more, and fixes some
typos too.
2023-09-08 21:59:25 +03:00
none
39a98dc426 std.tar: add support for file path in pax attributes
Handles .extended_header type to parse PAX attributes and check if they override
the path of the next file. Increases file path limit to std.fs.MAX_PATH_BYTES.

Fixes #15342
2023-09-08 21:55:14 +03:00
xdBronch
fa46750a84 remove outdated error message in std.fs 2023-09-08 21:47:44 +03:00
Linus Groh
c097209792 std.c.linux: Add getpw{nam,uid}() 2023-09-08 21:46:05 +03:00
Pascal S. de Kloe
9126852ba9 mem: explicit dupe and dupeZ error on Allocator 2023-09-07 21:56:57 +03:00
Gregory Anders
cab9da35bd std: enable FailingAllocator to fail on resize
Now that allocator.resize() is allowed to fail, programs may wish to
test code paths that handle resize() failure. The simplest way to do
this now is to replace the vtable of the testing allocator with one
that uses Allocator.noResize for the 'resize' function pointer.

An alternative way to support this testing capability is to augment the
FailingAllocator (which is already useful for testing allocation failure
scenarios) to intentionally fail on calls to resize(). To do this, add a
'resize_fail_index' parameter to the FailingAllocator that causes
resize() to fail after the given number of calls.
2023-09-06 19:06:32 +03:00
Luis Cáceres
8976ad7ecb std.net: Fix IPv6 address parsing for single digit
This fixes the case where IPv6 address parsing incorrectly succeeded on
input such as `1`, which now returns error.Incomplete.
2023-09-06 11:14:24 +03:00
Loris Cro
fda087ed81 autodoc: style links in source code 2023-09-04 18:56:45 +02:00
Jakub Konka
0e8f130aed
Merge pull request #16977 from kcbanner/lib_getauxval_fixup
linux: export getauxval when not compiling with libc
2023-09-04 09:11:15 +02:00
Jim Calabro
ec5a068ac1
Make a Couple Syscall Comments Consistent (#17066)
* Make a Couple Syscall Comments Consistent

* linux.diet.net -> man7.org
2023-09-04 09:09:11 +02:00
Krzysztof Wolicki
5cc1831ca4
autodoc: Fix rendering of enum types (#17058) 2023-09-03 18:34:29 +02:00
Loris Cro
e5c72a32a7 autodoc: fix rendering of std.json.ObjectMap
closes #17014
supersedes #17022
follow up issue #17061
2023-09-03 18:32:26 +02:00
Krzysztof Wolicki
555028086a
autodoc: Implement @call, @unionInit, @mulAdd support (#16918)
* autodoc: Implement `@call`, `@unionInit`, `@mulAdd` support

* autodoc: Implement builtinIndex in ex
2023-09-03 17:20:23 +02:00
Krzysztof Wolicki
86a9e1deaf
autodoc: Implement @bitSizeOf rendering in main.js (#16895) 2023-09-03 17:18:51 +02:00
Krzysztof Wolicki
80c1d48ccb
autodoc: Implement a[b], a.?, and a.* (#16863)
* autodoc: Implement elem_val_node and basic optional_payload_*

* autodoc: Add `.*` loads
2023-09-03 17:18:16 +02:00
Loris Cro
0516a4d629 autodoc: fix typo 2023-09-03 17:15:15 +02:00
Loris Cro
c0da41582b autodoc: better light mode colors
fix #15799
2023-09-03 17:12:52 +02:00
James Chen-Smith
c3a8f1fe92
autodoc: Extract decl ref style and fix light mode color (#15990)
Co-authored-by: James Chen-Smith <james@chen-smith.net>
Co-authored-by: Loris Cro <kappaloris@gmail.com>
2023-09-03 16:51:07 +02:00
Ambareesh "Amby" Balaji
62f727eedb std.fs: Fix typo in accessAbsoluteW 2023-09-03 12:03:14 +02:00
Jan Philipp Hafer
1816bb4ab0 std.os+windows: isAtLeast(.win10_rs5) in renameatW(), DeleteFile() for posix semantics
Usage of FILE_RENAME_IGNORE_READONLY_ATTRIBUTE or
FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE for posix semantics require
win10_rs5 instead of win10_rs1 necessary for posix semantics. Keep it as simple
as possible, since it is reasonable to expect users being able to update
win10_rs5 or use non-posix semantics instead.

Closes #17049.
2023-09-03 08:35:26 +02:00
Josh Wolfe
8b74eae9c6
std.ArrayHashMap.reIndex also recomputes hashes (#17054) 2023-09-02 17:00:20 -04:00
Marc Tiehuis
410be6995e std/hash: perform iterative + smhasher tests at comptime
Need to confirm how these fare on CI as per previous comments left which
stated OOM (on stage-1).
2023-09-02 16:58:03 +12:00
Marc Tiehuis
1c148f1619 std/hash: add generic tests for idempotency/iterative api 2023-09-02 15:37:49 +12:00
Marc Tiehuis
26d61812a8 std/hash: add smhasher verification tests
Not all hashes are added just yet as these need to be generated manually
from reference implementations as they are not included by default in
smhasher.
2023-09-02 15:37:49 +12:00
Michal Ziulek
bb2eb44430 std.coff: Fixed compile error. 2023-09-02 00:18:53 +02:00
Ryan Liptak
01f9cdd21a Temporarily disable Dir.statFile test when linking glibc
See https://github.com/ziglang/zig/issues/17034
2023-08-31 18:01:15 -07:00