Commit Graph

205 Commits

Author SHA1 Message Date
Andrew Kelley
07a71fc322 improved behavior on debug safety crash
* instead of emitting a breakpoint for a debug safety crash,
   zig calls a panic function which prints an error message
   and a stack trace and then calls abort.
 * on freestanding OS, this panic function has a default
   implementation of a simple infinite loop.
 * users can override the panic implementation by providing
   `pub fn panic(message: []const u8) -> unreachable { }`
 * workaround for LLVM segfaulting when you try to use cold
   calling convention on ARM.

closes #245
2017-02-06 03:10:32 -05:00
Andrew Kelley
0c88b1ce73 use printf in test runner code 2017-02-05 16:09:33 -05:00
Andrew Kelley
e56f903522 memset and memcpy implementations need not return dest 2017-02-04 23:04:07 -05:00
Andrew Kelley
c0b37e8514 add try expression
See #83
2017-02-02 17:09:27 -05:00
Andrew Kelley
b78c91951a remove ability to mark if and switch as inline
if and switch are implicitly inline if the condition/target
expression is known at compile time.

instead of:

```
inline if (condition) ...
inline switch (target) ...
```

one can use:

```
if (comptime condition) ...
switch (comptime target) ...
```
2017-02-02 13:23:18 -05:00
Andrew Kelley
88a253c64d fix crash when passing void to var args function
closes #235
2017-01-31 15:50:38 -05:00
Andrew Kelley
4b3f18de3c printf var args proof of concept
See #167

Need to troubleshoot when we send 2 slices to printf. It goes
into an infinite loop.

This commit introduces 4 builtin functions:

 * `@isInteger`
 * `@isFloat`
 * `@canImplictCast`
 * `@typeName`
2017-01-24 02:02:48 -05:00
Andrew Kelley
1826a96160 update charToDigit to take advantage of switch syntax 2017-01-23 01:19:03 -05:00
Andrew Kelley
0b34439c1f mem.free no longer requires explicit type argument 2017-01-23 00:11:21 -05:00
Andrew Kelley
47cf8520ad use comptime instead of inline for var and params
See #221
2017-01-22 19:51:37 -05:00
Andrew Kelley
fdbc2d8da1 implement error when assigning to field of const struct
closes #48
2017-01-16 15:24:03 -05:00
Andrew Kelley
c715309bc5 Merge branch 'master' into ir-merge 2017-01-16 14:23:32 -05:00
Andrew Kelley
e621ad014e pass cannot assign to constant test 2017-01-05 18:50:36 -05:00
Andrew Kelley
97e1054890 fix compiler rt 2017-01-05 04:20:07 -05:00
Andrew Kelley
ee09eb7f54 fix hash map implementation
standard library passes all tests now
2017-01-05 03:40:12 -05:00
Andrew Kelley
27a633b32a fix mem.sliceAsInt regression 2017-01-05 01:23:59 -05:00
Andrew Kelley
ff5120c584 IR: std makes it to codegen 2016-12-31 18:25:10 -05:00
Andrew Kelley
69132bdeda IR: progress toward compiling standard library
* comptime fn call
 * is_comptime doesn't count as an instruction dependency
 * update more std code to latest zig
2016-12-31 17:10:29 -05:00
Andrew Kelley
76fa6cdce3 eradicate use of zeroes in std 2016-12-31 01:31:23 -05:00
Andrew Kelley
b55efe5fab update more std library to new zig 2016-12-21 23:34:14 -05:00
Andrew Kelley
132e2fa5d9 errors from inline fn calls include stack trace 2016-12-18 20:52:40 -05:00
Andrew Kelley
82101198f1 workaround for Arch being a primitive type 2016-12-18 20:09:34 -05:00
Andrew Kelley
a71fbe49cb IR: add FnProto instruction 2016-12-18 19:40:26 -05:00
Andrew Kelley
37b13bf151 hello.zig working with all structs anonymous 2016-12-18 17:24:52 -05:00
Andrew Kelley
0d2f2b79ea IR: basic support for implicit casting to const pointer 2016-12-18 01:54:27 -05:00
Andrew Kelley
05b3b6a45e IR: update some std code to newest zig 2016-12-18 00:25:26 -05:00
Andrew Kelley
0f047337ac IR: fix this expression
Previously it returned a block instead of a function when
a function had any arguments.
2016-12-17 20:47:35 -05:00
Andrew Kelley
a07d7ee53d IR: fix compile time switch eval for enums 2016-12-17 17:57:26 -05:00
Andrew Kelley
c64f9991d5 IR: fix switching on enum 2016-12-17 17:48:07 -05:00
Andrew Kelley
ef63bc9cca IR: implement memcpy, memset, and slice expression 2016-12-12 00:31:35 -05:00
Andrew Kelley
a2257e4b81 IR: implement setFnVisible builtin 2016-11-21 15:36:25 -05:00
Andrew Kelley
19037014e5 IR: more maybe type support 2016-11-18 23:52:42 -05:00
Andrew Kelley
d94cb0566b IR: correctly codegening memset and memcpy 2016-11-18 22:24:41 -05:00
Steve Perkins
4b55966a16 add sort to CMakeLists + std/index 2016-11-03 07:01:40 +00:00
Steve Perkins
cf00245bf9 sort requires compare function.
Provide some handy functions for builtin comparable types.
2016-11-03 04:10:33 +00:00
Steve Perkins
e761aa2d2f sortCmp allows for a custom cmp function 2016-11-02 18:52:00 -04:00
Steve Perkins
c5b2bdae11 quicksort 2016-11-02 18:10:44 -04:00
Andrew Kelley
b581da41f8 remove compiler directives
* add `setFnTest`, `setFnVisible`, `setFnStaticEval`,
   `setFnNoInline` builtin functions to replace previous
   directive functionality
 * add `coldcc` and `nakedcc` as keywords which can be used as part
   of a function prototype.
 * `setDebugSafety` builtin can be used to set debug safety features
   at a per block scope level.
 * closes #169
2016-09-28 02:33:32 -04:00
Andrew Kelley
183976b242 add this keyword refers to thing in immediate scope
See #169
2016-09-26 23:47:30 -04:00
Andrew Kelley
f4d7c91363 std/rand: remove unneeded TODO 2016-09-26 22:42:25 -04:00
Andrew Kelley
87b7c28c9a cstr.len and cstr.cmp can run at compile time
closes #140
2016-09-26 22:33:33 -04:00
Andrew Kelley
7ce7e2c9d1 emit error for extern function
with byvalue return value or parameter.

currently we don't codegen byvalue parameters or return values
correctly for C compatibilty functions so instead of generating
incorrect code, we emit a compile error.

eventually we'll support this feature and remove the compile error.

See #180
2016-09-26 20:01:42 -04:00
Andrew Kelley
46eb77dbb2 stack trace is able to figure out compilation unit
each address is contained within

also fix a bug having to do with codegen for enum value
initialization expressions
2016-09-23 02:00:23 -04:00
Andrew Kelley
7aeca9bfed fix incorrect linking from previous commit 2016-09-21 17:40:50 -04:00
Andrew Kelley
b97bfc3ecb fix error when switch prong has implicit cast
closes #194
2016-09-20 16:10:34 -04:00
Andrew Kelley
3239b3cb69 use size_t for indexes
protect against incorrect copies in debug mode
2016-09-19 11:54:01 -04:00
Andrew Kelley
f1761632da darwin compat fixups
- delete commented out code
 - delete redundant check for missing
   mmacosx-version-min/maxdir
 - add TODO comment in std library
 - rename 'os' to 'self' in io.zig
 - `openSelfExe` aborts on darwin instead of compile error
 - only allow warnings on the one parseh test that has
   `#include <stdint.h>`.
2016-09-14 02:47:16 -04:00
alter
cf9b21c09f MacOSX compatibility
- Implemented some syscall for MacOSX
- tested on : El Capitan 10.11 x86_64
- make self hosted test run on macosx
- modified run_test so it does not fail when parseh throws
  warnings (most of them are related to buildin types from
  gcc that arent defined in header files and unions)
- making -mmacosx-version-min and -mios-version-min works like
  gcc (command line paramers have precedence over enviroment variables)
2016-09-14 02:46:02 -04:00
Andrew Kelley
06f2f4d64b change unreachable{} to @unreachable()
instead of a container init expression, it's a builtin
function call.
2016-09-13 16:46:27 -04:00
Andrew Kelley
ea2f6594ce std: fix compile error for unsupported os 2016-09-13 15:36:30 -04:00