Commit Graph

904 Commits (ac27a3ccee931aba28db3a5b734bc4cc7267dace)

Author SHA1 Message Date
Ned Palacios 1aec041371
json: fix encode/decode support for generic structs (#6489) 2020-09-29 03:15:00 +02:00
Alexander Medvednikov fca344d1fb all: fn args => params 2020-09-27 03:32:56 +02:00
Alexander Medvednikov e2c7126d11 checker: verify mutability of method args 2020-09-27 03:14:24 +02:00
Daniel Däschle 90d1a689db
gen: fix str gen for pointers in structs (#6462) 2020-09-24 21:14:16 +02:00
Alexander Medvednikov 47a62b12d4 autofree: advanced expr test 2020-09-24 19:22:16 +02:00
Daniel Däschle 4f09ddccb4
cgen: implement sum type str gen (#6454) 2020-09-23 20:51:51 +02:00
Uwe Krüger 9c0758639b
cgen: fix `for match {...} {` and `for select {...} {` (#6441) 2020-09-23 06:05:12 +02:00
Henrixounez e429a77de2
gen: named imported structs operator overloading and str methods (#6433) 2020-09-20 19:51:14 +02:00
Uwe Krüger 4ae88c69ac
sync/select: allow push of literals and calculated expressions (#6429) 2020-09-20 03:50:09 +02:00
Nick Treleaven 9958881cbe
parser: support parsing unsafe (as first token) as UnsafeExpr (#6032) 2020-09-19 19:18:36 +03:00
Uwe Krüger 31a52cdf21
cgen: implement channel `select` block code generation (#6424) 2020-09-19 02:14:35 +02:00
Daniel Däschle 1b9711edde
gen: fix C warnings by cleaning up skip_struct_init (#6416)
* gen: removes struct name from list which shouldn't be initialized

* gen: vfmt

* cgen: remove the skip_struct_init list

* Revert "cgen: remove the skip_struct_init list"

This reverts commit d9e1fdbb4c.

* fix ci

* vfmt vlib/v/gen/cgen.v

Co-authored-by: Delyan Angelov <delian66@gmail.com>
2020-09-18 16:36:40 +03:00
Daniel Däschle ffc8cf3925
gen: c don't generate x >= 0 check for unsigned ints in range exprs in matches (#6414) 2020-09-18 12:53:19 +03:00
Daniel Däschle f59b771c76
parser: fix nested amp (#6402) 2020-09-18 01:04:56 +02:00
spaceface777 ff92c3409d
ast: merge `IfExpr` and `CompIf` (#6011) 2020-09-18 00:58:54 +02:00
Uwe Krüger 1bc9063573
parser: implement parsing of `select` block (#6379) 2020-09-16 15:34:57 +02:00
Daniel Däschle 3a795e6d9b
gen: fixes C warnings by appending U after unsigned integer literals (#6384) 2020-09-16 15:50:41 +03:00
Alexander Medvednikov bffa100aa6 autofree: optional fix 2020-09-13 21:36:33 +02:00
Alexander Medvednikov db51ee08ea autofree: more fixes in optionals 2020-09-13 03:00:45 +02:00
Alexander Medvednikov b74c1805d7 cgen/autofree: fix and simplify optionals 2020-09-12 16:40:52 +02:00
Alexander Medvednikov 53bed596e7 autofree: do not free _ vars 2020-09-11 13:58:12 +02:00
Alexander Medvednikov e0d20eadff autofree: free strings on re-assignments 2020-09-11 13:55:20 +02:00
Enzo 18034bb95c
gen: fix multiple call of expression in match (#6324) 2020-09-08 00:38:24 +02:00
Alexander Medvednikov 9fbea31f47 autofree: fix exprs N levels deep 2020-09-06 13:02:32 +02:00
Uwe Krüger 047bf02985
builtin: fix `in` for various numeric types (#6311) 2020-09-06 12:45:02 +02:00
Alexander Medvednikov 3410705974 autofree: lots of fixes 2020-09-05 12:00:35 +02:00
Alexander Medvednikov 333f355e23 Revert "cgen: handle variables called "array""
This reverts commit cc714ca5cc.
2020-09-03 02:43:26 +02:00
Alexander Medvednikov cc714ca5cc cgen: handle variables called "array" 2020-09-03 02:01:21 +02:00
Nick Treleaven 5d3d14da53
cgen: support `typeof(expr).name` (#6253) 2020-08-30 08:56:18 +02:00
Alexander Medvednikov 15bdb8f7cd autofree: tmp arg var frees fixes 2020-08-27 11:30:35 +02:00
Uwe Krüger 393b46a6dd
channels: make `ch.len` and `ch.cap` available as properties (#6221) 2020-08-26 06:41:51 +02:00
Nick Treleaven 479bfa28de
cgen: implement fixed array `.len` property (#6212) 2020-08-25 08:48:28 +02:00
Alexander Medvednikov d547f74cb0 checker/cgen: interface smart casts 2020-08-24 11:10:26 +02:00
Maciej Obarski e8e0d9fa42
all: [direct_array_access] tag (#6203) 2020-08-24 09:04:50 +02:00
Uwe Krüger 61df70fdf5
all: enable `x = <-ch or {...}` (#6195) 2020-08-23 02:12:05 +02:00
Delyan Angelov 94ced907d2 sort: fix C compilation error for `fn abc(mut a []int) { a.sort() }` 2020-08-22 15:20:49 +03:00
Yarila682 7dde82322a
cgen: fix dereferencing a mutable array (#6191) 2020-08-22 12:48:09 +02:00
Delyan Angelov b5ca114a96 ui: fix compiling the calculator ui example with tcc 2020-08-22 12:58:48 +03:00
Daniel Däschle 0c183da116
checker: fix sort return type (#6182) 2020-08-20 17:29:40 +03:00
Delyan Angelov 8c7bcad6b1 cgen: support for `$if amd64 {}` and `$if aarch64 {}` 2020-08-20 15:28:37 +03:00
Alexander Medvednikov 51bd69cdd8 cgen: fix u64 in struct str() 2020-08-18 16:05:11 +02:00
Delyan Angelov 2f6757a56a Revert "cgen: fix all -Wmissing-variable-declarations (#5802)"
This reverts commit ae349ca6ba.

Fixing these warnings, unfortunately also means, that hot code
(which reloads a shared library during runtime) can not use V
constants, because the private static C variables in the shared
library will not be initialized by _vinit(), which is only called
by the main V program.

For example in examples/hot_reload/bounce.v, using `gx.blue`,
defined as:
`    blue   = Color { r:   0, g:   0, b: 255 }`
... will instead use a const with all 0 fields (i.e. a black color).
2020-08-18 11:55:55 +03:00
Delyan Angelov 937a3e14c5 cgen: add g.options_typedefs, g.shared_types, g.channel_definitions 2020-08-18 11:45:36 +03:00
Uwe Krüger 0d7cc8829a
cgen: implement channel `push()`/`pop()` using `<-` operator (#6154) 2020-08-17 23:35:36 +02:00
Daniel Däschle b5c1ea44dc
all: fix mutability after if-smartcast (#6129) 2020-08-17 21:11:11 +02:00
Nick Treleaven 36c98b3e5d
cgen: implement fixed array 'for in' for lvalue condition (#6151) 2020-08-17 21:10:47 +02:00
Alexander Medvednikov f965ddae49 parser: handle several errors in types; cgen: objC includes 2020-08-16 19:16:59 +02:00
Nick Treleaven 0f0a91fc9e
parser: support custom fixed size ArrayInit: `[3]int{init: -1}` (#6114) 2020-08-15 11:01:54 +02:00
Uwe Krüger 9602a25a0b
all: add builtin channel type `chan elem_type` (#6126) 2020-08-14 21:18:42 +02:00
Nick Treleaven 75212f9fab
cgen: error if ForInStmt is not handled (#6131) 2020-08-14 21:01:43 +02:00
Nick Treleaven 6016f28171
cgen: fix assigning ArrayInit to fixed array: `a = [3]int` (#6115) 2020-08-14 13:57:00 +02:00
Nick Treleaven 078ab47a9a
cgen: support `==`, `!=` on FixedArray (#6119) 2020-08-14 02:03:38 +02:00
Delyan Angelov 8580a0bcd7 cgen: run vfmt to silence `./v fmt -verify` 2020-08-13 21:22:52 +03:00
Daniel Däschle 64e8125807
cgen: fixe calling anon fn asynchronously (closes #6088) (#6121) 2020-08-13 20:06:56 +02:00
Delyan Angelov 1135dffe2d cgen: prevent generation of duplicate interface method wrappers 2020-08-13 20:56:58 +03:00
Alexander Medvednikov f8be2110ec sort: fix sorting by struct fields 2020-08-12 18:43:41 +02:00
Alexander Medvednikov e5e31f7210 sort: handle `.sort(a.field > b.field)` 2020-08-12 06:11:40 +02:00
Alexander Medvednikov 4bc0dde413 all: new `.sort(a < b)` syntax 2020-08-12 05:54:51 +02:00
Delyan Angelov ca7a64a451 cgen: add support for -g again 2020-08-12 02:05:45 +03:00
Enzo f238890fe9
compiler: move attributes to declarations (#6026) 2020-08-04 20:10:22 +02:00
Alexander Medvednikov 7a7572e478 autofree: free temp string exprs 2020-08-04 01:26:34 +02:00
Nick Treleaven 7f447bb82f
ast: use Block instead of UnsafeStmt (#5981) 2020-08-02 14:06:44 +03:00
Alexander Medvednikov adafd24819 gen: auto_str_methods.v 2020-08-01 16:36:12 +02:00
Delyan Angelov 0fb8074353 cgen: add support for `$if gcc {}` too 2020-07-31 21:25:37 +03:00
joe-conigliaro 1ea511b530
builder/cgen: get -usecache working for self cimpilation 2020-07-31 20:10:19 +10:00
Ruofan XU 1d59d35129
cgen: fix sum type match (#5978) 2020-07-28 22:17:25 +02:00
Ruofan XU 7027b2354b
cgen: fix array and map with fns (#5938) 2020-07-26 14:22:02 +02:00
Delyan Angelov 3d2fd471b6 ci: prepare for enabling compilation with g++ again 2020-07-25 20:20:49 +03:00
Alexander Medvednikov 3c1427a4e8 all: fix current module in build-module mode 2020-07-25 01:37:54 +02:00
Louis Schmieder b58b15993c
gen: compile time for (methods and fields) (#5957) 2020-07-25 00:02:44 +02:00
pancake 04ef2a2671
os: implement os.system for iOS and uncomment the `$if ios` blocks (#5947) 2020-07-24 10:17:32 +03:00
Alexander Medvednikov 632e27a4a9 all: fix a big mutability bug and update all mutable vars 2020-07-23 23:16:36 +02:00
Alexander Medvednikov 653d40bfe8 parser: do not duplicate table imports 2020-07-23 21:59:48 +02:00
pancake 36352085ae
v: add support for iOS crosscompilation (#5943) 2020-07-23 07:58:44 +03:00
Emily Hudson 0f98445f7f
cgen: properly handle more multi-return edge cases (#5933) 2020-07-23 00:39:19 +02:00
Ryan Willis 938e71b468
v: fix for `import cli { Command }` 2020-07-22 20:33:43 +03:00
Ruofan XU 0f72328d1f
cgen: minor generated C source format fix 2020-07-22 17:27:37 +03:00
Ruofan XU a370dd2867
cgen: further fixes to and array/map of fns (#5916) 2020-07-22 02:30:44 +02:00
kalapalo c3a2e9b5c4
cgen: fix sum type assignment with pointers (#5868) 2020-07-22 02:28:49 +02:00
Alexander Medvednikov 303b65c0b9 roadmap: io streams 2020-07-20 22:51:17 +02:00
Ruofan XU 88c8e194d0
cgen: fix map and array with fns (#5894) 2020-07-20 19:53:02 +03:00
Delyan Angelov c858978348 cgen: add support for `-d trace_gen` too. Add `v tracev` command. 2020-07-20 12:36:27 +03:00
Ruofan XU 9f6aacb739
cgen: fix array of fns init (#5884) 2020-07-19 21:44:03 +02:00
Enzo 8a855ccae1
fmt,vet: handle `var in [single_value]` (#5882) 2020-07-19 19:58:34 +02:00
Alexander Medvednikov 74d70b8719 all: more cached moduels fixes 2020-07-18 13:49:03 +02:00
Alexander Medvednikov 38e5569503 all: cached modules fixes 2020-07-18 11:15:44 +02:00
Enzo 90d9040e6e
all: make comment expressions + fix vfmt array init (#5851) 2020-07-17 19:13:22 +02:00
Nick Treleaven 39f90e25f3
all: `if` guard optional: define `err` in `else` branch (#5853) 2020-07-17 19:10:01 +02:00
Uwe Krüger ea322bdd97
checker, cgen: fix call of generic function returning normal type (#5865) 2020-07-17 18:28:45 +02:00
spaceface777 3583302ad4
parser: force `...` rather than `..` in matches for inclusive ranges (#5852) 2020-07-17 11:30:21 +03:00
Alexander Medvednikov e4fac6ff97 autofree: fix scope position 2020-07-16 19:40:14 +02:00
spaceface777 b900577dae
compiler: handle ranges as `match` conditions (#5847) 2020-07-16 16:41:18 +03:00
joe-conigliaro 612fe1b8fb
cgen: autofree scope var position fixes 2020-07-16 20:06:50 +10:00
Enzo 880c8e4dc9
cgen: else if guard (#5822) 2020-07-14 17:19:55 +02:00
Alexander Medvednikov c3ec5323f0 autofree: move new scope free behind -experimental for now 2020-07-14 15:30:55 +02:00
Alexander Medvednikov 7231b467a6 autofree: fix stmts() free 2020-07-14 14:50:51 +02:00
Alexander Medvednikov 1338e7fce2 autofree: free in each scope 2020-07-14 13:56:52 +02:00
ka-weihe df45488e09
cgen: fix warnings (#5820) 2020-07-14 00:16:31 +02:00
Uwe Krüger 6e6010d198
checker, cgen: implement auto-lock for `a[i]++`, `a[i]--` (#5817) 2020-07-13 15:01:32 +03:00
Uwe Krüger aa364ddaca
checker, cgen: checks for shared/lock, first autolock (#5815) 2020-07-13 12:19:28 +02:00
Nick Treleaven 53023c1ca9
all: add UnsafeExpr (#5793) 2020-07-12 12:58:33 +02:00
ka-weihe ae349ca6ba
cgen: fix all -Wmissing-variable-declarations (#5802) 2020-07-11 15:37:40 +02:00
Alexander Medvednikov d94a02ba79 strings: builder.writeln() optimization 2020-07-11 12:03:24 +02:00
Alexander Medvednikov a1073105e1 all: re-enable -prealloc 2020-07-11 11:25:56 +02:00
yuyi bf14e666ea
cgen: add `gen_map_equality_fn` to compare maps (#5770) 2020-07-10 18:08:17 +02:00
Emily Hudson 7488dd829d
all: _allow_multiple_values enum attribute (#5772) 2020-07-10 16:43:02 +02:00
yuyi 31ac20876c
cgen: minor formatting of `struct_init` (#5768) 2020-07-09 17:25:48 +02:00
Daniel Däschle c5dc1a33b6
all: remove `it` smartcast and replace with original variable name (#5764) 2020-07-09 17:14:14 +02:00
Daniel Däschle c0fa31e75a
cgen: if smartcast part 3 (#5755) 2020-07-08 19:14:47 +02:00
Daniel Däschle 5ea17ad2d4
all: if smartcast part 2 (#5754) 2020-07-08 15:46:58 +02:00
Daniel Däschle b62bf59c21
all: if-is smartcast part 1 (#5730) 2020-07-08 15:17:28 +02:00
Delyan Angelov 69d3c3f596 cgen: sort const inits/cleanups topologically, skip calling non `fn init(){}` fns 2020-07-08 14:28:58 +03:00
Alexander Medvednikov 2425c05c42 Revert "cgen: sort const inits/cleanups topologically too"
This reverts commit 38000f8622.
2020-07-08 12:56:56 +02:00
Uwe Krüger 88248b1b66
cgen: add support for shared arrays (#5721) 2020-07-08 11:05:43 +02:00
Delyan Angelov 38000f8622 cgen: sort const inits/cleanups topologically too 2020-07-08 11:22:30 +03:00
Ruofan XU 9c87ace153
cgen: fix cross assign for functions (#5734) 2020-07-08 09:17:26 +03:00
yuyi bd16dd9fdf
cgen: fix assert `sumtype is` (#5739) 2020-07-08 09:05:01 +03:00
yuyi b0ce66d141
gen: fix generated `defer` (#5717) 2020-07-08 08:39:11 +03:00
joe-conigliaro 5fd5e558ae
parser/checker/gen: anon fn direct call with args 2020-07-08 01:10:39 +10:00
yuyi dc24327b1e
cgen: minor optionals fix (#5714) 2020-07-07 14:21:02 +02:00
Uwe Krüger ef02373061
all: remove `rwshared` keyword, make its semantics default for `shared` (#5710) 2020-07-07 01:57:31 +02:00
yuyi c94038af89
cgen: improve generated code formatting (#5693) 2020-07-06 12:33:57 +02:00
Uwe Krüger c3614c0e38
cgen, sync: implement separate read/write locks for `rwshared` types (#5687) 2020-07-05 22:53:28 +02:00
joe-conigliaro 4e66728477
checker/table: rearrange sumtype check fns 2020-07-06 00:53:56 +10:00
joe-conigliaro 9d7f1a236a
checker/gen: fix nested sumtype matching 2020-07-06 00:25:04 +10:00
yuyi cda9240632
cgen: add unsafe block braces and comments in generated code (#5674) 2020-07-05 13:32:39 +02:00
yuyi 11866fb017
cgen: improve code formatting of `array_init` (#5663) 2020-07-04 21:49:04 +02:00
Delyan Angelov 35431d457b checker: add check for strict .str() method signature 2020-07-04 14:14:43 +03:00
Uwe Krüger 3b067f5f85
all: experimental locked concurrency support, part 1 (#5637) 2020-07-04 12:44:25 +02:00
yuyi 27149ba8bc
cgen: fix `in` in mutable arrays (#5647) 2020-07-04 12:12:44 +02:00
Ruofan XU 765ffa37eb
cgen: fix == for mut arraay args (#5648) 2020-07-04 11:36:33 +02:00
yuyi 67e85fa9dd
cgen: fix indent in `for_in_string` (#5631) 2020-07-03 18:10:45 +02:00
yuyi 61213263cd
cgen: remove extra `\n` in map.get (#5630) 2020-07-03 18:10:29 +02:00
Ruofan XU a2395ff3e8
cgen: fix mut map with relation op in fn (#5642) 2020-07-03 18:07:11 +02:00
Delyan Angelov 8adaf4efd4 cgen: allow `-printfn main` for _test.v files too 2020-07-03 17:53:48 +03:00
yuyi dff385cb37
cgen: fix map_in mut (#5638) 2020-07-03 17:33:53 +03:00
Alexander Medvednikov b7175b54eb vweb: ['/:arg1/:arg2/action'] attribute 2020-07-03 15:10:39 +02:00
yuyi 1efbb83060
cgen: add space before `else` in match (#5632) 2020-07-03 11:23:23 +02:00
yuyi 6cbc0e84f0
cgen: fix cross assign with mutable args (fix #5609 #5610 #5611) (#5614) 2020-07-02 11:09:26 +02:00
yuyi c21527d3c6
cgen: fix indent in multi_return (#5617) 2020-07-02 11:08:27 +02:00
yuyi e904732554
cgen: remove an extra \n in for loops (#5618) 2020-07-02 11:03:40 +02:00
Alexander Medvednikov 66f36f6dcc cgen: fix gen_cross_tmp_variable, part 2 2020-07-01 19:39:41 +02:00
Alexander Medvednikov 625ed030ef cgen: fix getn_cross_tmp_variable 2020-07-01 19:19:49 +02:00
Alexander Medvednikov dbcb23ddc8 ci: run v vet on cgen and ast 2020-07-01 19:07:19 +02:00
yuyi 40a393926d
cgen: fix cross assign of struct fields (#5606) 2020-07-01 18:43:14 +02:00
yuyi 2f614ad79f
parser: optimize cross assign using expr.str() (#5604) 2020-07-01 16:43:13 +02:00
Alexander Medvednikov 013a4fc0f6 cgen: do not free strings in const decls 2020-07-01 16:40:04 +02:00
Alexander Medvednikov 5eb76606ae cgen: store return vals in tmp vars with -autofree 2020-07-01 14:34:14 +02:00
yuyi 92eea7f95a
cgen: fix map cross assign (#5603) 2020-07-01 14:03:12 +02:00
yuyi 6c5b638202
parser: fix array cross assign (fix #5577) (#5591) 2020-07-01 12:11:03 +02:00