Commit Graph

119 Commits (5f7b97e84c7e2bc7682510e97996ad30147026d0)

Author SHA1 Message Date
Jakub Konka 4f24ab9cfc Fix skipping condition (skip when wasm32) 2020-05-29 00:06:26 +02:00
Jakub Konka 3dbe376c77 Link issue to the failing test case targeting wasm 2020-05-28 23:32:17 +02:00
Dmitry Atamanov dd62f63c04
fmt padding correction (#5403)
* Make .Left as default
2020-05-26 20:53:51 +03:00
Andrew Kelley 62fefe8648 std.fmt: non-exhaustive enums: avoid the loop when it's not necessary 2020-05-26 12:15:08 -04:00
daurnimator 5cdeac3b0e std: in fmt, use tag names of non-exhaustive enums when available 2020-05-26 12:00:33 -04:00
daurnimator 292d515e91 std: allow specifiying enums to be formatted as numbers 2020-05-26 12:00:33 -04:00
data-man 0ecdbdb3cb Support comptime floats in std.fmt 2020-05-25 12:48:59 -04:00
Jakub Konka d43c08a3e5 Add/fix missing WASI functionality to pass libstd tests
This rather large commit adds/fixes missing WASI functionality
in `libstd` needed to pass the `libstd` tests. As such, now by
default tests targeting `wasm32-wasi` target are enabled in
`test/tests.zig` module. However, they can be disabled by passing
the `-Dskip-wasi=true` flag when invoking the `zig build test`
command. When the flag is set to `false`, i.e., when WASI tests are
included, `wasmtime` with `--dir=.` is used as the default testing
command.

Since the majority of `libstd` tests were relying on `fs.cwd()`
call to get current working directory handle wrapped in `Dir`
struct, in order to make the tests WASI-friendly, `fs.cwd()`
call was replaced with `testing.getTestDir()` function which
resolved to either `fs.cwd()` for non-WASI targets, or tries to
fetch the preopen list from the WASI runtime and extract a
preopen for '.' path.

The summary of changes introduced by this commit:
* implement `Dir.makeDir` and `Dir.openDir` targeting WASI
* implement `Dir.deleteFile` and `Dir.deleteDir` targeting WASI
* fix `os.close` and map errors in `unlinkat`
* move WASI-specific `mkdirat` and `unlinkat` from `std.fs.wasi`
  to `std.os` module
* implement `lseek_{SET, CUR, END}` targeting WASI
* implement `futimens` targeting WASI
* implement `ftruncate` targeting WASI
* implement `readv`, `writev`, `pread{v}`, `pwrite{v}` targeting WASI
* make sure ANSI escape codes are _not_ used in stderr or stdout
  in WASI, as WASI always sanitizes stderr, and sanitizes stdout if
  fd is a TTY
* fix specifying WASI rights when opening/creating files/dirs
* tweak `AtomicFile` to be WASI-compatible
* implement `os.renameatWasi` for WASI-compliant `os.renameat` function
* implement sleep() targeting WASI
* fix `process.getEnvMap` targeting WASI
2020-05-18 16:09:49 +02:00
data-man 6647c3f054 Fixes fmt padding for some types 2020-05-16 12:45:43 -04:00
Andrew Kelley 8766821157 rework std.math.big.Int
Now there are 3 types:
 * std.math.big.int.Const
   - the memory is immutable, only stores limbs and is_positive
   - all methods operating on constant data go here
 * std.math.big.int.Mutable
   - the memory is mutable, stores capacity in addition to limbs and
     is_positive
   - methods here have some Mutable parameters and some Const
     parameters. These methods expect callers to pre-calculate the
     amount of resources required, and asserts that the resources are
     available.
 * std.math.big.int.Managed
   - the memory is mutable and additionally stores an allocator.
   - methods here perform the resource calculations for the programmer.
   - this is the high level abstraction from before

Each of these 3 types can be converted to the other ones.

You can see the use case for this in the self-hosted compiler, where we
only store limbs, and construct the big ints as needed.

This gets rid of the hack where the allocator was optional and the
notion of "fixed" versions of the struct. Such things are now modeled
with the `big.int.Const` type.
2020-05-01 06:47:56 -04:00
Tadeo Kondrak 350b2adacd
std.meta.IntType -> std.meta.Int 2020-04-28 19:11:31 -06:00
Tadeo Kondrak f977155fdb
@Vector -> std.meta.Vector 2020-04-28 00:47:13 -06:00
Timon Kruiper c829f2f7b7 Add mips support to standard library 2020-04-24 15:28:55 -04:00
markfirmware 203d6554b1 Update fmt.zig 2020-04-03 12:12:40 -04:00
Andrew Kelley 53b5aa812b
Merge remote-tracking branch 'origin/master' into llvm10 2020-03-19 22:19:24 -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 656ba530d8
Merge remote-tracking branch 'origin/master' into llvm10 2020-03-13 15:17:53 -04:00
Andrew Kelley 4905102901
fix all the TODOs from the pull request
* `std.Buffer.print` is removed; use `buffer.outStream().print`
 * `std.fmt.count` returns a `u64`
 * `std.Fifo.print` is removed; use `fifo.outStream().print`
 * `std.fmt.bufPrint` error is renamed from `BufferTooSmall`
   to `NoSpaceLeft` to match `std.os.write`.
 * `std.io.FixedBufferStream.getWritten` returns mutable buffer
   if the buffer is mutable.
2020-03-13 12:02:58 -04:00
Benjamin Feng 4aae55b4cc Replace fmt with new fmtstream 2020-03-12 10:41:09 -05:00
Michael Dusan 83f6f730cd std: simplify format enum-literals 2020-03-10 18:09:41 -04:00
Andrew Kelley 96c07674fc
Merge remote-tracking branch 'origin/master' into llvm10 2020-03-07 12:18:41 -05:00
daurnimator 4114b63d75
std: use std.ArrayList instead of std.Buffer in std/fmt.zig tests 2020-03-06 18:49:13 -05:00
Michael Dusan 1091fee242 std: format enum-literals 2020-03-05 16:03:12 -05:00
daurnimator 488ba1560f
std: fix math.absCast on i1 2020-03-05 16:00:19 +11:00
daurnimator 4f58bfe1a8
std: fix formatting of i1 integers 2020-03-05 15:52:19 +11:00
daurnimator d5359ea541
std: use testing.expectEqualSlices from tests 2020-03-05 15:51:21 +11:00
Andrew Kelley d1cb16aace
Merge remote-tracking branch 'origin/master' into llvm10 2020-03-03 09:44:13 -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
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
Vexu 22432b15e3
add test for `@intToEnum` 2020-02-26 11:19:40 -05:00
Andrew Kelley f33bf48af7
Merge remote-tracking branch 'origin/master' into llvm10 2020-02-25 16:30:40 -05:00
Vexu 538d9a5dd8
remove uses of `@ArgType` and `@IntType` 2020-02-24 23:39:03 +02:00
Vexu 45da72c5b6
remove usages of `@typeId`, `@memberCount`, `@memberName` and `@memberType` 2020-02-24 23:09:01 +02:00
frmdstryr 597648231b Format decmial 0.0 with no precision as just 0 2020-02-23 11:17:06 -05:00
Andrew Kelley 64365bc5d7
enable behavior and std lib tests for RISC-V 64-bit
closes #3338
2020-02-17 00:06:19 -05:00
Andrew Kelley cdba521a06
annotate skipped test with issue link 2020-02-13 16:13:53 -05:00
data-man 948a463cf1
fmt: vector formatting 2020-02-13 16:12:54 -05:00
vegecode d06bfc2e2a Correct comment to include comptime attribute on format output fn parameter
Without comptime, printing custom type through the stream interface fails
2020-02-12 13:16:32 -06:00
LemonBoy 3237528a59 fmt: Pass the fmt string to the inner formatters 2020-02-10 19:43:11 -05:00
Andrew Kelley 84323504ac
std.fmt.format: comptime output parameter 2020-02-05 16:52:18 -05:00
daurnimator a351350b88
std: format non-exhaustive enums 2020-01-31 22:33:56 +11:00
LemonBoy d27678fe83 fmt: Refactor the arg fetching code
* Error out if the requested index is out-of-bound
* Tidy-up all the arg-related variables in a struct
2020-01-30 18:07:02 -05:00
Benjamin Feng b077f3ab7d Promoted "leak_count_allocator" to the main testing.allocator 2020-01-29 22:22:00 -06:00
Benjamin Feng aa9caf5064 Create leak_count_allocator 2020-01-29 14:37:01 -06:00
Benjamin Feng 4d134a01f5 Move debug.global_allocator to testing.allocator 2020-01-29 12:21:29 -06:00
Andrew Kelley 9dffc369f1
Merge remote-tracking branch 'origin/master' into layneson-cpus_and_features 2020-01-25 23:25:29 -05:00
Nathan Michaels 0000de4fee Handle {s} format for C strings. (#4219)
* Handle {s} format for C strings.

* Fix "cstr" test to actually use c strings.
2020-01-20 12:23:43 -05:00
Andrew Kelley a867b43366
progress towards merging
see BRANCH_TODO file
2020-01-19 20:54:04 -05:00
LemonBoy 7e5e767ba0 Fix regression in char printing
Closes #4014
2020-01-16 12:17:16 -05:00
LemonBoy e81b505960 Use the correct calling convention for AEABI intrinsics 2020-01-07 13:42:47 -05:00
Andrew Kelley 25051832b3
std.fmt.format: add helpful compile error for non-tuple args 2019-12-31 13:13:13 -05:00
Vexu 21bc3353b8
translate-c-2 character literals and more test fixes 2019-12-18 01:04:01 +02:00
LemonBoy 19ddbd9e9e Make sure the address is aligned for intToPtr ops
Closes #773
2019-12-15 14:41:05 -05:00
Robin Voetter 8c096707b7
Additional replacements of @typeOf with @TypeOf 2019-12-10 11:09:41 -05:00
Robin Voetter 4b4fbe3887
Replace @typeOf with @TypeOf in all zig source
This change was mostly made with `zig fmt` and this also modified some whitespace. Note that in some files, `zig fmt` produced incorrect code, so the change was made manually.
2019-12-10 11:09:41 -05:00
Andrew Kelley a3f6a58c77
remove var args from the language
closes #208
2019-12-09 15:27:27 -05:00
Andrew Kelley 5d82744f1c
ability to give comptime and non-comptime types to same parameter 2019-12-09 13:30:53 -05:00
Andrew Kelley 8b2622cdd5
std.fmt.format: tuple parameter instead of var args 2019-12-08 22:53:51 -05:00
Andrew Kelley bef3769bb7
std.fmt.ParseUnsignedError is now public 2019-12-04 18:44:22 -05:00
Andrew Kelley bf3ac66150
remove type coercion from array values to references
* Implements #3768. This is a sweeping breaking change that requires
   many (trivial) edits to Zig source code. Array values no longer
   coerced to slices; however one may use `&` to obtain a reference to
   an array value, which may then be coerced to a slice.

 * Adds `IrInstruction::dump`, for debugging purposes. It's useful to
   call to inspect the instruction when debugging Zig IR.

 * Fixes bugs with result location semantics. See the new behavior test
   cases, and compile error test cases.

 * Fixes bugs with `@typeInfo` not properly resolving const values.

 * Behavior tests are passing but std lib tests are not yet. There
   is more work to do before merging this branch.
2019-11-27 03:37:50 -05:00
Andrew Kelley 47f06be369
string literals are now null terminated
this also deletes C string literals from the language, and then makes
the std lib changes and compiler changes necessary to get the behavior
tests and std lib tests passing again.
2019-11-21 20:43:41 -05:00
Felix Queißner cd5c9c8998 Fix missing @as cast in std.fmt.formatInt (#3650) 2019-11-10 23:08:24 +00:00
Andrew Kelley aa0daea541
update more of the std lib to use `@as` 2019-11-08 15:57:25 -05:00
Andrew Kelley e0db54e89d
update the codebase to use `@as` 2019-11-08 15:57:24 -05:00
shiimizu 7277670843 Add error when too few arguments are provided to std.fmt 2019-11-06 18:22:33 -05:00
Andrew Kelley c3d816a98e
std lib networking improvements, especially non-blocking I/O
* delete the std/event/net directory
 * `std.event.Loop.waitUntilFdReadable` and related functions
   no longer have possibility of failure. On Linux, they fall
   back to poll() and then fall back to sleep().
 * add some missing `noasync` decorations in `std.event.Loop`
 * redo the `std.net.Server` API. it's quite nice now, but
   shutdown does not work cleanly. There is a race condition with
   close() that I am actively working on.
 * move `std.io.OutStream` to its own file to match `std.io.InStream`.
   I started working on making `write` integrated with evented I/O,
   but it got tricky so I backed off and filed #3557. However
   I did integrate `std.os.writev` and `std.os.pwritev` with evented I/O.
 * add `std.Target.stack_align`
 * move networking tests to `lib/std/net/test.zig`
 * add `std.net.tcpConnectToHost` and `std.net.tcpConnectToAddress`.
 * rename `error.UnknownName` to `error.UnknownHostName` within the
   context of DNS resolution.
 * add `std.os.readv`, which is integrated with evented I/O.
 * `std.os.preadv`, is now integrated with evented I/O.
 * `std.os.accept4` now asserts that ENOTSOCK and EOPNOTSUPP never
    occur (misuse of API), instead of returning errors.
 * `std.os.connect` is now integrated with evented I/O.
   `std.os.connect_async` is gone. Just use `std.os.connect`.
 * fix false positive dependency loop regarding async function frames
 * add more compile notes to help when dependency loops occur
   in determining whether a function is async.
 * ir: change an assert to ir_assert to make it easier to find
   workarounds for when such an assert is triggered. In this case
   it was trying to parse an IPv4 address at comptime.
2019-10-29 22:59:30 -04:00
Felix Queißner c71857703f Adds documentation for std.fmt.format grammar and customization. (#3474) 2019-10-22 14:58:27 -04:00
Andrew Kelley 299991019d
rework the progress module and integrate with stage1 2019-10-17 20:20:22 -04:00
Andrew Kelley ed36dbbd9c
mv std/ lib/
that's all this commit does. further commits will fix cli flags and
such.

see #2221
2019-09-25 23:35:41 -04:00