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
216e14891e
zig build system creates symlinks atomically
...
* add std.base64
* add std.os.rename
* add std.os.atomicSymLink
2017-04-17 19:08:41 -04:00
Andrew Kelley
05b3082121
zig build system: progress toward install and uninstall
...
also:
* add std.os.path.join
* add std.os.deleteFile
2017-04-17 06:47:20 -04:00
Andrew Kelley
e4ec2d10c6
zig build system: implement custom command step
2017-04-17 06:47:20 -04:00
Andrew Kelley
47336abae3
improvements to zig build system and unwrap error safety
...
* zig build system: create standard dynamic library sym links
* unwrapping an error results in a panic message that contains
the error name
* rename error.SysResources to error.SystemResources
* add std.os.symLink
* add std.os.deleteFile
2017-04-17 06:47:20 -04:00
Andrew Kelley
d16ce67106
zig build system: ability to link against dynamic library step
2017-04-17 06:47:20 -04:00
Andrew Kelley
5fdefe58e4
zig build system understands the concept of dependencies
...
See #204
2017-04-13 17:21:00 -04:00
Andrew Kelley
2864359950
zig build system writes template build.zig file when none exists
...
see #204
2017-04-11 06:14:46 -04:00
Andrew Kelley
095591f0b0
add enumTagName builtin function
...
closes #299
2017-04-08 17:45:22 -04:00
Andrew Kelley
7611ed3484
allow implicit cast from `[N]T` to `&const []const T`
...
closes #296
2017-04-07 17:56:01 -04:00
Andrew Kelley
5eb78ba177
fix std.mem.IncrementingAllocator
...
updating ptr casting because of previous commit
2017-04-07 15:38:31 -04:00
Andrew Kelley
f7e9d7aa5d
ability to implicitly cast integer literal to &const Int
...
where Int is an integer type
also introduce `@intToPtr` builtin for converting a usize
to a pointer. users now have to use this instead of `(&T)(int)`.
closes #311
2017-04-07 15:35:38 -04:00
Andrew Kelley
273cebdf4d
peer resolve types [N]T, [M]T as []const T
...
closes #125
2017-04-06 18:07:38 -04:00
Andrew Kelley
10dbc735fe
zig build: use -D for options instead of -O
...
because -O is usually optimization level
2017-04-06 13:59:11 -04:00
Andrew Kelley
6fbe1632d0
Update zig build system to support user defined options
...
* Fix assertion failure when switching on type.
Closes #310
* Update zig build system to support user defined options.
See #204
* fmt.format supports {sNNN} to set padding for a buffer arg.
* add std.fmt.bufPrint and std.fmt.allocPrint
* std.hash_map.HashMap.put returns the previous value
* add std.mem.startsWith
2017-04-06 05:34:04 -04:00
Andrew Kelley
d15bcdce69
std: ChildProcess.spawn looks at PATH env var
...
closes #303
2017-04-05 17:55:50 -04:00
Andrew Kelley
9c803af044
zig build system: fix cleanup on error, report spawn error
2017-04-04 06:47:42 -04:00
Andrew Kelley
1c6000d047
zig build system improvements, add some std API
...
* add std.buf_map.BufMap
* add std.buf_set.BufSet
* add std.mem.split
* zig build system improvements (See #204 )
- automatically parses NIX_CFLAGS_COMPILE and NIX_LDFLAGS
- add builder.addCIncludePath
- add builder.addRPath
- add builder.addLibPath
- add exe.linkLibrary
2017-04-04 01:52:20 -04:00
Andrew Kelley
72fb2443e0
API for command line args
...
closes #300
2017-04-04 00:17:24 -04:00
Andrew Kelley
55dd2676ef
fix std build for darwin
2017-04-03 19:30:03 -04:00
Andrew Kelley
c9ae30d27e
delete alloca builtin function
...
See #225
introduce os.EnvMap
2017-04-03 18:11:57 -04:00
Andrew Kelley
c400cb429a
zig build system: add setLinkerScript and setTarget
...
* See #204 - zig build system
* allow builtin types Os, Environ, Arch to be used at runtime.
they have zero_bits=false and debug info now.
* Eradicate use of `@alloca` in std for syscalls. See #225
* add `std.io.writeFile`
* `std.debug.panic` adds a newline to format
2017-04-03 05:04:46 -04:00
Andrew Kelley
a1363b5227
proof of concept build system
...
see #204
2017-04-02 20:44:04 -04:00
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
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
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
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
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
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
87bc97daef
unify main entry point regardless of whether linking libc
...
closes #248
2017-03-22 11:26:30 -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
47f267d25f
break off some of std.io into std.fmt, generalize printf
...
closes #250
2017-03-09 19:12:15 -05:00
Jackie Meggesto
5bbde1dc91
Fix unused return value in darwin.zig
2017-03-02 19:21:02 -05:00
Andrew Kelley
6d0afc2bd2
add compile error for assigning number literal to non-comptime var
2017-03-02 18:51:19 -05:00
Andrew Kelley
9eb29e81f9
rename CBuf to Buffer0 and some minor std API changes
2017-02-28 03:07:11 -05:00
Andrew Kelley
a665872e88
add compile error for ignoring return value
...
also introduce the _ identifier which you can assign to
to discard a return value
closes #219
2017-02-24 15:01:19 -05:00
Andrew Kelley
4b99f5978f
add character format specifier to std.io.OutStream.printf
2017-02-23 18:56:10 -05:00
Andrew Kelley
fe3063e58c
update std code for MacOS
...
closes #264
2017-02-23 16:13:57 -05:00
Andrew Kelley
b6e7a0dadd
support arithmetic for non byte aligned integer types
...
see #261
2017-02-16 17:08:55 -05:00
Andrew Kelley
b61f1a9f7d
printf: only include + sign on signed ints if width specified
...
see #258
2017-02-12 17:46:28 -05:00
Andrew Kelley
6dba1f1c8e
slice and array re-work plus some misc. changes
...
* `@truncate` builtin allows casting to the same size integer.
It also performs two's complement casting between signed and
unsigned integers.
* The idiomatic way to convert between bytes and numbers is now
`mem.readInt` and `mem.writeInt` instead of an unsafe cast.
It works at compile time, is safer, and looks cleaner.
* Implicitly casting an array to a slice is allowed only if the
slice is const.
* Constant pointer values know if their memory is from a compile-
time constant value or a compile-time variable.
* Cast from [N]u8 to []T no longer allowed, but [N]u8 to []const T
still allowed.
* Fix inability to pass a mutable pointer to comptime variable at
compile-time to a function and have the function modify the
memory pointed to by the pointer.
* Add the `comptime T: type` parameter back to mem.eql. Prevents
accidentally creating instantiations for arrays.
2017-02-12 17:35:51 -05:00
Andrew Kelley
ca180d3f02
std.io.parseUnsigned buf parameter is const
...
fixes padding in printf
See #258
2017-02-11 15:06:20 -05:00
Andrew Kelley
f7173f4f08
fix crash on string literal with character code >= 128
...
See #258
2017-02-11 14:01:11 -05: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
8a859afd58
std.io supports printing integers as hex values
...
remove "unnecessary if statement" error
this "depends on compile variable" code is too hard to validate,
and has false negatives. not worth it right now.
std.str removed, instead use std.mem.
std.mem.eql and std.mem.sliceEql merged and do not require explicit
type argument.
2017-02-07 17:23:50 -05:00
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
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
Andrew Kelley
11a0644365
basic support for building a test target
2016-02-03 18:02:01 -07:00
Andrew Kelley
5ad84e4724
unreachable causes a trap in debug mode
2016-02-02 02:43:33 -07:00
Andrew Kelley
6f1a7a0d70
add abort function and "cold" fn attribute
2016-02-02 00:42:06 -07:00
MovingtoMars
3fd6c0ce25
fix some inaccuracy in float printing
2016-01-29 21:22:15 +13:00
MovingtoMars
a6c2b013fd
remove some magic numbers from float printing
2016-01-29 21:19:21 +13:00
MovingtoMars
850f6d2d02
better f64_is_nan
2016-01-29 21:12:33 +13:00
MovingtoMars
90a32629c0
float printing mostly works
2016-01-29 20:55:38 +13:00
Andrew Kelley
2fc4b3629a
std: remove incorrect float printing code
2016-01-28 12:54:30 -07:00
MovingtoMars
eb08fd5f5f
remove accidental printf from float printing
2016-01-28 19:44:44 +13:00
MovingtoMars
fb7a95b3c4
cleanup float printing
2016-01-28 19:43:08 +13:00
MovingtoMars
dc08412895
basic float printing
2016-01-28 19:28:43 +13:00
MovingtoMars
401a3361ea
malloc fails on mmap error code properly
2016-01-28 16:01:52 +13:00
MovingtoMars
9c502030a1
check mmap return against -1
2016-01-28 13:45:35 +13:00
MovingtoMars
04b721d535
malloc fails on proper errors
2016-01-28 13:18:29 +13:00
MovingtoMars
1a913f6bf2
simple malloc and free using mmap
2016-01-28 12:39:02 +13:00
Andrew Kelley
4e43973413
variable initializations are now mandatory
...
use `undefined` if you want uninitialized memory
2016-01-25 23:56:46 -07:00
Andrew Kelley
50854226a6
syntax: back to -> for return type, no more =>
2016-01-25 17:08:18 -07:00
Andrew Kelley
deb3586884
implement %% prefix operator
...
See #23
also make undefined constants use llvm undef value
2016-01-25 15:45:05 -07:00
Andrew Kelley
e85e7ebcf0
bootstrap: use %% operator instead of cast
2016-01-25 14:13:25 -07:00
Andrew Kelley
6db6609df8
implement %% operator
...
See #23
2016-01-25 13:53:40 -07:00
Andrew Kelley
bcb18338cd
update std lib to use error type and global variables
2016-01-24 22:53:00 -07:00
Andrew Kelley
f5cc7f65a3
fix parameter access of sret functions
2016-01-24 19:27:12 -07:00
Andrew Kelley
5c18826240
introduce the error keyword and type
...
See #23
2016-01-24 01:34:57 -07:00
Andrew Kelley
37aae53009
various small cleanups
2016-01-23 03:06:29 -07:00
Andrew Kelley
c0ea9290c4
main returns %void
2016-01-23 02:14:01 -07:00
Andrew Kelley
91d911007b
codegen: fix field access of arrays
...
also fix error type analyze error
2016-01-23 00:53:43 -07:00
Andrew Kelley
bfceb18631
character literal returns a number literal
2016-01-22 23:24:09 -07:00
Andrew Kelley
523e3b86af
support statically initialized array literal
2016-01-22 22:02:07 -07:00
Andrew Kelley
b61406b607
add test for const number literal
2016-01-22 16:02:08 -07:00
Andrew Kelley
32e2196257
number literal rework
2016-01-21 03:02:25 -07:00
Andrew Kelley
5e212db29c
parsing error value decls and error value literals
...
and return with '?' or '%' prefix
2016-01-20 18:18:50 -07:00
Andrew Kelley
ae2151a751
use signed integer for sizes of things
2016-01-18 21:13:14 -07:00
Andrew Kelley
32821e7098
add function pointer support
...
See #14
2016-01-18 16:42:45 -07:00
Andrew Kelley
4c50606b9d
refactor std to use for loop
2016-01-18 07:16:17 -07:00
Andrew Kelley
fbbef14013
add for loop which can iterate over arrays
...
See #51
2016-01-18 07:00:45 -07:00
Andrew Kelley
5f7685336f
better main symbol prototype
...
closes #64
2016-01-16 00:07:34 -07:00
Andrew Kelley
dc162c7f83
rename "use" to "import"
2016-01-15 18:45:52 -07:00
Andrew Kelley
86f55bce53
add void arrays test
2016-01-15 18:41:19 -07:00
Andrew Kelley
0c9afede9e
overflow intrinsics take type as first argument
2016-01-14 17:04:35 -07:00
Andrew Kelley
5f9ecb8566
instead of 'as' to cast, call type as function
2016-01-14 02:52:33 -07:00
Andrew Kelley
b28b7f63d1
all types are now expressions
...
See #22
2016-01-13 18:15:51 -07:00
Andrew Kelley
49d0971cd4
detect and report top level decl dependency loop
2016-01-10 00:03:31 -07:00
Andrew Kelley
6d9119fcd9
add memcpy and memset intrinsics
2016-01-09 02:16:54 -07:00
Andrew Kelley
bdca82ea66
implement pub const
2016-01-09 00:37:48 -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
d14a31100f
implement unknown size array indexing and slicing
2016-01-08 17:52:45 -07:00
Andrew Kelley
0c84ecd19d
codegen: fix else if expression and maybe unwrap expr
2016-01-08 03:59:37 -07:00
Andrew Kelley
e1f498212c
fix codegen for implicit maybe wrap
2016-01-08 02:52:27 -07:00
Andrew Kelley
a3c97081ca
add ?? maybe unwrapping binary operator
...
add null literal
fix number literal / maybe interactions
2016-01-07 03:23:38 -07:00
Andrew Kelley
9b9fd5ad23
re-add errno.zig
2016-01-07 03:22:53 -07:00
Andrew Kelley
c75d40680f
while detects simple constant condition
2016-01-06 18:02:42 -07:00
Andrew Kelley
5f0bfcac24
fix undefined reference to memcpy in release mode
...
when not depending on libc, we generate memcpy and memset
implementations.
2016-01-06 06:40:25 -07:00
Andrew Kelley
5e64c4d92f
support pub structs. move rand to std lib.
...
guess number example prints the answer now
2016-01-06 04:41:11 -07:00
Andrew Kelley
3c43bc9208
support unknown size arrays
2016-01-06 01:28:58 -07:00
Andrew Kelley
4ef062b9c8
array syntax is [10]i32 instead of [i32; 10]
2016-01-05 22:47:47 -07:00
Andrew Kelley
3327b0488d
add #min_value() and #max_value()
2016-01-05 06:30:49 -07:00
Andrew Kelley
44d5d008d0
partial import segregation
...
See #3
2016-01-04 03:31:57 -07:00
Andrew Kelley
b453345554
add rand example that doesn't yet work
2016-01-03 00:30:41 -07:00
Andrew Kelley
1abb4e59be
fix various bugs related to guess number example
2016-01-02 21:56:33 -07:00
Andrew Kelley
258bc73eee
fix implicit cast after unreachable bad code gen
2016-01-02 20:13:10 -07:00
Andrew Kelley
187d00ca83
ability to access pointers with array indexing syntax
...
closes #40
2016-01-02 19:47:36 -07:00
Andrew Kelley
968b85ad77
closer to guess number example working
2016-01-02 03:38:45 -07:00
Andrew Kelley
9ce36ba0cc
inline assembly uses -> instead of return
2015-12-23 15:49:34 -07:00
Andrew Kelley
1f48b626a1
std: even more efficient inline assembly
2015-12-15 02:47:39 -07:00
Andrew Kelley
673d638070
std: more efficient inline assembly
2015-12-15 01:55:52 -07:00
Andrew Kelley
a292eb8d64
support inline assembly expressions with return type
2015-12-15 00:46:56 -07:00
Andrew Kelley
66ca916805
std: expose exit syscall
2015-12-15 00:07:51 -07:00
Andrew Kelley
83b68c9f13
add global variable support
...
closes #12
2015-12-14 23:10:18 -07:00
Andrew Kelley
3049410260
`const` and `var` instead of `let` and `let mut`
...
closes #34
2015-12-14 18:51:07 -07:00
Andrew Kelley
f17e20d5fe
instead of *mut and *const, & and &const
...
closes #33
2015-12-14 18:10:25 -07:00
Andrew Kelley
630917b29b
std: factor out the write syscall and make it public
2015-12-14 03:06:54 -07:00
Andrew Kelley
e411467e1d
add number literal type
...
it gets implicitly casted to whatever is needed.
closes #24
2015-12-14 02:46:37 -07:00
Andrew Kelley
ac630d354d
std: print_str no longer requires length argument
...
add explicit casting support from array to string
2015-12-12 02:05:08 -07:00
Andrew Kelley
a10277bd94
prepare codebase for struct and string support
...
parsing code for structs, strings, and c string literals
partial semantic analyzing code for structs, strings, and c string literals
2015-12-12 00:10:37 -07:00
Andrew Kelley
d697404f64
hello world working without libc
2015-12-11 03:55:26 -07:00
Andrew Kelley
15ba5bc54e
provide std.zig and add it to import paths
2015-12-10 17:42:47 -07:00
Andrew Kelley
0dbee2300e
add inline assembly support
2015-12-10 15:34:38 -07:00