Commit Graph

92 Commits

Author SHA1 Message Date
Andrew Kelley
a791417552 add @fieldParentPtr builtin function
closes #320
2017-04-18 02:28:05 -04:00
Andrew Kelley
407916cd2f rename @intType to @IntType to follow convention
closes #327
2017-04-18 00:05:09 -04:00
Andrew Kelley
41144a8566 ability to inline at function callsite
closes #306
2017-04-13 00:13:54 -04:00
Andrew Kelley
095591f0b0 add enumTagName builtin function
closes #299
2017-04-08 17:45:22 -04:00
Andrew Kelley
c9ae30d27e delete alloca builtin function
See #225

introduce os.EnvMap
2017-04-03 18:11:57 -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
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
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
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
fc100d7b3b lots of miscellaneous things all in one big commit
* add `@compileLog(...)` builtin function
   - Helps debug code running at compile time
   - See #240
 * fix crash when there is an error on the start value of a slice
 * add implicit cast from int and float types to int and float
   literals if the value is known at compile time
 * make array concatenation work with slices in addition to
   arrays and c string literals
 * fix compile error message for something not having field access
 * fix crash when `@setDebugSafety()` was called from a
   function being evaluated at compile-time
 * fix compile-time evaluation of overflow math builtins.
 * avoid debug safety panic handler in builtin.o and compiler_rt.o
   since we use no debug safety in these modules anyway
 * add compiler_rt functions for division on ARM
   - Closes #254
 * move default panic handler to std.debug so users can
   call it manually
 * std.io.printf supports a width in the format specifier
2017-02-09 03:09:25 -05:00
Andrew Kelley
6f316d8ebd setGlobalSection and setGlobalAlign work for functions 2017-02-05 12:50:19 -05:00
Andrew Kelley
419e75eb23 remove volatileStore builtin; add volatile pointers
closes #238
2017-02-04 21:49:27 -05:00
Andrew Kelley
0919ea0afd ability to set global variable alignment and ...
..section in the initialization expression
2017-02-04 10:22:07 -05:00
Andrew Kelley
5a86c04996 add volatileStore() builtin function
See #238

We can revisit how volatile will work later - for now
here's a builtin function to do it.
2017-02-03 15:14:18 -05:00
Andrew Kelley
8c9016b6d1 add setGlobalAlign and setGlobalSection builtin functions
closes #241
2017-02-03 13:56:56 -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
e5b1758010 remove staticEval builtin in favor of comptime expression 2017-01-22 23:21:00 -05:00
Andrew Kelley
d784705353 IR: implement macro for function aliasing function pointer 2017-01-12 03:15:06 -05:00
Andrew Kelley
fde276a3bf IR: implement error for missing or extra switch prongs 2017-01-10 16:28:49 -05:00
Andrew Kelley
6caf32195a pass unnecessary if statement test 2017-01-08 22:25:38 -05:00
Andrew Kelley
349cd79fe4 containers created during eval get names for parameters 2017-01-05 03:22:00 -05:00
Andrew Kelley
66a83d8738 IR: pass intToEnum test 2016-12-26 16:34:18 -05:00
Andrew Kelley
c8a7ab7eff IR: pass cStringConcatenation test 2016-12-26 16:04:14 -05:00
Andrew Kelley
735cdbfdac IR: pass intToPtrCast test 2016-12-26 15:45:50 -05:00
Andrew Kelley
4664f793dc IR: pass enumToInt test 2016-12-26 02:36:04 -05:00
Andrew Kelley
f47dea2a2e IR: support compile time global pointer reinterpret
this required moving the place we store types to ConstExprValue
2016-12-25 04:15:23 -05:00
Andrew Kelley
6f91fb4c37 IR: support const ref 2016-12-22 10:39:10 -05:00
Andrew Kelley
9b61682037 IR: implement runtime enum init and switch on enum with variable 2016-12-21 21:49:05 -05:00
Andrew Kelley
1f6dacbb2f IR: enum init support 2016-12-20 01:50:32 -05:00
Andrew Kelley
2419f0c914 IR: support maybe defers 2016-12-19 17:25:09 -05:00
Andrew Kelley
09c34352f8 IR: if and switch guaranteed compile time if target expr is 2016-12-19 00:04:51 -05:00
Andrew Kelley
a71fbe49cb IR: add FnProto instruction 2016-12-18 19:40:26 -05:00
Andrew Kelley
b59841a80f IR: fix err variable in ErrOkOr instruction 2016-12-18 13:20:19 -05:00
Andrew Kelley
d245fabb80 IR: consolidate Ref and PrefixOpAddressOf instructions 2016-12-17 22:00:55 -05:00
Andrew Kelley
12fcbecbf8 IR: add more instructions
* MaybeWrap
 * TestErr
 * UnwrapErrCode
 * UnwrapErrPayload
 * ErrUnionTypeChild
 * ErrWrapCode
 * ErrWrapPayload
2016-12-17 16:16:17 -05:00
Andrew Kelley
647d13168a IR: implement maybe return expression 2016-12-13 19:36:56 -05:00
Andrew Kelley
3f3630d7e3 IR: implement the rest of the builtin functions
* returnAddress
 * frameAddress
 * addWithOverflow
 * subWithOverflow
 * mulWithOverflow
 * shlWithOverflow
 * alignOf
2016-12-13 04:30:41 -05:00
Andrew Kelley
a6d2bdf605 IR: implement breakpoint builtin 2016-12-13 01:48:40 -05:00
Andrew Kelley
76a849b1f2 IR: implement memberCount builtin 2016-12-12 01:59:55 -05:00
Andrew Kelley
ef63bc9cca IR: implement memcpy, memset, and slice expression 2016-12-12 00:31:35 -05:00
Andrew Kelley
fb21570630 IR: implement alloca builtin 2016-12-11 19:43:06 -05:00
Andrew Kelley
9b17c0ff7f IR: implement intType builtin
and int type field access
and fix compile time bool not
2016-12-11 16:30:01 -05:00
Andrew Kelley
3429639e84 IR: implement truncate builtin 2016-12-11 15:31:07 -05:00
Andrew Kelley
433c17aeb1 IR: implement divExact builtin 2016-12-11 14:27:37 -05:00
Andrew Kelley
8fcb1a141b IR: implement fence and cmpxchg builtins 2016-12-11 04:06:07 -05:00
Andrew Kelley
10cea15cc3 IR: implement embedFile builtin 2016-12-11 00:43:23 -05:00
Andrew Kelley
2dd85d52cc IR: fix implementation of parseh
libc hello world works now
2016-12-11 00:13:43 -05:00