346 Commits

Author SHA1 Message Date
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