297 Commits

Author SHA1 Message Date
Vexu
cd5b7b9e1d
translate-c: use correct scope in for loop condition 2020-05-27 14:14:17 +03:00
Andrew Kelley
dd05f2be80 run zig fmt on std lib 2020-05-24 10:04:09 -04:00
Andrew Kelley
8a3cd82b85 translate-c: fix a use-after-free bug 2020-05-23 23:15:58 -04:00
Andrew Kelley
c78a2e2e8d translate-c: emit local typedefs 2020-05-23 19:59:26 -04:00
Andrew Kelley
395786fd50 translate-c: fix regression in param name mangling 2020-05-23 19:28:14 -04:00
Andrew Kelley
88f5e3a60d translate-c: fix regression in switch statement 2020-05-23 17:58:35 -04:00
Andrew Kelley
f67b8c68a0 translate-c: fix regression on array initialization 2020-05-23 17:52:46 -04:00
Andrew Kelley
32c27daae4 translate-c: fix decl statement regression 2020-05-23 17:50:35 -04:00
Andrew Kelley
46f50ee76c translate-c: fix regression in do-while loop 2020-05-23 17:25:13 -04:00
Andrew Kelley
1a90a5e63a translate-c is building again, but I have 1 @panic in there 2020-05-23 16:24:03 -04:00
Andrew Kelley
e072692e1f update translate-c to new AST API 2020-05-23 12:48:17 -04:00
Andrew Kelley
8df0841d6a stage2 parser: token ids in their own array
To prevent cache misses, token ids go in their own array, and the
start/end offsets go in a different one.

perf measurement before:
         2,667,914      cache-misses:u
     2,139,139,935      instructions:u
       894,167,331      cycles:u

perf measurement after:
         1,757,723      cache-misses:u
     2,069,932,298      instructions:u
       858,105,570      cycles:u
2020-05-22 12:34:12 -04:00
Andrew Kelley
e694cd265a more progress on updating translate-c 2020-05-21 00:14:55 -04:00
Andrew Kelley
3c5d581ce3 update translate-c to the new fn params AST node API 2020-05-20 23:28:31 -04:00
Andrew Kelley
5db9f306ba update translate-c for new Root and ContainerDecl AST 2020-05-20 16:54:21 -04:00
Andrew Kelley
8c10178a1e golly jeepers it's taking a long time to update translate-c 2020-05-20 13:53:53 -04:00
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
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
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
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
Matthew Knight
c5198bd76f added scoped typedef to translate-c 2020-05-02 20:22:43 -07: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
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
joachimschmidt557
3fd38429e4 Enable formatting in std.big.Int.format 2020-04-15 12:51:43 -04:00
Vexu
ca3bf6e6ad
translate-c cleanup and zig fmt 2020-04-15 15:15:32 +03:00
Vexu
a016fb8c62
translate-c: correct invalid shortcut 2020-04-15 15:14:10 +03:00
Lachlan Easton
0122f2cff6 Translate C: Redo Add comment containing c source location for failed decls. 2020-04-14 22:13:43 +10:00
Andrew Kelley
3c34c313cf revert Translate C: Add comment containing c source location for failed decls
This reverts 0db108101a30a2ac5ec4dc9911d488f9036256b8.

Unfortunately this caused a regression. Closes #5007.
2020-04-11 17:56:48 -04:00
Auguste Rame
df14578c9d
Merge branch 'master' into nameless-fields 2020-04-10 11:49:50 -04:00
Lachlan Easton
d7902707bc
Translate C: Allow casting literal ints to pointers 2020-04-08 14:11:01 -04:00
Vexu
7b5fb79b5b
Translate C: Put an alignCast in c style pointer casts to allow opaque types to cast properly in C macros
Translate C: add test case for aligning opaque types in pointer casts
2020-04-08 14:11:01 -04:00
SuperAuguste
882aa86843 more fixes 2020-04-07 15:08:46 -04:00
Vexu
adaf7ad672
Merge pull request #4684 from LakeByTheWoods/comment_failed_decls
Translate C: Add comment containing c source location for failed decls
2020-04-07 21:47:32 +03:00
SuperAuguste
f21ac0220a msvc fix 2020-04-07 14:39:24 -04:00
SuperAuguste
9298d38cee remove debug statement 2020-04-07 13:33:01 -04:00
SuperAuguste
94841d0292 Nameless struct field consistency 2020-04-07 13:26:17 -04:00
Vexu
c5ced0d74a
Merge pull request #4939 from SuperAuguste/master
translate-c: Properly translate C multicharacter literals
2020-04-06 10:31:17 +03:00
SuperAuguste
6106cf4419 fixes 2020-04-05 19:06:43 -04:00
Vexu
6ef15fc8d0
Merge pull request #4901 from phase/feature/translate-c-remassign
translate-c: RemAssign and DivAssign
2020-04-05 21:05:18 +03:00
Jadon Fowler
ae376e0758 translate-c: remove unneeded semicolon
Signed-off-by: Jadon Fowler <j@jadon.io>
2020-04-05 10:44:42 -04:00
SuperAuguste
027e2a1673 fix multichar literals in translate_c 2020-04-04 17:56:25 -04:00