Commit Graph

543 Commits

Author SHA1 Message Date
Shritesh Bhattarai
56a905c7d1 docgen: add lib codeblock type and use it for wasm32-freestanding 2019-05-16 14:58:10 -04:00
Jimmi Holst Christensen
ba3d18a80e added grammar rule for enum literal to docs 2019-05-11 20:26:41 +02:00
Shawn Landden
d1f9b8184d docs for @hasField 2019-05-06 11:58:04 -05:00
Shritesh Bhattarai
2f39da7cdd docgen: show -target command line argument 2019-05-03 15:56:33 -04:00
Shritesh Bhattarai
5c04c22bcc docgen: support wasm and wasi 2019-05-03 15:56:33 -04:00
Andrew Kelley
8cda4fd73a
docs: remove @setGlobalLinkage section
`@setGlobalLinkage` was removed with #462. The not-yet-implemented
proposal for external weak symbols is #1917.
2019-05-03 13:38:24 -04:00
Andrew Kelley
f8117a0799
docs: update for shared libraries 2019-05-02 12:00:16 -04:00
Andrew Kelley
6e4f69a54a
docgen: add exe_build_err tag 2019-05-01 15:34:36 -04:00
Andrew Kelley
54a93e5393
docs: add note to @setRuntimeSafety 2019-05-01 15:09:03 -04:00
Shritesh Bhattarai
efc5122fb6 docgen: properly close tags for skipped execs 2019-04-26 19:33:33 -04:00
Andrew Kelley
fb2acaff06
@sizeOf returns 0 for comptime types
This defines `@sizeOf` to be the runtime size of a type, which means
that it is zero for types such as comptime_int, type, and (enum
literal).

See #2209
2019-04-24 22:31:53 -04:00
hryx
06bf918436 Sync grammar with spec
- Remove rule LabeledExpr
- Add rule CurlySuffixExpr
2019-04-24 14:38:56 -04:00
Matt Stancliff
3b6a4fe4cd Fix test in langref to assert against modified var 2019-04-18 16:14:30 -04:00
Andrew Kelley
b29241fc08
docs: update intro text 2019-04-16 14:23:58 -04:00
Duncan
a43fd7a550 Add favicon to langref.html 2019-04-13 16:20:33 -04:00
Andrew Kelley
e309ad884a
fix outdated/incorrect docs for @truncate
closes #2234
2019-04-10 23:00:53 -04:00
Jay Weisskopf
98fa065de7 docs: Underline link when hovering over it
In addition to the pointer, this gives some visual feedback to the user
that the element is interactive. This is a very common style pattern
across the web.
2019-04-09 00:31:25 -04:00
Andrew Kelley
974977f12f
docgen: add a space between the header and the section symbol 2019-04-05 23:12:25 -04:00
Andrew Kelley
f6be6ace1f
docgen: allow urls to have numbers 2019-04-05 17:33:58 -04:00
Andrew Kelley
a5b47bc2c2
docs: update @typeInfo definition and clarify field order 2019-04-05 12:38:15 -04:00
Jay Weisskopf
3cce56af99 docs: Use section symbol §, not paragraph symbol ¶
A header may cover more than one paragraph, so a section symbol is more appropriate. 

https://en.wikipedia.org/wiki/Section_sign
2019-04-05 11:09:38 -04:00
Andrew Kelley
7dd1e0fc2b
docs: add Variables section
closes #1927
2019-04-04 12:26:47 -04:00
Andrew Kelley
90b6eab05a
docs: complete the documentation for extern struct
closes #1522
2019-04-04 01:23:41 -04:00
Andrew Kelley
b60f2d0c9f
langref: rework the theming and layout
* Instead of the only color scheme being dark, the language reference
   now has a light theme by default, and respects the user's light/dark
   preference via prefers-color-scheme media query. Most browsers don't
   support this yet, so we just have to wait patiently for the future to
   arrive. closes #2172.

 * Instead of a side bar index, the index is inline with the rest of the
   content. This is simpler and more friendly to all user agents, and means
   we don't need the media query for mobile devices. It also makes
   back-references work, so now headers link to the table of contents
   and the table of contents links to headers.
2019-04-03 17:39:07 -04:00
Andrew Kelley
5aee17e888
regression fixes and fix packed struct abi size 2019-04-02 18:31:19 -04:00
MateuszOkulus
62af701804 Remove binary and octal float literals from documentation.
Part of #2093
2019-03-31 10:49:55 -04:00
Andrew Kelley
5eaead6a56
implement allowzero pointer attribute
closes #1953

only needed for freestanding targets.

also adds safety for `@intToPtr` when the address is zero.
2019-03-25 12:55:45 -04:00
Andrew Kelley
64dddd7afe
add compile error for ignoring error
closes #772
2019-03-23 19:33:00 -04:00
Andrew Kelley
4d50bc3f8d
add peer type resolution for *const T and ?*T
closes #1298
2019-03-23 18:48:12 -04:00
Andrew Kelley
89953ec83d
character literals: allow unicode escapes
also make the documentation for character literals more clear.
closes #2089

see #2097
2019-03-23 17:35:21 -04:00
Andrew Kelley
55cb9ef138
docs: clarify NaN, inf, -inf
closes #2089
2019-03-23 15:25:38 -04:00
Matt Stancliff
1ca78e39e4 Fix typos around pointer usage 2019-03-22 14:10:17 -04:00
Jimmi Holst Christensen
23af502d04 Updated langref to newest grammar 2019-03-22 09:01:30 +01:00
Andrew Kelley
246304125a
add documentation for zig test
closes #1518
2019-03-20 23:50:22 -04:00
Andrew Kelley
15c316b0d8
add docs for assembly and fix global assembly parsing
Previously, global assembly was parsed expecting it to have
the template syntax. However global assembly has no inputs,
outputs, or clobbers, and thus does not have template syntax.
This is now fixed.

This commit also adds a compile error for using volatile
on global assembly, since it is meaningless.

closes #1515
2019-03-20 19:00:23 -04:00
Andrew Kelley
3c36929603
zig targets prints the available libcs 2019-03-19 15:04:29 -04:00
Andrew Kelley
567175f833
add documentation for Memory
closes #1904
2019-03-18 21:40:24 -04:00
Andrew Kelley
080dd27157
breaking: fix @typeInfo handling of global error set type
`builtin.TypeInfo.ErrorSet` is now `?[]Error`
instead of `struct{errors:[]Error}`.

closes #1936
2019-03-14 11:57:56 -04:00
Andrew Kelley
85d0f0d45b
fix @setRuntimeSafety not able to override release modes 2019-03-13 14:46:53 -04:00
Andrew Kelley
0588fed15f
add documentation for pub
closes #1727
2019-03-13 13:05:23 -04:00
Andrew Kelley
4e40bd8633
add documentation for @"" syntax
closes #1614
2019-03-13 12:01:32 -04:00
Andrew Kelley
1a94dec50e
docs: finish initial documentation for implicit casts
closes #1514
2019-03-11 19:34:58 -04:00
Andrew Kelley
3ff0e8bd96
Revert "docgen: --cache off for tests"
This reverts commit 0a8a7a57e7.

This workaround is no longer necessary.
2019-03-11 10:35:42 -04:00
Andrew Kelley
918dbd4551
std.zig: this is no longer a keyword 2019-03-10 15:55:54 -04:00
Andrew Kelley
0a8a7a57e7
docgen: --cache off for tests 2019-03-09 11:29:15 -05:00
Andrew Kelley
94e52dba85
fix docgen and fix unnecessarily adding .root suffix to objects 2019-03-09 01:00:45 -05:00
Andrew Kelley
91955dee58
breaking changes to zig build API and improved caching
* in Zig build scripts, getOutputPath() is no longer a valid function
   to call, unless setOutputDir() was used, or within a custom make()
   function. Instead there is more convenient API to use which takes
   advantage of the caching system. Search this commit diff for
   `exe.run()` for an example.
 * Zig build by default enables caching. All build artifacts will go
   into zig-cache. If you want to access build artifacts in a convenient
   location, it is recommended to add an `install` step. Otherwise
   you can use the `run()` API mentioned above to execute programs
   directly from their location in the cache. Closes #330.
   `addSystemCommand` is available for programs not built with Zig
   build.
 * Please note that Zig does no cache evicting yet. You may have to
   manually delete zig-cache directories periodically to keep disk
   usage down. It's planned for this to be a simple Least Recently
   Used eviction system eventually.
 * `--output`, `--output-lib`, and `--output-h` are removed. Instead,
   use `--output-dir` which defaults to the current working directory.
   Or take advantage of `--cache on`, which will print the main output
   path to stdout, and the other artifacts will be in the same directory
   with predictable file names. `--disable-gen-h` is available when
   one wants to prevent .h file generation.
 * `@cImport` is always independently cached now. Closes #2015.
   It always writes the generated Zig code to disk which makes debug
   info and compile errors better. No more "TODO: remember C source
   location to display here"
 * Fix .d file parsing. (Fixes the MacOS CI failure)
 * Zig no longer creates "temporary files" other than inside a
   zig-cache directory.

This breaks the CLI API that Godbolt uses. The suggested new invocation
can be found in this commit diff, in the changes to `test/cli.zig`.
2019-03-08 23:23:11 -05:00
Andrew Kelley
f7835000b6
@returnAddress and @frameAddress return usize now 2019-03-02 15:34:58 -05:00
Sahnvour
4bac22e888 all integers returned by @typeInfo are now comptime_int 2019-03-02 14:27:37 -05:00
Andrew Kelley
e8dad62441
fix docs typo 2019-03-01 17:23:27 -05:00
Andrew Kelley
5424b4320d
remove namespace type; files are empty structs
closes #1047
2019-02-28 10:11:32 -05:00
Andrew Kelley
22dd0db9bf
improve docs for unions and switching on tagged unions
closes #1943
2019-02-26 22:57:01 -05:00
Andrew Kelley
ade10387a5
breaking changes to the way targets work in zig
* CLI: `-target [name]` instead of `--target-*` args.
   This matches clang's API.
 * `builtin.Environ` renamed to `builtin.Abi`
   - likewise `builtin.environ` renamed to `builtin.abi`
 * stop hiding the concept of sub-arch. closes #1526
 * `zig targets` only shows available targets. closes #438
 * include all targets in readme, even those that don't
   print with `zig targets` but note they are Tier 4
 * refactor target.cpp and make the naming conventions
   more consistent
 * introduce the concept of a "default C ABI" for a given
   OS/Arch combo. As a rule of thumb, if the system compiler
   is clang or gcc then the default C ABI is the gnu ABI.
2019-02-26 15:58:10 -05:00
Andrew Kelley
aab8e13529
add docs for zero bit types and pointers to zero bit types
closes #1561
2019-02-25 18:31:37 -05:00
Andrew Kelley
d0c39895aa
docs for packed structs
closes #1513
2019-02-22 10:56:49 -05:00
Andrew Kelley
0c5f897904
fix @bitCast when src/dest types have mismatched handle_is_ptr
* separate BitCast and BitCastGen instructions
 * closes #991
 * closes #1934
 * unrelated: fix typo in docs (thanks gamester for pointing it out)
2019-02-22 08:49:27 -05:00
John Schmidt
99adda9df5 Some function doc tweaks (#1961)
* Add docs for the inline function attribute

* Remove outdated comment

Seems like a leftover from when implicit returns were around.

* Consistent terminology
2019-02-18 17:53:41 -05:00
Andrew Kelley
043090020f
docs: shadowing
closes #1245
2019-02-18 17:49:26 -05:00
Andrew Kelley
8922008dec
docs: note top level declarations are order-independent
closes #1244
2019-02-18 17:41:55 -05:00
Andrew Kelley
7a84fe79b9
pull request fixups 2019-02-18 13:05:26 -05:00
emekoi
9b3013d2f6
make @enumToInt work on union(enum)
closes #1711
2019-02-18 11:43:45 -05:00
Andrew Kelley
7293e012d7
breaking: fix @sizeOf to be alloc size rather than store size
* Fixes breaches of the guarantee that `@sizeOf(T) >= @alignOf(T)`
 * Fixes std.mem.secureZero for integers where this guarantee previously
   was breached
 * Fixes std.mem.Allocator for integers where this guarantee previously
   was breached

Closes #1851
Closes #1864
2019-02-15 18:05:50 -05:00
Andrew Kelley
973a93d43b
add docs for C pointers 2019-02-14 19:03:04 -05:00
Andrew Kelley
6769183a9d
fix implicit cast error unions with non-optional to optional pointer
and update self hosted compiler for C pointers

See #1059
2019-02-14 15:48:28 -05:00
Andrew Kelley
661fc79fba
langref: update grammar with c pointers
See #1059
2019-02-10 12:02:56 -05:00
Andrew Kelley
caf672c495
@truncate: comptime 0 when target type is 0 bits
also if the dest type is a comptime_int, then treat it
as an implicit cast.

also compile error for attempting to truncate undefined

closes #1568
2019-02-09 21:38:34 -05:00
Andrew Kelley
31be1ddf09
docs: add threadlocal keyword to grammar 2019-02-09 20:57:45 -05:00
Andrew Kelley
a8a63feba7
docgen: update for threadlocal keyword 2019-02-09 00:28:12 -05:00
Andrew Kelley
d6f2af378a
fix docs
broken by c2db077574
2019-02-08 19:38:16 -05:00
Andrew Kelley
c2db077574
std.debug.assert: remove special case for test builds
Previously, std.debug.assert would `@panic` in test builds,
if the assertion failed. Now, it's always `unreachable`.

This makes release mode test builds more accurately test
the actual code that will be run.

However this requires tests to call `std.testing.expect`
rather than `std.debug.assert` to make sure output is correct.

Here is the explanation of when to use either one, copied from
the assert doc comments:

Inside a test block, it is best to use the `std.testing` module
rather than assert, because assert may not detect a test failure
in ReleaseFast and ReleaseSafe mode. Outside of a test block, assert
is the correct function to use.

closes #1304
2019-02-08 18:23:38 -05:00
Andrew Kelley
36bade5c56
fixups, and modify std.mem.join and std.os.path.resolve API
* zig fmt
 * std.mem.join takes a slice of slices instead of var args
 * std.mem.join takes a separator slice rather than byte,
   and always inserts it. Previously it would not insert the separator
   if there already was one, violating the documented behavior.
 * std.mem.join calculates exactly the correct amount to allocate
   and has no call to allocator.shrink()
 * bring back joinWindows and joinPosix and the corresponding tests.
   it is intended to be able to call these functions from any OS.
 * rename std.os.path.resolveSlice to resolve (now resolve takes
   a slice of slices instead of var args)
2019-02-07 00:42:41 -05:00
Andrew Kelley
c804ae2d6b
Merge branch 'zig-backport-std.os.path' of https://github.com/kristate/zig into kristate-zig-backport-std.os.path 2019-02-06 22:53:34 -05:00
Andrew Kelley
3abf293a84
doc/targets.md has moved to the github wiki
https://github.com/ziglang/zig/wiki/How-to-Add-Support-For-More-Targets
2019-02-06 11:53:09 -05:00
Andrew Kelley
ac4e38226b
docs: clarify passing aggregate types as parameters 2019-02-05 10:28:56 -05:00
Andrew Kelley
9b8e23934b
introduce --single-threaded build option
closes #1764

This adds another boolean to the test matrix; hopefully it does not
inflate the time too much.

std.event.Loop does not work with this option yet. See #1908
2019-02-01 18:05:54 -05:00
Andrew Kelley
545064c1d9
introduce vector type for SIMD
See #903

 * create with `@Vector(len, ElemType)`
 * only wrapping addition is implemented

This feature is far from complete; this is only the beginning.
2019-01-30 23:39:25 -05:00
Andrew Kelley
581edd643f
backport copy elision changes
This commit contains everything from the copy-elision-2
branch that does not have to do with copy elision directly,
but is generally useful for master branch.

 * All const values know their parents, when applicable, not
   just structs and unions.
 * Null pointers in const values are represented explicitly,
   rather than as a HardCodedAddr value of 0.
 * Rename "maybe" to "optional" in various code locations.
 * Separate DeclVarSrc and DeclVarGen
 * Separate PtrCastSrc and PtrCastGen
 * Separate CmpxchgSrc and CmpxchgGen
 * Represent optional error set as an integer, using the 0 value.
   In a const value, it uses nullptr.
 * Introduce type_has_one_possible_value and use it where applicable.
 * Fix debug builds not setting memory to 0xaa when storing
   undefined.
 * Separate the type of a variable from the const value of a variable.
 * Use copy_const_val where appropriate.
 * Rearrange structs to pack data more efficiently.
 * Move test/cases/* to test/behavior/*
 * Use `std.debug.assertOrPanic` in behavior tests instead of
   `std.debug.assert`.
 * Fix outdated slice syntax in docs.
2019-01-29 22:30:30 -05:00
Andrew Kelley
9c328b4291
simpler implementation of && and || hints
This accomplishes the same goal, but with less changes, so that
I can backport copy elision stuff easier.
2019-01-29 22:29:56 -05:00
kristopher tate
5bf9ffdc5b Hint at use of and/or when &&/|| is improperly used (#1886) 2019-01-25 21:10:40 +01:00
vegecode
f6cd68386d @bitreverse intrinsic, part of #767 (#1865)
* bitreverse - give bswap behavior

* bitreverse, comptime_ints, negative values still not working?

* bitreverse working for negative comptime ints

* Finished bitreverse test cases

* Undo exporting a bigint function. @bitreverse test name includes ampersand

* added docs entry for @bitreverse
2019-01-02 16:47:47 -05:00
Andrew Kelley
45081c1e9c
hello world example can use const instead of var 2018-12-23 13:57:37 -05:00
Andrew Kelley
82bf1eb7a1
docs: fix alphabetical sorting of builtin functions 2018-12-14 20:21:23 -05:00
Andrew Kelley
6395cf8d6b
fix mistakes introduced in b883bc8 2018-12-13 06:07:39 -05:00
Andrew Kelley
b883bc873d
breaking API changes to all readInt/writeInt functions & more
* add `@bswap` builtin function. See #767
 * comptime evaluation facilities are improved to be able to
   handle a `@ptrCast` with a backing array.
 * `@truncate` allows "truncating" a u0 value to any integer
   type, and the result is always comptime known to be `0`.
 * when specifying pointer alignment in a type expression,
   the alignment value of pointers which do not have addresses
   at runtime is ignored, and always has the default/ABI alignment
 * threw in a fix to freebsd/x86_64.zig to update syntax from
   language changes
 * some improvements are pending #863

closes #638
closes #1733

std lib API changes
 * io.InStream().readIntNe renamed to readIntNative
 * io.InStream().readIntLe renamed to readIntLittle
 * io.InStream().readIntBe renamed to readIntBig
 * introduced io.InStream().readIntForeign
 * io.InStream().readInt has parameter order changed
 * io.InStream().readVarInt has parameter order changed
 * io.InStream().writeIntNe renamed to writeIntNative
 * introduced io.InStream().writeIntForeign
 * io.InStream().writeIntLe renamed to writeIntLittle
 * io.InStream().writeIntBe renamed to writeIntBig
 * io.InStream().writeInt has parameter order changed
 * mem.readInt has different parameters and semantics
 * introduced mem.readIntNative
 * introduced mem.readIntForeign
 * mem.readIntBE renamed to mem.readIntBig and different API
 * mem.readIntLE renamed to mem.readIntLittle and different API
 * introduced mem.readIntSliceNative
 * introduced mem.readIntSliceForeign
 * introduced mem.readIntSliceLittle
 * introduced mem.readIntSliceBig
 * introduced mem.readIntSlice
 * mem.writeInt has different parameters and semantics
 * introduced mem.writeIntNative
 * introduced mem.writeIntForeign
 * mem.writeIntBE renamed to mem.readIntBig and different semantics
 * mem.writeIntLE renamed to mem.readIntLittle and different semantics
 * introduced mem.writeIntSliceForeign
 * introduced mem.writeIntSliceNative
 * introduced mem.writeIntSliceBig
 * introduced mem.writeIntSliceLittle
 * introduced mem.writeIntSlice
 * removed mem.endianSwapIfLe
 * removed mem.endianSwapIfBe
 * removed mem.endianSwapIf
 * added mem.littleToNative
 * added mem.bigToNative
 * added mem.toNative
 * added mem.nativeTo
 * added mem.nativeToLittle
 * added mem.nativeToBig
2018-12-12 20:35:04 -05:00
Jay Weisskopf
5f5364ad73 font-family fallbacks for unsupported system-ui 2018-12-11 01:44:48 -05:00
Jay Weisskopf
57113bab2f docs: Prefer system-ui font-family
system-ui is a new generic font-family for matching the font used in the operating system's native user interface. E.g. Roboto on Android, San Francisco on macOS, Segoe UI on Windows, etc.

https://caniuse.com/#search=system-ui
2018-12-11 01:44:48 -05:00
Henry Nelson
68b0fce62f Document explicitly ignoring expression values 2018-12-11 01:42:54 -05:00
kristopher tate
2b78a90424
std.os.path: remove dependance on std.mem.join;
std/os/child_process.zig: windows

test/cli.zig: godbolt;

doc/docgen.zig
2018-11-30 03:52:27 +09:00
Andrew Kelley
b1a676b279
docs: fix some incorrect error documentation 2018-11-19 13:20:39 -05:00
Andrew Kelley
f8a782fb2e
all numbers with comptime known values implicitly cast
to all number types. If the value does not fit,
a compile error is emitted.

closes #422
closes #1712
2018-11-18 19:37:59 -05:00
Jimmi HC
f1fd8d2b1f Updated docs to newest grammar 2018-11-17 14:36:36 +01:00
Andrew Kelley
704374e512
rename section keyword to linksection
add zig fmt support for this syntax

closes #1152
2018-11-17 01:38:35 -05:00
Vallentin
398914eb71 Fixed typos 2018-11-16 14:03:39 -05:00
Jimmi Holst Christensen
14308db923 Manual update to new grammar.
TODO: Figure out how we can auto update this, when the grammar changes in
the zig-spec repo
2018-11-14 08:56:26 +01:00
Jimmi Holst Christensen
8139c5a516
New Zig formal grammar (#1685)
Reverted #1628 and changed the grammar+parser of the language to not allow certain expr where types are expected
2018-11-13 05:08:37 -08:00
Andrew Kelley
63f636e7b7
limit integer types to maximum bit width of 65535
closes #1541
2018-11-06 11:09:14 -05:00
Andrew Kelley
2b395d4ede
remove @minValue,@maxValue; add std.math.minInt,maxInt
closes #1466
closes #1476
2018-10-26 15:01:51 -04:00
Andrew Kelley
eb0b1d38ff
remove 3 more implicit casts to const pointers
see #1465
2018-10-25 12:52:12 -04:00
Andrew Kelley
b4801186b7
langref: dark style. easier on the eyes 2018-10-23 22:11:31 -04:00
emekoi
d7cec5b37c fixes #1667 2018-10-23 21:29:04 -04:00