Commit Graph

527 Commits (9a0a378e2f957f6acf5fbb37818d1cc0e3a38d33)

Author SHA1 Message Date
hryx 247e567422
Don't return a slice pointing to a deceased stack address 2019-06-28 18:01:41 -07:00
hryx 102bf5200c
Fix string literal: not null-terminated (thanks @mikdusan) 2019-06-28 17:40:20 -07:00
hryx cc74bf5136
Translate IntegralCast; add stage2 test coverage 2019-06-27 23:12:33 -07:00
hryx 646268875e
Use new width format option 2019-06-27 22:16:31 -07:00
hryx 2060c7c39b
Merge branch 'master' into translate-c-userland 2019-06-27 22:12:34 -07:00
hryx 3e0ff32bd8
Separate with space instead of LF to prevent rendering excessive indentation 2019-06-27 21:17:27 -07:00
hryx b4bd52cc51
Create and render big.Int from IntegerLiteral; group BinaryOperator 2019-06-27 21:02:48 -07:00
Marc Tiehuis f5af349bd6
Merge pull request #2714 from ziglang/fmt-overhaul
Add positional, precision and width support to std.fmt
2019-06-25 20:15:33 +12:00
hryx 8435351581
Escape C string literals 2019-06-24 22:37:19 -07:00
hryx f845994839
transBinaryOperator: Add, Sub 2019-06-23 17:17:21 -07:00
hryx 69b90e0681
transStringLiteral 2019-06-23 15:06:16 -07:00
hryx b2e06c3bf4
Observe translate mode in stage2 2019-06-23 14:32:45 -07:00
hryx c423697c78
Merge branch 'master' into translate-c-userland 2019-06-23 12:31:22 -07:00
hryx 1c86a191da
Fix order of tokens; omit 'pub' for fn types 2019-06-23 01:03:28 -07:00
hryx 4c8b460fec
Fix recursive self-referential block 2019-06-22 22:30:15 -07:00
hryx 4ae95d7ffc
Translate assignment BinaryOperator statements 2019-06-22 17:29:36 -07:00
hryx 6325ffc3f1
Assign undefined literal (instead of null) when no init value 2019-06-22 17:29:10 -07:00
Sahnvour 987c209b40 heap: make one global instance of DirectAllocator
it is now stateless, so the de/init are not necessary anymore
2019-06-22 14:10:53 -04:00
Marc Tiehuis 11526b6e9d breaking: Add positional, precision and width support to std.fmt
This removes the odd width and precision specifiers found and replacing
them with the more consistent api described in #1358.

Take the following example:

    {1:5.9}

This refers to the first argument (0-indexed) in the argument list. It
will be printed with a minimum width of 5 and will have a precision of 9
(if applicable).

Not all types correctly use these parameters just yet. There are still
some missing gaps to fill in. Fill characters and alignment have yet to
be implemented.
2019-06-21 20:11:15 +12:00
hryx 0f545e5a2b
transReturnStmt 2019-06-10 23:06:54 -07:00
hryx 84e479d94f
(broken) local var decls, integer literals (part) 2019-06-09 23:35:48 -07:00
daurnimator ed41d10a06
std: existing LinkedList is actually a TailQueue 2019-06-10 15:41:40 +10:00
Andrew Kelley b735764898
different array literal syntax when inferring the size
old syntax:  []i32{1, 2, 3}
new syntax: [_]i32{1, 2, 3}

closes #1797
2019-06-09 19:26:32 -04:00
hryx 586c36dd1d
Restore fn decls removed during conflict 2019-06-08 17:02:00 -07:00
hryx ad0f0562d8
Merge branch 'master' into translate-c-userland 2019-06-08 16:23:27 -07:00
hryx ed5b8335b5
(broken) translate Paren type 2019-06-08 16:09:25 -07:00
hryx 1692a76d28
transImplictCastExpr: LValueToRValue 2019-06-08 15:57:43 -07:00
hryx 1f82c7ba22
transCStyleCastExpr 2019-06-08 15:54:15 -07:00
Andrew Kelley 5784631fab
update the default macos version min to 10.14 2019-06-07 12:20:02 -04:00
Andrew Kelley 7878f9660f
dep tokenizer: run zig fmt and move exports to canonical location 2019-05-30 12:07:55 -04:00
Andrew Kelley 5954d5235f
Merge pull request #2182 from mikdusan/issue.2046
new .d file parser for stage1 compiler
2019-05-30 11:53:08 -04:00
Andrew Kelley bfc86776d5
run zig fmt to update `use` to `usingnamespace` 2019-05-29 19:09:58 -04:00
hryx 3e14f86f9e
Implement missing clang functions from last commit 2019-05-29 15:33:44 -07:00
Michael Dusan 2975bdc684
add review changes
- use std.heap.c_allocator
- use @panic instead of unreachable
- use extern enum for tokenizer result type
2019-05-29 14:39:13 -04:00
Gonzalo Diethelm 6547468af6 clang.zig cleanup #9: rename arg0 to self 2019-05-28 18:05:08 +02:00
Gonzalo Diethelm 8d50d4f3fc clang.zig cleanup #8: add missing consts 2019-05-28 18:05:08 +02:00
Gonzalo Diethelm b639447263 clang.zig cleanup #7: add missing struct 2019-05-28 18:05:08 +02:00
Gonzalo Diethelm f4b4ea402e clang.zig cleanup #6: move block around 2019-05-28 18:05:08 +02:00
Gonzalo Diethelm fd9e63da53 clang.zig cleanup #5: add missing enums 2019-05-28 18:05:08 +02:00
Gonzalo Diethelm 7f1dd05fa7 clang.zig cleanup #4: move block around 2019-05-28 18:05:08 +02:00
Gonzalo Diethelm 5df2e791c2 clang.zig cleanup #3: move block around 2019-05-28 18:05:08 +02:00
Gonzalo Diethelm abf97cc232 clang.zig cleanup #2: move block around 2019-05-28 18:05:08 +02:00
Gonzalo Diethelm 333c050a1d clang.zig cleanup #1: move block around 2019-05-28 18:05:07 +02:00
Gonzalo Diethelm 775a25b7fd Add declarations missing from clang.zig 2019-05-28 18:05:07 +02:00
hryx e632c2ade3
(broken) port a bunch of stuff from stage1 translate-c 2019-05-27 23:55:48 -07:00
hryx b558d0996a
expr: DeclRefExpr 2019-05-27 19:20:23 -07:00
hryx e07888e54c
expr: FunctionToPointerDecay & ArrayToPointerDecay for ImplicitCastExpr 2019-05-27 18:18:27 -07:00
hryx 22299869ba
Prevent infinite recursion 2019-05-27 17:54:40 -07:00
hryx e1f3eec9cc
Merge branch 'master' into translate-c-userland 2019-05-27 17:24:21 -07:00
Andrew Kelley 3fccc07479
self-hosted translate-c: fix bad memory arena references 2019-05-27 20:22:15 -04:00
Michael Dusan d4b241c14e
new .d file parser for C compilation
- wip for #2046
- clang .d output must be created with `clang -MV` switch
- implemented in Zig
- hybridized for zig stage0 and stage1
- zig test src-self-hosted/dep_tokenizer.zig
2019-05-27 19:47:10 -04:00
hryx 2aa1c5da5d
Remove unused local struct type 2019-05-27 15:58:21 -07:00
hryx 3bbee1ba2e
expr: BitCast for ImplicitCastExpr 2019-05-27 14:38:09 -07:00
Andrew Kelley 0c6ab61b22
tests passing on linux 2019-05-26 23:35:26 -04:00
hryx 9c437f9032
var decl: ImplicitCastExpr 2019-05-26 19:14:50 -07:00
hryx 1a8f8c6262
var decl: init node 2019-05-26 17:36:47 -07:00
hryx c79b8aeaef
var decl: threadlocal 2019-05-26 17:05:49 -07:00
hryx 99f0b28d39
var decl: mut_token, create child scope 2019-05-26 16:51:25 -07:00
hryx fceedada5c
WIP translate var decl 2019-05-26 15:43:13 -07:00
Andrew Kelley 2f040a23c8
clean up references to os 2019-05-26 18:32:44 -04:00
Andrew Kelley 5a57610039
clean up code now that #769 is implemented 2019-05-14 19:23:31 -04:00
hryx 3a3a738478
Recursive rewrite of stage2 parser, part 3 2019-05-12 02:01:45 -07:00
Andrew Kelley 10e9d47b49
stage2 translate-c: implement functions with no prototype
stage1 translate-c actually has this wrong. When exporting a function,
it's ok to use empty parameters. But for prototypes, "no prototype"
means that it has to be emitted as a function that accepts anything,
e.g. extern fn foo(...) void;

See #1964
2019-05-11 12:09:11 -04:00
Andrew Kelley 5f4c3e6557
stage2 translate-c: simple function definitions
See #1964
2019-05-10 23:35:46 -04:00
Andrew Kelley dbb5da14f4
stage2 translate-c: builtin types and pub
See #1964
2019-05-10 17:56:00 -04:00
Andrew Kelley 82219b1fd5
translate-c: better handling of restore points 2019-05-10 17:44:47 -04:00
Andrew Kelley a6f7a9ce2b
translate-c: we have our first test of self-hosted
See #1964
2019-05-10 16:03:54 -04:00
Andrew Kelley 1c0223899c
translate-c: progress on self-hosted function prototypes
See #1964
2019-05-10 01:24:00 -04:00
Andrew Kelley eea2de108d
translate-c: progress on self-hosted function prototypes
See #1964
2019-05-09 16:52:30 -04:00
Andrew Kelley 46e1c34fcf
self-hosted translate-c progress on function decls
See #1964
2019-05-08 22:05:59 -04:00
Andrew Kelley 9bbd71c9ab
add --bundle-compiler-rt function to link options
and use it when building libuserland.a

The self-hosted part of stage1 relies on zig's compiler-rt, and so we
include it in libuserland.a.

This should potentially be the default, but for now it's behind a linker
option.

self-hosted translate-c: small progress on translating functions.
2019-05-08 20:51:49 -04:00
Andrew Kelley a7f99c8ee9
self-hosted translate-c: iterate over top level decls
See #1964
2019-04-30 00:21:45 -04:00
Shritesh Bhattarai d02489fd9a fix missing semicolon 2019-04-26 21:01:20 -04:00
Andrew Kelley 2d6520d5d4
zig fmt is built directly into stage1 rather than child process
Previously, `zig fmt` on the stage1 compiler (which is what we currently
ship) would perform what equates to `zig run std/special/fmt_runner.zig`

Now, `zig fmt` is implemented with the hybrid zig/C++ strategy outlined
by #1964.

This means Zig no longer has to ship some of the stage2 .zig files, and
there is no longer a delay when running `zig fmt` for the first time.
2019-04-26 20:46:28 -04:00
Andrew Kelley 28071ac637
self-hosted translate-c emits a hello world AST
Also breaking std lib API change: the return value of
std.zig.parse returns `*ast.Tree` rather than `ast.Tree`.

See #1964
2019-04-26 15:43:36 -04:00
Andrew Kelley 535d419590
translate-c: self-hosted implementation can detect C errors
See #1964
2019-04-25 00:06:58 -04:00
Andrew Kelley 712274997e
translate-c: unify API for self-hosted and C++ translate-c
See #1964
2019-04-25 00:06:57 -04:00
Andrew Kelley 976080462c
translate-c: a little closer to self-hosted implementation 2019-04-25 00:06:54 -04:00
Andrew Kelley ff3cdbc3a0
stage1 assertions always on, and have stack traces 2019-04-17 15:58:20 -04:00
Andrew Kelley 89763c9a0d
stage1 is now a hybrid of C++ and Zig
This modifies the build process of Zig to put all of the source files
into libcompiler.a, except main.cpp and userland.cpp.

Next, the build process links main.cpp, userland.cpp, and libcompiler.a
into zig1. userland.cpp is a shim for functions that will later be
replaced with self-hosted implementations.

Next, the build process uses zig1 to build src-self-hosted/stage1.zig
into libuserland.a, which does not depend on any of the things that
are shimmed in userland.cpp, such as translate-c.

Finally, the build process re-links main.cpp and libcompiler.a, except
with libuserland.a instead of userland.cpp. Now the shims are replaced
with .zig code. This provides all of the Zig standard library to the
stage1 C++ compiler, and enables us to move certain things to userland,
such as translate-c.

As a proof of concept I have made the `zig zen` command use text defined
in userland. I added `zig translate-c-2` which is a work-in-progress
reimplementation of translate-c in userland, which currently calls
`std.debug.panic("unimplemented")` and you can see the stack trace makes
it all the way back into the C++ main() function (Thanks LemonBoy for
improving that!).

This could potentially let us move other things into userland, such as
hashing algorithms, the entire cache system, .d file parsing, pretty
much anything that libuserland.a itself doesn't need to depend on.

This can also let us have `zig fmt` in stage1 without the overhead
of child process execution, and without the initial compilation delay
before it gets cached.

See #1964
2019-04-16 19:12:20 -04:00
Marc Tiehuis 78af62a19a Pack big.Int sign and length fields
This effectively takes one-bit from the length field and uses it as the
sign bit. It reduces the size of an Int from 40 bits to 32 bits on a
64-bit arch.

This also reduces std.Rational from 80 bits to 64 bits.
2019-04-11 19:36:35 +12:00
Andrew Kelley d0551db5cd
introduce the enum literal type
see #683
2019-03-24 00:44:18 -04:00
Andrew Kelley 64dddd7afe
add compile error for ignoring error
closes #772
2019-03-23 19:33:00 -04:00
Andrew Kelley a581f4f0e2
Merge remote-tracking branch 'origin/master' into llvm8 2019-03-18 20:03:23 -04:00
Andrew Kelley 9c13e9b7ed
breaking changes to std.mem.Allocator interface API
Before, allocator implementations had to provide `allocFn`,
`reallocFn`, and `freeFn`.

Now, they must provide only `reallocFn` and `shrinkFn`.
Reallocating from a zero length slice is allocation, and
shrinking to a zero length slice is freeing.

When the new memory size is less than or equal to the
previous allocation size, `reallocFn` now has the option
to return `error.OutOfMemory` to indicate that the allocator
would not be able to take advantage of the new size.

For more details see #1306. This commit closes #1306.

This commit paves the way to solving #2009.

This commit also introduces a memory leak to all coroutines.
There is an issue where a coroutine calls the function and it
frees its own stack frame, but then the return value of `shrinkFn`
is a slice, which is implemented as an sret struct. Writing to
the return pointer causes invalid memory write. We could work
around it by having a global helper function which has a void
return type and calling that instead. But instead this hack will
suffice until I rework coroutines to be non-allocating. Basically
coroutines are not supported right now until they are reworked as
in #1194.
2019-03-15 17:57:21 -04:00
Andrew Kelley 4cb55d3af6 Merge remote-tracking branch 'origin/master' into llvm8 2019-03-10 18:07:28 -04:00
Andrew Kelley 918dbd4551
std.zig: `this` is no longer a keyword 2019-03-10 15:55:54 -04:00
Andrew Kelley 0714e19598
Merge remote-tracking branch 'origin/master' into llvm8 2019-03-04 08:24:56 -05:00
Andrew Kelley e402455704
rename std lib files to new convention 2019-03-02 16:46:04 -05:00
Andrew Kelley 582fdc2869
fix dependency loops, pub, tests, use decls, root source
* fix dependency loop detection
   - closes #679
   - closes #1500
 * fix `pub`
 * fix tests
 * fix use decls
 * main package file gets a special "" namespace path
2019-03-01 15:35:29 -05:00
Andrew Kelley 0fd64e6c69
stage2: update for changes regarding sub-architecture 2019-02-28 14:10:45 -05:00
Andrew Kelley 5424b4320d
remove namespace type; files are empty structs
closes #1047
2019-02-28 10:11:32 -05:00
Andrew Kelley 2dcf1a2392
Merge remote-tracking branch 'origin/master' into llvm8 2019-02-28 09:19:18 -05:00
Andrew Kelley 33174f11ef fix regressions on Windows 2019-02-26 16:24:32 -05:00
Andrew Kelley ade10387a5
breaking changes to the way targets work in zig
* CLI: `-target [name]` instead of `--target-*` args.
   This matches clang's API.
 * `builtin.Environ` renamed to `builtin.Abi`
   - likewise `builtin.environ` renamed to `builtin.abi`
 * stop hiding the concept of sub-arch. closes #1526
 * `zig targets` only shows available targets. closes #438
 * include all targets in readme, even those that don't
   print with `zig targets` but note they are Tier 4
 * refactor target.cpp and make the naming conventions
   more consistent
 * introduce the concept of a "default C ABI" for a given
   OS/Arch combo. As a rule of thumb, if the system compiler
   is clang or gcc then the default C ABI is the gnu ABI.
2019-02-26 15:58:10 -05:00
Andrew Kelley c9fb5240d6
remove --no-rosegment workaround now that valgrind bug is fixed
See #896

Zig 0.3.0+ and Valgrind 3.14+ do not need the workaround.
2019-02-19 08:39:36 -05:00
Maya Rashish bc10382ec1 Add NetBSD support
Mostly picking the same paths as FreeBSD.
We need a little special handling for crt files, as netbsd uses its
own (and not GCC's) for those, with slightly different names.
2019-02-17 09:17:34 +02:00
Andrew Kelley ba56f365c8
bring zig fmt to stage1 2019-02-16 00:53:32 -05:00
Andrew Kelley 99b19adeb3 stage2: fix windows regressions 2019-02-14 23:46:53 -05:00
Andrew Kelley e025c70166
stage2: fix llvm.zig with opaque types back to single-item pointer 2019-02-14 23:17:11 -05:00
Andrew Kelley 6769183a9d
fix implicit cast error unions with non-optional to optional pointer
and update self hosted compiler for C pointers

See #1059
2019-02-14 15:48:28 -05:00
Andrew Kelley 90b8cd4a45
add C pointer type to @typeInfo
See #1059
2019-02-11 16:07:40 -05:00
Andrew Kelley 1864acd326
Merge remote-tracking branch 'origin/master' into llvm8 2019-02-09 18:57:39 -05:00
Andrew Kelley c2db077574
std.debug.assert: remove special case for test builds
Previously, std.debug.assert would `@panic` in test builds,
if the assertion failed. Now, it's always `unreachable`.

This makes release mode test builds more accurately test
the actual code that will be run.

However this requires tests to call `std.testing.expect`
rather than `std.debug.assert` to make sure output is correct.

Here is the explanation of when to use either one, copied from
the assert doc comments:

Inside a test block, it is best to use the `std.testing` module
rather than assert, because assert may not detect a test failure
in ReleaseFast and ReleaseSafe mode. Outside of a test block, assert
is the correct function to use.

closes #1304
2019-02-08 18:23:38 -05:00
Andrew Kelley a94304d3e4
Merge remote-tracking branch 'origin/master' into llvm8 2019-02-07 12:21:20 -05:00
Andrew Kelley 36bade5c56
fixups, and modify std.mem.join and std.os.path.resolve API
* zig fmt
 * std.mem.join takes a slice of slices instead of var args
 * std.mem.join takes a separator slice rather than byte,
   and always inserts it. Previously it would not insert the separator
   if there already was one, violating the documented behavior.
 * std.mem.join calculates exactly the correct amount to allocate
   and has no call to allocator.shrink()
 * bring back joinWindows and joinPosix and the corresponding tests.
   it is intended to be able to call these functions from any OS.
 * rename std.os.path.resolveSlice to resolve (now resolve takes
   a slice of slices instead of var args)
2019-02-07 00:42:41 -05:00
Andrew Kelley c804ae2d6b
Merge branch 'zig-backport-std.os.path' of https://github.com/kristate/zig into kristate-zig-backport-std.os.path 2019-02-06 22:53:34 -05:00
Andrew Kelley f32f7a937f
Merge remote-tracking branch 'origin/master' into llvm8 2019-02-04 21:26:50 -05:00
Andrew Kelley 67bd45f0cf
adjustments to std.mem split / separate
* rename std.mem.split to std.mem.tokenize
 * add future deprecation notice to docs
 * (unrelated) add note to std.os.path.resolve docs
 * std.mem.separate - assert delimiter.len not zero
 * fix implementation of std.mem.separate to respect the delimiter
 * separate the two iterators to different structs
2019-02-04 15:24:06 -05:00
Andrew Kelley dfbc063f79
`std.mem.Allocator.create` replaced with better API
`std.mem.Allocator.createOne` is renamed to `std.mem.Allocator.create`.

The problem with the previous API is that even after copy elision,
the initalization value passed as a parameter would always be a copy.
With the new API, once copy elision is done, initialization
functions can directly initialize allocated memory in place.

Related:
 * #1872
 * #1873
2019-02-03 16:13:28 -05:00
Andrew Kelley 545064c1d9
introduce vector type for SIMD
See #903

 * create with `@Vector(len, ElemType)`
 * only wrapping addition is implemented

This feature is far from complete; this is only the beginning.
2019-01-30 23:39:25 -05:00
Andrew Kelley 1411df4e27 update to llvm8 trunk. all tests passing 2019-01-24 09:31:00 -05:00
Andrew Kelley 036a49e97d Merge remote-tracking branch 'origin/master' into llvm8 2019-01-01 18:36:12 -05:00
nebulaeonline fdea12b2d9 msvc subsystem option handling; added uefi os type 2018-12-23 22:44:02 -05:00
Andrew Kelley c0e391e94a self-hosted: add hurd os to switch 2018-12-23 18:30:13 -05:00
Andrew Kelley c00216701c Merge remote-tracking branch 'origin/master' into llvm8 2018-12-23 17:04:26 -05:00
Andrew Kelley f301474531
self-hosted: add DeviceBusy as a BuildError 2018-12-21 23:01:21 -05:00
Andrew Kelley b883bc873d
breaking API changes to all readInt/writeInt functions & more
* add `@bswap` builtin function. See #767
 * comptime evaluation facilities are improved to be able to
   handle a `@ptrCast` with a backing array.
 * `@truncate` allows "truncating" a u0 value to any integer
   type, and the result is always comptime known to be `0`.
 * when specifying pointer alignment in a type expression,
   the alignment value of pointers which do not have addresses
   at runtime is ignored, and always has the default/ABI alignment
 * threw in a fix to freebsd/x86_64.zig to update syntax from
   language changes
 * some improvements are pending #863

closes #638
closes #1733

std lib API changes
 * io.InStream().readIntNe renamed to readIntNative
 * io.InStream().readIntLe renamed to readIntLittle
 * io.InStream().readIntBe renamed to readIntBig
 * introduced io.InStream().readIntForeign
 * io.InStream().readInt has parameter order changed
 * io.InStream().readVarInt has parameter order changed
 * io.InStream().writeIntNe renamed to writeIntNative
 * introduced io.InStream().writeIntForeign
 * io.InStream().writeIntLe renamed to writeIntLittle
 * io.InStream().writeIntBe renamed to writeIntBig
 * io.InStream().writeInt has parameter order changed
 * mem.readInt has different parameters and semantics
 * introduced mem.readIntNative
 * introduced mem.readIntForeign
 * mem.readIntBE renamed to mem.readIntBig and different API
 * mem.readIntLE renamed to mem.readIntLittle and different API
 * introduced mem.readIntSliceNative
 * introduced mem.readIntSliceForeign
 * introduced mem.readIntSliceLittle
 * introduced mem.readIntSliceBig
 * introduced mem.readIntSlice
 * mem.writeInt has different parameters and semantics
 * introduced mem.writeIntNative
 * introduced mem.writeIntForeign
 * mem.writeIntBE renamed to mem.readIntBig and different semantics
 * mem.writeIntLE renamed to mem.readIntLittle and different semantics
 * introduced mem.writeIntSliceForeign
 * introduced mem.writeIntSliceNative
 * introduced mem.writeIntSliceBig
 * introduced mem.writeIntSliceLittle
 * introduced mem.writeIntSlice
 * removed mem.endianSwapIfLe
 * removed mem.endianSwapIfBe
 * removed mem.endianSwapIf
 * added mem.littleToNative
 * added mem.bigToNative
 * added mem.toNative
 * added mem.nativeTo
 * added mem.nativeToLittle
 * added mem.nativeToBig
2018-12-12 20:35:04 -05:00
kristopher tate 1e60ca4b75
stage2: update std.os.path.join method signature;
stage2: take 2;
2018-11-30 03:52:28 +09:00
Andrew Kelley dd2450b1b2
tier 2 support for freebsd 2018-11-27 20:56:43 -05:00
Andrew Kelley 9493738e54
Merge branch 'freebsd-up' of https://github.com/myfreeweb/zig into freebsd2 2018-11-19 17:24:41 -05:00
Andrew Kelley c21884e1d6 Merge remote-tracking branch 'origin/master' into llvm8 2018-11-17 02:18:56 -05:00
Jimmi Holst Christensen 2a9843de95
Added NullOutStream and CountingOutStream (#1722) 2018-11-15 09:37:39 -08:00
Andrew Kelley 0c3bd0c3d1
zig fmt: add --check flag
closes #1558
closes #1555
2018-11-15 00:26:43 -05:00
Jimmi Holst Christensen 8139c5a516
New Zig formal grammar (#1685)
Reverted #1628 and changed the grammar+parser of the language to not allow certain expr where types are expected
2018-11-13 05:08:37 -08:00
Andrew Kelley c19bc7ecb4 update self-hosted compiler for new targets 2018-11-05 11:32:02 -05:00
Andrew Kelley 2b395d4ede
remove @minValue,@maxValue; add std.math.minInt,maxInt
closes #1466
closes #1476
2018-10-26 15:01:51 -04:00
Greg V 831bb66895 Set up libc/rtld paths for FreeBSD 2018-10-20 15:21:35 +03:00
Andrew Kelley d5648d2640
remove implicit cast from T to *const T
closes #1465
2018-10-15 18:23:47 -04:00
Jimmi Holst Christensen 378d3e4403
Solve the return type ambiguity (#1628)
Changed container and initializer syntax
* <container> { ... } -> <container> . { ... }
* <exrp> { ... } -> <expr> . { ...}
2018-10-15 09:51:15 -04:00
Andrew Kelley d40c4e7c89
Merge pull request #1429 from shawnl/arm64
initial arm64 support
2018-10-06 00:11:39 -04:00
Andrew Kelley 9d4eaf1e07
update std lib API for I/O
std.io.FileInStream -> std.os.File.InStream
std.io.FileInStream.init(file) -> file.inStream()
std.io.FileOutStream -> std.os.File.OutStream
std.io.FileOutStream.init(file) -> file.outStream()

remove a lot of error code possibilities from os functions

std.event.net.socketRead -> std.event.net.read
std.event.net.socketWrite -> std.event.net.write
add std.event.net.readv
add std.event.net.writev
add std.event.net.readvPosix
add std.event.net.writevPosix
add std.event.net.OutStream
add std.event.net.InStream

add std.event.io.InStream
add std.event.io.OutStream
2018-09-30 17:28:35 -04:00
Andrew Kelley c06a61e9bf
remove `this`. add `@This()`.
closes #1283
2018-09-13 16:34:33 -04:00
Andrew Kelley 178d69191b windows: std.fs functions support concurrent ops
when reading and writing the same file descriptors
2018-09-12 13:55:35 -04:00
Shawn Landden 342cff28f5 initial arm64 support 2018-09-08 03:52:28 +00:00
Andrew Kelley 832caefc2a fix regressions 2018-09-02 18:35:32 -04:00
Andrew Kelley ea1b21dbdb fix linux
* error.BadFd is not a valid error code. it would always be a bug to
   get this error code.
 * merge error.Io with existing error.InputOutput
 * merge error.PathNotFound with existing error.FileNotFound.
   Not all OS's support both.
 * add os.File.openReadC
 * add error.BadPathName for windows file operations with invalid
   characters
 * add os.toPosixPath to help stack allocate a null terminating byte
 * add some TODOs for other functions to investigate removing the
   allocator requirement
 * optimize some implementations to use the alternate functions when
   a null byte is already available
 * add a missing error.SkipZigTest
 * os.selfExePath uses a non-allocating API
 * os.selfExeDirPath uses a non-allocating API
 * os.path.real uses a non-allocating API
 * add os.path.realAlloc and os.path.realC
 * convert many windows syscalls to use the W versions (See #534)
2018-08-21 20:31:50 -04:00
Andrew Kelley 51852d2587 fix windows 2018-08-21 16:07:28 -04:00
Andrew Kelley 598e80957e windows: call CancelIo when canceling an fs watch 2018-08-10 13:19:07 -04:00
Andrew Kelley 0df485d4dc self-hosted: reorganize creation and destruction of Compilation 2018-08-10 12:28:20 -04:00
Andrew Kelley b219feb3f1 initial windows implementation of std.event.fs.Watch 2018-08-09 16:48:44 -04:00
Andrew Kelley 60955feab8 std.event.fs.Watch distinguishes between Delete and CloseWrite on darwin
TODO: after 1 event emitted for a deleted file, the file is no longer
watched
2018-08-07 22:14:30 -04:00
Andrew Kelley c5f1925bc8 when decls don't change, don't regenerate them 2018-08-03 17:59:11 -04:00
Andrew Kelley 5dfcd09e49 self-hosted: watch files and trigger a rebuild 2018-08-03 17:22:17 -04:00
Andrew Kelley 7f6e97cb26 fixups from the merge 2018-08-02 17:36:08 -04:00
Andrew Kelley 951124e177 evented I/O zig fmt 2018-08-02 17:24:15 -04:00
Andrew Kelley 821805aa92 WIP: Channel.getOrNull 2018-08-02 17:04:17 -04:00
Andrew Kelley a870228ab4 self-hosted: use std.event.fs.readFile 2018-07-30 13:44:36 -04:00
Andrew Kelley 02713e8d8a fix race conditions in self-hosted compiler; add test
* fix race condition in std.event.Channel deinit
 * add support to zig build for --no-rosegment
 * add passing self-hosted compare-output test for calling a function
 * put a global lock on LLD linking because it's not thread safe
2018-07-24 21:28:54 -04:00
Andrew Kelley adefd1a52b self-hosted: function calling another function 2018-07-24 20:24:05 -04:00
Andrew Kelley 2ea08561cf self-hosted: function types use table lookup 2018-07-24 14:20:49 -04:00
Andrew Kelley 72599d420b self-hosted: find all libc paths; windows linker code 2018-07-24 00:06:34 -04:00
Andrew Kelley 2614ef056a self-hosted: basic linker code for macos 2018-07-23 17:38:03 -04:00
Andrew Kelley 5a919dd82d Merge remote-tracking branch 'origin/master' into self-hosted-libc-hello-world 2018-07-23 14:32:13 -04:00
Andrew Kelley 10d2f08d37 self-hosted: fix error messages not cleaning up correctly 2018-07-23 14:28:14 -04:00
Andrew Kelley d767fae47e self-hosted: add first compare-output test 2018-07-23 00:35:53 -04:00
Andrew Kelley 93e78ee722 self-hosted can compile libc hello world 2018-07-22 23:28:53 -04:00
Andrew Kelley 58c5f94a99 self-hosted: share C++ code for finding libc on windows 2018-07-20 23:38:13 -04:00
Andrew Kelley f5a67dba08 self-hosted: implicit cast comptime ints to other ints
we now have successful exit codes from main linking
against libc
2018-07-20 01:46:49 -04:00
Andrew Kelley 33fbd8c1d3 self-hosted: convert some stuff to async/await 2018-07-20 00:13:48 -04:00
Andrew Kelley d9fc149752 relative path to cwd in compile errors 2018-07-19 23:52:44 -04:00
Andrew Kelley 3908b4fdee self-hosted: refactor ParsedFile out of existence
also we are successfully analyzing the return type of main
2018-07-19 15:11:39 -04:00
Andrew Kelley 1d85b588ea self-hosted: progress on IR for supporting libc hello world
* add c int types
 * some more ir stubs
2018-07-19 00:08:47 -04:00
Andrew Kelley bd1c55d2c2 self-hosted: compile errors for return in wrong place
* outside fn definition
 * inside defer expression
2018-07-18 17:43:36 -04:00
Andrew Kelley aa3b41247f self-hosted: linking against libc
also introduce `zig libc` command to display paths
`zig libc file.txt` will parse equivalent text and use that for libc
paths.
2018-07-18 17:43:36 -04:00
Andrew Kelley 3e4a3fa5b7 self-hosted: find libc on linux 2018-07-18 17:43:36 -04:00
Andrew Kelley a8a1b5af07 fix build on windows
* move getAppDataDir and utf16leToUtf8 from self-hosted to std lib
 * fix std.event.Loop on windows
2018-07-18 10:07:22 -04:00
Josh Wolfe 843529d234 implement proper utf16leToUtf8 2018-07-18 03:01:01 -04:00
Andrew Kelley ecf8da00c5 self-hosted: linking 2018-07-17 13:18:13 -04:00
Andrew Kelley 1a7cf4cbce port 69e3b4e to self-hosted compiler
See #1249
2018-07-17 10:42:44 -04:00
Andrew Kelley 3bb00eac37 self-hosted: implement getAppDataDir for windows 2018-07-17 00:01:36 -04:00
Andrew Kelley 97bfeac13f self-hosted: create tmp dir for .o files and emit .o file for fn 2018-07-16 20:52:50 -04:00
Andrew Kelley 363f4facea self-hosted: generate LLVM IR for simple function 2018-07-15 00:07:33 -04:00
Andrew Kelley 28c3d4809b rename Module to Compilation
and CompilationUnit to ObjectFile
2018-07-14 16:31:17 -04:00
Andrew Kelley 278829fc2c self-hosted: adding a fn to an llvm module 2018-07-14 16:03:22 -04:00
Marc Tiehuis bf441ed244 Add --stdin option to zig fmt 2018-07-14 11:43:35 -04:00
Andrew Kelley e78b1b810f self-hosted: basic IR pass2 2018-07-13 21:56:38 -04:00
Andrew Kelley 69e60e351b self-hosted: better IR for empty fn
avoids a void
2018-07-12 15:22:23 -04:00
Andrew Kelley 687bd92f9c self-hosted: generate zig IR for simple function
no tests for this yet. I think the quickest path to testing will be
creating the .o files and linking with libc, executing, and then
comparing output.
2018-07-12 15:12:44 -04:00
Andrew Kelley 9bdcd2a495 add std.event.Future
This is like a promise, but it's for multiple getters, and
uses an event loop.
2018-07-11 16:00:06 -04:00
Andrew Kelley c6c49389eb self-hosted: add compile error test for missing fn name 2018-07-11 01:26:46 -04:00
Andrew Kelley 8197a14ceb self-hosted test: use C allocator since we depend on libc 2018-07-10 20:27:15 -04:00
Andrew Kelley 574e31f0a0 self-hosted: first passing test
* introduce std.atomic.Int
 * add src-self-hosted/test.zig which is tested by the main test suite
   - it fully utilizes the multithreaded async/await event loop so the
     tests should Go Fast
 * `stage2/bin/zig build-obj test.zig` is able to spit out an error if 2 exported
   functions collide
 * ability for `zig test` to accept `--object` and `--assembly`
   arguments
 * std.build: TestStep supports addLibPath and addObjectFile
2018-07-10 20:18:43 -04:00
Andrew Kelley 8fba0a6ae8 introduce std.event.Group for making parallel async calls 2018-07-10 15:17:01 -04:00
Andrew Kelley ccef60a640
Merge pull request #1198 from ziglang/m-n-threading
M:N threading
2018-07-09 22:06:47 -04:00
Andrew Kelley 10cc49db1c define c macros before importing llvm h files
Seems to matter on Ubuntu 16.04.

closes #1196
2018-07-09 22:05:22 -04:00
Andrew Kelley eb326e1553 M:N threading
* add std.atomic.QueueMpsc.isEmpty
 * make std.debug.global_allocator thread-safe
 * std.event.Loop: now you have to choose between
   - initSingleThreaded
   - initMultiThreaded
 * std.event.Loop multiplexes coroutines onto kernel threads
 * Remove std.event.Loop.stop. Instead the event loop run() function
   returns once there are no pending coroutines.
 * fix crash in ir.cpp for calling methods under some conditions
 * small progress self-hosted compiler, analyzing top level declarations
 * Introduce std.event.Lock for synchronizing coroutines
 * introduce std.event.Locked(T) for data that only 1 coroutine should
   modify at once.
 * make the self hosted compiler use multi threaded event loop
 * make std.heap.DirectAllocator thread-safe

See #174

TODO:
 * call sched_getaffinity instead of hard coding thread pool size 4
 * support for Windows and MacOS
 * #1194
 * #1197
2018-07-07 00:32:19 -04:00
Andrew Kelley 06e8c2e519 fix stage2 macos build
See #1173
2018-07-02 17:55:59 -04:00
Andrew Kelley 2da999372a add another BuildError code 2018-07-02 15:25:23 -04:00
Andrew Kelley a3f55aaf34 add event loop Channel abstraction
This is akin to channels in Go, except:
 * implemented in userland
 * they are lock-free and thread-safe
 * they integrate with the userland event loop

The self hosted compiler is changed to use a channel for events,
and made to stay alive, watching files and performing builds when
things change, however the main.zig file exits after 1 build.

Note that nothing is actually built yet, it just parses the input
and then declares that the build succeeded.

Next items to do:
 * add windows and macos support for std.event.Loop
 * improve the event loop stop() operation
 * make the event loop multiplex coroutines onto kernel threads
 * watch source file for updates, and provide AST diffs
   (at least list the top level declaration changes)
 * top level declaration analysis
2018-07-02 14:38:11 -04:00
Andrew Kelley 8866bef92c clean up self hosted main. delete unsupported commands 2018-06-22 01:54:38 -04:00
Andrew Kelley 85f928f8bf remove std.mem.Allocator.construct and other fixups 2018-06-20 17:33:29 -04:00
kristopher tate 71db8df548 std: update stdlib to match updated allocator create signature; ref #733 2018-06-21 00:40:21 +09:00
Andrew Kelley 1ca90b5856 zig fmt: support directories
zig fmt accepts any number of file paths. For each one, if it
is a file, then it formats the file. If it is a directory, then
zig recursively scans the directory, formatting all files that
end in `.zig`.

it maintains a map of paths that have been seen already, to avoid
softlink loops.

closes #1068
2018-06-18 13:58:08 -04:00
Andrew Kelley 6943cefebf std.os.path.dirname: return null instead of empty slice
for when there is no directory component. Makes it harder
to write bugs.

closes #1017
2018-06-14 16:15:32 -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 ec1b6f6673
breaking syntax change: ??x to x.? (#1095)
See #1023

This also renames Nullable/Maybe to Optional
2018-06-09 23:42:14 -04:00
Braedon f389e53735 Add newline to zig fmt error (#1064) 2018-06-06 10:45:19 -04:00
Marc Tiehuis e514454c0e Make zig fmt exit with error on any parse errors
This is required for proper detection in editor plugins. Other files may
have been formatted correctly, this only indicates that some failed.
2018-06-02 20:49:35 +12: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 717ac85a5a zig fmt: add --color option to CLI help text 2018-05-30 18:37:12 -04:00
Andrew Kelley a05acaf9fd Add --color CLI option to zig fmt
It doesn't actually do terminal color yet because we need to add
cross platform terminal color abstractions. But it toggles between
the single line error reporting and the multiline error reporting.

See #1026
2018-05-30 18:26:09 -04:00
Andrew Kelley d8699ae57e zig fmt: don't compute a sha-256 for no reason
I forgot to delete this code before pushing 2c96f19fd3
2018-05-30 16:45:32 -04:00
Andrew Kelley ea58f4a5a9 run zig fmt on the codebase 2018-05-30 16:09:11 -04:00
Andrew Kelley 2c96f19fd3 std.zig.render returns bool of whether anything changed
zig fmt only renames files and prints to stdout for files which changed
2018-05-30 14:58:27 -04:00
Andrew Kelley b184ae5ca5 run zig fmt on some of the codebase
See #1003
2018-05-26 23:00:29 -04:00
Andrew Kelley c38b165db4 all tests passing with postfix deref syntax 2018-05-17 23:21:44 -04:00
Andrew Kelley 4c3aa09f2a self hosted compiler: remove unused flag 2018-05-13 01:06:52 -04:00
Andrew Kelley c3ddf5069e zig fmt: fix not writing results 2018-05-10 00:40:07 -04:00
Andrew Kelley bbae6267fe fix self hosted compiler 2018-05-09 21:45:29 -04:00
Marc Tiehuis 03bec631bd Replace File.exists with File.access 2018-04-13 21:27:09 +12:00
Marc Tiehuis b946982e90 Use builtin Arch/Os/Environ 2018-04-13 20:12:30 +12:00
Marc Tiehuis 7fe1c7c04f Remove cc command 2018-04-13 19:43:18 +12:00
Andrew Kelley 7b2cb7e679 remove --zig-install-prefix arg now that we find std at runtime 2018-04-12 11:00:11 -04:00
Marc Tiehuis 803f0a295b Revise self-hosted command line interface
Commands are now separated more precisely from one another. Arguments
are parsed mostly using a custom argument parser instead of manually.
This should be on parity feature-wise with the previous main.zig but
adds a few extra code-paths as well that were not yet implemented.

Subcommands are much more prominent and consistent. The first argument
is always a sub-command and then all following arguments refer to that
command. Different commands display there own usage messages and options
based on what they can do instead of a one-for-all usage message that
was only applicable for the build commands previously.

The `cc` command is added and is intended for driving a c compiler. See #490.
This is currently a wrapper over the system cc and assumes that it
exists, but it should suffice as a starting point.
2018-04-12 22:28:47 +12:00
Andrew Kelley 477ded9042 add missing call in zig fmt to commit results to disk 2018-04-10 11:00:57 -04:00
Ben Noordhuis b60b01ce97 skeleton stage 2 support for 'zig build'
Initial port of the 'zig build' logic from the stage 1 compiler to the
stage 2 compiler sans code generation and BUILD_INFO support.
2018-03-28 18:30:41 +02: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 46aa416c48 std.os and std.io API update
* move std.io.File to std.os.File
 * add `zig fmt` to self hosted compiler
 * introduce std.io.BufferedAtomicFile API
 * introduce std.os.AtomicFile API
 * add `std.os.default_file_mode`
 * change FileMode on posix from being a usize to a u32
 * add std.os.File.mode to return mode of an open file
 * std.os.copyFile copies the mode from the source file instead of
   using the default file mode for the dest file
 * move `std.os.line_sep` to `std.cstr.line_sep`
2018-02-10 21:02:24 -05:00
Andrew Kelley 8c31eaf2a8 std zig tokenizer: don't require 3 newlines at the end of the source 2018-02-10 14:52:39 -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 1fb308ceee self hosted compiler: move tokenization and parsing to std lib 2018-02-09 13:08:02 -05:00
Andrew Kelley 0d5ff6f462 error sets - most tests passing 2018-02-08 02:08:45 -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 e5bc5873d7 rename "debug safety" to "runtime safety"
closes #437
2018-01-25 01:46:12 -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
Andrew Kelley cf39819478 add new kind of test: generating .h files. and more
* docgen supports obj_err code kind for demonstrating
   errors without explicit test cases
 * add documentation for `extern enum`. See #367
 * remove coldcc keyword and add @setIsCold. See #661
 * add compile errors for non-extern struct, enum, unions
   in function signatures
 * add .h file generation for extern struct, enum, unions
2018-01-22 22:24:07 -05:00
Andrew Kelley 793f031c4c remove 32-bit windows from supported targets list
we still want to support it, but there are too many bugs
to claim that we support it right now.

See #537
2018-01-14 15:17:07 -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 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 a45db7e853 add building the self hosted compiler to the main test suite 2018-01-03 18:25:17 -05:00
Andrew Kelley 36ff26609b fix self hosted compiler on windows 2018-01-03 04:55:49 -05:00
Josh Wolfe 4e3d7fc4bc fix self-hosted parser test 2017-12-26 23:29:15 -07:00
Josh Wolfe 192a039173 move utf8 parsing to std
source files no longer need to end with a newline
2017-12-26 23:17:33 -07:00
Andrew Kelley 6fece14cfb self-hosted: build against zig_llvm and embedded LLD
Now the self-hosted compiler re-uses the same C++ code for interfacing
with LLVM as the C++ code.
It also links against the same LLD library files.
2017-12-26 19:44:08 -05:00
Josh Wolfe d6a74ed463 [self-hosted] source must be valid utf8. see #663 2017-12-23 21:47:13 -07: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
Josh Wolfe 0082989f22 [self-hosted] tokenizer error for ascii control codes 2017-12-23 18:35:45 -07:00
Josh Wolfe 45ab752f9a source files must end with newline 2017-12-23 17:47:48 -07: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
Josh Wolfe ab44939941 roughly parsing infix operators 2017-12-17 11:16:55 -07:00
Josh Wolfe d295279b16 self-hosted: implement var decl align 2017-12-12 19:50:43 -07:00
Josh Wolfe 0003cc8105 self-hosted: implement addr of align parsing 2017-12-12 19:26:33 -07:00
Andrew Kelley 23058d8b43 self-hosted: link with LLVM 2017-12-11 23:34:59 -05:00
Andrew Kelley ed4d94a5d5 self-hosted: test all out of memory conditions 2017-12-11 21:12:47 -05:00
Andrew Kelley c4e7d05ce3 refactor debug.global_allocator into mem.FixedBufferAllocator 2017-12-11 17:27:31 -05:00
Andrew Kelley d8d379faf1 self-hosted: refactor into multiple files
add return expression
add number literal
2017-12-11 16:18:06 -05:00
Andrew Kelley a3a590a32a self-hosted: workaround for issue #537 2017-12-11 14:47:20 -05:00
Andrew Kelley fd6a36a235 self-hosted: parsing and rendering blocks 2017-12-11 09:21:06 -05:00
Andrew Kelley 9a51091a5c self-hosted: clean up parser 2017-12-10 23:19:01 -05:00
Andrew Kelley f951bcf01b self-hosted: parse variable declarations with types 2017-12-10 23:02:45 -05:00
Andrew Kelley 53d58684a6 self-hosted: parse var decls 2017-12-10 22:44:04 -05:00
Andrew Kelley f210f17d30 add self-hosted parsing and rendering to main tests 2017-12-10 21:26:52 -05:00
Andrew Kelley dc2e3465c7 rendering source code without recursion 2017-12-10 19:40:46 -05:00
Andrew Kelley 62ead3a2ee parsing an extern fn declaration 2017-12-09 20:50:31 -05:00
Andrew Kelley e9efa74333 partial parameter decl parsing 2017-12-09 20:01:13 -05:00
Andrew Kelley f466e539ef tokenizing libc hello world 2017-12-08 23:56:07 -05:00
Andrew Kelley d431b0fb99 parse a simple variable declaration 2017-12-08 23:15:43 -05:00
Andrew Kelley 37fbf01755 awkward void union field syntax no longer needed 2017-12-06 21:41:38 -05:00
Andrew Kelley 18b8a625f5 upgrade to new args api 2017-12-06 18:22:52 -05:00
Andrew Kelley 08d531143f parser skeleton 2017-12-05 00:20:23 -05:00
Andrew Kelley 3976981ab3 tokenizing hello world 2017-12-04 23:40:33 -05:00
Andrew Kelley 7297baa9c6 tokenizing basic operators 2017-12-04 23:29:39 -05:00
Andrew Kelley 07898cc0df tokenizing string literals 2017-12-04 23:25:59 -05:00
Andrew Kelley 798dbe487b simple tokenization 2017-12-04 23:09:03 -05:00
Andrew Kelley 31d9dc3539 read a file 2017-12-04 22:05:27 -05:00
Andrew Kelley 5a25505668 rename "parsec" to "translate-c" 2017-11-24 14:56:05 -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 634e8713c3 add @memberType and @memberName builtin functions
see #383

there is a plan to unify most of the reflection into 2
builtin functions, as outlined in the above issue,
but this gives us needed features for now, and we can
iterate on the design in future commits
2017-11-06 22:07:19 -05:00
Andrew Kelley a31b23c46b more compile-time type reflection
See #383
2017-11-03 00:00:57 -04:00
Andrew Kelley 540bac0928 Merge branch 'master' into self-hosted 2017-10-27 01:28:08 -04:00
Andrew Kelley 4f4da3c10c wip self hosted code 2017-10-24 10:08:20 -04:00
Andrew Kelley 92751d5e24 self hosted zig: print usage 2017-10-21 17:31:06 -04:00