Commit graph

9579 commits

Author SHA1 Message Date
Haze Booth
237c5429b0 Don't attempt to use io from thin air 2020-06-19 02:06:27 -04:00
Andrew Kelley
c9a0ec25e0 self-hosted: add Tracy integration
This tool helps give an intuitive picture of performance. This will help
us understand where to improve the code.
2020-06-18 21:55:37 -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
355319fb67 zig cc: add missing cxxabi include path 2020-06-18 18:17:26 -04:00
Andrew Kelley
7e44302260 stage2: explicit hash and equality function for the DeclTable 2020-06-18 17:12:56 -04:00
Andrew Kelley
81f766eecd self-hosted parser: make a function pointer comptime 2020-06-18 17:12:56 -04:00
Andrew Kelley
46b57748a5 stage1: stop emitting memset to undefined when safety is off 2020-06-18 17:12:56 -04:00
Andrew Kelley
02f688d710 remove std.debug.warn debugging logs 2020-06-18 17:12:56 -04:00
Andrew Kelley
7e58c56ca7 self-hosted: implement Decl lookup
* Take advantage of coercing anonymous struct literals to struct types.
 * Reworks Module to favor Zig source as the primary use case.
   Breaks ZIR compilation, which will have to be restored in a future commit.
 * Decl uses src_index rather then src, pointing to an AST Decl node
   index, or ZIR Module Decl index, rather than a byte offset.
 * ZIR instructions have an `analyzed_inst` field instead of Module
   having a hash table.
 * Module.Fn loses the `fn_type` field since it is redundant with
   its `owner_decl` `TypedValue` type.
 * Implement Type and Value copying. A ZIR Const instruction's TypedValue
   is copied to the Decl arena during analysis, which allows freeing the
   ZIR text instructions post-analysis.
 * Don't flush the ELF file if there are compilation errors.
 * Function return types allow arbitrarily complex expressions.
 * AST->ZIR for function calls and return statements.
2020-06-18 17:12:56 -04:00
Andrew Kelley
b4eac0414a stage2: hook up Zig AST to ZIR
* Introduce the concept of anonymous Decls
 * Primitive Hello, World with inline asm works
 * There is still an unsolved problem of how to manage ZIR instructions
   memory when generating from AST. Currently it leaks.
2020-06-18 17:12:56 -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
tgschultz
38e69a9e6a Added test to ensure minimum number of bytes is emitted for writes 2020-06-16 16:20:59 +00:00
tgschultz
a0160d776f Code cleanup, documentation added, read*Mem functions now take *[]const u8 2020-06-16 16:20:59 +00:00
tgschultz
00ec81b0dc Overhauled leb128:
handles integers < 8 bits
    incorrect overflow bugs fixed
    simplified *mem implementations
    added wrte* functions
    added thurough write/read testing
2020-06-16 16:20:59 +00:00
tgschultz
928d3ee9ea Code cleanup, documentation added, read*Mem functions now take *[]const u8 2020-06-16 16:20:58 +00:00
tgschultz
e94eba5df5 Overhauled leb128:
handles integers < 8 bits
    incorrect overflow bugs fixed
    simplified *mem implementations
    added wrte* functions
    added thurough write/read testing
2020-06-16 16:20:58 +00:00
tgschultz
7f24860737 Code cleanup, documentation added, read*Mem functions now take *[]const u8 2020-06-16 16:20:58 +00:00
tgschultz
8978fe94cf Overhauled leb128:
handles integers < 8 bits
    incorrect overflow bugs fixed
    simplified *mem implementations
    added wrte* functions
    added thurough write/read testing
2020-06-16 16:20:58 +00: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