Commit Graph

3866 Commits

Author SHA1 Message Date
Andrew Kelley
0262dda9b8 std: remove comptime const 2021-04-22 23:52:52 -07:00
jacob gw
ce41ddcd23 std: fix potential bug in parseInt 2021-04-22 22:42:46 -04:00
Andrew Kelley
93d1c2d6d4 std: fix compile errors caught by stage2 AstGen
Follow-up from 507a8096d2
2021-04-22 19:32:57 -07:00
Andrew Kelley
8dd7378013 delete packed enums from the language
No need for any such thing. Instead, provide an integer tag type for the
enum.
2021-04-22 19:21:50 -07:00
Andrew Kelley
507a8096d2 std: fix compile errors caught by stage2 AstGen
* `comptime const` is redundant
 * don't use `extern enum`; specify a tag type.
   `extern enum` is only when you need tags to alias. But aliasing tags
   is a smell. I will be making a proposal shortly to remove `extern enum`
   from the language.
 * there is no such thing as `packed enum`.
 * instead of `catch |_|`, omit the capture entirely.
 * unused function definition with missing parameter name
 * using `try` outside of a function or test
2021-04-22 18:07:46 -07:00
Andrew Kelley
a008fb0a71 std.fs: delete unused label
stage2 starting to catch problems with the standard library :)
2021-04-20 17:57:35 -07:00
Andrew Kelley
30c9808391 AstGen: implement anytype parameters 2021-04-20 17:38:06 -07:00
jacob gw
b4aec0e31d stage2: make std.fmt.parseInt ignore _ 2021-04-20 17:08:05 -04:00
Andrew Kelley
e315120b79 AstGen: implement array initialization expressions 2021-04-19 23:23:24 -07:00
Andrew Kelley
22015c1b3b std.MultiArrayList: ensureUnusedCapacity/ensureTotalCapacity
Same as c8ae581fef, but for
MultiArrayList.
2021-04-19 15:02:37 -07:00
Andrew Kelley
c8ae581fef std: deprecate ensureCapacity, add two other capacity functions
I've run into this footgun enough times, nearly every time I want
`ensureUnusedCapacity`, not `ensureCapacity`. This commit deprecates
`ensureCapacity` in favor of `ensureTotalCapacity` and introduces
`ensureUnusedCapacity`.
2021-04-16 17:56:30 -07:00
Andrew Kelley
7818586a2b fix new references to std.builtin that should have been std.Target 2021-04-15 19:14:54 -07:00
Andrew Kelley
798ad631f3 stage2 start.zig: slight simplification
fewer required language features to allow this to work
2021-04-15 19:06:39 -07:00
Andrew Kelley
429cd2b5dd std: change @import("builtin") to std.builtin 2021-04-15 19:06:39 -07:00
Andrew Kelley
a38042e3ac ci: windows: proper flags to zig build 2021-04-15 02:02:36 -07:00
Andrew Kelley
04b8354702 freebsd: disable failing test
See #8538
2021-04-15 00:59:40 -07:00
lithdew
81adcd533e os/posix: handle ECONNRESET for write/writev 2021-04-14 16:40:06 -07:00
Andrew Kelley
5a3ea9bece Merge remote-tracking branch 'origin/llvm12'
Happy LLVM 12 Release Day.

Please note that the llvm 12 tag does not include the latest commit in
the release/12.x branch, which is in fact a bug fix for a regression
that is causing a failure in Zig's test suite.

Zig master branch is tracking release/12.x, and will be enabling the
test that is fixed by that commit.
2021-04-14 14:41:57 -07:00
Michael Dusan
28ae498254 dwarf: fix LineNumberProgram check
- on first iteration populate `prev_` fields and do nothing else

closes #8421
2021-04-12 17:18:56 -04:00
Andrew Kelley
c4c7cb252a
Merge pull request #8502 from xackus/std-docs
std docs: @This() in generic types
2021-04-12 11:37:00 -07:00
Michael Dusan
0fa1a2cb73
Revert "dwarf: fix LineNumberProgram check"
- needed/needs to go through review process

This reverts commit 746f65f8b3.
2021-04-12 06:55:12 -04:00
Michael Dusan
746f65f8b3
dwarf: fix LineNumberProgram check
- tolerate out-of-order DW_AT_ranges

closes #8421
2021-04-12 06:12:00 -04:00
xackus
ab991cab84 std docs: @This() in generic types 2021-04-12 09:31:45 +02:00
Andrew Kelley
c5e662d860
Merge pull request #8497 from LemonBoy/some-ppc-fixes
Improve Improve PowerPC support
2021-04-11 18:59:31 -07:00
Michael Dusan
93cf9560b1
Merge remote-tracking branch 'origin/master' into llvm12 2021-04-11 17:40:19 -04:00
xackus
7857ad78db std docs: update var to anytype 2021-04-11 22:59:30 +02:00
LemonBoy
44f8ce690d std: Fix typo in sqrt implementation
The code initializes twice `t` instead of `t1`, leaving the latter
uninitialized. The problem manifested itself by corrupting the LSBs of
the result in unpredictable ways.
2021-04-11 21:27:39 +02:00
LemonBoy
8d94dc625b compiler-rt: Introduce PowerPC-specific f128 helpers
For historical reasons IEEE f128 ops use `kf` instead of `tf` in their
names, there's no functional change.
2021-04-11 21:26:22 +02:00
LemonBoy
9bebdc77d6 std: Fix TLS definitions for 32bit PowerPC targets
Correct some silly errors and add the missing piece to set the thread
pointer (r2).
2021-04-11 21:26:22 +02:00
Benjamin Feng
073d8e55c3 Initialize the ppc stack frame correctly 2021-04-10 22:47:22 -05:00
Benjamin Feng
2e85eb2bf8 Rename time32 syscalls to match rest of stdlib 2021-04-10 22:47:22 -05:00
Benjamin Feng
ae3a0ff2d1 _start assembly for ppc 2021-04-10 22:47:22 -05:00
Benjamin Feng
b409accc96 Copy over ppc clone from musl 2021-04-10 22:47:22 -05:00
Benjamin Feng
df910b33f4 Add ppc Linux bits 2021-04-10 22:47:22 -05: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
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
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
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
Andrew Kelley
9a2de796bd stage2: clean up pretty printing compile errors 2021-04-09 00:19:44 -07:00
jacob gw
99ec511c4c stage2: pretty print compilation errors 2021-04-08 23:17:36 -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
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
xackus
2d2316f5c0 translate-c: fix meta.cast to ?*c_void 2021-04-08 08:33:26 +03:00