Commit Graph

101 Commits (a4ac6d15c42a4a06eb5e2bfe73224384d3613bf6)

Author SHA1 Message Date
Vexu a4ac6d15c4
translate-c-2 array initializer expr 2019-12-14 10:49:25 +02:00
Vexu e4ca1f441b
translate-c-2 record type 2019-12-14 02:00:01 +02:00
Vexu 45abfa9e71
revert removal of translate mode in stage 1 2019-12-13 19:06:32 +02:00
Vexu 41a67126a5
translate-c-2 typedef 2019-12-13 17:40:37 +02:00
Vexu eb057ef41c
translate-c-2 dont eval init expr 2019-12-13 15:07:10 +02:00
Vexu 0795f17db2
translate-c-2 incompleteArray 2019-12-12 21:39:04 +02:00
Vexu 3bca025091
update tests 2019-12-12 18:18:43 +02:00
Merlyn Morgan-Graham 12171dba92 Add function parameters to self-hosted translate-C 2019-12-10 23:52:40 -08:00
Robin Voetter 4b4fbe3887
Replace @typeOf with @TypeOf in all zig source
This change was mostly made with `zig fmt` and this also modified some whitespace. Note that in some files, `zig fmt` produced incorrect code, so the change was made manually.
2019-12-10 11:09:41 -05:00
Andrew Kelley a3f6a58c77
remove var args from the language
closes #208
2019-12-09 15:27:27 -05:00
Andrew Kelley 47f06be369
string literals are now null terminated
this also deletes C string literals from the language, and then makes
the std lib changes and compiler changes necessary to get the behavior
tests and std lib tests passing again.
2019-11-21 20:43:41 -05:00
daurnimator ed956b5812 translate-c: add support for MacroQualified definitions 2019-11-19 01:05:17 +00:00
Andrew Kelley 3cf5c2c62b
fix regressed tests and update docs to use "type coercion" 2019-11-08 15:57:25 -05:00
Andrew Kelley e0db54e89d
update the codebase to use `@as` 2019-11-08 15:57:24 -05:00
Vexu 6b61fcddfa fix translate-c arrow deref 2019-11-06 13:58:55 -05:00
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