Commit Graph

429 Commits

Author SHA1 Message Date
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
Josh Wolfe
6fe7dd93cb that's not a keyword 2018-10-22 20:44:59 -04:00
Andrew Kelley
d5648d2640
remove implicit cast from T to *const T
closes #1465
2018-10-15 18:23:47 -04:00
Jimmi Holst Christensen
378d3e4403
Solve the return type ambiguity (#1628)
Changed container and initializer syntax
* <container> { ... } -> <container> . { ... }
* <exrp> { ... } -> <expr> . { ...}
2018-10-15 09:51:15 -04:00
Andrew Kelley
8700f4d2b1
docs: add comment about operator overloading 2018-10-05 18:25:20 -04:00
Andrew Kelley
c81a4b3e3d
docs: fix double escaping html entities 2018-10-05 10:21:08 -04:00
Andrew Kelley
8d6601d7ce
improve pointer documentation
closes #1630
2018-10-04 22:51:36 -04:00
Andrew Kelley
9d4eaf1e07
update std lib API for I/O
std.io.FileInStream -> std.os.File.InStream
std.io.FileInStream.init(file) -> file.inStream()
std.io.FileOutStream -> std.os.File.OutStream
std.io.FileOutStream.init(file) -> file.outStream()

remove a lot of error code possibilities from os functions

std.event.net.socketRead -> std.event.net.read
std.event.net.socketWrite -> std.event.net.write
add std.event.net.readv
add std.event.net.writev
add std.event.net.readvPosix
add std.event.net.writevPosix
add std.event.net.OutStream
add std.event.net.InStream

add std.event.io.InStream
add std.event.io.OutStream
2018-09-30 17:28:35 -04:00
Andrew Kelley
cc490f0026
update @typeInfo docs 2018-09-27 12:34:41 -04:00
Andrew Kelley
9485043b3c
fix implicit casting to *c_void
closes #1588

also some small std lib changes regarding posix sockets
and one doc typo fix
2018-09-26 11:06:09 -04:00
Andrew Kelley
839492d0e8
fix not syntax highlighting builtin module 2018-09-25 12:03:09 -04:00
Andrew Kelley
422269ea6e
minor langref improvements 2018-09-24 14:38:51 -04:00
Andrew Kelley
3c1f9baff1
doc: add note about reproducible builds 2018-09-22 10:22:01 -04:00
Andrew Kelley
7c5e3e1f8e
fixups 2018-09-21 14:15:58 -04:00
Andrew Kelley
5a21d3dce0
Merge branch 'BitByteOffsetOfs' of https://github.com/raulgrell/zig into raulgrell-BitByteOffsetOfs 2018-09-21 13:10:21 -04:00