Commit Graph

2230 Commits

Author SHA1 Message Date
Andrew Kelley
46aa416c48 std.os and std.io API update
* move std.io.File to std.os.File
 * add `zig fmt` to self hosted compiler
 * introduce std.io.BufferedAtomicFile API
 * introduce std.os.AtomicFile API
 * add `std.os.default_file_mode`
 * change FileMode on posix from being a usize to a u32
 * add std.os.File.mode to return mode of an open file
 * std.os.copyFile copies the mode from the source file instead of
   using the default file mode for the dest file
 * move `std.os.line_sep` to `std.cstr.line_sep`
2018-02-10 21:02:24 -05:00
Andrew Kelley
8c31eaf2a8 std zig tokenizer: don't require 3 newlines at the end of the source 2018-02-10 14:52:39 -05:00
Andrew Kelley
a2bd9f8912 std lib: modify allocator idiom
Before we accepted a nullable allocator for some stuff like
opening files. Now we require an allocator.

Use the mem.FixedBufferAllocator pattern if a bound on the amount
to allocate is known.

This also establishes the pattern that usually an allocator is the
first argument to a function (possibly after "self").

fix docs for std.cstr.addNullByte

self hosted compiler:
 * only build docs when explicitly asked to
 * clean up main
 * stub out zig fmt
2018-02-09 18:27:50 -05:00
Andrew Kelley
e7bf8f3f04 fix compiler crash switching on global error with no else 2018-02-09 13:49:58 -05:00
Andrew Kelley
1fb308ceee self hosted compiler: move tokenization and parsing to std lib 2018-02-09 13:08:02 -05:00
Andrew Kelley
3919afcad2 fix crash with error peer type resolution
closes #765
2018-02-09 11:16:04 -05:00
Andrew Kelley
2c697e50db appveyor: don't try to build for mingw
pacman is giving me:
:: msys2-runtime and catgets are in conflict.
Remove catgets? [y/N] error: unresolvable package conflicts detected
error: failed to prepare transaction (conflicting dependencies)
2018-02-09 01:15:17 -05:00
Andrew Kelley
5911962842
Merge pull request #759 from zig-lang/error-sets
Error Sets
2018-02-09 00:47:57 -05:00
Andrew Kelley
8e554561df appveyor: answer Yes to all pacman questions 2018-02-09 00:47:13 -05:00
Andrew Kelley
32c988a2d7 fix build runner on windows 2018-02-09 00:24:23 -05:00
Andrew Kelley
916d24cd21 add compile error tests for error sets 2018-02-08 23:44:21 -05:00
Andrew Kelley
4b16874f04 add test for comptime err to int with only 1 member of set 2018-02-08 22:44:15 -05:00
Andrew Kelley
ee982ae162 syntax: parse ?error!i32 as ?(error!i32) 2018-02-08 22:30:08 -05:00
Andrew Kelley
0efe441dfd if statements support comptime known test error, runtime payload 2018-02-08 22:18:13 -05:00
Andrew Kelley
54c06bf715 error sets: runtime safety for int-to-err and err set cast 2018-02-08 21:54:44 -05:00
Andrew Kelley
8fc6e31567 std: fix return type of std.c.write 2018-02-08 20:46:12 -05:00
Andrew Kelley
f9be970375 Merge remote-tracking branch 'origin/master' into error-sets 2018-02-08 20:45:26 -05:00
Andrew Kelley
57edd4dcb3 error sets - fix bad value for constant error literal 2018-02-08 18:13:07 -05:00
Marc Tiehuis
1c236b0766 Add ArrayList functions (#755)
at - Get the item at the n-th index.

insert - Insert and item into the middle of the list, resizing and copying
existing elements if needed.

insertSlice - Insert a slice into the middle of the list, resizing and
copying existing elements if needed.
2018-02-08 11:22:31 -05:00
Andrew Kelley
fee875770c error set casting building 2018-02-08 11:09:18 -05:00
Andrew Kelley
76239f2089 error sets - update langref. all tests passing 2018-02-08 03:02:41 -05:00
Andrew Kelley
0d5ff6f462 error sets - most tests passing 2018-02-08 02:08:45 -05:00
Andrew Kelley
68238d5678 fix comptime fn execution not returning error unions properly 2018-02-07 22:33:05 -05:00
Ben Noordhuis
dd20f558f0 implement openSelfExe() on darwin (#753) 2018-02-07 18:14:32 -05:00
Jeff Fowler
c88e6e8aee improve behavior of zig build (#754)
See #748
2018-02-07 17:45:20 -05:00
Ben Noordhuis
79ad1d9610 format struct pointers as "<typename>@<address>" (#752) 2018-02-07 16:18:48 -05:00
Ben Noordhuis
0090c2d70b DRY 'is slice?' conditionals in parser (#750) 2018-02-07 14:38:49 -05:00
Andrew Kelley
f99b8b006f error sets - fix most std lib compile errors 2018-02-05 18:09:13 -05:00
Andrew Kelley
6940212ecb error sets: fix peer resolution of error unions 2018-02-05 17:42:13 -05:00
Andrew Kelley
917e6fe370 handle linux returning EINVAL for large writes
See #743
2018-02-05 13:21:08 -05:00
Andrew Kelley
40e4e42a66 handle linux returning EINVAL for large reads
see #743
2018-02-05 12:48:29 -05:00
Andrew Kelley
44d8d654a0 fix test failure, organize code, add new compile error 2018-02-05 09:26:39 -05:00
Andrew Kelley
ec59f76526
Merge pull request #743 from bnoordhuis/linux-random
Use /dev/urandom and sysctl(RANDOM_UUID) on Linux.
2018-02-05 08:09:10 -05:00
Andrew Kelley
b7bc259093 make OutStream and InStream take an error set param 2018-02-05 07:38:24 -05:00
Andrew Kelley
893f1088df error sets - peer resolution for error unions 2018-02-05 01:49:14 -05:00
Andrew Kelley
15075d2c3d error sets - compile error for equality with no common errors 2018-02-05 00:05:04 -05:00
Andrew Kelley
31abef172a fix accidentally linking against kernel32 on non windows 2018-02-04 22:13:21 -05:00
Andrew Kelley
21ce559c9c add --forbid-library
to help track down accidentally linking against a library
2018-02-04 22:06:03 -05:00
Ben Noordhuis
73ee434c8c Use /dev/urandom and sysctl(RANDOM_UUID) on Linux.
Add fallback paths for when the getrandom(2) system call is not
available.  Try /dev/urandom first and sysctl(RANDOM_UUID) second.

The sysctl issues a warning in the system logs with some kernels but
that seems like an acceptable tradeoff for the fallback of a fallback.
2018-02-04 18:58:36 +01:00
Andrew Kelley
61718742f7 *WIP* error sets - std lib test compile but try to link against windows 2018-02-03 14:42:20 -05:00
Andrew Kelley
ef5e7bb469 *WIP* error sets - an inferred error set can end up being the global one 2018-02-03 14:06:37 -05:00
Andrew Kelley
abf5ae6897 *WIP* error sets - support fns called at comptime 2018-02-03 11:51:29 -05:00
Andrew Kelley
b8f59e14cd *WIP* error sets - correctly resolve inferred error sets 2018-02-02 18:13:32 -05:00
Andrew Kelley
39d5f44863 *WI* error sets - basic support working 2018-02-02 14:26:14 -05:00
Andrew Kelley
cfb2c67692 *WIP* error sets - rewrite "const cast only" function 2018-02-02 11:50:19 -05:00
Andrew Kelley
15eb28efaf
Merge pull request #738 from corngood/cygwin-fixes
make lld include paths private
2018-02-02 10:53:54 -05:00
David McFarland
4ec856b0f0 make lld include paths private
This fixes a build failure on cygwin caused by <string.h> -> <strings.h> taking
the latter from one of the lld paths.
2018-02-02 10:49:31 -04:00
Andrew Kelley
406496ca33 *WIP* error sets - allow peer type resolution to create new error set 2018-02-01 23:32:09 -05:00
Andrew Kelley
13b36d458f *WIP* error sets - fix implicit cast 2018-02-01 10:23:25 -05:00
Andrew Kelley
5f518dbeb9 *WIP* error sets converting std lib 2018-01-31 22:48:40 -05:00