Commit Graph

1207 Commits (640389bb2b04766e58e206c53ee2048c54534eb9)

Author SHA1 Message Date
Andrew Kelley 640389bb2b expose environment variables in standard library
closes #118
2017-04-02 19:14:23 -04:00
Andrew Kelley 8fd0fddce5 zig build system progress
* In-progress os.ChildProcess.spawn implementation. See #204
 * Add explicit cast from integer to error. Closes #294
 * fix casting from error to integer
 * fix compiler crash when initializing variable to undefined
   with no type
2017-04-02 18:19:59 -04:00
Josh Wolfe 0594487a2e fix else-if parsing
implicit semicolon rules apply recursively to the "else" clause of if and try

if (a) {} else {} // implicit semicolon
if (a) {} else if (a) {} // implicit semicolon
if (a) {} else while (a) {} // implicit semicolon
2017-04-02 15:15:48 -07:00
Josh Wolfe a33be6fc99 defer without a block body requires a following semicolon 2017-04-02 13:47:23 -07:00
Josh Wolfe 8d03d666af add secret void expression after defer statement if it's the last statement in a block 2017-04-02 13:18:12 -07:00
Josh Wolfe e3c796258c allow implicit semicolon after defer {} 2017-04-02 13:01:23 -07:00
Josh Wolfe 136a9a9d6b variable declarations must be followed by semicolon 2017-04-02 12:46:18 -07:00
Josh Wolfe 4b9e782d37 fix confusion in block expression parsing
closes #292

* if, try, while, for, comptime, defer are "greedy" with {} blocks,
  meaning if their bodies are blocks, then no suffix operator is allowed
  after the block. The {} block gets "built into" the containing statement,
  like the body of a switch statement.
* the Expression syntactic element is no longer "greedy" with {} blocks,
  meaning it's possible to have suffix operators after {} blocks without
  needing the {} block to be an rhs operand first.
2017-04-02 11:50:34 -07:00
Josh Wolfe 9968879261 Require top-level-declaration comptime use {}
This forbids `comptime 1 comptime 1` at top-level scope.
2017-04-02 11:02:47 -07:00
Josh Wolfe 087324a639 show implicit semicolon rules in langref grammar 2017-04-02 10:53:00 -07:00
Josh Wolfe 36a015741d clean up analysis of {blocks}
* Don't insert void statements all over the place. {} now stays as
  {} instead of {{}}, and {;} becomes {} instead of {{};{}}.
* Ensure final statement is always the return value statement, or
  the block is empty. This means {label:} becomes {label:{}}.
2017-03-31 08:54:03 -07:00
Josh Wolfe d5a6cdb03f ignore eclipse project configuration 2017-03-31 08:47:09 -07:00
Andrew Kelley f8e63c4584 change `@bitcast` to `@ptrcast`
See #290
2017-03-31 06:18:20 -04:00
Andrew Kelley 3ca027ca82 first pass at zig build system
* `zig build --export [obj|lib|exe]` changed to `zig build_obj`,
   `zig build_lib` and `zig build_exe` respectively.
 * `--name` parameter is optional when it can be inferred from the
   root source filename. closes #207
 * `zig build` now looks for `build.zig` which interacts with
   `std.build.Builder` to describe the targets, and then the zig
   build system prints TODO: build these targets. See #204
 * add `@bitcast` which is mainly used for pointer reinterpret
   casting and make explicit casting not do pointer reinterpretation.
   Closes #290
 * fix debug info for byval parameters
 * sort command line help options
 * `std.debug.panic` supports format string printing
 * add `std.mem.IncrementingAllocator`
 * fix const ptr to a variable with data changing at runtime.
   closes #289
2017-03-31 05:55:41 -04:00
Josh Wolfe 536c35136a fix cmake finding dependencies for ubuntu 2017-03-29 22:18:12 -07:00
Andrew Kelley f48f7f43fe std/mem: take advantage of new printf 2017-03-28 18:05:01 -04:00
Andrew Kelley a32b5929cc add stack protector safety when linking libc
* introduce zigrt file. it contains only weak symbols so that
   multiple instances can be merged. it contains __zig_panic
   so that multiple .o files can call the same panic function.
 * remove `@setFnVisible` builtin and add @setGlobalLinkage builtin
   which is more powerful
 * add `@panic` builtin function.
 * fix collision of symbols with extern prototypes and internal
   function names
 * add stack protector safety when linking against libc. To add
   the safety mechanism without libc requires implementing
   Thread Local Storage. See #276
2017-03-26 21:07:07 -04:00
Andrew Kelley 8aeea72654 add debug safety checks for remainder division
See #217
2017-03-26 15:06:43 -04:00
Andrew Kelley 6ee63c8f58 update langref
&&= and ||= are gone
2017-03-26 14:48:23 -04:00
Andrew Kelley 3103355805 add comptime eval for some uint comparisons with 0
closes #55
2017-03-26 14:41:17 -04:00
Andrew Kelley 5bc9feb5cb organize std and make import relative to current file
closes #216
2017-03-26 06:39:28 -04:00
Andrew Kelley 7ce753a16b replace "&&" and "||" with "and" and "or"
closes #272
2017-03-26 05:21:28 -04:00
Andrew Kelley 451ce09067 new unreachable syntax
* `noreturn` is the primitive type.
 * `unreachable` is a control flow keyword.
 * `@unreachable()` builtin function is deleted.

closes #214
2017-03-26 04:58:48 -04:00
Andrew Kelley 22e6bfca96 add comptime top level declaration
closes #255
2017-03-26 04:32:13 -04:00
Andrew Kelley 9ae426a06b add test for implicit conversion from array to mutable slice
should be a compile error

closes #146
2017-03-26 03:46:06 -04:00
Andrew Kelley 7c53230a61 introduce copyable concept
closes #103
2017-03-26 03:39:18 -04:00
Andrew Kelley 5c04730534 use intel dialect for inline assembly
closes #242
2017-03-23 18:59:43 -04:00
Andrew Kelley fd634f3db3 don't mangle symbols with underscores
closes #275
2017-03-23 18:28:10 -04:00
Andrew Kelley d6856859d3 improvements for windows and libc integration
* standard library knows if it is linking against libc and will
   sometimes call libc functions in that case instead of providing
   redundant definitions
 * fix infinite loop bug when resolving use declarations
 * allow calling the same C function from different C imports.
   closes #277
 * push more logic from compiler to std/bootstrap.zig
 * standard library provides way to access errno
   closes #274
 * fix compile error in standard library for windows
 * add implementation of getRandomBytes for windows
2017-03-23 02:59:58 -04:00
Andrew Kelley 01b2bf4a44 on Darwin/MacOS/iOS, add c to link libs implicitly 2017-03-22 11:55:41 -04:00
Andrew Kelley 87bc97daef unify main entry point regardless of whether linking libc
closes #248
2017-03-22 11:26:30 -04:00
Andrew Kelley e1c47d6fe8 fix test regression regarding shadowing names
closes #271
2017-03-20 15:32:13 -04:00
Andrew Kelley fa7c64ccd5 lazy analysis of top level declarations
previously, we had lazy analysis of top level declarations,
but if a declaration was referenced within a compile-time
if or switch statement, that would still add the top
level declaration to the resolution queue.

now we have a declref ir instruction, which is only resolved
if we analyze the instruction. this takes into account comptime
branching.

closes #270
2017-03-18 11:28:43 -04:00
Andrew Kelley af536ac343 introduce new test syntax
* remove setFnTest builtin
 * add test "name" { ... } syntax
 * remove --check-unused argument. functions are always lazy now.
2017-03-16 16:02:35 -04:00
Andrew Kelley 329457bb4f Merge branch 'master' into lld 2017-03-14 21:39:04 -04:00
Andrew Kelley a76558db26 fix behavior with reinterpreting constant memory 2017-03-14 21:38:27 -04:00
Andrew Kelley 7efa2cd81c add --each-lib-rpath option and corresponding config option
This adds an rpath entry for each used dynamic library directory.
This is necessary on some systems such as NixOS.
2017-03-13 13:11:55 -04:00
Andrew Kelley d10bbd28e9 use lld instead of system linker 2017-03-13 11:54:56 -04:00
Andrew Kelley 7bc0145b80 types with zero bits do not have a pointer handle 2017-03-10 11:30:30 -05:00
Andrew Kelley 434f017aee codegen nullable void the same way as bool
See #104
2017-03-10 11:21:41 -05:00
Andrew Kelley c78dc5043b add default value for macosx version min when compiling natively
closes #264
2017-03-10 02:58:23 -05:00
Andrew Kelley c91dbdb27c fix not allocating enough memory for passing args
fixes a bug introduced in c62db5721c
2017-03-10 02:50:53 -05:00
Andrew Kelley cd31f875a6 update to llvm 4.0 2017-03-10 02:29:01 -05:00
Andrew Kelley 47f267d25f break off some of std.io into std.fmt, generalize printf
closes #250
2017-03-09 19:12:15 -05:00
Andrew Kelley c62db5721c support passing var args directly
See #77
2017-03-09 16:13:38 -05:00
Andrew Kelley 558ae2f21a fix a case of invalid ptr const-ness 2017-03-08 17:02:18 -05:00
Andrew Kelley ddd9624e2d fix assertion error, trying to dereference to array
thanks to hoppetosse on IRC for reporting the issue
2017-03-07 19:08:02 -05:00
Andrew Kelley eb9f1e2d53 add basic emacs syntax file 2017-03-02 23:03:44 -05:00
Andrew Kelley b78752e2d2 remove zeroes from vim syntax file 2017-03-02 23:03:30 -05:00
Andrew Kelley 0b942f5ee2 Merge pull request #269 from Jmeggesto/master
Fix unused return value in darwin.zig
2017-03-02 19:21:58 -05:00