Commit Graph

405 Commits

Author SHA1 Message Date
Jimmi Holst Christensen
42033ea3ca
Merge pull request #1167 from ziglang/comptime-array-by-value
Implement const_values_equal for arrays
2018-06-30 18:58:31 +02:00
Jimmi HC
3ec38b2494 Implement const_values_equal for array type
* This allows arrays to be passed by value at comptime
2018-06-28 10:34:37 +02:00
Marc Tiehuis
4a35d7eeeb Correct hex-float parsing
Unblocks #495.
2018-06-28 20:12:03 +12:00
Andrew Kelley
2fa588e81d fix coroutine accessing freed memory
closes #1164
2018-06-27 18:45:21 -04:00
Andrew Kelley
19961c50e4 fix comptime @tagName crashing sometimes
closes #1118
2018-06-27 13:15:55 -04:00
Ben Noordhuis
440c1d52b4 simplify comptime floating-point @divTrunc
Replace a conditional ceil/floor call with an unconditional trunc call.
2018-06-27 16:20:04 +02:00
Ben Noordhuis
fd75e73ee9 add f16 type
Add support for half-precision floating point operations.

Introduce `__extendhfsf2` and `__truncsfhf2` in std/special/compiler_rt.

Add `__gnu_h2f_ieee` and `__gnu_f2h_ieee` as aliases that are used in
Windows builds.

The logic in std/special/compiler_rt/extendXfYf2.zig has been reworked
and can now operate on 16 bits floating point types.

`extendXfYf2()` and `truncXfYf2()` are marked `inline` to work around
a not entirely understood stack alignment issue on Windows when calling
the f16 versions of the builtins.

closes #1122
2018-06-27 16:20:04 +02:00
Ben Noordhuis
0ebc7b66e6 scope variables in floating point cast tests
Fixes a bug where the result of a @floatCast wasn't actually checked; it
was checking the result from the previous @floatCast.
2018-06-27 16:20:04 +02:00
Andrew Kelley
11ca38a4e9 fix crash for optional pointer to empty struct
closes #1153
2018-06-26 15:27:41 -04:00
Andrew Kelley
8866bef92c clean up self hosted main. delete unsupported commands 2018-06-22 01:54:38 -04:00
Andrew Kelley
5f38d6e2e9 add casting docs, __extenddftf2, and __extendsftf2 2018-06-21 14:44:35 -04:00
Isaac Hier
f1207a8e74 Add test case 2018-06-21 08:32:05 -04:00
Ben Noordhuis
eb6a8e6a3b fix f128 remainder division bug
The modulo operation computed rem(b+rem(a,b), b) which produces -1
for a=1 and b=2.

Switch to a - b * trunc(a/b) which produces the expected result, 1.

closes #1137
2018-06-20 17:37:38 -04:00
Andrew Kelley
e891f9cd9d zig fmt 2018-06-20 17:16:27 -04:00
Andrew Kelley
55193cb13b fix runtime fn ptr equality codegen
closes #1140
2018-06-20 06:46:53 -04:00
Andrew Kelley
7c99c30bf4 fix calling method with comptime pass-by-non-copyign-value self arg
closes #1124
2018-06-19 19:35:59 -04:00
Andrew Kelley
c7804277bf @floatToInt now has safety-checked undefined behavior
when the integer part does not fit in the destination integer type

 * Also fix incorrect safety triggered for integer casting an
   `i32` to a `u7`. closes #1138
 * adds compiler-rt function: `__floatuntidf`
2018-06-19 16:06:10 -04:00
Andrew Kelley
85422d7aea
Merge pull request #1136 from alexnask/typeinfo_improvements
@typeInfo now uses optional types instead of @typeOf(undefined)
2018-06-19 11:46:32 -04:00
Alexandros Naskos
1392313236 @typeInfo now uses optional types instead of @typeOf(undefined) 2018-06-19 17:45:19 +03:00
Andrew Kelley
a3ddd0826b remove enum to/from int casting syntax; add @enumToInt/@intToEnum
see #1061
2018-06-19 03:50:38 -04:00
Andrew Kelley
626b73e8be remove error to/from int casting syntax; add @errorToInt/@intToError
See #1061
2018-06-18 18:48:29 -04:00
Andrew Kelley
1aafbae5be remove []u8 casting syntax. add @bytesToSlice and @sliceToBytes
See #1061
2018-06-18 17:25:29 -04:00
Andrew Kelley
5d705fc6e3 remove error set casting syntax. add @errSetCast
See #1061
2018-06-18 15:01:42 -04:00
Andrew Kelley
d49d6f0cde fix compiler crash when using @intToFloat with float literal
closes #1132
2018-06-18 11:04:18 -04:00
Andrew Kelley
4210f1f6a0 remove bool to int syntax. add @boolToInt
add missing docs

See #1061
2018-06-18 03:07:16 -04:00
Andrew Kelley
7912061226 remove integer and float casting syntax
* add `@intCast`
 * add `@floatCast`
 * add `@floatToInt`
 * add `@intToFloat`

See #1061
2018-06-17 02:57:07 -04:00
Andrew Kelley
472b7ef7e6 disable byval 2018-06-16 19:37:00 -04:00
Andrew Kelley
e311cd562b don't automatically take pointer when passing by non-copying value
this commit does not have all tests passing
2018-06-16 19:37:00 -04:00
Andrew Kelley
59b3dc8907 allow passing by non-copying value
closes #733
2018-06-16 19:36:33 -04:00
Alexandros Naskos
4ec09ac243 Enabled optional types of zero bit types with no LLVM DI type. (#1110)
* Zero bit optional types do not need a LLVM DI type
2018-06-14 10:57:28 -04:00
Andrew Kelley
86adc1ef39 add docs and missing test case for merging error sets
See #367
2018-06-12 19:38:59 -04:00
Andrew Kelley
259413251d fix ability to call mutating methods on zero size structs
closes #838
2018-06-12 15:06:02 -04:00
Andrew Kelley
03c16c6c54 implement @tagName as a switch instead of table lookup
closes #976
closes #1080
2018-06-11 14:58:42 -04:00
Andrew Kelley
77678b2cbc
breaking syntax change: orelse keyword instead of ?? (#1096)
use the `zig-fmt-optional-default` branch to have zig fmt
automatically do the changes.

closes #1023
2018-06-10 01:13:51 -04:00
Andrew Kelley
ec1b6f6673
breaking syntax change: ??x to x.? (#1095)
See #1023

This also renames Nullable/Maybe to Optional
2018-06-09 23:42:14 -04:00
Andrew Kelley
6edd81109d nullable pointers follow const-casting rules
any *T -> ?*T cast is allowed implicitly, even
when it occurs deep inside the type, and the cast
is a no-op at runtime.

in order to add this I had to make the comptime value
representation of nullable pointers the same as the
comptime value representation of normal pointers,
so that we don't have to do any recursive transformation
of values when doing this kind of cast.
2018-06-09 00:26:26 -04:00
Jimmi HC
bf3d1c1aab Allow access of array.len through a pointer 2018-06-08 09:21:31 +02:00
Andrew Kelley
f0b6dac1f2 add implicit casts from *[N]T
* to `[]T`
 * to `[*]T`

See #770
2018-06-07 22:41:58 -04:00
Andrew Kelley
b65203f573 remove @canImplicitCast builtin
nobody will miss it
2018-06-07 19:50:25 -04:00
Andrew Kelley
31aefa6a21 fix structs that contain types which require comptime
Now, if a struct has any fields which require comptime,
such as `type`, then the struct is marked as requiring
comptime as well. Same goes for unions.

This means that a function will implicitly be called
at comptime if the return type is a struct which contains
a field of type `type`.

closes #586
2018-06-07 18:07:30 -04:00
Andrew Kelley
d3693dca73 Pointer Reform: update @typeInfo
* add assertion for trying to do @typeInfo on global error set
 * remove TypeInfo.Slice
 * add TypeInfo.Pointer.Size with possible values
   - One
   - Many
   - Slice

See #770
2018-06-06 00:39:39 -04:00
Jimmi HC
a8146ade2a Renamed UndefinedLiteral to Undefined 2018-06-05 11:54:11 +02:00
Jimmi HC
236c680f6b Removed NullLiteral to Null 2018-06-05 11:30:01 +02:00
Jimmi HC
02cb220faf Renamed "(int/float literal)" to "comptime_int/float" 2018-06-05 11:14:43 +02:00
Andrew Kelley
e53b683bd3
Pointer Reform: proper slicing and indexing (#1053)
* enable slicing for single-item ptr to arrays
 * disable slicing for other single-item pointers
 * enable indexing for single-item ptr to arrays
 * disable indexing for other single-item pointers

see #770
closes #386
2018-06-04 22:11:14 -04:00
Andrew Kelley
d21a1922eb support zig fmt: off and zig fmt: on between top level decls
closes #1030
closes #1033
2018-06-04 12:15:02 -04:00
Andrew Kelley
96164ce613 disallow single-item pointer indexing
add pointer arithmetic for unknown length pointer
2018-06-04 01:39:57 -04:00
Andrew Kelley
5f38a01ede run zig fmt 2018-06-01 01:22:35 -04:00
Andrew Kelley
2a7c8c5b10 add test case for pointer to type and slice of type
closes #588
2018-06-01 00:18:10 -04:00
Andrew Kelley
fcbb7426fa use * for pointer type instead of &
See #770

To help automatically translate code, see the
zig-fmt-pointer-reform-2 branch.

This will convert all & into *. Due to the syntax
ambiguity (which is why we are making this change),
even address-of & will turn into *, so you'll have
to manually fix thes instances. You will be guaranteed
to get compile errors for them - expected 'type', found 'foo'
2018-05-31 17:28:07 -04:00