Commit Graph

42 Commits (f5a67dba08b81c7109c52f6ad957aefdd646b56e)

Author SHA1 Message Date
Andrew Kelley ced3aae3b2 cleaner output from zig build when there are compile errors 2018-07-07 20:31:50 -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 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
Andrew Kelley ea58f4a5a9 run zig fmt on the codebase 2018-05-30 16:09:11 -04:00
Andrew Kelley 0c16cd2d0e run zig fmt on the codebase
See #1003
2018-05-29 04:23:38 -04:00
Andrew Kelley 445b03384a introduce std.heap.ArenaAllocator and std.heap.DirectAllocator
* DirectAllocator does the underlying syscall for every allocation.
 * ArenaAllocator takes another allocator as an argument and
   allocates bytes up front, falling back to DirectAllocator with
   increasingly large allocation sizes, to avoid calling it too often.
   Then the entire arena can be freed at once.

The self hosted parser is updated to take advantage of ArenaAllocator
for the AST that it returns. This significantly reduces the complexity
of cleanup code.

docgen and build runner are updated to use the combination of
ArenaAllocator and DirectAllocator instead of IncrementingAllocator,
which is now deprecated in favor of FixedBufferAllocator combined
with DirectAllocator.

The C allocator calls aligned_alloc instead of malloc, in order to
respect the alignment parameter.

Added asserts in Allocator to ensure that implementors of the
interface return slices of the correct size.

Fixed a bug in Allocator when you call realloc to grow the allocation.
2018-02-12 02:14:44 -05:00
Andrew Kelley f9be970375 Merge remote-tracking branch 'origin/master' into error-sets 2018-02-08 20:45:26 -05:00
Andrew Kelley 0d5ff6f462 error sets - most tests passing 2018-02-08 02:08:45 -05:00
Jeff Fowler c88e6e8aee improve behavior of `zig build` (#754)
See #748
2018-02-07 17:45:20 -05:00
Andrew Kelley 5f518dbeb9 *WIP* error sets converting std lib 2018-01-31 22:48:40 -05: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 7b57454cc1 clean up error return tracing
* error return tracing is disabled in release-fast mode
 * add @errorReturnTrace
 * zig build API changes build return type from `void` to `%void`
 * allow `void`, `noreturn`, and `u8` from main. closes #535
2018-01-15 00:01:02 -05:00
Andrew Kelley 32ea6f54e5 *WIP* proof of concept error return traces 2018-01-12 02:12:11 -05:00
Andrew Kelley 3c094116aa remove %% prefix operator
See #632
closes #545
closes #510

this makes #651 higher priority
2018-01-09 00:51:51 -05:00
Andrew Kelley 632d143bff replace `a %% b` with `a catch b`
See #632

better fits the convention of using keywords for control flow
2018-01-07 17:28:20 -05:00
Andrew Kelley 66717db735 replace `%return` with `try`
See #632

better fits the convention of using keywords for control flow
2018-01-07 16:53:13 -05:00
Andrew Kelley 79d50d9933 appveyor: enable verbose link for self hosted compiler 2018-01-04 23:43:46 -05:00
Andrew Kelley e0a1466bd8 build: add --search-prefix option 2017-12-23 22:14:35 -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 4543413491 std.io: introduce buffered I/O and change API
I started working on #465 and made some corresponding std.io
API changes.

New structs:
 * std.io.FileInStream
 * std.io.FileOutStream
 * std.io.BufferedOutStream
 * std.io.BufferedInStream

Removed:
 * std.io.File.in_stream
 * std.io.File.out_stream

Now instead of &file.out_stream or &file.in_stream to get access to
the stream API for a file, you get it like this:

var file_in_stream = io.FileInStream.init(&file);
const in_stream = &file_in_stream.stream;

var file_out_stream = io.FileOutStream.init(&file);
const out_stream = &file_out_stream.stream;

This is evidence that we might not need any OOP features -
See #130.
2017-11-07 03:22:27 -05:00
Andrew Kelley f7837f445e bump build_runner allocator to use 30 MB 2017-11-01 16:46:10 -04:00
Andrew Kelley 9e234d4208 breaking change to std.io API
* Merge io.InStream and io.OutStream into io.File
 * Introduce io.OutStream and io.InStream interfaces
   - io.File implements both of these
 * Move mem.IncrementingAllocator to heap.IncrementingAllocator

Instead of:

```
%return std.io.stderr.printf("hello\n");
```

now do:

```
std.debug.warn("hello\n");
```

To print to stdout, see `io.getStdOut()`.

 * Rename std.ArrayList.resizeDown to std.ArrayList.shrink.
2017-10-31 04:47:55 -04:00
Andrew Kelley 5f28a9d238 cleaner verbose flags and zig build prints failed command 2017-10-25 23:10:41 -04:00
Andrew Kelley b61a6ec8a6 implement command line argument parsing for windows
See #302
2017-10-11 22:50:16 -04:00
Andrew Kelley 766547dbfe bump incrementing allocator memory in build system to 20MB
See #467
2017-09-14 20:28:38 -04:00
Andrew Kelley 051ee8e626 change slicing syntax from ... to ..
See #359
2017-05-19 10:39:59 -04:00
Andrew Kelley 5c094d7390 std: rename List to ArrayList and re-organize...
...the exports of std.

closes #356
2017-05-04 14:05:06 -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 38a04a267c zig build: when compiling C files put .o files in cache dir
See #328
2017-04-30 13:01:35 -04:00
Andrew Kelley a147f06585 zig puts temporary object files in zig-cache folder
See #298
2017-04-28 02:22:12 -04:00
Andrew Kelley 0cce115476 update syntax for try and nullable unwrapping
closes #285
2017-04-21 16:46:33 -04:00
Andrew Kelley 37b9a2e6a4 convert compare-output tests to use zig build system 2017-04-19 01:15:20 -04:00
Andrew Kelley 05b3082121 zig build system: progress toward install and uninstall
also:
 * add std.os.path.join
 * add std.os.deleteFile
2017-04-17 06:47:20 -04:00
Andrew Kelley 5fdefe58e4 zig build system understands the concept of dependencies
See #204
2017-04-13 17:21:00 -04:00
Andrew Kelley 2864359950 zig build system writes template build.zig file when none exists
see #204
2017-04-11 06:14:46 -04:00
Andrew Kelley 10dbc735fe zig build: use -D for options instead of -O
because -O is usually optimization level
2017-04-06 13:59:11 -04:00
Andrew Kelley 6fbe1632d0 Update zig build system to support user defined options
* Fix assertion failure when switching on type.
   Closes #310
 * Update zig build system to support user defined options.
   See #204
 * fmt.format supports {sNNN} to set padding for a buffer arg.
 * add std.fmt.bufPrint and std.fmt.allocPrint
 * std.hash_map.HashMap.put returns the previous value
 * add std.mem.startsWith
2017-04-06 05:34:04 -04:00
Andrew Kelley 1c6000d047 zig build system improvements, add some std API
* add std.buf_map.BufMap
 * add std.buf_set.BufSet
 * add std.mem.split
 * zig build system improvements (See #204)
   - automatically parses NIX_CFLAGS_COMPILE and NIX_LDFLAGS
   - add builder.addCIncludePath
   - add builder.addRPath
   - add builder.addLibPath
   - add exe.linkLibrary
2017-04-04 01:52:20 -04:00
Andrew Kelley 72fb2443e0 API for command line args
closes #300
2017-04-04 00:17:24 -04:00
Andrew Kelley a1363b5227 proof of concept build system
see #204
2017-04-02 20:44:04 -04:00
Andrew Kelley 3ca027ca82 first pass at zig build system
* `zig build --export [obj|lib|exe]` changed to `zig build_obj`,
   `zig build_lib` and `zig build_exe` respectively.
 * `--name` parameter is optional when it can be inferred from the
   root source filename. closes #207
 * `zig build` now looks for `build.zig` which interacts with
   `std.build.Builder` to describe the targets, and then the zig
   build system prints TODO: build these targets. See #204
 * add `@bitcast` which is mainly used for pointer reinterpret
   casting and make explicit casting not do pointer reinterpretation.
   Closes #290
 * fix debug info for byval parameters
 * sort command line help options
 * `std.debug.panic` supports format string printing
 * add `std.mem.IncrementingAllocator`
 * fix const ptr to a variable with data changing at runtime.
   closes #289
2017-03-31 05:55:41 -04:00