Commit Graph

53 Commits

Author SHA1 Message Date
Andrew Kelley
6115cf2240 migrate from std.Target.current to @import("builtin").target
closes #9388
closes #9321
2021-10-04 23:48:55 -07:00
Andrew Kelley
d29871977f remove redundant license headers from zig standard library
We already have a LICENSE file that covers the Zig Standard Library. We
no longer need to remind everyone that the license is MIT in every single
file.

Previously this was introduced to clarify the situation for a fork of
Zig that made Zig's LICENSE file harder to find, and replaced it with
their own license that required annual payments to their company.
However that fork now appears to be dead. So there is no need to
reinforce the copyright notice in every single file.
2021-08-24 12:25:09 -07:00
Tau
8d0671157c Correct hasUniqueRepresentation for vectors
Closes #9333.
2021-07-21 15:19:57 -04:00
Andrew Kelley
f21a3ed540 std.TrailerFlags: remove superfluous parameter 2021-06-21 17:03:03 -07:00
Jacob G-W
9fffffb07b fix code broken from previous commit 2021-06-21 17:03:03 -07:00
Andrew Kelley
615d45da77 Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
Conflicts:
 * src/codegen/spirv.zig
 * src/link/SpirV.zig

We're going to want to improve the stage2 test harness to print
the source file name when a compile error occurs otherwise std lib
contributors are going to see some confusing CI failures when they cause
stage2 AstGen compile errors.
2021-05-17 19:30:38 -07:00
Aiz672
8467373bb8 Remove isIntegerNumber and isFloatingNumber 2021-05-17 08:41:44 +03:00
Andrew Kelley
5619ce2406 Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
Conflicts:
 * doc/langref.html.in
 * lib/std/enums.zig
 * lib/std/fmt.zig
 * lib/std/hash/auto_hash.zig
 * lib/std/math.zig
 * lib/std/mem.zig
 * lib/std/meta.zig
 * test/behavior/alignof.zig
 * test/behavior/bitcast.zig
 * test/behavior/bugs/1421.zig
 * test/behavior/cast.zig
 * test/behavior/ptrcast.zig
 * test/behavior/type_info.zig
 * test/behavior/vector.zig

Master branch added `try` to a bunch of testing function calls, and some
lines also had changed how to refer to the native architecture and other
`@import("builtin")` stuff.
2021-05-08 14:45:21 -07:00
Veikka Tuominen
fd77f2cfed std: update usage of std.testing 2021-05-08 15:15:30 +03:00
Andrew Kelley
474ade88b5 std: fix compile errors found by stage2 AstGen 2021-04-29 20:33:29 -07:00
Martin Wickham
96ae451bbe Add some enum utilities 2021-03-18 14:05:01 -07:00
Andrew Kelley
5f35dc0c0d zig fmt the std lib 2021-02-24 21:29:23 -07:00
Tadeo Kondrak
0b5f3c2ef9
Replace @TagType uses, mostly with std.meta.Tag 2021-01-30 22:26:44 +02:00
LemonBoy
1c13ca5a05 stage2: Use {s} instead of {} when formatting strings 2021-01-02 17:12:57 -07:00
daurnimator
bbab5e19b4 std: loop in trailer flags can be indexing operation 2021-01-01 15:48:48 -07:00
daurnimator
4387e50d4f std: use FieldEnum from TrailerFlags 2021-01-01 15:48:48 -07:00
Frank Denis
6c2e0c2046 Year++ 2020-12-31 15:45:24 -08:00
Julius Putra Tanu Setiaji
f9506e9155 Handle unions in autoHash 2020-12-26 19:43:15 +08:00
Julius Putra Tanu Setiaji
1df601d581 Make hasUniqueRepresentation false for slices 2020-12-26 11:57:09 +08:00
LemonBoy
9e5869262a std: Bool has no definite representation too
The padding bits are undefined.
2020-12-14 20:06:46 +01:00
LemonBoy
44556bfebe std: non-byte-multiple sized integers have no definite representation
Closes #7445
2020-12-14 20:06:46 +01:00
LemonBoy
ef7db9717e std: introduce meta.traits.is{Integral,Float} 2020-12-10 09:23:48 +01:00
Tadeo Kondrak
25ec2dbc1e Add builtin.Signedness, use it instead of is_signed 2020-11-19 18:59:21 +02:00
Jan Prudil
aadccc4206 Make std.meta.Int accept a signedness parameter 2020-10-17 14:09:59 +02:00
Tadeo Kondrak
d81648ce8c
Add alignment field to TypeInfo.UnionField and TypeInfo.StructField
Closes https://github.com/ziglang/zig/issues/6122
2020-10-01 15:01:25 -06:00
Tadeo Kondrak
1b2154dfe2 builtin: Add TypeInfo.StructField.is_comptime 2020-09-02 00:17:59 -04:00
Tadeo Kondrak
e4b61aa527
std.meta.TrailerFlags fixes 2020-08-27 16:02:00 -06:00
Tadeo Kondrak
f94583076e
std.meta.TrailerFlags: use @Type to improve API
- Use an enum of all field names instead of string literals
- Create a struct type with all fields optional instead of relying on
anonymous struct literals

This should provide better type inference, compile errors, and a
(subjectively) cleaner API.
2020-08-27 15:11:33 -06:00
Andrew Kelley
4a69b11e74 add license header to all std lib files
add SPDX license identifier
copyright ownership is zig contributors
2020-08-20 16:07:04 -04:00
Dmitry Atamanov
a9590f3bf8
Support tuples in mem.len and trait.isIndexable (#5897) 2020-08-14 01:14:32 +03:00
Andrew Kelley
5139aa7ba4
Merge pull request #5932 from Sahnvour/hash
new trait `hasUniqueRepresentation` and hashmap speedup
2020-07-27 07:12:54 +00:00
Sahnvour
7ae1b3a6b3 add trait hasUniqueRepresentation 2020-07-26 22:01:33 +02:00
data-man
39915ae086 Add trait.isTuple 2020-07-17 17:55:55 +03:00
Andrew Kelley
c5b7322319 TrailerFlags test: fix bad alignment assumption on 32-bit 2020-07-15 04:04:04 -07:00
Andrew Kelley
804b51b179 stage2: VarDecl and FnProto take advantage of TrailerFlags API
These AST nodes now have a flags field and then a bunch of optional
trailing objects. The end result is lower memory usage and consequently
better performance. This is part of an ongoing effort to reduce the
amount of memory parsed ASTs take up.

Running `zig fmt` on the std lib:
 * cache-misses: 2,554,321 => 2,534,745
 * instructions: 3,293,220,119 => 3,302,479,874
 * peak memory: 74.0 MiB => 73.0 MiB

Holding the entire std lib AST in memory at the same time:

  93.9 MiB => 88.5 MiB
2020-07-15 02:07:30 -07:00
Andrew Kelley
eac6280241 add std.meta.TrailerFlags API
This is useful for saving memory when allocating an object that has many
optional components. The optional objects are allocated sequentially in
memory, and a single integer is used to represent each optional object
and whether it is present based on each corresponding bit.
2020-07-14 17:19:17 -07:00
Vexu
e85fe13e44
run zig fmt on std lib and self hosted 2020-07-11 20:41:19 +03:00
Andrew Kelley
8f4bc77260
Merge pull request #5449 from data-man/more_traits
Add more traits
2020-06-01 14:50:01 -04:00
data-man
dc4fea983d Use tuples in multiTrait 2020-05-28 23:10:44 -04:00
data-man
c91786caf3 zig fmt 2020-05-28 16:41:15 +05:00
data-man
f9bdf325d3 Added tests with tuple 2020-05-28 16:39:00 +05:00
data-man
78a1f6976d Add more traits 2020-05-27 04:00:38 +05:00
data-man
b13dd3cf61 Treat vectors as indexable 2020-05-24 20:44:17 -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
Vexu
45da72c5b6
remove usages of @typeId, @memberCount, @memberName and @memberType 2020-02-24 23:09:01 +02:00
xackus
7664c3bc11 remove @bytesToSlice, @sliceToBytes from tests, docs 2020-02-23 18:03:50 +01:00
xackus
7396b144ba modernize std.meta 2020-02-14 09:35:38 -05:00
Andrew Kelley
7c1dbfab72
self-hosted: manually parse args 2019-12-11 02:08:33 -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
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