Commit Graph

264 Commits (0ac502f37257c607fc835840d02f0401c5e59442)

Author SHA1 Message Date
Andrew Kelley 00878a15d7
zig fmt: support sentinel-terminated pointer syntax 2019-11-23 22:21:25 -05:00
Vexu d40f204ec0
self hosted compiler: small miscellaneous fixes 2019-11-23 21:57:24 +02:00
Vexu 03cc81665b
Merge branch 'master' into modernize-stage2 2019-11-23 19:13:48 +02:00
Andrew Kelley fd6020c4e2
update tests, better error messages, update self-hosted tokenizer 2019-11-21 20:43:41 -05:00
Andrew Kelley 21f344b3b9
add null terminated pointers and arrays to self-hosted
as well as `@typeInfo` and `@Type`
2019-11-21 20:43:41 -05:00
Vexu b92f42d1f4
implemented container doc comments in stage 2 2019-11-14 16:25:06 +02:00
Andrew Kelley 3cf5c2c62b
fix regressed tests and update docs to use "type coercion" 2019-11-08 15:57:25 -05:00
Andrew Kelley aa0daea541
update more of the std lib to use `@as` 2019-11-08 15:57:25 -05:00
Vexu c6076a1360
self hosted compiler: use enum literals 2019-11-07 10:30:56 +02:00
Andrew Kelley 845be4ea3e
fix regression in translate-c 2019-10-28 15:29:50 -04:00
Andrew Kelley 4b80e376e3
std.net.getAddressList 2019-10-28 15:29:50 -04:00
Andrew Kelley 79cb383f7d
fix 32-bit build of translate_c.zig 2019-10-24 19:46:11 -04:00
Vexu 2151f84d59 implement new async syntax in self-hosted compiler 2019-08-16 06:17:28 -07:00
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 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
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 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
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
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 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
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
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
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 5a57610039
clean up code now that #769 is implemented 2019-05-14 19:23:31 -04: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
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 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