802 Commits

Author SHA1 Message Date
Vexu
74f7d710bb
Merge pull request #5032 from LakeByTheWoods/redo_translate_c
Translate C: Redo Add comment containing c source location for failed decls.
2020-05-16 17:37:19 +03:00
Vexu
3e375ee2b9
translate-c use tagName for token id 2020-05-16 14:17:50 +03:00
Vexu
5ac684ec50
fix building translate-c 2020-05-16 13:05:43 +03:00
Vexu
afab095b61
translate-c remove error set from checkForBuiltinTypedef 2020-05-13 17:53:15 +03:00
Vexu
f2d3266075
Merge pull request #4932 from Qix-/fix-private-access
Fix private access
2020-05-08 18:21:15 +03:00
Vexu
10abffcd98
fix more private member access 2020-05-08 15:10:38 +03:00
Andrew Kelley
ba43492c0e
Merge pull request #5268 from tadeokondrak/remove-callconv-redundant-syntax
Remove syntax redundant with callconv
2020-05-07 12:42:26 -04:00
Vexu
06e6d39c6c
Merge pull request #5257 from matt1795/scoped-typedef
Add scoped typedef to translate-c
2020-05-06 12:28:30 +03:00
Vexu
c0b269bf46
translate-c: small patch to fix bultin type detection 2020-05-06 11:48:46 +03:00
Matthew Knight
52f0adb305 checkForBuiltinTypedef now returns a string 2020-05-05 23:26:00 -07:00
Tadeo Kondrak
6745a6f6f6
zig fmt 2020-05-05 09:38:02 -06:00
Tadeo Kondrak
7ada59f873
remove nakedcc/stdcallcc/async fn/extern fn fnproto 2020-05-05 09:37:28 -06:00
Matthew Knight
db4833d4d6 moved duplicated code to common functions 2020-05-04 23:45:31 -07:00
Jonathan Marler
75b699b2c6 os.zig: add ETIMEDOUT error case to read function
According to documentation ETIMEDOUT (110) is a valid error code for the read function.  I just had my long-running  (been running for about 7 weeks) network program crash because it did not handle the ETIMEDOUT error code from "read".
2020-05-04 13:48:34 -04:00
Matthew Knight
c5198bd76f added scoped typedef to translate-c 2020-05-02 20:22:43 -07:00
Andrew Kelley
92f3e9c92a remove last use of share_with_child_process 2020-05-02 01:54:36 -04:00
Andrew Kelley
b70e6da914 back to stage2 tests passing 2020-05-01 06:47:56 -04:00
Andrew Kelley
8766821157 rework std.math.big.Int
Now there are 3 types:
 * std.math.big.int.Const
   - the memory is immutable, only stores limbs and is_positive
   - all methods operating on constant data go here
 * std.math.big.int.Mutable
   - the memory is mutable, stores capacity in addition to limbs and
     is_positive
   - methods here have some Mutable parameters and some Const
     parameters. These methods expect callers to pre-calculate the
     amount of resources required, and asserts that the resources are
     available.
 * std.math.big.int.Managed
   - the memory is mutable and additionally stores an allocator.
   - methods here perform the resource calculations for the programmer.
   - this is the high level abstraction from before

Each of these 3 types can be converted to the other ones.

You can see the use case for this in the self-hosted compiler, where we
only store limbs, and construct the big ints as needed.

This gets rid of the hack where the allocator was optional and the
notion of "fixed" versions of the struct. Such things are now modeled
with the `big.int.Const` type.
2020-05-01 06:47:56 -04:00
Andrew Kelley
1d202008d8 add ZIR transform test case 2020-05-01 06:47:20 -04:00
Andrew Kelley
751903ba8f zir: add breakpoint() instruction and object file ability 2020-05-01 06:47:20 -04:00
Andrew Kelley
f89dbe6c4e link: introduce the concept of output mode and link mode 2020-05-01 06:47:20 -04:00
Andrew Kelley
28729efe29 ZIR: implement return instruction 2020-05-01 06:47:20 -04:00
Andrew Kelley
6b0f7de247 ZIR: add cmp and condbr instructions 2020-05-01 06:47:20 -04:00
Andrew Kelley
fb67a7260d link: recognize that Windows does not have POSIX fs modes 2020-05-01 06:47:20 -04:00
Andrew Kelley
2bae942800 add ZIR compare output test case to test suite 2020-05-01 06:47:20 -04:00
Ian Simonson
a2c3ebb756 Use transCreateNodeInfixOp instead of maybeSuppressResult 2020-04-30 19:10:10 +10:00
Ian Simonson
e6fa0beb33 Translate-C convert bools to int in complex expressions
Pre-requisite for having a test case for #5062
In complex C statements which are outside of macros,
it is valid C to perform e.g. a bitor between an
integer and a boolean `5 | (8 == 9)`

Currently this results in a zig error after translating
as `c_int | bool` is invalid Zig.

Detects if a sub-expression of a numeric operator is
boolean and if so converts it to int
2020-04-30 12:48:27 +10:00
Andrew Kelley
03dd1fca94
Merge pull request #5195 from tadeokondrak/opaquetype-to-type-opaque
@OpaqueType -> `@Type(.Opaque)
2020-04-28 16:21:07 -04:00
Tadeo Kondrak
83d2d7ab8a
Mangle field names with a local counter in records
See https://github.com/ifreund/river/issues/17 for an issue that occurs
because the field names are mangled globally. When using the generated
bindings, you have no choice but to use the unstable names or redeclare
the entire struct. This commit changes the behaviour to use a local
counter per record declaration, so the names are predictable each time.
2020-04-28 08:45:51 -06:00
Tadeo Kondrak
17e41f6cd3
@OpaqueType -> @Type(.Opaque) 2020-04-28 00:02:13 -06:00
Andrew Kelley
41e17106cd zig fmt: still print the relative path
The previous commit made zig fmt print absolute paths; this commit keeps
the absolute path resolution but still prints the relative paths to
stdout.
2020-04-27 13:38:19 -04:00
Ryan Liptak
fdff381a56 fmt: Fix relative paths with . and .. on Windows
This is a band-aid fix due to NtCreateFile failing on paths with . or .. in them.
2020-04-27 13:35:59 -04:00
Andrew Kelley
c22b54c9d8 stage2 zir: remove dead code
this was part of the live coding stream and I forgot to delete it before
committing
2020-04-26 17:37:04 -04:00
Andrew Kelley
d44c9bdbd9 ir: elemptr and add instructions 2020-04-26 01:20:58 -04:00
Andrew Kelley
9ebf25d145 link: change default executable mode to 0o777
Jonathan S writes:

On common systems with a 022 umask, this will still result in a
file created with 755 permissions, but it works appropriately if the
system is configured more leniently. (As another data point, C's fopen
seems to open files with the 666 mode.)
2020-04-24 15:36:08 -04:00
Andrew Kelley
058937e44d bug fixes to make it work 2020-04-24 02:09:30 -04:00
Andrew Kelley
229e99ca37 codegen: write the updated code size to PT_LOAD section header 2020-04-23 23:53:52 -04:00
Andrew Kelley
2d35f71fa9 codegen rdx set immediate 2020-04-23 20:30:20 -04:00
Andrew Kelley
757d13d784 codegen supports embedded-in-code constants
also coerce no longer requires a bitcast
2020-04-23 20:23:16 -04:00
Andrew Kelley
0ac502f372 codegen for setting rax and rdi registers 2020-04-23 19:40:17 -04:00
Andrew Kelley
63b54bcf51 codegen for inline assembly 2020-04-23 18:58:47 -04:00
Andrew Kelley
99ec614b71 codegen for const ints and string literals 2020-04-23 17:46:01 -04:00
Andrew Kelley
24a01eed90 basics of writing ELF and machine code generation 2020-04-23 16:41:20 -04:00
Andrew Kelley
a3dfe36ca1 zir-to-elf skeleton 2020-04-22 23:42:58 -04:00
Andrew Kelley
e8545db9d4
Merge pull request #5130 from ziglang/stage2-ir
beginnings of non-LLVM self-hosted backend
2020-04-22 14:42:46 -04:00
Andrew Kelley
1eda2ada9a std.math.big.Int: don't rely on the allocator when printing 2020-04-22 03:49:50 -04:00
Andrew Kelley
d58233b361 ir: improve ZIR emission enough to emit hello world 2020-04-22 03:08:50 -04:00
Andrew Kelley
b1a86040dd ir: emit zir for fntype 2020-04-22 00:26:37 -04:00
Andrew Kelley
993e654554 emit zir skeleton 2020-04-22 00:04:52 -04:00
Andrew Kelley
2e6ccec100 ir: analyze asm instruction 2020-04-21 22:19:32 -04:00