Commit Graph

12762 Commits

Author SHA1 Message Date
Andrew Kelley
88d0e77b97 parse: implement error for invalid bit range and alignment 2021-02-21 00:18:20 -07:00
rgreenblatt
a5dcd07382 fix unspecified fmt 2021-02-21 01:31:46 +02:00
Veikka Tuominen
4074e79748
translate-c: use global scope for typedef/record/enum type translation if needed
If the type is a reference to a global declaration that has not yet
been translated we need to use the global scope for translation
so that other functions can also reference it.
2021-02-20 13:32:07 +02:00
Andrew Kelley
669c2054a8 stage2: debug line nops supports bigger padding 2021-02-19 22:55:42 -07:00
Andrew Kelley
ed1e5cb3f6 stage2: fix a couple off by one errors
All stage2 tests are passing again in this branch.

Remaining checklist for this branch:
 * get the rest of the zig fmt test cases passing
   - re-enable the translate-c test case that is blocking on this
 * implement the 2 `@panic(TODO)`'s in parse.zig
 * use fn_proto not fn_decl for extern function declarations
2021-02-19 21:47:11 -07:00
Michael Dusan
153cd4da0c macos: fix cond to enable ZIG_SYSTEM_LINKER_HACK
closes #8037
2021-02-19 23:37:13 -05:00
Andrew Kelley
5b597a16c6 stage2: fix not setting up ZIR arg instruction correctly
This is a regression from when I briefly flirted with changing how arg
ZIR instructions work in this branch, and then failed to revert it
correctly.
2021-02-19 20:57:06 -07:00
Andrew Kelley
d8560edc29 stage2: fix incorrect ast.Tree.getNodeSource impl 2021-02-19 20:28:47 -07:00
Andrew Kelley
70761d7c52 stage2: remove incorrect newlines from log statements 2021-02-19 20:27:06 -07:00
Andrew Kelley
6959b177ef stage2: test harness: panic on OOM rather than assert
also add a prefix to test names for C backend
2021-02-19 20:26:48 -07:00
Andrew Kelley
8fee41b1d5 stage2: AST: clean up parse errors
* struct instead of tagged union
 * delete dead code
 * simplify parser code
 * remove unnecessary metaprogramming
2021-02-19 18:04:52 -07:00
Andrew Kelley
74878565e5 readme: update introduction link 2021-02-19 16:38:04 -07:00
Isaac Freund
95b95ea33e
stage2: make same line doc comments a parse error
Allowing same line doc comments causes some ambiguity as to how
generated docs should represent the case in which both same line
and preceding line doc comments are present:

/// preceding line
const foobar = 42; /// same line

Furthermore disallowing these makes things simpler as there is now only
one way to add a doc comment to a decl or struct field.
2021-02-19 22:59:27 +01:00
Veikka Tuominen
6f6568b1fd
translate-c: correctly add semicolon to if statements 2021-02-19 20:48:06 +02:00
Veikka Tuominen
d672c20b8a
Merge pull request #7479 from ziglang/translate-c-ast
Make translate-c use intermediate AST
2021-02-19 13:03:29 +02:00
Veikka Tuominen
974a1c5525
translate-c: small fixes to avoid generating invalid code for macros 2021-02-19 12:50:42 +02:00
Andrew Kelley
914540ddb5 astgen: fix remaining compile errors
Now it builds and what remains in this branch is:
 * fix the stage2 compiler regressions from this branch
 * finish the rest of zig fmt test cases, get them passing
 * Merge in Vexu's translate-c AST branch & fix translate-c regressions
2021-02-19 00:04:31 -07:00
Andrew Kelley
9010bd8aec stage2: astgen: fix most of the remaining compile errors
more progress on converting astgen to the new AST memory layout.
only a few code paths left to update.
2021-02-18 20:09:29 -07:00
Veikka Tuominen
3aba1fa04f
translate-c: ensure failed macros don't get defined multiple times 2021-02-19 01:52:27 +02:00
Veikka Tuominen
df5a8120df
translate-c: small miscellaneous improvements 2021-02-18 21:34:31 +02:00
Andrew Kelley
29daf10639 stage2: fix a couple more compilation errors 2021-02-17 22:34:06 -07:00
Andrew Kelley
5a2620fcca stage2: fix some of the compilation errors in this branch 2021-02-17 22:22:10 -07:00
Andrew Kelley
c66481f9bc astgen: finish updating expressions to new mem layout
Now all that is left is compile errors and whatever regressions this
branch introduced.
2021-02-17 20:59:21 -07:00
Veikka Tuominen
7ca53bdfaa
translate-c: improve switch translation 2021-02-17 22:11:26 +02:00
Evan Haas
3717bedb4e translate-c: Add test for using correct block label for StmtExpr
The previous iteration of translate-c used an incorrect block label
in the break statement for a translated C statement expression. This adds
a test to ensure the correct label is used in the new intermediate AST
version of translate-c.
2021-02-17 16:27:21 +02:00
Veikka Tuominen
d5fecbd0ba
translate-c: support scoped typedef, enum and record decls
Closes #5256
2021-02-17 16:26:11 +02:00
Veikka Tuominen
e2974759dd
translate-c: demote untranslatable declarations to externs 2021-02-17 14:11:49 +02:00
Isaac Freund
4b226286e8
zig fmt: get rid of Space.no_comment
Using this in its current state would be a bug as it could cause line
comments to be deleted or a `// zig fmt: (on|off)` directive to be
missed.

Removing it doesn't currently cause any test failures, if a reason for
its continued existence is discovered in the future another solution
will have to be found.
2021-02-17 00:03:39 +01:00
Isaac Freund
895fb2bd6d
zig fmt: implement 'zig fmt: (on|off)' directives
With the new implementation, these now work anywhere in the source code
as opposed to only at the top level.
2021-02-16 23:20:53 +01:00
Isaac Freund
070e548acf
std: remove io.AutoIndentingStream
This type is not widely applicable enough to be a public part of the
public interface of the std.

The current implementation in only fully utilized by the zig fmt
implementation, which could benefit by even tighter integration as
will be demonstrated in the next commit. Therefore, move the current
io.AutoIndentingStream to lib/std/zig/render.zig.

The C backend of the self hosted compiler also use this type currently,
but it does not require anywhere near its full complexity. Therefore,
implement a greatly simplified version of this interface in
src/codegen/c.zig.
2021-02-16 23:20:46 +01:00
Andrew Kelley
68e7726478 std.fs.net.Stream: add writev and writevAll
I noticed that the write function does not properly use non-blocking
I/O. This file needs to be reworked for evented I/O to properly take
advantage of non-blocking writes to network sockets.
2021-02-16 11:01:17 -07:00
Veikka Tuominen
9a826ccbe0
translate-c: elide some unecessary casts of literals 2021-02-16 16:40:43 +02:00
Veikka Tuominen
74e9d4ca82
translate-c: get all translate-c tests passing 2021-02-16 16:40:43 +02:00
Veikka Tuominen
78fba4e021
translate-c: get all run-translated-c tests passing 2021-02-16 16:40:43 +02:00
Veikka Tuominen
77a11e6873
translate-c: render records and enums 2021-02-16 16:40:43 +02:00
Veikka Tuominen
c0540967e9
translate-c: render array stuff 2021-02-16 16:40:43 +02:00
Veikka Tuominen
62162a0717
translate-c: render control flow 2021-02-16 16:40:42 +02:00
Veikka Tuominen
c4dfabf4dc
translate-c: render macro functions, use cast type as return type
Closes #8004
2021-02-16 16:40:42 +02:00
Veikka Tuominen
f191251ddb
translate-c: render functions 2021-02-16 16:40:42 +02:00
Veikka Tuominen
227f167958
translate-c: render binops and break/continue 2021-02-16 16:40:42 +02:00
Veikka Tuominen
685778c5a7
translate-c: render unary ops 2021-02-16 16:40:42 +02:00
Veikka Tuominen
1147ecc5fd
translate-c: render variables and builtin calls 2021-02-16 16:40:42 +02:00
Veikka Tuominen
d7460db044
translate-c: render a bunch of simple nodes and calls 2021-02-16 16:40:39 +02:00
Veikka Tuominen
13a9db2085
translate-c: begin implementing ast.render 2021-02-16 16:40:06 +02:00
Veikka Tuominen
2a74a1ebaa
translate-c: bunch of small fixes to get it compiling 2021-02-16 16:40:06 +02:00
Veikka Tuominen
66bbd75a83
translate-c: convert macro translation 2021-02-16 16:40:06 +02:00
Veikka Tuominen
c30c2f7c13
translate-c: convert assignment and conditional exprs 2021-02-16 16:40:05 +02:00
Veikka Tuominen
450b718b9e
translate-c: convert field/array access, call, pre/postcrement 2021-02-16 16:40:05 +02:00
Veikka Tuominen
cadd4483be
translate-c: convert switch 2021-02-16 16:40:05 +02:00
Veikka Tuominen
66dd64ec15
translate-c: convert most control flow 2021-02-16 16:40:05 +02:00