Vexu
57aa8997bd
fix escape sequence rendering
2019-07-23 14:49:19 -04:00
Andrew Kelley
6fe3b20962
Merge branch 'translate-c-userland' of https://github.com/hryx/zig into hryx-translate-c-userland
2019-07-15 22:19:54 -04:00
Andrew Kelley
c0489abcdb
translate-c: fix incorrectly translated double function pointer
...
closes #2887
2019-07-13 12:38:10 -04:00
Andrew Kelley
4e58855a4a
translate-c: better detection of pointer to struct demoted to opaque
2019-07-12 12:11:26 -04:00
hryx
cc74bf5136
Translate IntegralCast; add stage2 test coverage
2019-06-27 23:12:33 -07:00
hryx
b2e06c3bf4
Observe translate mode in stage2
2019-06-23 14:32:45 -07:00
hryx
226a23d977
stage1: always render space after fn
like stage2
2019-06-23 12:46:17 -07:00
Andrew Kelley
10e9d47b49
stage2 translate-c: implement functions with no prototype
...
stage1 translate-c actually has this wrong. When exporting a function,
it's ok to use empty parameters. But for prototypes, "no prototype"
means that it has to be emitted as a function that accepts anything,
e.g. extern fn foo(...) void;
See #1964
2019-05-11 12:09:11 -04:00
Andrew Kelley
5f4c3e6557
stage2 translate-c: simple function definitions
...
See #1964
2019-05-10 23:35:46 -04:00
Andrew Kelley
dbb5da14f4
stage2 translate-c: builtin types and pub
...
See #1964
2019-05-10 17:56:00 -04:00
Andrew Kelley
82219b1fd5
translate-c: better handling of restore points
2019-05-10 17:44:47 -04:00
Andrew Kelley
a6f7a9ce2b
translate-c: we have our first test of self-hosted
...
See #1964
2019-05-10 16:03:54 -04:00
Andrew Kelley
eb65410b62
translate-c: enough C tokenization/parsing to handle shifting in macros
...
See #2451
2019-05-09 12:48:38 -04:00
Andrew Kelley
62065a9aea
translate-c: handle int to ptr and ptr to int casting
...
See #2451
2019-05-09 12:17:23 -04:00
Andrew Kelley
e3542196c0
translate-c: NULL pointers translate to null
...
See #1967
2019-05-08 19:21:54 -04:00
LemonBoy
77383f968d
translate-c: Emit @ptrCast + @alignPtr sequence
...
Avoid producing Zig code that doesn't compile due to mismatched
alignments between pointers.
Always emit a @alignOf instead of hardcoding the alignment value
returned by LLVM for portability sake of the generated code.
2019-04-29 21:30:19 -04:00
LemonBoy
ab424bbb35
translate-c: Add test for implicit casts
2019-04-22 22:23:41 +02:00
Andrew Kelley
a17bf219c6
Merge pull request #2069 from ziglang/glibc-assert-translation
...
Implemented enough of translate-c to translate assert
2019-03-18 14:43:17 -04:00
Jimmi Holst Christensen
9171e7a7c1
More work on ignoring values correctly
2019-03-18 14:55:57 +01:00
Jimmi HC
5ae400fb39
fixed void cast and added the last tests
2019-03-15 19:11:46 +01:00
Jimmi Holst Christensen
a77b2a0810
Implemented enough of translate-c to translate assert
...
This required the following
* __extention__
* ({})
* Fixing if (0) ; else ;
2019-03-15 16:12:41 +01:00
Jimmi Holst Christensen
3ef9b899e4
workaround for #2043
2019-03-15 11:17:21 +01:00
Sahnvour
9b99356551
translate-c: additional test case for integer suffixes on 0
2019-03-11 16:36:27 -04:00
Sahnvour
fa9fcab620
translate-c: add support for integer suffixes on 0 (zero) litteral inside macro definitions
2019-03-10 14:56:35 -04:00
LemonBoy
e280dce30f
Translate parameterless C functions ( #1978 )
...
Both FunctionNoProto and FunctionProto are subclasses of FunctionType,
the only difference is that the former is parameterless.
2019-02-18 10:26:45 -05:00
Andrew Kelley
f57182456d
Merge pull request #1898 from Sahnvour/translate-c-arrays
...
Translate c arrays
2019-02-16 14:07:41 -05:00
Andrew Kelley
d6e0d82c32
translate-c: back to *c_void for opaque types
...
See #1059
2019-02-14 23:09:31 -05:00
Andrew Kelley
342bca7f46
C pointer comparison and arithmetic
...
See #1059
2019-02-11 15:31:09 -05:00
Andrew Kelley
d9e01be973
translate-c: use C pointer type everywhere
...
See #1059
2019-02-11 14:56:59 -05:00
Sahnvour
075fda3c73
translate-c: add tests. Commented for now as the output is currently empty until #646 is fixed.
2019-02-05 20:36:57 +01:00
Jimmi Holst Christensen
8139c5a516
New Zig formal grammar ( #1685 )
...
Reverted #1628 and changed the grammar+parser of the language to not allow certain expr where types are expected
2018-11-13 05:08:37 -08:00
Jimmi Holst Christensen
378d3e4403
Solve the return type ambiguity ( #1628 )
...
Changed container and initializer syntax
* <container> { ... } -> <container> . { ... }
* <exrp> { ... } -> <expr> . { ...}
2018-10-15 09:51:15 -04:00
Andrew Kelley
877036e7ef
fix translate-c test expecting incorrect C ABI on windows
2018-09-24 15:14:20 -04:00
Andrew Kelley
004c383292
fix translate-c incorrectly translating negative enum init values
...
closes #1360
2018-09-24 12:19:16 -04:00
Andrew Kelley
b2917e6be0
Revert "Merge branch 'mtn-translate-c-enum-vals'"
...
This reverts commit 937b822fa9
, reversing
changes made to dd4b13ac03
.
Tests failing on Windows.
Re-opens #1360
2018-08-21 20:50:03 -04:00
kristopher tate
b023db2e82
src/translate_c.cpp: correctly bridge llvm::APSInt with Zig BigInt;
...
ACHTUNG: llvm::APSInt stores an int's sign inside of its getRawData; Internally to Zig we store an integer's sign outside of getRawData! (~aps_int) calls .flip() internally on the raw data to match Zig.
test/translate_c.zig: enum: add wider range of values (u64) to try;
2018-08-20 22:46:11 -04:00
Michael Noronha
7e7e59d881
translate-c: Correctly translate enum init values, addressing #1360
2018-08-20 22:45:19 -04:00
Andrew Kelley
dd4b13ac03
Revert "translate-c: Correctly translate enum init values, addressing #1360 ( #1377 )"
...
This reverts commit b8ce8f219c
.
Squashing the commits from the pull request resulted in kristopher tate
from being omitted from the authors. A future commit will merge
the code correctly.
2018-08-20 22:39:39 -04:00
Michael Noronha
b8ce8f219c
translate-c: Correctly translate enum init values, addressing #1360 ( #1377 )
...
* translate-c: Correctly translate enum init values
* translate-c: Test enum initialization
* translate-c: Flip to positive using APSInt builtins
* src/translate_c.cpp: correctly bridge llvm::APSInt with Zig BigInt;
ACHTUNG: llvm::APSInt stores an int's sign inside of its getRawData; Internally to Zig we store an integer's sign outside of getRawData! (~aps_int) calls .flip() internally on the raw data to match Zig.
* test/translate_c.zig: enum: add wider range of values (u64) to try;
closes #1360
2018-08-20 14:29:26 -04:00
Andrew Kelley
63a23e848a
translate-c: fix for loops with var init and empty body
2018-08-05 18:40:14 -04:00
Andrew Kelley
387fab60a6
translate-c: fix do while with empty body
2018-08-05 18:32:38 -04:00
Andrew Kelley
c420b234cc
translate-c: handle for loop with empty body
2018-08-05 18:18:24 -04:00
Andrew Kelley
aa232089f2
translate-c: fix while loop with no body
2018-08-05 18:06:39 -04:00
Andrew Kelley
77678b2cbc
breaking syntax change: orelse keyword instead of ?? ( #1096 )
...
use the `zig-fmt-optional-default` branch to have zig fmt
automatically do the changes.
closes #1023
2018-06-10 01:13:51 -04:00
Andrew Kelley
652f4bdf62
disallow unknown-length pointer to opaque
...
This also means that translate-c has to detect when a pointer to
opaque is happening, and use `*` instead of `[*]`.
See #1059
2018-06-05 18:03:21 -04:00
Andrew Kelley
96164ce613
disallow single-item pointer indexing
...
add pointer arithmetic for unknown length pointer
2018-06-04 01:39:57 -04:00
Andrew Kelley
fcbb7426fa
use * for pointer type instead of &
...
See #770
To help automatically translate code, see the
zig-fmt-pointer-reform-2 branch.
This will convert all & into *. Due to the syntax
ambiguity (which is why we are making this change),
even address-of & will turn into *, so you'll have
to manually fix thes instances. You will be guaranteed
to get compile errors for them - expected 'type', found 'foo'
2018-05-31 17:28:07 -04:00
Andrew Kelley
0c16cd2d0e
run zig fmt on the codebase
...
See #1003
2018-05-29 04:23:38 -04:00
Andrew Kelley
c38b165db4
all tests passing with postfix deref syntax
2018-05-17 23:21:44 -04:00
Andrew Kelley
bf21747a42
translate-c: fix typedef duplicate definition of variable
...
closes #998
2018-05-09 20:23:36 -04:00