61 Commits

Author SHA1 Message Date
Andrew Kelley
080022f6c6 self-hosted: fix compile errors, except for codegen.zig 2020-05-13 20:06:01 -04:00
Vexu
e72f45475d
Merge pull request #4683 from LakeByTheWoods/parser_test
Add visible newlines to parser_test output when there's a failure.
2020-04-30 12:04:23 +03:00
Vexu
2d06e731ec
rename diffIndex to indexOfDiff 2020-04-30 10:33:50 +03:00
Tadeo Kondrak
350b2adacd
std.meta.IntType -> std.meta.Int 2020-04-28 19:11:31 -06:00
Andrew Kelley
9ebf25d145 link: change default executable mode to 0o777
Jonathan S writes:

On common systems with a 022 umask, this will still result in a
file created with 755 permissions, but it works appropriately if the
system is configured more leniently. (As another data point, C's fopen
seems to open files with the 666 mode.)
2020-04-24 15:36:08 -04:00
Andrew Kelley
a3dfe36ca1 zir-to-elf skeleton 2020-04-22 23:42:58 -04:00
Andrew Kelley
22e7ca5613 ir: analysis of fn instruction 2020-04-21 16:06:15 -04:00
Andrew Kelley
cc1c2bd568 simplify ZIR spec; separate parsing/rendering from analysis 2020-04-20 19:21:03 -04:00
Vexu
b6fe839248
update std lib to decls being disallowed between fields 2020-04-18 23:56:05 +03:00
Lachlan Easton
daff072af2 Add visible newlines to parser_test output when there's a failure.
Also print first line that differs between expected and result.
2020-04-10 10:38:36 +10:00
Benjamin Feng
cb98984ae6 Generate clearer size mismatch error message 2020-04-05 18:38:19 -04:00
xackus
cd20e0cc67 rename mem.separate to mem.split 2020-04-04 17:37:51 -04:00
daurnimator
b1eb831aba
std: fix mem.span* when an optional pointer is passed 2020-04-01 01:44:55 +11:00
Andrew Kelley
9e7ae06249
std lib API deprecations for the upcoming 0.6.0 release
See #3811
2020-03-30 14:23:22 -04:00
Sebastian
ef419dd72d mem.zeroes .Array improvements
Before (when given an array with many elements):
```
zig\std\mem.zig:345:13: error: evaluation exceeded 1000
backwards branches
            for (array) |*element| {
            ^
```
related to https://github.com/ziglang/zig/issues/4847#issuecomment-605721461
2020-03-30 11:16:25 -04:00
daurnimator
3be720a729 std: mem span functions can take an optional pointer 2020-03-30 11:04:58 -04:00
Andrew Kelley
28a6c136e9
revert std.mem.span to prefer len over sentinel; add spanZ 2020-03-19 19:30:09 -04:00
Andrew Kelley
f614d94faa
update std lib to take advantage of slicing with comptime indexes 2020-03-19 14:48:47 -04:00
Andrew Kelley
7fa88cc0a6
std lib fixups for new semantics
std lib tests are passing now
2020-03-19 09:53:55 -04:00
Andrew Kelley
8ea0a00f40
improve std lib code for the new semantics 2020-03-19 09:53:54 -04:00
Andrew Kelley
8d0ac6dc4d
@ptrCast supports casting a slice to pointer 2020-03-19 09:53:54 -04:00
Andrew Kelley
0707be8de8
fixes in semantic analysis needed to support this feature 2020-03-19 09:53:54 -04:00
Andrew Kelley
a27a8561e9
adjust renameatW to always supply dest root dir
this fixes tests for wine
2020-03-15 17:26:29 -04:00
Andrew Kelley
7e45a3ef6a fix typo in new mem.len test 2020-03-15 15:57:51 -04:00
Andrew Kelley
6c2b23593b fix std.mem.span handling of sentinel-terminated arrays
previously this function would use the array length, but now it scans
the array looking for the first sentinel that occurs.
2020-03-15 15:46:56 -04:00
Andrew Kelley
51c6bb92b1
Merge pull request #4709 from LemonBoy/implement-2096
Stricter shift left/right safety checks
2020-03-11 14:22:40 -04:00
LemonBoy
2f1052a313 std: Fix broken tests 2020-03-10 23:50:04 +01:00
Jonathan Marler
90c232bbe8 add allocSentinel function 2020-03-10 15:03:59 -04:00
Michaël Larouche
f5954dad83 Fix crash when freeing empty string as null-terminated sentinel 2020-03-05 17:08:12 -05:00
xackus
00be934569 short std.builtin enum literals in std lib 2020-03-01 13:57:41 -05:00
Andrew Kelley
ef3d761da5
breaking: std.mem.len no longer takes a type argument
also update fmt code to use std.mem.span.
2020-03-01 13:21:39 -05:00
Andrew Kelley
5b26128bac
add new functions to std.mem and deprecate others
add std.mem.Span
add std.mem.span
add std.mem.length
add std.mem.indexOfSentinel

deprecate std.mem.len
deprecate std.mem.toSlice
deprecate std.mem.toSliceConst
2020-03-01 13:07:55 -05:00
Andrew Kelley
4505857e30
revert changes outside std.fmt 2020-03-01 13:07:31 -05:00
daurnimator
0b0de22fd1
std: format contents of sentinel terminated many pointers
std: add std.meta.Sentinel to get sentinel of a type
2020-03-01 13:04:29 -05:00
Andrew Kelley
5503f3f7c4
Merge pull request #4544 from BarabasGitHub/zeroes-for-non-extern-types
implement zeroes for non extern structs and native types
2020-02-24 22:01:56 -05:00
Vexu
538d9a5dd8
remove uses of @ArgType and @IntType 2020-02-24 23:39:03 +02:00
Bas van den Berg
f7aa4f5280 Processed review comments. Updated documentation, used the typinfo for field access, generate compile error on allowzero and set C poitners to null 2020-02-24 22:15:04 +01:00
Bas van den Berg
195195d238 vectors do not support iterating, do not support them (for now) 2020-02-24 20:50:51 +01:00
Bas van den Berg
0972b2a8fe implement zeroes for non extern structs and native types 2020-02-24 20:38:33 +01:00
xackus
7664c3bc11 remove @bytesToSlice, @sliceToBytes from tests, docs 2020-02-23 18:03:50 +01:00
xackus
783e8ad031 remove @bytesToSlice, @sliceToBytes from std lib 2020-02-21 19:46:53 +01:00
xackus
fdae5f5a07 implement bytesAsSlice, sliceAsBytes 2020-02-21 19:40:29 +01:00
Andrew Kelley
4b02a39aa9
self-hosted libc detection
* libc_installation.cpp is deleted.
   src-self-hosted/libc_installation.zig is now used for both stage1 and
   stage2 compilers.
 * (breaking) move `std.fs.File.access` to `std.fs.Dir.access`. The API
   now encourages use with an open directory handle.
 * Add `std.os.faccessat` and related functions.
 * Deprecate the "C" suffix naming convention for null-terminated
   parameters. "C" should be used when it is related to libc. However
   null-terminated parameters often have to do with the native system
   ABI rather than libc. "Z" suffix is the new convention. For example,
   `std.os.openC` is deprecated in favor of `std.os.openZ`.
 * Add `std.mem.dupeZ` for using an allocator to copy memory and add a
   null terminator.
 * Remove dead struct field `std.ChildProcess.llnode`.
 * Introduce `std.event.Batch`. This API allows expressing concurrency
   without forcing code to be async. It requires no Allocator and does
   not introduce any failure conditions. However it is not thread-safe.
 * There is now an ongoing experiment to transition away from
   `std.event.Group` in favor of `std.event.Batch`.
 * `std.os.execvpeC` calls `getenvZ` rather than `getenv`. This is
   slightly more efficient on most systems, and works around a
   limitation of `getenv` lack of integration with libc.
 * (breaking) `std.os.AccessError` gains `FileBusy`, `SymLinkLoop`, and
   `ReadOnlyFileSystem`. Previously these error codes were all reported
   as `PermissionDenied`.
 * Add `std.Target.isDragonFlyBSD`.
 * stage2: access to the windows_sdk functions is done with a manually
   maintained .zig binding file instead of `@cImport`.
 * Update src-self-hosted/libc_installation.zig with all the
   improvements that stage1 has seen to src/libc_installation.cpp until
   now. In addition, it now takes advantage of Batch so that evented I/O
   mode takes advantage of concurrency, but it still works in blocking
   I/O mode, which is how it is used in stage1.
2020-02-16 13:25:30 -05:00
daurnimator
6ea6d5a4bd
std: use testing.allocator in tests 2020-02-14 19:15:09 +11:00
Andrew Kelley
3b622f4494
fix off-by-one error in std.unicode.utf8ToUtf16LeWithNull
and fix larger-than-one-byte sentinels when being freed

Thank you to João Pedro for identifying both problems and
providing example code to solve them.

closes #4413
2020-02-09 14:56:19 -05:00
daurnimator
5cc4932461
std: allocator interface sets freed memory to undefined 2020-01-21 03:17:40 +11:00
Timon Kruiper
0deab8fd3b Add std.mem.zeroes to the standard library
This zero initializes the type passed in. Can be used to zero
initialize c structs.
2020-01-06 19:24:17 -05:00
Andrew Kelley
5575e2a168
std.mem.compare: breaking API changes
* `std.mem.Compare` is now `std.math.Order` and the enum tags
   renamed to follow new style convention.
 * `std.mem.compare` is renamed to `std.mem.order`.
 * new function `std.math.order`
2020-01-01 18:08:40 -05:00
Andrew Kelley
8918cb06fc
sentinel slicing improvements
* add runtime safety for slicing pointers, arrays, and slices.
 * slicing without a sentinel value results in non-sentineled slice
 * improved `std.debug.panic` handling of panic-during-panic
2019-12-20 18:28:59 -05:00
Andrew Kelley
26f3c2d061
fix std.mem.addNullByte and implement sentinel slicing
see #3770
2019-12-20 18:28:56 -05:00