13207 Commits

Author SHA1 Message Date
Benjamin Feng
df910b33f4 Add ppc Linux bits 2021-04-10 22:47:22 -05:00
Michael Dusan
d99dc21b9f test: overhaul stack_trace testing
- limit expected-output to main source file;
  ie. tolerate changes to start.zig
- when mode != .Debug the function name is now symbolically represented;
  ie. tolerate changes in llvm optimizer effects on the callstack
- cleanup how test cases are specified
- add test case predicates for excluding by arch, os or custom fn
2021-04-10 23:20:06 -04:00
Michael Dusan
75f86dab3f macos: add aarch64 (arm64) to downloads page 2021-04-10 19:33:17 -07:00
Isaac Freund
5b9ea5dd1e zig fmt: fix line comment detection
Previously hasComment() would consider a string literal "//" to be a
line comment. Fix this by only searching the bytes between tokens.
2021-04-10 23:10:24 +02:00
Carlos Zúñiga
ecd38c70cc Fix langref.html anchor navigation 2021-04-10 12:51:39 -07:00
Meghan Denny
ab43f2376e lib/std: remove empty init from HashMapUnmanaged 2021-04-10 12:49:02 -07:00
Lewis Gaul
ecf555c693
zig fmt: render array init on one line if no trailing comma
Continue to insert a trailing comma if there is a comment or multiline
string literal present.
2021-04-10 16:39:26 +02:00
jacob gw
0d92bd474f stage2: fix case where public variables did not work 2021-04-09 11:54:38 -07:00
Andrew Kelley
b3f5d4dc4c stage2: fix regression from previous commit
I forgot to build, sorry about that.
2021-04-09 10:38:44 -07:00
Andrew Kelley
7c4c5495be stage2: fix stderr deadlock and slightly wrong tty coloring 2021-04-09 10:34:10 -07:00
Andrew Kelley
f75cdd1acd
Merge pull request #8470 from ziglang/stage2-start
stage2: blaze the trail for std lib integration
2021-04-09 10:15:46 -07:00
Andrew Kelley
952032b40c
Merge pull request #8439 from Luukdegram/wasm-mem
stage2: wasm - "Hello world"
2021-04-09 10:08:21 -07:00
jacob gw
afe5862111 stage2: add error for private decls accessed from other files 2021-04-09 10:05:15 -07:00
LemonBoy
bfc8500390 testing: Avoid @import-ing builtins module
Use std.builtins instead.
2021-04-09 10:04:16 -07:00
LemonBoy
b0e905a30d testing: Avoid printing expected line twice
When the line has trailing whitespace we already print it with a
carriage return symbol at the end, don't print it one more time.
2021-04-09 10:04:16 -07:00
LemonBoy
1943c2dc68 testing: Use indexOfScalar instead of indexOf 2021-04-09 10:04:16 -07:00
LemonBoy
5ebcd8ccaf zig fmt: Fix rendering of arrays with single row
rowSize used to return null if all the elements were placed on the same
line as the right brace, making the rendering logic skip the whole set
of elements.

Given the usage of rowSize let's just drop the null and always return
the number of elements.

Fixes #8423
2021-04-09 10:03:45 -07:00
Luuk de Gram
eaaf75c157
Fix memory cleanup and update unplugging to avoid infinite loop 2021-04-09 09:24:52 +02:00
Andrew Kelley
cc525bc002 Merge pretty printing compile errors branch 2021-04-09 00:20:26 -07:00
Andrew Kelley
9a2de796bd stage2: clean up pretty printing compile errors 2021-04-09 00:19:44 -07:00
jacob gw
0f105ea324 stage2: fix bug where a parser error would break errors
A parser error would deinit the tree, but the tree is needed for the
node locations. This removes the offending code written before node
locations.
2021-04-08 23:17:36 -07:00
jacob gw
99ec511c4c stage2: pretty print compilation errors 2021-04-08 23:17:36 -07:00
g-w1
c6791d87d4
stage2: delete allowing input (and output) zir from the pipeline (#8471)
Remove -femit-zir as we aren't going to need it. Also remove zir test code
This removes a TODO that asserts the file is not zir.
2021-04-09 02:11:33 -04:00
Andrew Kelley
23db96931e AstGen: implement @typeInfo builtin 2021-04-08 22:38:13 -07:00
Andrew Kelley
6e05d53e88 AstGen: implement struct init with ResultLoc.ty 2021-04-08 22:33:40 -07:00
Andrew Kelley
91e1414b50 stage2: implement array access to a global array 2021-04-08 21:56:42 -07:00
Andrew Kelley
6d616d8257 update stack trace test cases to new start.zig line offsets 2021-04-08 21:56:19 -07:00
Andrew Kelley
1b702f8ddb stage2: fix the memory leaks 2021-04-08 20:52:02 -07:00
Andrew Kelley
61b868f9a5 stage2: simplify Decl src_node field
Also fix "previous definition here" error notes to be correct.
2021-04-08 20:37:19 -07:00
Andrew Kelley
482b995a49 stage2: blaze the trail for std lib integration
This branch adds "builtin" and "std" to the import table when using the
self-hosted backend.

"builtin" gains one additional item:

```
pub const zig_is_stage2 = true; // false when using stage1 backend
```

This allows the std lib to do conditional compilation based on detecting
which backend is being used. This will be removed from builtin as soon
as self-hosted catches up to feature parity with stage1.
Keep a sharp eye out - people are going to be tempted to abuse this.
The general rule of thumb is do not use `builtin.zig_is_stage2`. However
this commit breaks the rule so that we can gain limited start.zig support
as we incrementally improve the self-hosted compiler.

This commit also implements `fullyQualifiedNameHash` and related
functionality, which effectively puts all Decls in their proper
namespaces. `fullyQualifiedName` is not yet implemented.

Stop printing "todo" log messages for test decls unless we are in test
mode.

Add "previous definition here" error notes for Decl name collisions.

This commit does not bring us yet to a newly passing test case.

Here's what I'm working towards:

```zig
const std = @import("std");

export fn main() c_int {
    const a = std.fs.base64_alphabet[0];
    return a - 'A';
}
```

Current output:

```
$ ./zig-cache/bin/zig build-exe test.zig
test.zig:3:1: error: TODO implement more analyze elemptr
zig-cache/lib/zig/std/start.zig:38:46: error: TODO implement structInitExpr ty
```

So the next steps are clear:
 * Sema: improve elemptr
 * AstGen: implement structInitExpr
2021-04-08 19:05:05 -07:00
xackus
c28d1fe173 std docs: fix layout broken by the banner 2021-04-09 00:36:59 +02:00
Luuk de Gram
ff5774d93d
Refactor link/wasm.zig to use offset table
This refactor inserts an offset table into wasm's data section
where each offset points to the actual data region.
This means we can keep offset indexes consistant and do not
have to perform any computer to determine where in the data section
something like a static string exists. Instead during runtime
it will load the data offset onto the stack.
2021-04-08 22:47:08 +02:00
Luuk de Gram
47f3642788
Cleanup 2021-04-08 22:47:08 +02:00
Luuk de Gram
9fd1dab582
Handle incremental compilation correctly 2021-04-08 22:47:08 +02:00
Luuk de Gram
1bd5552fc1
Calculate data length to ensure correct pointer offsets 2021-04-08 22:47:08 +02:00
Luuk de Gram
00b2e31589
Basic "Hello world" working 2021-04-08 22:47:08 +02:00
Andrew Kelley
9f744f19e7
Merge pull request #8464 from gracefuu/grace/wasm-ops
stage2 wasm: Add division and bitwise/boolean ops &, |, ^, and, or
2021-04-08 13:41:49 -07:00
joachimschmidt557
d7a89f9876 stage2 AArch64: Add conditional branch instructions 2021-04-08 13:39:11 -07:00
Andrew Kelley
b9e508c410 stage2: revert to only has_decl and export ZIR support
Reverting most of the code from the previous commits in this branch.
Will pull in the code with modifications bit by bit.
2021-04-08 11:29:31 -07:00
Timon Kruiper
a483e38df6 stage2: fix bug where invalid ZIR was generated
The following code caused an assertion to be hit:
```
pub fn main() void {
    var e: anyerror!c_int = error.Foo;
    const i = e catch 69;
    assert(69 - i == 0);
}
```
2021-04-08 14:23:18 +02:00
Timon Kruiper
ac14b52e85 stage2: add support for start.zig
This adds a simplified start2.zig that the current stage2 compiler is
able to generate code for.
2021-04-08 14:23:18 +02:00
Timon Kruiper
e85cd616ef stage2: implement builtin function hasDecl 2021-04-08 14:23:18 +02:00
Timon Kruiper
a97efbd185 stage2: add support for root pkg
Fix some infinite recursions, because the code assumed that packages
cannot point to each other. But this assumption does not hold anymore.
2021-04-08 14:23:18 +02:00
Timon Kruiper
fb16cb9183 stage2: add initial support for builtin pkg
We currently emit a simplified builtin2.zig that is able to be parsed
and correctly interpreted in stage2.
2021-04-08 14:23:17 +02:00
Timon Kruiper
91e416bbf0 stage2: add a simplified export builtin call
std.builtin.ExportOptions is not yet supported, thus the second argument
of export is now a simple string that specifies the exported symbol
name.
2021-04-08 14:22:56 +02:00
Timon Kruiper
272fe0cbfe stage2: fix bug in ZIR gen of global comptime block
A global comptime block did not end with a break_inline instruction
which caused an assertion to be hit.
2021-04-08 14:20:40 +02:00
Andrew Kelley
ab5a445d25
Merge pull request #8459 from joachimschmidt557/stage2-regalloc
Stage2 Register Manager: add getReg function
2021-04-08 00:01:46 -07:00
xackus
2d2316f5c0 translate-c: fix meta.cast to ?*c_void 2021-04-08 08:33:26 +03:00
Andrew Kelley
d4f61f9842
Merge pull request #8449 from ziglang/stage2-enums
stage2: implement simple enums
2021-04-07 22:29:28 -07:00
Andrew Kelley
7595915775 stage2: add remaining enum compile error test cases 2021-04-07 22:24:52 -07:00