Commit Graph

20 Commits

Author SHA1 Message Date
Jimmi HC
bf3d1c1aab Allow access of array.len through a pointer 2018-06-08 09:21:31 +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
0c16cd2d0e run zig fmt on the codebase
See #1003
2018-05-29 04:23:38 -04:00
Andrew Kelley
a35b366eb6 [breaking] delete ptr deref prefix op
start using zig-fmt-pointer-reform branch build of zig fmt
to fix code to use the new syntax

all of test/cases/* are processed, but there are more left
to be done - all the std lib used by the behavior tests
2018-04-30 20:35:54 -04:00
Andrew Kelley
3671582c15 syntax: functions require return type. remove ->
The purpose of this is:

 * Only one way to do things
 * Changing a function with void return type to return a possible
   error becomes a 1 character change, subtly encouraging
   people to use errors.

See #632

Here are some imperfect sed commands for performing this update:

remove arrow:

```
sed -i 's/\(\bfn\b.*\)-> /\1/g' $(find . -name "*.zig")
```

add void:

```
sed -i 's/\(\bfn\b.*\))\s*{/\1) void {/g' $(find ../ -name "*.zig")
```

Some cleanup may be necessary, but this should do the bulk of the work.
2018-01-25 04:10:11 -05:00
Andrew Kelley
d917815d81 explicitly return from blocks
instead of last statement being expression value

closes #629
2017-12-22 00:50:30 -05:00
Andrew Kelley
d9eabde319 add Child property of slice type
also rename child field to Child for pointer and array
2017-09-13 14:30:57 -04:00
Andrew Kelley
9fb4d1fd6c std: os.ChildProcess knows when its child died
using signal handlers
2017-09-07 23:10:51 -04:00
Andrew Kelley
67b6dd28ec allow array literals to have size and fix comptime bug 2017-08-31 16:30:46 -04:00
Andrew Kelley
68add5d828 clean up behavior test names 2017-05-23 21:38:31 -04:00
Andrew Kelley
051ee8e626 change slicing syntax from ... to ..
See #359
2017-05-19 10:39:59 -04:00
Andrew Kelley
af536ac343 introduce new test syntax
* remove setFnTest builtin
 * add test "name" { ... } syntax
 * remove --check-unused argument. functions are always lazy now.
2017-03-16 16:02:35 -04:00
Andrew Kelley
1195994880 fix inability to write to global in some cases
before, when we initialized a variable by copying the
initialization value, it made the internal const value
references point to a duplicate value, resulting in
a phony duplicate global value being updated instead of
the real on. now the behavior is as expected.

thanks to hoppetosse for pointing out this bug on IRC.
2017-02-27 00:07:11 -05:00
Andrew Kelley
25761570f1 more robust const struct values 2017-02-26 23:50:04 -05:00
Andrew Kelley
6dba1f1c8e slice and array re-work plus some misc. changes
* `@truncate` builtin allows casting to the same size integer.
   It also performs two's complement casting between signed and
   unsigned integers.
 * The idiomatic way to convert between bytes and numbers is now
   `mem.readInt` and `mem.writeInt` instead of an unsafe cast.
   It works at compile time, is safer, and looks cleaner.
 * Implicitly casting an array to a slice is allowed only if the
   slice is const.
 * Constant pointer values know if their memory is from a compile-
   time constant value or a compile-time variable.
 * Cast from [N]u8 to []T no longer allowed, but [N]u8 to []const T
   still allowed.
 * Fix inability to pass a mutable pointer to comptime variable at
   compile-time to a function and have the function modify the
   memory pointed to by the pointer.
 * Add the `comptime T: type` parameter back to mem.eql. Prevents
   accidentally creating instantiations for arrays.
2017-02-12 17:35:51 -05:00
Andrew Kelley
8a859afd58 std.io supports printing integers as hex values
remove "unnecessary if statement" error
this "depends on compile variable" code is too hard to validate,
and has false negatives. not worth it right now.

std.str removed, instead use std.mem.

std.mem.eql and std.mem.sliceEql merged and do not require explicit
type argument.
2017-02-07 17:23:50 -05:00
Andrew Kelley
e5b1758010 remove staticEval builtin in favor of comptime expression 2017-01-22 23:21:00 -05:00
Andrew Kelley
3b5e26b7f7 self hosted tests import std library 2017-01-05 03:57:48 -05:00
Andrew Kelley
aee7ad3de2 IR: port all passing tests over 2016-12-26 03:44:59 -05:00
Andrew Kelley
6c9ec3688e IR testing: rename cases3 dir to cases 2016-12-26 02:49:30 -05:00