Commit Graph

962 Commits

Author SHA1 Message Date
Vincenzo Palazzo
80f3c8d276
docs: add documentation on errdefer with caputure syntax
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2022-05-17 21:08:32 +02:00
Vincenzo Palazzo
8328f5ed51
docs: add documentation about return stm in the defer method
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2022-05-17 18:34:28 +02:00
Koakuma
fb0692334e target: Rename sparcv9 -> sparc64
Rename all references of sparcv9 to sparc64, to make Zig align more with
other projects. Also, added new function to convert glibc arch name to Zig
arch name, since it refers to the architecture as sparcv9.

This is based on the suggestion by @kubkon in PR 11847.
(https://github.com/ziglang/zig/pull/11487#pullrequestreview-963761757)
2022-05-13 16:43:59 -04:00
Jonathan Marler
9e89000ffc Update usages of process.getEnvMap and change BufMap -> EnvMap where applicable
# Conflicts:
#	lib/std/build/RunStep.zig
2022-05-11 18:40:53 -06:00
Kirk Scheibelhut
67c4b16d6e docs: T.bit_count -> @typeInfo(T).Int.bits
bit_count was removed in #6246
2022-05-10 17:28:44 -04:00
Andrew Kelley
ec95e00e28 flatten lib/std/special and improve "pkg inside another" logic
stage2: change logic for detecting whether the main package is inside
the std package. Previously it relied on realpath() which is not portable.
This uses resolve() which is how imports already work.

 * stage2: fix cleanup bug when creating Module
 * flatten lib/std/special/* to lib/*
   - this was motivated by making main_pkg_is_inside_std false for
     compiler_rt & friends.
 * rename "mini libc" to "universal libc"
2022-05-06 22:41:00 -07:00
Andrew Kelley
09f1d62bdf add new builtin function @tan
The reason for having `@tan` is that we already have `@sin` and `@cos`
because some targets have machine code instructions for them, but in the
case that the implementation needs to go into compiler-rt, sin, cos, and
tan all share a common dependency which includes a table of data. To
avoid duplicating this table of data, we promote tan to become a builtin
alongside sin and cos.

ZIR: The tag enum is at capacity so this commit moves
`field_call_bind_named` to be `extended`. I measured this as one of
the least used tags in the zig codebase.

Fix libc math suffix for `f32` being wrong in both stage1 and stage2.
stage1: add missing libc prefix for float functions.
2022-04-27 16:45:23 -07:00
Motiejus Jakštys
6d0283e6bc
[doc update] add size_t (#11482)
For those souls looking for a zig `size_t` equivalent, and not
lucky/educated enough (that was me yesterday) to know it's the same as
`uintptr_t`.

From a recent discussion on IRC.
2022-04-21 14:33:42 -04:00
Cody Tapscott
7b090df668 stdlib std.os: Improve wasi-libc parity for WASI CWD emulation
Two major changes here:
  1. We store the CWD as a simple `[]const u8` and lookup Preopens for
     every absolute or CWD-referenced file operation, based on the
     Preopen with the longest match (i.e. most specific path)
  2. Preorders are normalized to POSIX absolute paths at init time.
     Behavior depends on the "cwd_root" parameter of `initPreopensWasi`:

	`cwd_root` is used for any Preopens that start with "."

	  For example:
            "./foo/bar" - inits to -> "{cwd_root}/foo/bar"
            "foo/bar"   - inits to -> "/foo/bar"
	    "/foo/bar"  - inits to -> "/foo/bar"

        `cwd_root` must be an absolute path.

	Using "/" as `cwd_root` gives behavior similar to wasi-libc.
2022-04-16 18:08:05 +02:00
Kirk Scheibelhut
971ef7b9c2 Remove primitive values from keyword reference
5a53ab28 removed these as keywords, and the Primitive Values section
of the docs already exists to describe them.
2022-04-09 12:48:36 +02:00
Philipp Lühmann
795f075790 langref: rename incorrect expect to assert 2022-04-04 15:44:01 +03:00
dxps
9a127501f6 chore: doc fixes, closes 11091 2022-03-25 11:22:30 +02:00
Robin Voetter
5c3325588e stage1: make type names more unique 2022-03-19 19:40:46 -04:00
Andrew Kelley
f3f5a5d05b stage2: improve @typeName
* make it always return a fully qualified name. stage1 is inconsistent
   about this.
 * AstGen: fix anon_name_strategy to correctly be `func` when anon type
   creation happens in the operand of the return expression.
 * Sema: implement type names for the "function" naming strategy.
 * Put "enum", "union", "opaque", or "struct" in place of "anon" when
   creating respective anonymous Decl names.
 * std.testing: add `expectStringStartsWith`. Didn't end up using it
   after all.

Also this enables the real test runner for stage2 LLVM backend (sans
wasm32) since it works now.
2022-03-18 00:12:22 -07:00
Andrew Kelley
73e51133c3 langref: small clarification of @reduce 2022-03-17 17:22:57 -07:00
Andrew Kelley
d42d31f72f basic language features do not belong in std.meta 2022-03-14 00:11:46 -07:00
Andrew Kelley
627209253c langref: fix a stray anyopaque that should be a void 2022-03-08 14:58:53 -07:00
The Depressed Milkman
cd43f323d2 correct @frameSize() params in documentation
The documentation omitted the primary parameter, making it difficult to
understand what this function actually does.
2022-03-06 10:32:07 +02:00
Exonorid
91a88a789f
Add documentation for common mistakes in errdefer scoping 2022-02-23 14:33:51 +02:00
Veikka Tuominen
c9dde10f86 stage1: improve error message when casting tuples 2022-02-17 17:39:54 +02:00
Andrew Kelley
dc6553d93e CI: update download page and langref for 0.9.1 2022-02-14 20:08:04 -07:00
Andrew Kelley
1e49d1fca8 langref: correct info about type info of declarations 2022-02-14 12:26:55 -07:00
Andrew Kelley
210ee1067b update more API usage of std.Progress
fixes regression introduced in 5a00e24963
2022-02-08 17:49:40 -07:00
Kirk Scheibelhut
71321b6941
Various documentation fixes
Co-authored-by: Kirk Scheibelhut <kjs@scheibo.com>
Co-authored-by: extrasharp <genericpb@gmail.com>
2022-02-04 21:27:50 +02:00
GithubPrankster
23e981bbd1 Correct f80 description 2022-02-02 15:54:30 +02:00
PhaseMage
8a97807d68
Full response file (*.rsp) support
I hit the "quotes in an RSP file" issue when trying to compile gRPC using
"zig cc". As a fun exercise, I decided to see if I could fix it myself.
I'm fully open to this code being flat-out rejected. Or I can take feedback
to fix it up.

This modifies (and renames) _ArgIteratorWindows_ in process.zig such that
it works with arbitrary strings (or the contents of an RSP file).

In main.zig, this new _ArgIteratorGeneral_ is used to address the "TODO"
listed in _ClangArgIterator_.

This change closes #4833.

**Pros:**

- It has the nice attribute of handling "RSP file" arguments in the same way it
  handles "cmd_line" arguments.
- High Performance, minimal allocations
- Fixed bug in previous _ArgIteratorWindows_, where final trailing backslashes
  in a command line were entirely dropped
- Added a test case for the above bug
- Harmonized the _ArgIteratorXxxx._initWithAllocator()_ and _next()_ interface
  across Windows/Posix/Wasi (Moved Windows errors to _initWithAllocator()_
  rather than _next()_)
- Likely perf benefit on Windows by doing _utf16leToUtf8AllocZ()_ only once
  for the entire cmd_line

**Cons:**

- Breaking Change in std library on Windows: Call
  _ArgIterator.initWithAllocator()_ instead of _ArgIterator.init()_
- PhaseMage is new with contributions to Zig, might need a lot of hand-holding
- PhaseMage is a Windows person, non-Windows stuff will need to be double-checked

**Testing Done:**

- Wrote a few new test cases in process.zig
- zig.exe build test -Dskip-release (no new failures seen)
- zig cc now builds gRPC without error
2022-01-30 21:27:52 +02:00
Sage Hane
e288148f60
fs: Use OpenMode enum instead of read/write flags. 2022-01-29 15:52:08 +02:00
Veikka Tuominen
67d04a988a std: add f80 bits 2022-01-28 11:45:04 -07:00
praschke
6d1b1374f7 docs: reorganize @truncate and @intCast for clarity 2022-01-27 19:51:17 +02:00
Philipp Lühmann
db1edb6535 fix precedence in langref or example 2022-01-27 19:39:35 +02:00
Exonorid
3e6952ad16 Added documentation for implicit struct pointer dereferencing 2022-01-27 19:33:07 +02:00
r00ster
dd076d8cba Add missing package to the langref that's always available 2022-01-07 14:18:47 -05:00
ominitay
7e16bb36d8 Change ArgIterator.next() return type
Changes the return type of `ArgIterator.next()` from
`?(NextError![:0]u8)` to `NextError!?[:0]u8`.
2021-12-21 11:15:33 -08:00
John Schmidt
0d09b87c14 Langref: replace mentions of c_void with anyopaque 2021-12-21 11:13:21 -08:00
Andrew Kelley
a18bf7a7bf Release 0.9.0 2021-12-20 13:13:19 -07:00
Andrew Kelley
80b21cef5a langref: fix tidy html error
regressed in 8468b544e8
2021-12-18 23:57:00 -07:00
Isaac Freund
9f9f215305
stage1, stage2: rename c_void to anyopaque (#10316)
zig fmt now replaces c_void with anyopaque to make updating
code easy.
2021-12-19 00:24:45 -05:00
bnprks
8468b544e8
Add Vector documentation (#10303)
* Create Vector language documentation

Main changes to docs:
1. Create brief documentation on Zig vector types with code example
2. Get rid of the SIMD sub-heading under the main Vectors heading,
and update links accordingly
3. Add an example to the `@shuffle` docs
2021-12-18 23:40:57 -05:00
Isaac Freund
516945d7d9
langref: document @prefetch() builtin 2021-12-11 00:29:31 +01:00
Michael Byrne
7e2fae10c9
Add documentation for sentinel-terminated slicing (#10010)
closes #9680
2021-12-03 20:37:48 -05:00
Andrew Kelley
f3edff439e improve detection of how to execute binaries on the host
`getExternalExecutor` is moved from `std.zig.CrossTarget` to
`std.zig.system.NativeTargetInfo.getExternalExecutor`.

The function also now communicates a bit more information about *why*
the host is unable to execute a binary. The CLI is updated to report
this information in a useful manner.

`getExternalExecutor` is also improved to detect such patterns as:
 * x86_64 is able to execute x86 binaries
 * aarch64 is able to execute arm binaries
 * etc.

Added qemu-hexagon support to `getExternalExecutor`.

`std.Target.canExecBinaries` of is removed; callers should use the more
powerful `getExternalExecutor` instead.

Now that `zig test` tries to run the resulting binary no matter what,
this commit has a follow-up change to the build system and docgen to
utilize the `getExternalExecutor` function and pass `--test-no-exec`
in some cases to avoid getting the error.

Additionally:

 * refactor: extract NativePaths and NativeTargetInfo into their own
   files named after the structs.
 * small improvement to langref to reduce the complexity of the `callconv`
   expression in a couple examples.
2021-12-02 21:51:14 -07:00
Lee Cannon
02e5e0ba1f
allocgate: apply missed changes 2021-11-30 23:32:48 +00:00
Lee Cannon
1093b09a98
allocgate: renamed getAllocator function to allocator 2021-11-30 23:32:47 +00:00
Lee Cannon
75548b50ff
allocgate: stage 1 and 2 building 2021-11-30 23:32:47 +00: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
Michael Byrne
ee98d87008 Minor rewording of "Shadowing" section within language reference 2021-10-23 02:57:20 -04:00
Andrew Kelley
7f006287ae
Merge pull request #9878 from pfgithub/patch-4
Add line numbers to langref
2021-10-12 14:21:28 -04:00
Andrew Kelley
6115cf2240 migrate from std.Target.current to @import("builtin").target
closes #9388
closes #9321
2021-10-04 23:48:55 -07:00
Mr. Paul
65e4926c5b langref: Explain Zig Test
Updates the Language Reference sections: Comments, Values, and Zig Test.

Zig Test section moved down with the goal "make sure it can be read top to
bottom sensibly" in mind (issue #1524).

Comments and Values section examples changed test declarations to a main
function and expect statement to print statements.

A print statement was added to the "String Literals and Unicode Code Point"
section's example to demonstrate the "u" format specifier.

Zig Test Section:
* Addresses the question: "How does the syntax work?".
* Partially answers the question: "What can I do with the zig test tool?" but
should be sufficient to understand the examples in all of this document.
* Addresses the question: "How does a top-level test block differ from a function definition?"
* Provides a example to run multiple test.

Lacks clear definitions of containers, top-level, order independence, lazy
analysis, resolve, reference.

GitHub Issues: #8221, #8234
2021-10-04 15:35:01 -04:00