Commit Graph

21 Commits (118d41ef8325b4c1ca8be1fea66c2e8368b67e32)

Author SHA1 Message Date
Andrew Kelley ac4d55dec1 behavior tests passing with new pointer deref syntax 2018-05-01 01:53:04 -04:00
Andrew Kelley b21bcbd775 fix std threads for macos 2018-04-29 02:52:04 -04:00
Andrew Kelley 96ecb40259 add fuzz tests for std.atomic.Stack 2018-04-28 17:53:06 -04:00
tgschultz a1083b019c Added DirectAllocator support for alignments > os.page_size on posix systems 2018-04-21 20:41:49 -05:00
Andrew Kelley ec0846a00f std.heap.ArenaAllocator: fix incorrectly activating safety check 2018-02-12 03:21:18 -05:00
Andrew Kelley 227ead54be back to malloc instead of aligned_alloc for c_allocator
it seems that a 7 years old standard is still too new for the
libc variants that are ubiquitous

(tests failing on macos for not providing C11 ABI)
2018-02-12 03:15:12 -05:00
Andrew Kelley 4a4ea92cf3 remove std.heap.IncrementingAllocator
Use std.heap.FixedBufferAllocator combined with
std.heap.DirectAllocator instead.

std.mem.FixedBufferAllocator is moved to std.heap.FixedBufferAllocator
2018-02-12 02:44:31 -05: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 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 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
Andrea Orru e932919e68 Darwin -> MacOSX, added Zen. See #438 2018-01-06 23:10:53 -05:00
Andrew Kelley 4183c6f1a5 move std/debug.zig to a subdirectory
self hosted compiler parser tests do some fuzz testing
2017-12-23 22:15:48 -05:00
Andrew Kelley 39c7bd24e4 port most of main.cpp to self hosted compiler 2017-12-23 00:57:56 -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 62c25af802 add higher level arg-parsing API + misc. changes
* add @noInlineCall - see #640
   This fixes a crash in --release-safe and --release-fast modes
   where the optimizer inlines everything into _start and
   clobbers the command line argument data.
   If we were able to verify that the user's code never reads
   command line args, we could leave off this "no inline"
   attribute.
 * add i29 and u29 primitive types. u29 is the type of alignment,
   so it makes sense to be a primitive.
   probably in the future we'll make any `i` or `u` followed by
   digits into a primitive.
 * add `aligned` functions to Allocator interface
 * add `os.argsAlloc` and `os.argsFree` so that you can get
   a `[]const []u8`, do whatever arg parsing you want, and then free
   it. For now this uses the other API under the hood, but it could
   be reimplemented to do a single allocation.
 * add tests to make sure command line argument parsing works.
2017-12-06 18:12:05 -05:00
scurest 48c8181886 fix redeclaration of mem (#585) 2017-11-05 15:46:54 -06:00
scurest bd6f8d99c5 add test for c_allocator 2017-11-05 15:46:10 -06: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