Commit Graph

229 Commits

Author SHA1 Message Date
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
Andrew Kelley
9e92dbdd08 std: use parameter type inference on min and max functions 2016-09-10 20:53:57 -04:00
Andrew Kelley
fc9ff13fb6 std: avoid calling close twice in InStream
thanks ofelas for pointing this out
2016-09-08 14:21:42 -04:00
Andrew Kelley
d324b1befa ability to infer parameter types 2016-09-08 00:24:48 -04:00
Andrew Kelley
cfaced3f73 rename errName builtin to errorName 2016-09-05 17:03:11 -04:00
Andrew Kelley
768a9780ca rename compileErr builtin to compileError 2016-09-05 17:01:54 -04:00
Andrew Kelley
320e26590a fix std io input to work for non seekable fds 2016-08-31 20:23:47 -07:00
Andrew Kelley
651dc31247 implement null as a literal type 2016-08-29 22:14:09 -07:00
Andrew Kelley
6149f73189 std: more progress toward stack printing 2016-08-29 22:13:59 -07:00
Andrew Kelley
ed50bd1b65 progress toward stack trace printing 2016-08-17 20:11:04 -07:00
Andrew Kelley
a2ac06dcd5 std: replace print_u64/i64 with printInt 2016-08-16 22:59:32 -07:00
Andrew Kelley
37d167f6e0 std: conform to style guidelines 2016-08-16 22:42:50 -07:00
Andrew Kelley
0ae9023832 add CBuf to standard library
and fix ability to take address of variables
from other namespaces
2016-08-11 22:25:13 -07:00
Andrew Kelley
0d5ecc4312 ability to have a return type of 'type' 2016-08-07 20:08:37 -07:00
Andrew Kelley
0450b73e3e std: add tests for mt32 and mt64 2016-07-28 20:14:57 -07:00
Andrew Kelley
711e3d71b9 std: add vaporware plans for floating point builtins 2016-07-27 23:46:20 -07:00
Andrew Kelley
1fa0cabf9d remove multiline comments
closes #161
2016-07-27 23:26:12 -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
3eb5afd245 std: cleanup of rand 2016-07-27 19:52:38 -07:00
Andrew Kelley
06c4b35eb1 std: improve rand implementation and API 2016-07-26 23:51:58 -07:00
Andrew Kelley
bc81ddfea6 unsigned integers for sizes of things
Closes #62.
2016-07-26 20:40:11 -07:00
Andrew Kelley
76f87cdd96 std: add OutStream.write_byte 2016-07-26 18:13:22 -07:00
Andrew Kelley
78d4fb20c4 inline parameters
This replaces the current generic syntax for functions and replaces
it with the concept of inline parameters.

This paves the way for the "all structs anonymous" proposal.

Closes #151.
2016-07-25 22:55:15 -07:00
Andrew Kelley
b08bc84a36 don't add no-frame-pointer-elim for inline functions
and make syscall functions inline
this gets the tests all passing on i386
2016-05-18 18:30:03 -07:00
Andrew Kelley
3273e99d70 linux: accept calls accept4 with 0 for flags 2016-05-18 17:18:28 -07:00
Andrew Kelley
7edef4f3fd add beginning of print stack trace function
introduce std.debug and move std.assert to std.debug.assert
add mem.copy
2016-05-17 13:32:43 -07:00
Andrew Kelley
3df9389215 compiler-rt: add __aeabi_uldivmod 2016-05-15 12:02:37 -07:00
Travis McDemus
7b0052abbb Add unsigned and signed generic print fns
Signed-off-by: Andrew Kelley <superjoe30@gmail.com>
2016-05-15 01:41:15 -07:00
Andrew Kelley
6ae6b5f5b5 add compile_err builtin 2016-05-14 18:54:37 -07:00
Andrew Kelley
76f909edeb std: take advantage of ability to cast maybe pointer to isize 2016-05-14 12:38:27 -07:00
Andrew Kelley
6a7f3c8df7 std: make parsing an unsigned number generic 2016-05-13 11:11:55 -07:00
Andrew Kelley
5d2f86116f std: fix linux.get_errno 2016-05-13 09:54:56 -07:00
Andrew Kelley
8e3ab28be9 ability to cast maybe pointer to isize/usize
also ability to put noalias on maybe pointer
2016-05-13 09:54:56 -07:00
Andrew Kelley
26718a619c recognize ar program and pass --gc-sections to ld
See #54
2016-05-11 14:44:10 -07:00
Andrew Kelley
6b7ffd4cbe builtin: use explicit type instead of typeof function 2016-05-11 13:18:28 -07:00
Andrew Kelley
22888ca524 some work in progress networking code
also, casting to or from a u8 slice makes a function impure
2016-05-10 15:00:59 -07:00
Andrew Kelley
d92ae20f45 add hashmap to standard library
closes #22
2016-05-09 15:07:38 -07:00
Andrew Kelley
f1e5be9686 fix ability to use previous generic params and
add error when `%return` shows up in a function with incorrect
return type
2016-05-09 13:44:29 -07:00
Andrew Kelley
56908dcb9d add debug safety for shortening casts
closes #150
2016-05-09 08:44:41 -07:00
Andrew Kelley
9e905ab364 not-yet-working implementation of generic hash map 2016-05-08 16:05:41 -07:00
Andrew Kelley
0c32b0b4ad add list implementation to standard library 2016-05-08 01:34:00 -07:00
Andrew Kelley
01c46eef3a std: separate str and cstr 2016-05-07 10:52:52 -07:00
Andrew Kelley
8c79438f6b better array concatenation semantics
closes #87
2016-05-07 10:05:59 -07:00
Andrew Kelley
094336f07c add integer wrapping
see #46
2016-05-05 17:19:01 -07:00
Andrew Kelley
f2bc5ccbc2 more networking standard library code 2016-05-04 14:52:15 -07:00
Andrew Kelley
66ed7a5eb5 beginnings of network standard library code 2016-05-03 20:48:53 -07:00
Andrew Kelley
4815c03caa better parameter codegen
* ability to take address of a parameter (closes #97)
 * debug symbols work for parameters
2016-04-27 17:34:53 -07:00
Andrew Kelley
d1fa5692c6 add array bounds checking in debug mode
closes #27
2016-04-26 11:36:11 -07:00
Andrew Kelley
a25307c0a1 add optional continue expression to while loop
closes #139
2016-04-19 20:28:44 -07:00
Andrew Kelley
9658c05fd4 std: remove broken windows random implementation 2016-04-19 17:15:23 -07:00
Andrew Kelley
f4c7e1bf49 rearrange standard library a bit 2016-04-18 16:42:56 -07:00
Andrew Kelley
be4df96e4b passing all tests 2016-04-12 13:30:52 -07:00
Andrew Kelley
7a05e18efb implement @err_name builtin function 2016-04-09 08:55:53 -07:00
Andrew Kelley
5dbc21b511 update cat example, refactor std
partial implementation of @err_name
2016-04-08 16:21:30 -07:00
Andrew Kelley
1d4c66b56b support multiple generic function instances
See #22
2016-04-07 10:34:54 -07:00
Andrew Kelley
9c3d7b628c rename syscall.zig to linux.zig 2016-03-01 14:11:38 -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
notkild
8a827fafa6 Add support to open, create and close file 2016-02-28 23:12:58 +01:00
Andrew Kelley
77ffb5075b update bootstrap to work for macos too
* Directives can have arbitrary expressions as parameters
 * Fix switch statement not generating code sometimes
 * Rename "main" fn in bootstrap.zig to "zig_user_main" to
   avoid name collisions
 * codegen: fix badref when unreachable is last thing in an
   expression
 * support #condition directive on exported functions
2016-02-16 16:41:56 -07:00
Andrew Kelley
01fda6199e dummy implementation of os_get_random_bytes for windows 2016-02-13 22:59:49 -07:00
Andrew Kelley
c8376af92d add @ctz, @clz and compiler_rt implementation 2016-02-13 12:50:13 -07:00
Andrew Kelley
7828456b30 std: delete malloc and free
later we'll add a full featured allocator instead of this
2016-02-12 02:23:22 -07:00
Andrew Kelley
592210a173 i386 support
closes #115

Thanks to Seo Sanghyeon for the port code.
2016-02-12 02:04:46 -07:00
Andrew Kelley
d8f6388b63 if statements can be const expr evaluated
also introduce error for unnecessary if statement
but if the condition depends on a compile variable, then
the if statement is OK
2016-02-09 18:53:28 -07:00
Andrew Kelley
207862647c std: fix parse_u64 implementation and add test
also codegen implement comparision with pure errors
2016-02-09 09:51:25 -07:00
Andrew Kelley
6b3ce918db array.len generates a constant number literal expression 2016-02-07 15:52:52 -07:00
Andrew Kelley
42fe4e3cc8 remove ptr field access of arrays
use &array[0] instead
2016-02-07 15:43:19 -07:00
Andrew Kelley
94ed9f622a blocks with one statement pass constant expression eval 2016-02-07 12:38:51 -07:00
Andrew Kelley
4c8f26e9f6 std: remove auto flushing of stderr. use printf 2016-02-06 19:48:42 -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
4339d55562 update for loop syntax
it matches more closely the %% binary operator syntax

See #51
2016-02-05 17:15:19 -07:00
Andrew Kelley
ff5673ae1b add rand.float32 to standard library 2016-02-05 04:30:19 -07:00
Andrew Kelley
bb4a532785 move os_get_random_bytes to os.zig 2016-02-04 01:00:54 -07:00
Andrew Kelley
a6d4335217 fix running tests when linking with libc 2016-02-03 23:07:55 -07:00
Andrew Kelley
2521afef69 add ability to call function pointer field
also introduce the self hosted tests

closes #108
2016-02-03 21:34:09 -07:00
Andrew Kelley
c3123158b7 fix handling of implicit casts in binary operators 2016-02-03 19:07:15 -07:00
Andrew Kelley
39223c1847 test runner prints test names 2016-02-03 18:38:09 -07:00