Commit Graph

1375 Commits

Author SHA1 Message Date
Andrew Kelley fff3c1fff4 un-special-case startup code in the std lib
Previously, the compiler had special logic to determine whether to
include the startup code, which was in `std/special/start.zig`. Now,
the file is moved to `std/start.zig`, and there is no special logic
in the compiler. Instead, the standard library unconditionally imports
the `start.zig` file, which then has a `comptime` block that does the
logic of determining what, if any, start symbols to export. Instead of
`start.zig` being in its own special package, it is just another normal
file that is part of the standard library.

`std.builtin.TestFn` is now part of the standard library rather than
specially generated by the compiler.
2019-12-12 18:33:44 -05:00
Robin Voetter f0ee0688f2 Replace typeOf with TypeOf in stage0 2019-12-10 11:09:30 -05:00
Andrew Kelley a3f6a58c77 remove var args from the language
closes #208
2019-12-09 15:27:27 -05:00
Andrew Kelley 6504c5098e tuple detection does not require AST node 2019-12-08 18:39:52 -05:00
Andrew Kelley 525b1e8fb4 Merge pull request #3856 from ziglang/builtin-call
introduce `@call` and remove other builtin calls
2019-12-06 15:49:47 -05:00
Andrew Kelley 343987cd05 remove @inlineCall from zig 2019-12-06 14:12:01 -05:00
Andrew Kelley e41495de9d private linkage for unnamed internal constants 2019-12-05 23:13:42 -05:00
Andrew Kelley ef83358eb6 remove @noInlineCall from zig 2019-12-05 17:37:29 -05:00
Andrew Kelley 1f602fe8c5 implement @call
closes #3732
2019-12-05 17:07:15 -05:00
Andrew Kelley e3ebaab3c7 fix zig builtin 2019-12-03 13:57:13 -05:00
Andrew Kelley a91f552393 WinMainCRTStartup implies defaulting to console subsystem 2019-12-03 12:52:28 -05:00
Andrew Kelley 6a046c1bcd activate start code when pub main exists
and rename LinkType->LinkMode, OutType->OutputMode
2019-12-03 12:50:42 -05:00
Vexu 20bcdab462 correct caching and add test for missing fn name 2019-12-03 12:50:41 -05:00
Vexu a0ca30ce01 move more startup code to std lib 2019-12-03 12:50:18 -05:00
LemonBoy 26c8930b95 Accept comptime-known expression for asm 2019-12-02 19:53:06 -05:00
Andrew Kelley b5df18c8fd inline ConstGlobalRefs into ZigValue
Having ConstGlobalRefs be a pointer in ZigValue was a hack that caused
plenty of bugs. It was used to work around difficulties in type coercing
array values into slices.

However, after #3787 is merged, array values no longer type coerce into
slices, and so this provided an opportunity to clean up the code.

This has the nice effect of reducing stage1 peak RAM usage during the
std lib tests from 3.443 GiB to 3.405 GiB (saving 39 MiB).

There is one behavior test failing in this branch, which I plan to debug
after merging #3787.
2019-12-01 00:29:16 -05:00
Andrew Kelley 85e1e3b95f Merge pull request #3284 from Sahnvour/export_variables
Improved support for exporting variables
2019-11-30 00:25:52 -05:00
Michael Dusan 6c89f96df1 stage1: consolodate interning
- merge const_void_val → intern.x_void
- move const_zero_byte → intern.zero_byte
- wrap intern access
2019-11-25 17:18:56 -05:00
Michael Dusan a647a88dfc const interning for 1-possible-value types 2019-11-25 15:04:49 -05:00
Michael Dusan 8f3e972da6 unembed ZigValue from IrInstruction 2019-11-25 15:04:39 -05:00
Michael Dusan acd95546b7 rename ConstExprValue → ZigValue 2019-11-25 15:04:29 -05:00
Andrew Kelley 34b1ebefaa Merge remote-tracking branch 'origin/master' into null-terminated-pointers 2019-11-24 20:28:46 -05:00
Sahnvour 1bde3b6821 gen-h: register the need for stdbool.h and stdint.h when exploring types recursively
otherwise they wouldn't be included when only a struct contains them
2019-11-24 21:33:58 +01:00
Sahnvour 49156e3980 gen-h: add a pass for exported variables 2019-11-24 21:33:58 +01:00
Sahnvour 104b6f1629 refactored gen_h_file to improve maintainability and output
- extracted functions
- factorised extern "C" into a block containing all function prototypes instead of writing macros all over the place
- using intermediate buffers instead of writing directly to the output file
2019-11-24 21:33:58 +01:00
Andrew Kelley 4c7b52503b all tests passing 2019-11-24 02:14:21 -05:00
Andrew Kelley 7597735bad update the stage1 implementation to the new proposal
See #3731
2019-11-23 04:45:35 -05:00
Vexu 0b63573674 improve broken llvm module error message 2019-11-21 23:21:14 -05:00
Andrew Kelley 47f06be369 string literals are now null terminated
this also deletes C string literals from the language, and then makes
the std lib changes and compiler changes necessary to get the behavior
tests and std lib tests passing again.
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
LemonBoy a11da37734 Update discriminant value also for zero-sized unions
Fixes #3681
2019-11-14 17:07:20 +00:00
Andrew Kelley d89f39d719 rework layout of struct type fields
This removes the remaining hack in the implementation of anonymous
struct literals, and they can now therefore now have greater than 16
fields/elements.
2019-11-14 03:52:39 -05:00
Andrew Kelley f2f698a888 rework comptime struct value layout, removing 1/2 hacks
in the implementation of anonymous struct literals
2019-11-14 03:52:36 -05:00
Andrew Kelley 8bae70454d Merge pull request #3675 from Vexu/atomic-store
Add @atomicStore builtin
2019-11-13 03:06:55 +00:00
Andrew Kelley 32b37e695a fix anonymous struct literal assigned to variable
closes #3667
2019-11-12 21:57:25 -05:00
Andrew Kelley 37318bf151 fn parameters participate in result location semantics
See #3665
2019-11-12 18:55:17 -05:00
Vexu 110ef2e528 add @atomicStore builtin 2019-11-13 00:25:44 +02:00
Andrew Kelley bf8870a60b fix unresolved type making it to codegen
found this trying to build oxid
2019-11-11 22:11:22 -05:00
Andrew Kelley 2a6fbbd8fb introduce @as builtin for type coercion
This commit also hooks up type coercion (previously called implicit
casting) into the result location mechanism, and additionally hooks up
variable declarations, maintaining the property that:

    var a: T = b;

is semantically equivalent to:

    var a = @as(T, b);

See #1757
2019-11-08 15:57:24 -05:00
Shawn Landden 2e52fafac5 correctly use llvm undef in release modes 2019-11-07 02:51:04 -05:00
LemonBoy 528908a06e Fix ptrCast of array references to fn
Closes #3607
2019-11-07 02:46:10 -05:00
Andrew Kelley cbaa10fc3b implement storing vector elements via runtime index 2019-11-05 12:11:57 -05:00
Andrew Kelley 70be308c43 implement loading vector elements via runtime index 2019-11-05 12:11:40 -05:00
Andrew Kelley 76d188551e implement store of vector element with comptime index 2019-11-05 12:11:18 -05:00
Andrew Kelley 55e54d98c4 runtime load vector element with comptime index 2019-11-05 12:11:16 -05:00
Andrew Kelley 4f594527c0 detect async fn recursion and emit compile error 2019-10-28 15:10:48 -04:00
Andrew Kelley f2d0d9820d synchronize the target features for compiling C code
d91fc0fdd8 changed zig's behavior to
disable the SSE feature when cross compiling for i386-freestanding.

This commit does the same when compiling C Code.
2019-10-28 14:37:32 -04:00
Noam Preil d91fc0fdd8 Don't use SSE on freestanding 2019-10-26 16:46:43 -04:00
Noam Preil b8305b5648 Don't save/restore stack on newStackCall to noreturn function 2019-10-26 16:45:46 -04:00
Timon Kruiper d04c58816d Translate-c: Fix a segfault when to many errors are emitted
This was already fixed when doing `@cImport`, but not yet when
running `zig translate-c`.
2019-10-26 13:09:23 -04:00