Andrew Kelley
c6295fe9ab
remove zigrt
...
adds test case for #394
partially reverts a32b5929cc
2017-09-30 20:21:57 -04:00
Andrew Kelley
816689a3b1
ptrCast gives compile error for increasing alignment
...
See #37
2017-08-29 16:52:31 -04:00
Andrew Kelley
c5c9d98065
introduce align keyword
...
* remove `@setGlobalAlign`
* add align keyword for setting alignment on functions and
variables.
* loads and stores use alignment from pointer
* memcpy, memset use alignment from pointer
* add syntax for pointer alignment
* slices can have volatile
* add u2, i2 primitives
* ignore preferred align and use abi align everywhere
* back to only having alignOf builtin.
preferredAlignOf is too tricky to be useful.
See #432 . Partial revert of
e726925e80
.
See #37
2017-08-29 07:51:34 -04:00
Andrew Kelley
d1e68c3ca8
better bigint/bigfloat implementation
2017-07-08 17:59:10 -04:00
Andrew Kelley
6a93dda3e1
progress toward windows hello world working
2017-06-14 00:04:34 -04:00
Andrew Kelley
e5b90651ba
compileError builtin includes "referenced by" notes
...
to help track down the cause
closes #278
2017-06-03 15:09:40 -04:00
Andrew Kelley
2dfb1ebee2
const global values can reference each other
...
Before, if you did something like:
```
const hi1 = "hi";
const hi2 = hi1;
```
This would create the "hi" data twice in the built object.
But since the value is const we don't have to duplicate the
data, now we take advantage of this fact.
closes #336
2017-05-27 00:54:14 -04:00
Andrew Kelley
d6b01931ef
implicitly cast by value var args parameters to const references
...
See #336
2017-05-26 16:44:13 -04:00
Andrew Kelley
fcdd808c5c
fix segfault with array of variadic functions
...
closes #377
2017-05-25 13:48:10 -04:00
Andrew Kelley
9f3cca8615
add error for break/continue exiting defer expression
...
See #284
2017-05-21 10:44:55 -04:00
Andrew Kelley
b483db4868
typeId builtin instead of isInteger, isFloat, etc
...
closes #373
2017-05-17 12:26:35 -04:00
Andrew Kelley
01f066de37
ability to slice ptr to hard coded integer at comptime
...
closes #369
2017-05-09 22:23:38 -04:00
Andrew Kelley
818a0a2629
switch expression - add compile errors
...
* for duplicate integer value
* for missing integer values
* for missing else prong
see #43
2017-05-07 12:07:35 -04:00
Andrew Kelley
17b935325e
@import("builtin")
instead of @compileVar
...
See #226
Closes #220
2017-05-01 13:12:38 -04:00
Andrew Kelley
7e11ef79d6
zig test no longer requires a separate test_runner.o file
...
See #298
2017-04-27 16:19:20 -04:00
Andrew Kelley
7b0542d08b
build system: consolidate duplicate code and more
...
* add ability to add assembly files when building an exe, obj, or lib
* add implicit cast from `[N]T` to `?[]const T` (closes #343 )
* remove link_exe and link_lib in favor of allowing build_exe and
build_lib support no root zig source file
2017-04-26 19:17:05 -04:00
Andrew Kelley
6de33ded81
make undefined as a constant value lazy
...
closes #268
2017-04-23 14:34:40 -04:00
Andrew Kelley
f2140efc52
Merge remote-tracking branch 'origin/parser'
2017-04-13 03:09:09 -04:00
Andrew Kelley
bf57d8a7e3
typedefpocalypse
...
closes #314
2017-04-13 03:07:58 -04:00
Josh Wolfe
919910312d
make it an error to ignore a statement's value
...
this makes {1;} an error.
2017-04-12 22:21:35 -07:00
Andrew Kelley
11a6550324
fix some -Wconversion errors
2017-04-10 20:02:39 -04:00
Andrew Kelley
095591f0b0
add enumTagName builtin function
...
closes #299
2017-04-08 17:45:22 -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
e1c47d6fe8
fix test regression regarding shadowing names
...
closes #271
2017-03-20 15:32:13 -04:00
Andrew Kelley
25761570f1
more robust const struct values
2017-02-26 23:50:04 -05:00
Andrew Kelley
3075d8aee7
fix use decls not always working
2017-02-23 16:52:13 -05:00
Andrew Kelley
d794549985
bitfields support for array of non-store-aligned packed structs
2017-02-22 00:49:10 -05:00
Andrew Kelley
0148f39df9
pointers with bit offset contain length
...
adds compile error when passing pointer that is byte-aligned
at the beginning but not the end to a function expecting
a fully byte aligned pointer
closes #261
2017-02-16 19:35:42 -05:00
Andrew Kelley
fc5d47b9b9
reading from a bit field partially works
...
See #261
Still need to do:
* reading a field that has bit offset 0 but still needs to
shift and truncate
* writing a field
2017-02-16 15:45:41 -05:00
Andrew Kelley
4b5cc80f66
move volatile pointers to central type table
2017-02-16 13:58:42 -05:00
Andrew Kelley
1fc2082b4c
ability to declare const bitfields
...
See #261
2017-02-15 18:55:29 -05:00
Andrew Kelley
63d37b7cff
add runtime debug safety for dividing integer min value by -1
...
closes #260
2017-02-14 01:08:30 -05:00
Andrew Kelley
39287d7346
rework compile-time known pointer values
...
See #257
2017-02-11 13:13:45 -05:00
Andrew Kelley
916a96fb72
variables, memcpy, and memset all get alignment
...
See #37
2017-02-07 01:50:10 -05:00
Andrew Kelley
419e75eb23
remove volatileStore builtin; add volatile pointers
...
closes #238
2017-02-04 21:49:27 -05:00
Andrew Kelley
71d335e5cc
implement packed structs
...
closes #183
2017-02-03 11:39:24 -05:00
Andrew Kelley
2b88441295
fix behavior when initializing struct with undefined
2017-02-02 14:55:01 -05:00
Andrew Kelley
d13cec6894
fix var args allocating wrong amount of memory in compiler
2017-01-31 16:04:26 -05:00
Andrew Kelley
d2b94afaf2
fix compile time initialization of array with undefined
2017-01-29 23:35:34 -05:00
Andrew Kelley
17cb85dfb8
basic support for functions with variable length arguments
...
See #77
2017-01-23 16:40:17 -05:00
Andrew Kelley
201a3c121a
introduce comptime expression
...
closes #221
2017-01-22 22:59:52 -05:00
Andrew Kelley
0c1800a9c9
fix some stuff when llvm has assertions on
2017-01-13 17:33:19 -05:00
Andrew Kelley
d784705353
IR: implement macro for function aliasing function pointer
2017-01-12 03:15:06 -05:00
Andrew Kelley
430e33b869
partially fix parseh command
2017-01-10 15:39:52 -05:00
Andrew Kelley
349cd79fe4
containers created during eval get names for parameters
2017-01-05 03:22:00 -05:00
Andrew Kelley
a9acc8cb45
IR: error for returning from defer expression
...
also fix peer type resolution for pure error mixed with error union
2016-12-28 03:47:02 -05:00
Andrew Kelley
25a5fc32fe
IR: pass passSliceOfEmptyStructToFn test
2016-12-28 01:15:09 -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
1f6dacbb2f
IR: enum init support
2016-12-20 01:50:32 -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
82101198f1
workaround for Arch being a primitive type
2016-12-18 20:09:34 -05:00
Andrew Kelley
e50ced44a2
IR: all structs anonymous
2016-12-18 16:56:50 -05:00
Andrew Kelley
85b6d14637
IR: support var type args and fix phi peer type resolution
2016-12-18 00:09:43 -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
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
8fcb1a141b
IR: implement fence and cmpxchg builtins
2016-12-11 04:06:07 -05:00
Andrew Kelley
2dd85d52cc
IR: fix implementation of parseh
...
libc hello world works now
2016-12-11 00:13:43 -05:00
Andrew Kelley
6ed202ab16
IR: implement defer
2016-12-06 21:26:17 -05:00
Andrew Kelley
0541532ed6
IR: implement generic function calls
2016-12-05 05:12:44 -05:00
Andrew Kelley
363606d87b
IR: inline function evaluation works on generic functions
2016-12-05 01:08:17 -05:00
Andrew Kelley
2f259b8176
IR: re-organize where state goes to prepare for generics
...
* Rip out legacy code for generics
* put scope in instruction instead of AST nodes
* separate top level decl stuff from AST nodes
- remove the assumption that there is a 1:1 correspondence
between an output instruction and an AST node
- This way we won't have to clone AST nodes for generics.
2016-12-04 03:40:40 -05:00
Andrew Kelley
f6cbb73c74
rewrite scope implementation
...
* now there are not extra unused hash tables
* each variable declaration opens a new scope inside a function
2016-12-01 21:08:12 -05:00
Andrew Kelley
c6ace9720c
rename BlockContext to Scope
2016-12-01 13:55:56 -05:00
Andrew Kelley
eb5693d91f
IR: function call porting progress
...
also implemented container init
generics is still todo
2016-11-28 02:40:01 -05:00
Andrew Kelley
84f7805029
IR: support import builtin function
2016-11-26 20:52:22 -05:00
Andrew Kelley
05de70017d
IR: support slice types
2016-11-07 18:58:01 -05:00
Andrew Kelley
a2e3293930
WIP moving all analysis to IR
2016-11-04 15:36:30 -04:00
Andrew Kelley
1a0111d4c3
*WIP*
2016-10-30 02:46:16 -04:00
Andrew Kelley
afc5507b64
ir: ability to modify global vars
2016-10-29 19:14:48 -04:00
Andrew Kelley
77ae3442ef
explicit casting works with IR
2016-10-09 02:20:01 -04:00
Andrew Kelley
cd1bd78aa9
simple add function works with IR
2016-10-02 23:48:48 -04:00
Andrew Kelley
633781e31d
empty function compiles successfully with IR
2016-09-30 20:12:00 -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
0d5ecc4312
ability to have a return type of 'type'
2016-08-07 20:08:37 -07:00
Andrew Kelley
8552d7fd19
explicit wrapping integer operations
...
instead of wrapping integer types
closes #159
2016-07-27 23:08:27 -07:00
Andrew Kelley
9d29674711
ability to cast slice to u8 slice
2016-05-07 18:45:28 -07:00
Andrew Kelley
2ed72022ce
support generic data structures
...
See #22
2016-05-07 17:00:58 -07:00
Andrew Kelley
094336f07c
add integer wrapping
...
see #46
2016-05-05 17:19:01 -07:00
Andrew Kelley
7a05e18efb
implement @err_name builtin function
2016-04-09 08:55:53 -07:00
Andrew Kelley
f1d338194e
rewrite how importing works
...
* Introduce the concept of packages. Closes #3
* Add support for error notes.
* Introduce `@import` and `@c_import` builtin functions and
remove the `import` and `c_import` top level declarations.
* Introduce the `use` top level declaration.
* Add `--check-unused` parameter to perform semantic
analysis and codegen on all top level declarations, not
just exported ones and ones referenced by exported ones.
* Delete the root export node and add `--library` argument.
2016-03-01 03:13:40 -07:00
Andrew Kelley
f580c7fa43
handle libc include path and libc lib path differently
2016-02-15 16:52:37 -07:00
Andrew Kelley
87cdbb6c25
improve performance for get_fn_type
2016-02-07 18:32:19 -07:00
Andrew Kelley
6a2ede5a6e
parsing code for defer and more
...
* disable goto and label support see #44
* refactor the way block contexts work
2016-02-05 23:20:34 -07:00
Andrew Kelley
b28f7d0808
types sized and aligned with LLVM target data layout API
2016-02-03 02:01:42 -07:00
Andrew Kelley
3c2093fec6
parseh understands types better and handles some situations better
...
See #88
Also, includes partial implementation of typedef top level declaration.
See #95
Also, fix function types. Previously the way we were deduping function type
pointers was incorrect.
2016-01-31 01:20:47 -07:00
Andrew Kelley
0278468479
upgrade to the libclang C++ API
...
c_import creates a tmp .h file and parses it with libclang,
reporting any errors found.
See #88
2016-01-27 00:01:49 -07:00
Andrew Kelley
32e2196257
number literal rework
2016-01-21 03:02:25 -07:00
Andrew Kelley
3a326d5005
pave the road for function pointers
...
See #14
2016-01-18 08:50:10 -07:00
Andrew Kelley
0c9afede9e
overflow intrinsics take type as first argument
2016-01-14 17:04:35 -07:00
Andrew Kelley
b28b7f63d1
all types are now expressions
...
See #22
2016-01-13 18:15:51 -07:00
Andrew Kelley
4d7835e21a
delete unused enumfield and enumdecl node types
2016-01-10 17:27:58 -07:00
Andrew Kelley
3ef2f7058b
refactor out the horrible beast that was codegen_node
2016-01-10 15:13:39 -07:00
Andrew Kelley
35b74d4013
order-independent declarations even from imports
...
closes #42
2016-01-10 01:25:20 -07:00
Andrew Kelley
1fe1235e14
order-independent declarations
...
code constructs and traverses a dependency graph in a deterministic
order.
2016-01-09 23:49:22 -07:00
Andrew Kelley
6d9119fcd9
add memcpy and memset intrinsics
2016-01-09 02:16:54 -07:00
Andrew Kelley
0c24ed8a81
rename restrict
to noalias
2016-01-08 23:48:24 -07:00
Andrew Kelley
b7dd88ad68
suport checked arithmetic operations via intrinsics
...
closes #32
2016-01-08 23:41:40 -07:00
Andrew Kelley
14b9cbd43c
add restrict qualifier on pointer arguments
2016-01-08 20:59:47 -07:00
Andrew Kelley
0c84ecd19d
codegen: fix else if expression and maybe unwrap expr
2016-01-08 03:59:37 -07:00
Andrew Kelley
9aea99a999
implement array slicing syntax
...
closes #52
2016-01-07 05:29:11 -07:00