Commit Graph

43 Commits

Author SHA1 Message Date
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
a2bd9f8912 std lib: modify allocator idiom
Before we accepted a nullable allocator for some stuff like
opening files. Now we require an allocator.

Use the mem.FixedBufferAllocator pattern if a bound on the amount
to allocate is known.

This also establishes the pattern that usually an allocator is the
first argument to a function (possibly after "self").

fix docs for std.cstr.addNullByte

self hosted compiler:
 * only build docs when explicitly asked to
 * clean up main
 * stub out zig fmt
2018-02-09 18:27:50 -05:00
Andrew Kelley
32c988a2d7 fix build runner on windows 2018-02-09 00:24:23 -05:00
Andrew Kelley
0d5ff6f462 error sets - most tests passing 2018-02-08 02:08:45 -05:00
Andrew Kelley
31abef172a fix accidentally linking against kernel32 on non windows 2018-02-04 22:13:21 -05:00
Andrew Kelley
b8f59e14cd *WIP* error sets - correctly resolve inferred error sets 2018-02-02 18:13:32 -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
b3a6faf13e replace %defer with errdefer
See #632

now we have 1 less sigil
2018-01-23 23:08:09 -05:00
Jimmi Holst Christensen
a76023bcd8 Removed PLARGE_INTEGER 2018-01-19 21:49:16 +01:00
Jimmi Holst Christensen
90714a3831 Implemented windows versions of seekTo and getPos 2018-01-19 21:30:57 +01: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
e1c03d9e8e self-hosted compiler works on windows
* better error message for realpath failing
 * fix bug in std.io.readFileAllocExtra incorrectly returning
   error.EndOfStream
 * implement std.os.selfExePath and std.os.selfExeDirPath for windows
2018-01-04 13:48:45 -05:00
Andrew Kelley
ea805c5fe7 fix darwin and windows from previous commit 2017-12-22 02:33:39 -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
dimenus
a7d07d412c Added DLL loading capability in windows to the std lib. 2017-11-16 21:49:05 -06:00
Andrew Kelley
20c2dbdbd3 add windows implementation of io.File.getEndPos 2017-11-10 14:36:03 -05:00
Andrew Kelley
fcef7c4bb2 fix std.io.InStream for windows
now we handle PIPE_BROKEN as an EOF

also set up framework for debugging unexpected posix/windows errors
2017-10-15 16:45:43 -04:00
Andrew Kelley
bb169a7b36 fix child process stdio piping behavior on windows 2017-10-15 16:03:32 -04:00
Andrew Kelley
a98373f144 use correct integer type for windows BOOL 2017-10-15 14:01:55 -04:00
Andrew Kelley
8ab5313043 implement environment variables for windows 2017-10-15 01:23:10 -04:00
Andrew Kelley
531f3344dc implement std.os.rename for windows 2017-10-14 17:56:18 -04:00
Andrew Kelley
61d715d784 implement std.os.symLink for windows 2017-10-14 17:39:44 -04:00
Andrew Kelley
ad6eec9480 fix regressions from previous commit on windows 2017-10-14 17:10:53 -04:00
Andrew Kelley
0307dc0b77 organize windows utility functions 2017-10-14 16:59:43 -04:00
Andrew Kelley
0bc80411f6 implement os.makeDir for windows 2017-10-14 15:32:29 -04:00
Andrew Kelley
8d3eaab871 implement std.os.ChildProcess for windows 2017-10-14 15:32:18 -04:00
Andrew Kelley
7f9dc4ebc1 fix std.os.getRandomBytes for windows 2017-10-11 23:14:48 -04:00
Andrew Kelley
b61a6ec8a6 implement command line argument parsing for windows
See #302
2017-10-11 22:50:16 -04:00
Andrew Kelley
e6334fe46d implement std.io.InStream for windows
See #302
2017-10-09 15:59:10 -04:00
Andrew Kelley
c4262da8de implement os.path.real for windows and update allocator interface 2017-10-09 14:21:35 -04:00
Andrew Kelley
a4310cf8b4 implement std.os.deleteFile for windows 2017-10-08 23:06:56 -04:00
Andrew Kelley
9d5f15fe3d implement os.getCwd for windows 2017-10-08 21:44:24 -04:00
Andrew Kelley
fd5a5db400 implement IncrementingAllocator for Windows 2017-09-27 22:59:58 -04:00
Andrew Kelley
8f0dfcbcfb Revert "windows API functions are not stdcalls"
This reverts commit 59410a2f13.

yes they are
2017-09-24 04:18:13 -04:00
Andrew Kelley
59410a2f13 windows API functions are not stdcalls 2017-09-24 04:09:13 -04:00
Andrew Kelley
ba41be67f0 windows gui hello world 2017-09-24 03:55:45 -04:00
Andrew Kelley
751ab72a82 std: fix os.sleep on darwin and windows 2017-09-19 09:46:41 -04:00
Jonathan Marler
3f8b26c06a Allow INVALID_HANDLE_VALUE for windows to work on 32-bit and 64-bit. (#457) 2017-09-10 11:16:27 -04:00
Andrew Kelley
57fb8efde2 add missing stdcallcc to ExitProcess decl 2017-08-06 16:13:52 -04:00
Andrew Kelley
6a93dda3e1 progress toward windows hello world working 2017-06-14 00:04:34 -04:00
Andrew Kelley
199bbb6292 progress toward hello world without libc in windows 2017-06-04 10:08:55 -04:00