Commit Graph

172 Commits

Author SHA1 Message Date
Andrew Kelley
caaeab9882 add setEvalBranchQuota builtin function 2017-08-19 17:10:29 -04:00
Andrew Kelley
cd2f65ff6a add compile error for globally shadowing a primitive type
closes #423
2017-08-19 02:02:25 -04:00
Andrew Kelley
1b5d61bee9 fix bitCast for big integers
and make bigfloat use __float128
2017-08-17 22:52:12 -04:00
Andrew Kelley
2173e1f457 fix big integer shifting by large number 2017-08-17 22:01:19 -04:00
Andrew Kelley
e63d864c1e add compiler_rt functions for f128
* __letf2
 * __cmptf2
 * __getf2
 * __unordtf2
 * __eqtf2
 * __lttf2
 * __netf2
 * __gttf2
2017-08-17 19:10:15 -04:00
Andrew Kelley
0d117bb0a9 fix wrong value for clz, ctz at compile time
closes #418

also make clz, ctz return smaller integer bit widths
and use smaller integer bit widths for enum tag types
2017-08-17 17:14:35 -04:00
Andrew Kelley
6a98bf3dba compiler_rt implementations for __fixuns* functions
* add u128 and i128 integer types
 * add f128 floating point type
 * implement big integer multiplication (See #405)
2017-08-16 19:07:35 -04:00
Andrew Kelley
35d3444e27 more intuitive left shift and right shift operators
Before:
 * << is left shift, not allowed to shift 1 bits out
 * <<% is left shift, allowed to shift 1 bits out
 * >> is right shift, allowed to shift 1 bits out

After:
 * << is left shift, allowed to shift 1 bits out
 * >> is right shift, allowed to shift 1 bits out
 * @shlExact is left shift, not allowed to shift 1 bits out
 * @shrExact is right shift, not allowed to shift 1 bits out

Closes #413
2017-08-09 10:09:38 -04:00
Andrew Kelley
54675b060a add ptrToInt builtin, remove usize(ptr) cast
closes #415
2017-08-08 17:38:25 -04:00
Andrew Kelley
2234788fa8 add ability to explicitly cast float to integer
closes #414
2017-08-07 15:57:41 -04:00
Marc Tiehuis
0705b711f8 Correct floating-point literal allowed ranges
The exponent range for floating-point values is [-1022, 1023].

Fixes #399.
2017-08-07 18:08:09 +12:00
Andrew Kelley
d1e68c3ca8 better bigint/bigfloat implementation 2017-07-08 17:59:10 -04:00
scurest
1a63f27247 allow trailing commas
closes #392
2017-06-17 10:34:51 -04:00
Andrew Kelley
1566ca21c4 fix peer type resolution for array and error
closes #388
2017-06-17 10:29:04 -04:00
Andrew Kelley
865b53f286 fix alignOf builtin
* fix assertion error when type is not yet complete
 * fix alignment value

closes #391
2017-06-15 23:47:05 -04:00
Andrew Kelley
ae61e26680 fix compiler segfault on null ?? x
closes #390
2017-06-14 19:32:52 -04:00
Andrew Kelley
7f0620a20f partial implementation of printing floating point numbers with errol3
also add bitCast builtin function. closes #387
2017-06-14 00:24:25 -04:00
Andrew Kelley
1ae2002b41 fix crash when writing to const hardcoded ptr
closes #381
2017-05-29 14:25:00 -04:00
Andrew Kelley
8ae4ffa493 fix crash when unwrapping optional field of global variable
closes #379
2017-05-29 14:08:39 -04:00
Andrew Kelley
2dfb1ebee2 const global values can reference each other
Before, if you did something like:

```
const hi1 = "hi";
const hi2 = hi1;
```

This would create the "hi" data twice in the built object.
But since the value is const we don't have to duplicate the
data, now we take advantage of this fact.

closes #336
2017-05-27 00:54:14 -04:00
Andrew Kelley
d6b01931ef implicitly cast by value var args parameters to const references
See #336
2017-05-26 16:44:13 -04:00
Andrew Kelley
c42c91ee7c fix segfault with array of generic functions
closes #377
2017-05-26 14:39:18 -04:00
Andrew Kelley
68add5d828 clean up behavior test names 2017-05-23 21:38:31 -04:00
Andrew Kelley
9f3cca8615 add error for break/continue exiting defer expression
See #284
2017-05-21 10:44:55 -04:00
Andrew Kelley
29b488245d add setFloatMode builtin and std.math.floor
* skip installing std/rand_test.zig as it's not needed beyond running
   the std lib tests
 * add std.math.floor function
 * add setFloatMode builtin function to choose between
   builtin.FloatMode.Optimized (default) and builtin.FloatMode.Strict
   (Optimized is equivalent to -ffast-math in gcc)
2017-05-20 23:06:32 -04:00
Andrew Kelley
051ee8e626 change slicing syntax from ... to ..
See #359
2017-05-19 10:39:59 -04:00
Andrew Kelley
b483db4868 typeId builtin instead of isInteger, isFloat, etc
closes #373
2017-05-17 12:26:35 -04:00
Andrew Kelley
9851a943ed add compile error for compile-time integer cast truncating bits
closes #371
2017-05-16 17:04:35 -04:00
Andrew Kelley
6237411716 inline function call with builtin function instead...
...of special syntax.

partially reverts 41144a8566

closes #306
2017-05-09 22:54:23 -04:00
Andrew Kelley
01f066de37 ability to slice ptr to hard coded integer at comptime
closes #369
2017-05-09 22:23:38 -04:00
Andrew Kelley
2f20fe6ecd delete @generatedCode builtin function
good riddance
2017-05-07 23:25:36 -04:00
Andrew Kelley
e485af94d4 fix inability to initialize global pointer to global array element
closes #366
2017-05-07 18:09:45 -04:00
Andrew Kelley
dc2df15528 add test case for all prongs unreachable in switch
See #43
2017-05-07 13:26:41 -04:00
Andrew Kelley
11d8a8cc7b fix comptime switch on enum with ref payload
See #43
2017-05-07 13:21:53 -04:00
Andrew Kelley
818a0a2629 switch expression - add compile errors
* for duplicate integer value
   * for missing integer values
   * for missing else prong

see #43
2017-05-07 12:07:35 -04:00
Andrew Kelley
29beb603b7 allow division and remainder operators sometimes
when the values are comptime known and the result would be the same,
allow `/` and `%` for signed integers and floats.

closes #365
2017-05-06 23:59:57 -04:00
Andrew Kelley
157af4332a builtin functions for division and remainder division
* add `@divTrunc` and `@divFloor` functions
 * add `@rem` and `@mod` functions
 * add compile error for `/` and `%` with signed integers
 * add `.bit_count` for float primitive types

closes #217
2017-05-06 23:13:12 -04:00
Andrew Kelley
b6a679c0ed implement else on loops and break can give an expression
closes #357
2017-05-04 12:43:11 -04:00
Andrew Kelley
20b1491e6b implement while for nullables and error unions
See #357
2017-05-04 10:28:00 -04:00
Andrew Kelley
698829b772 change while syntax
Old:

```
while (condition; expression) {}
```

New:

```
while (condition) : (expression) {}
```

This is in preparation to allow nullable and
error union types as the condition. See #357
2017-05-03 18:12:07 -04:00
Andrew Kelley
644ea2dde9 remove test and try expressions in favor of if expressions
See #357
2017-05-03 17:23:11 -04:00
Andrew Kelley
7c236f6dd8 fix compiler crash when referencing a variable...
...in an if after an if in the 2nd switch prong

closes #355
2017-05-02 12:59:09 -04:00
Andrew Kelley
9f92042da9 allow undefined to be resolved with other types
closes #295
2017-05-01 22:37:34 -04:00
Andrew Kelley
17b935325e @import("builtin") instead of @compileVar
See #226
Closes #220
2017-05-01 13:12:38 -04:00
Andrew Kelley
43e7ac8418 add peer type resolution []T and [0]T
closes #349

also fix slicing const array to be []const T instead of []T
2017-04-30 12:21:24 -04:00
Andrew Kelley
cbfe4b4bae add implicit cast from [0]T to %[]T
closes #347

also add std.os.path.relative
2017-04-29 19:23:33 -04:00
Andrew Kelley
7b0542d08b build system: consolidate duplicate code and more
* add ability to add assembly files when building an exe, obj, or lib
 * add implicit cast from `[N]T` to `?[]const T` (closes #343)
 * remove link_exe and link_lib in favor of allowing build_exe and
   build_lib support no root zig source file
2017-04-26 19:17:05 -04:00
Josh Wolfe
c6605cba83 blocks check that their statements are void
closes #291

This changes the error message "return value ignored" to "expression value is ignored".
This is because this error also applies to {1;}, which has no function calls.

Also fix ignored expression values in std and test.
This caught a bug in debug.readAllocBytes where an early Eof error would have been missed.
See #219.
2017-04-23 21:15:15 -07:00
Andrew Kelley
aafb0b9082 slicing now returns correct const-ness
also remove the ability to override constness when slicing

closes #334
2017-04-22 12:19:20 -04:00
Andrew Kelley
1a0081b763 add peer type resolution for T and ?T
See #334
2017-04-22 11:45:04 -04:00