Commit Graph

9473 Commits

Author SHA1 Message Date
Andrew Kelley
64dfd1883e zig fmt: avoid unnecessary file system access
zig fmt previously would write a temp file, and then either rename it
into place if necessary, or unlink it if nothing was changed. Now zig
fmt renders into a memory buffer, and only writes the temp file and
renames it into place if anything changed.

Based on the performance testing I did this actually did not have much
of an impact, however it's likely that on other operating systems and
other hard drives this could make a big difference.
2020-06-20 20:14:33 -04:00
Andrew Kelley
0a9672fb86 rework zig fmt to avoid unnecessary realpath() calls
* add `std.fs.Dir.stat`
 * zig fmt checks for sym link loops using inodes instead of using
   realpath
2020-06-20 19:46:14 -04:00
Andrew Kelley
da549a72e1 zig fmt 2020-06-20 18:39:15 -04:00
Andrew Kelley
d87cd06296 rework zig fmt to use less syscalls and open fds
* `std.fs.Dir.Entry.Kind` is moved to `std.fs.File.Kind`
 * `std.fs.File.Stat` gains the `kind` field, so performing a stat() on
   a File now tells what kind of file it is. On Windows this only will
   distinguish between directories and files.
 * rework zig fmt logic so that in the case of opening a file and
   discovering it to be a directory, it closes the file descriptor
   before re-opening it with O_DIRECTORY, using fewer simultaneous open
   file descriptors when walking a directory tree.
 * rework zig fmt logic so that it pays attention to the kind of
   directory entries, and when it sees a sub-directory it attempts to
   open it as a directory rather than a file, reducing the number of
   open() syscalls when walking a directory tree.
2020-06-20 18:27:37 -04:00
DrDeano
bc0ca73887 Moved the check for formatting a directory
The original check for a directory was for the `readAllAlloc` so move the check from open to read. This in turn fixes the fmt step in the build script for directories.
2020-06-20 17:25:12 -04:00
data-man
5229f6ec68 Use writer in std.fmt 2020-06-20 18:23:57 +00:00
Veikka Tuominen
aa894cea2c
Merge pull request #5645 from Sobeston/patch-7
langref - document that This works on enums too
2020-06-20 11:34:07 +00:00
Sebastian
8527718350
langref - document that This works on enums too 2020-06-20 12:16:57 +01:00
Eleanor NB
605769ec25 Replaced all occurrences of std.debug.warn in the docs with std.debug.print 2020-06-19 19:03:37 -04:00
Haze Booth
237c5429b0 Don't attempt to use io from thin air 2020-06-19 02:06:27 -04:00
Andrew Kelley
0d18eda1d6
Merge pull request #5348 from ifreund/std-log
Introduce std.log
2020-06-18 21:40:06 -04:00
Andrew Kelley
c70633eacd
Merge pull request #5203 from tadeokondrak/@type-for-even-more-types
implement @typeInfo for Frame and implement @Type for Frame, EnumLiteral, and ErrorSet
2020-06-18 21:25:03 -04:00
Andrew Kelley
b9e3df92db Merge branch 'deingithub-fmt-mode-thingybob'
closes #5617
closes #5616
2020-06-18 21:09:32 -04:00
Andrew Kelley
f7bcc8e040 rework zig fmt to only make one allocation
taking advantage of the fstat size
2020-06-18 21:08:30 -04:00
Cassidy Dingenskirchen
8b49487c33 Fix fs.File.mode() not returning mode_t on windows 2020-06-18 20:41:40 -04:00
Cassidy Dingenskirchen
b30642a86a Fix zig fmt clobbering a file's mode 2020-06-18 20:41:40 -04:00
Michael Rees
bd17a373cc Add std.unicode.Utf8Iterator.peek 2020-06-18 20:35:03 -04:00
Andrew Kelley
5ea0f589c9
Merge pull request #5625 from antlilja/master
Improve support for f128 and comptime_float operations
2020-06-18 20:32:43 -04:00
Vexu
caaa26c9f0 reference emit_raw in std lib tests 2020-06-18 20:17:53 -04:00
Andrew Kelley
4a38799631 make file and fn_name fields of SourceLocation also null-terminated
One of the main motivating use cases for this language feature is
tracing/profiling tools, which expect null-terminated strings for these
values. Since the data is statically allocated, making them
additionally null-terminated comes at no cost.

This prevents the requirement of compile-time code to convert to
null-termination, which could increase the compilation time of
code with tracing enabled.

See #2029
2020-06-18 17:09:10 -04:00
Andrew Kelley
e54ed9f638
Merge pull request #5628 from Vexu/src
Implement @src
2020-06-18 16:23:56 -04:00
Vexu
14acc65675
add tests for @src 2020-06-18 21:11:34 +03:00
Vexu
a5379aa3ee
implement @src 2020-06-18 21:11:09 +03:00
Isaac Freund
c3e0224792
Add std.debug.print for "printf debugging" 2020-06-17 18:36:44 +02:00
antlilja
eb7fad28f8 Improve f128 standard library support
* Add functions: floor128, ceil128, trunc128 and round128
* Add corresponding tests
2020-06-17 18:18:45 +02:00
antlilja
1157ee1307 Improve builtin op support for f128/comptime_float
* Add support for fabs, floor, ceil, trunc and round
* Add behavior tests
2020-06-17 17:35:45 +02:00
Isaac Freund
8e5393a779
Deprecate std.debug.warn 2020-06-17 02:14:52 +02:00
Isaac Freund
0bd067d19a
Introduce std.log
std.log provides 8 log levels and corresponding logging functions. It
allows the user to override the logging "backend" by defining root.log
and to override the default log level by defining root.log_level.

Logging functions accept a scope parameter which allows the implementer
of the logging "backend" to filter logging by library as well as level.

Using the standardized syslog [1] log levels ensures that std.log will
be flexible enough to work for as many use-cases as possible. If we were
to stick with only 3/4 log levels, std.log would be insufficient for
large and/or complex projects such as a kernel or display server.

[1]: https://tools.ietf.org/html/rfc5424#section-6.2.1
2020-06-17 02:14:52 +02:00
Andrew Kelley
9781342042
Merge pull request #5607 from daurnimator/cleanup-debug-stderr
std: clean up debug stderr variables
2020-06-16 18:27:44 -04:00
Jonathan Marler
f0b8791da7 ArrayList(u8) support writer interface 2020-06-16 18:26:54 -04:00
Andrew Kelley
593db7e8d0
Merge pull request #5608 from alexnask/windows_utf16_dir
Use PathSpace and wide FS calls on windows in stage1
2020-06-16 18:26:02 -04:00
Jakub Konka
04c3fae720 Remove obsolete branch in ir_analyze_cast
Branch handling `*[N]T` to `E![]T` is already handled in a more complete
branch handling `*[N]T` to `[]T` *and* `*[N]T` to `E![]T` so it seems
safe to remove this one.
2020-06-16 18:24:45 -04:00
Andrew Kelley
f595545c10
Merge pull request #5422 from pixelherodev/error_tests
[Stage2/Testing] ZIR tests for expected errors
2020-06-16 03:50:56 -04:00
Noam Preil
a99e61ebaa
Stage2/Testing: Code cleanup 2020-06-15 21:47:42 -04:00
Noam Preil
afec3e72f4
Stage2/Testing: Enable another test 2020-06-15 20:42:22 -04:00
Noam Preil
7d1c9a69cc
Stage2/Testing: Remove dead code 2020-06-15 20:33:43 -04:00
Noam Preil
adb21f1caf
Stage2/Testing: Add error tests to ZIRCase 2020-06-15 20:33:43 -04:00
Noam Preil
7ee0462f5f
Stage2/Testing: Fix transformation tests 2020-06-15 20:33:39 -04:00
Noam Preil
1e5945d0a9
Stage2/Testing: remove ZIRTransformCase 2020-06-15 20:33:39 -04:00
Noam Preil
71dca252a5
Stage2/Testing: Rename stage -> update 2020-06-15 20:33:32 -04:00
Noam Preil
b6bd51ed69
Stage2/Testing: Move Transformation case to ZIRCase 2020-06-15 20:33:25 -04:00
Noam Preil
e77fc7fe7e
Stage2/Testing: Fix error specification 2020-06-15 20:33:17 -04:00
Noam Preil
6dce317fe3
Stage2/Testing: Fix error tests 2020-06-15 20:33:07 -04:00
Noam Preil
d4fd7c6a01
Stage2/Testing: Staged test harness draft design 2020-06-15 20:32:54 -04:00
Noam Preil
2ed07a36f8
[Stage2/Testing] Attempt to call nakedcc function 2020-06-15 17:52:21 -04:00
Noam Preil
bf8b3a4394
[Stage2/Testing] Handle decl and export errors 2020-06-15 17:51:43 -04:00
Noam Preil
68cc068a3a
[Stage2/Testing] Make API more friendly 2020-06-15 17:51:43 -04:00
Noam Preil
bebc1f49cf
[Stage2/Testing] Add (failing) test 2020-06-15 17:51:43 -04:00
Noam Preil
2d1d012f11
[Stage2/Testing] Reduce test 2020-06-15 17:51:43 -04:00
Noam Preil
e030414c16
[Stage2/Testing] Always finish case, note all errs 2020-06-15 17:51:43 -04:00