Commit Graph

9263 Commits (2a3a4cfc84f93b92ac2f97d1a0573a58cf8db657)

Author SHA1 Message Date
Delyan Angelov 41e763f79c
checker: add error for `type StructAlias = Struct struct Struct { field StructAlias }` 2022-01-02 15:54:40 +02:00
yuyi 64f1ea6fe9
checker: extract containers.v, struct.v, for.v from checker.v (#13012) 2022-01-02 15:52:19 +02:00
Delyan Angelov 41078bc438
v.eval: fix hardcoded math ops in infix_gen.v, add interpret_test.v 2022-01-02 10:33:21 +02:00
Delyan Angelov 1521d08e84
eval: ignore ast.Module (fixes `v interpret file.v` regression after 07cf6d9) 2022-01-02 10:09:50 +02:00
Delyan Angelov 9278d4ec19
docs: fix a typo 2022-01-02 09:18:24 +02:00
Alexander Medvednikov 0e1cfd4a28 checker: simplify type sizeof check and fix c2v globals 2022-01-01 19:56:13 +03:00
penguindark 908296cdfb
regex: improve errors for edge cases (#13008)
* code cleaning, added more clear errors for dots and ORs

* added failed match index for better find functions, updated tests

* added index in match failed, updated tests

* test cleaning

* test check
2022-01-01 09:21:27 +02:00
pancake 7b4ba66720
js: use JS.String instead of string in builtin javascript functions (#13004) 2022-01-01 09:17:08 +02:00
yuyi 7622ff3f54
checker: check using const var as function (#13006) 2022-01-01 09:15:43 +02:00
yuyi 6438512529
checker: add error for `for mut var in string {` (fix #12998) (#13000) 2021-12-31 09:54:06 +02:00
yuyi a0a1807e2b
builtin: add charptr str() and change string format (#12973) 2021-12-30 23:34:24 +03:00
Delyan Angelov b10ff1e41b
checker: infer generic interface type in `i := Interface(Struct<u32>{})` 2021-12-30 21:24:52 +02:00
Delyan Angelov ae036b6146
checker: fix infinite recursion on generic interface cast 2021-12-30 19:28:42 +02:00
Delyan Angelov df8384b62e
v.scanner: report the start of unfinished string literals too 2021-12-30 18:29:52 +02:00
Delyan Angelov 93c40e696d
all: add support for `type MyEnumAlias = MyEnum` 2021-12-30 13:42:06 +02:00
Delyan Angelov bf9f684c59
ast: improve support for type aliases, in TypeSymbol.xyz_info methods 2021-12-30 13:17:10 +02:00
Delyan Angelov 7531f78f67
ast: remove const hack for global_table, use a proper global instead 2021-12-30 13:15:55 +02:00
yuyi d421f28de4
checker: minor cleanup in cast_expr() (#12995) 2021-12-29 21:48:23 +02:00
Delyan Angelov 4114dd0815
v.builder: fix `v -no-retry-compilation -cc tcc -usecache examples/tetris/` 2021-12-29 21:45:01 +02:00
Delyan Angelov 99fdcd2e71
v.builder: fix `v -cc tcc -no-retry-compilation build-module vlib/sync/stdatomic` 2021-12-29 21:32:30 +02:00
Delyan Angelov ca5154747e cgen: fix `v -usecache examples/news_fetcher.v` on macos (.sort() compare_ functions duplication) 2021-12-29 20:15:51 +02:00
Delyan Angelov cb34309f6f
cgen: fix chained `./v -usecache -o v cmd/v` (and all other V programs that use maps) 2021-12-29 17:57:04 +02:00
yuyi cc577e1bfb
parser: check variable redefinition error (#12992) 2021-12-29 13:44:08 +02:00
Delyan Angelov 69c90ef50d
hash.fnv1a: add generic fnv1a.sum64_struct/1 and fnv1a.sum32_struct/1 + tests 2021-12-29 12:03:24 +02:00
Delyan Angelov 7c78bf9466
hash.fnv1a: add fnv1a.sum64_bytes and fnv1a.sum32_bytes, add doc comments and tests 2021-12-29 11:27:26 +02:00
Delyan Angelov 9b8cf1ad37
markused: fix V compiler panics with -skip-unused, for code using generics 2021-12-29 09:48:13 +02:00
Hunam 5607cfbd32
datatypes: add a Queue.last() method (#12987) 2021-12-29 08:01:47 +02:00
Delyan Angelov 43fee6b3d5
all: fix registration of methods with the same name on different generic structs 2021-12-28 21:42:48 +02:00
Delyan Angelov 730b2a9263
sync: move sync.atomic2 to sync.stdatomic, cleanup 2021-12-28 10:16:22 +02:00
yuyi c1711b8f05
checker: check string cast to number (fix #12982) (#12983) 2021-12-28 07:55:39 +02:00
Alexander Medvednikov 6176ce9f03 all: c2v fixes 2021-12-28 08:00:56 +03:00
penguindark dadc965082
regex: implement negation groups, more flexibility for bsls, small fixes (#12981)
* removed memory allocations in cleaning during clear calls

* first test implementation of negative groups, more flexibility for bsls

* fixed bsls failed tests

* fmt

* added \n to regex tests
2021-12-27 22:18:48 +02:00
Delyan Angelov 14648fa41e
parser: reduce max_expr_level to 310 (due to more limited stack size on windows) 2021-12-27 20:21:58 +02:00
yuyi 34e175a343
checker: minor cleanup of the fns classification (#12977) 2021-12-27 13:11:10 +02:00
Delyan Angelov a2eb90ee4e
parser: prevent too deep recursions in p.check_undefined_variables 2021-12-27 12:30:17 +02:00
Toby Webb 35418b8413
cgen: fix compile error on locking interface value (#12883) 2021-12-26 20:01:00 +02:00
Delyan Angelov c26e040d33
ci: bump retry count to 5 for tcp_test.v 2021-12-26 19:05:05 +02:00
yuyi 2e68af22d3
cgen: improve auto_str error messages (#12972) 2021-12-26 18:32:15 +02:00
yuyi 55d9c24063
ast: fix generic fn with multiple return (#12971) 2021-12-26 16:44:41 +02:00
Delyan Angelov 8a10dbcf27
vlib: rename `adt` to `datatypes` 2021-12-26 16:01:36 +02:00
Larpon 2210f89ea3
sokol: type alias all `sapp` structs (#12962) 2021-12-26 13:02:51 +02:00
pancake 04be2465dc
cgen: check call argument on methods (#12965) 2021-12-26 11:53:56 +02:00
yuyi 3b5de71e60
builtin: add none str() (fix #12964) (#12967) 2021-12-26 11:41:51 +02:00
yuyi 03864e4ab8
checker: fix cast enum to alias (#12968) 2021-12-26 11:34:20 +02:00
Daniel Däschle 10f63b3cd7
cgen: remove "main" from inline sum type str (#12963) 2021-12-25 23:58:45 +03:00
Daniel Däschle 35282396ec
all: inline sum types (#12912) 2021-12-25 18:26:40 +03:00
Miccah 485b392cb3
adt: implement a binary MinHeap data structure (#12956) 2021-12-25 12:03:50 +02:00
yuyi 8764a3a973
checker: check errors of cast to byte (#12961) 2021-12-25 11:34:15 +02:00
yuyi d0ad79cd8b
checker: fix generic array builtin method call (#12957) 2021-12-24 14:42:23 +02:00
yuyi a83786d867
checker: minor cleanup in cast_expr() (#12954) 2021-12-24 11:38:27 +02:00
Miccah d69d2c600b
adt: implement a doubly linked list (#12950) 2021-12-24 11:19:40 +02:00
yuyi c0dcd1a9a5
ast: fix reference of alias char type (#12951) 2021-12-24 11:11:20 +02:00
Hunam 68452cff76
adt: add queue (#12941) 2021-12-23 18:57:15 +02:00
Hunam 54a6973548
adt: add linked list (#12937) 2021-12-23 18:23:04 +02:00
Delyan Angelov fa2de89db9
orm: do not order by default, ordering is slow; also fix a bug for tables without defined primary keys 2021-12-23 16:43:22 +02:00
Hunam d7deda5078
vlib: add an `adt` module (Abstract Data Types) (#12901) 2021-12-23 15:16:29 +02:00
yuyi d4f28c88b3
checker: minor cleanup in the checker.v (#12945) 2021-12-23 15:02:09 +02:00
Benjamin Stigsen 546c388b02
gg: renaming drawing functions (#12913) 2021-12-23 13:31:25 +02:00
yuyi ad1ef6a9e2
cgen: fix map get assign blank var with optional (#12943) 2021-12-23 13:04:36 +02:00
playX a2468e1e0c
js,os: fix integer arithmetic; add Process.close() and os.is_readable() for VJS; Make tetris run on JS backend (#12940) 2021-12-23 11:36:42 +02:00
yuyi d3ccdfd75c
cgen: fix channel of sumtype (#12938) 2021-12-23 11:26:15 +02:00
Delyan Angelov db1175e455
parser: handle `[noreturn]` on methods too 2021-12-22 19:58:37 +02:00
yuyi 1028f0b59e
fmt: fix error of generic struct_init using module (fix #12893) (#12935) 2021-12-22 19:11:09 +02:00
Delyan Angelov e256f1b2aa
checker,cgen: stabilise generic method handling (fix a source code ordering issue) 2021-12-22 18:03:46 +02:00
penguindark 278c08704c
all: support slices with negative indexes `#[start..end]` (gated arrays) (#12914) 2021-12-22 16:34:02 +03:00
playX 2b9f993574
gg: add text rendering, keyboard event handling for JS and other fixes (#12932) 2021-12-22 12:26:52 +02:00
yuyi 6eb44f472a
cgen: fix multiple return with sumtype (#12930) 2021-12-22 12:09:08 +02:00
yuyi 6a4fa6096e
cgen: fix blank ident in for_c_stmt (#12931) 2021-12-22 09:34:26 +02:00
pancake cb65f2ff44
js: generate es5 methods for valueOf() and toString() (#12928)
Co-authored-by: pancake <pancake@nopcode.org>
2021-12-22 09:20:45 +02:00
zakuro 2693631643
parser: make codegen generate correct module name (#12929) 2021-12-22 10:55:57 +11:00
spaceface cfb814a0e3
gen: support returning large types from closures on amd64 (#12926) 2021-12-22 00:18:45 +02:00
playX b68c217d53
js: remove usage of default arguments for `-es5` flag (#12921) 2021-12-21 20:23:40 +02:00
joe-conigliaro 07cf6d9f96
parser/scanner: make codegen impl use own parser. closes #12857 (#12925) 2021-12-21 19:48:06 +02:00
yuyi fc83f0bfd0
cgen: clean up gen_assign_stmt() (#12915) 2021-12-21 19:23:55 +02:00
yuyi de3665af69
cgen: fix interface method using struct embed (#12924) 2021-12-21 19:16:05 +02:00
playX ade14491d4
gg: add event handling for mouse down/up and mouse leave/out on VJS (#12917) 2021-12-21 12:31:29 +02:00
yuyi 460f7c6637
cgen: fix fixed array of interfaces equality (#12908) 2021-12-20 19:09:22 +02:00
Delyan Angelov 68ada041e6
tests: support `VTEST_ONLY_FN=*test_sincos* ./v test .` and `./v test -run-only test_sin .` 2021-12-20 18:45:04 +02:00
playX 5f0160bf11
js,gg: more work on porting gg to JS backend (#12903) 2021-12-20 16:18:21 +03:00
Delyan Angelov f81654e3a7
builtin: add `s.match_glob(wildcard_pattern)` 2021-12-20 14:17:08 +02:00
yuyi 7c85c2ab1f
checker: fix error of map selector assign (#12902) 2021-12-20 08:09:15 +02:00
Miccah d07975335d
time: add Duration.str() (#12897)
* time: add str() method to Duration

* add Duration.str tests, move time.infinite to time.v, to be visible to the JS backend

Co-authored-by: Delyan Angelov <delian66@gmail.com>
2021-12-19 19:32:42 +02:00
Delyan Angelov 840a92c14e
v.builder: change the default stack size for apps produced by MSVC to 16MB 2021-12-19 18:40:29 +02:00
yuyi cd0b581445
ast: rename 'table.get_type_symbol()' to 'table.sym()' and more related calls (#12898) 2021-12-19 18:25:18 +02:00
yuyi c957f59071
cgen: minor cleanup in cgen.v (#12896) 2021-12-19 14:31:04 +02:00
Delyan Angelov 41176c4967
cgen: add `bool` and `complex` to c_reserved 2021-12-19 13:44:54 +02:00
Leo Developer a7019ac86c
cgen: fix parallel waiter function generation (#12895) 2021-12-19 13:38:48 +02:00
yuyi 2ab861ef89
cgen: fix generic array of interface method call (fix #12882) (#12888) 2021-12-18 18:08:19 +02:00
yuyi 5e5c78ed37
cgen: minor cleanup of the field order in the Gen struct definition (#12890) 2021-12-18 17:52:33 +02:00
spaceface de92f819f0
cgen: support closures with any number of parameters of any size on amd64 (#12891) 2021-12-18 17:33:24 +02:00
Benjamin Stigsen 3a504480d9
gg: add draw_arc_empty (#12887) 2021-12-18 12:39:14 +02:00
Sandro Martini 80995f3a2d
log: improve logging interface (#12886) 2021-12-18 12:38:43 +02:00
Delyan Angelov 927eecf7c0 ci: retry more return_in_lock_test.v 2021-12-18 10:19:13 +02:00
yuyi 7c255f0ff2
builtin, cgen: fix array of map init with default value (#12885) 2021-12-18 10:07:25 +02:00
ChAoS_UnItY 50d988ebc7
v.parser: forbid unsupported language functions/types in specific backends (#12655) 2021-12-18 10:00:31 +02:00
Benjamin Stigsen 75830f1fe3
gg: add draw_ellipse_filled() + draw_ellipse_empty() APIs (#12869) 2021-12-17 21:19:18 +02:00
pancake 08766da7e8
js: dont use async js_main in '-es5' mode (#12870) 2021-12-17 16:37:19 +02:00
Tim Basel 130d189fce
cgen: fix overwriting methods of embedded structs + empty struct for interfaces (#12876) 2021-12-17 15:32:31 +02:00
playX b482da74e9
gg: move code using C types to c.v files, add js.v files (#12873) 2021-12-17 15:22:09 +02:00
yuyi 66070ec63e
cgen: fix error of 'map_a[map_b[key]] += 2' (#12872) 2021-12-17 15:17:08 +02:00
yuyi c9f6a96936
cgen: fix array of interfaces equality error (#12874) 2021-12-17 14:58:17 +02:00
spaceface d80dd77adf
cgen: support closures on arm32 as well (#12875) 2021-12-17 14:26:24 +02:00
zakuro e5e3979e45
fmt: fix removal of selective imported types used in type decl (#12868) 2021-12-17 05:20:16 +02:00
zakuro 2f7ac7e407
cgen: fix c error when use reserved keyword as if guard var (#12871) 2021-12-17 04:50:52 +02:00
yuyi f87f8ec3f7
cgen: fix defer with function variables (fix #12854) (#12866) 2021-12-16 20:58:54 +02:00
Delyan Angelov 5f1eaaf3b1 ci: retry more channel_select_6_test.v 2021-12-16 20:12:40 +02:00
spaceface c6b902d2b7
cgen: support closures on arm64 (#12863) 2021-12-16 18:02:05 +02:00
spaceface 8a34fb7857
ci: run the full V test suite on arm64 (#12865) 2021-12-16 17:44:21 +02:00
Delyan Angelov 6ff953d936
preludes,builder,cgen: add support for VTEST_RUNNER=tap and -test-runner tap (#12523) 2021-12-16 15:59:46 +02:00
Delyan Angelov caac89d6ca
checker: fix `function x is private` error in main, for `pub const abc = x()` in a (sub)module 2021-12-16 12:03:49 +02:00
yuyi 674f99a658
checker: minor clean up in comptime_call() (#12860) 2021-12-16 11:47:47 +03:00
yuyi d8a333058d
checker, cgen: fix generic map with generic type key (#12859) 2021-12-16 09:53:05 +02:00
Delyan Angelov 1261468d8e
ci: fix failed windows-msvc task (sokol examples) 2021-12-15 20:18:45 +02:00
Benjamin Stigsen d90ef1f29f
gg: draw_arc fixes (#12827) 2021-12-15 21:17:07 +03:00
yuyi c44115c67d
checker: fix goto label with comptime tmpl (#12853) 2021-12-15 18:48:43 +02:00
Delyan Angelov 2b981b011e
ast: fix bug in parsing `-Isomething -Danother` from #flag and #pkgconfig directives 2021-12-15 17:55:52 +02:00
spaceface 65f12f3217
checker: fix invalid cast warning for flag enums (#12848) 2021-12-15 16:58:25 +02:00
playX 11d2b8b354
js: support `-es5` flag (#12846) 2021-12-15 15:47:34 +02:00
Delyan Angelov df7f2aa8a3
all: support `[markused]` tags for fns/consts/globals 2021-12-15 14:34:49 +02:00
Delyan Angelov 1a6899e85e
cgen: fix building with `-no-preludes -no-builtin -skip-unused` (part 2) 2021-12-15 13:30:21 +02:00
yuyi 2ce1647ea0
cgen: fix error of embedded struct generating interface_table (#12847) 2021-12-15 13:21:21 +02:00
Delyan Angelov fa1a7a85f0
cgen: fix building with `-no-preludes -no-builtin` (part 1) 2021-12-15 12:47:28 +02:00
Larpon 1d41d9daf9
json2: improve readability, add tests utilizing fix #12667 (#12836) 2021-12-15 12:20:05 +02:00
spaceface d13fe7843c
v: fix build and failing tests on arm64 (#12840) 2021-12-15 09:00:38 +02:00
yuyi 1c629f4a93
cgen: fix ci error of empty struct init (#12838) 2021-12-15 08:49:30 +02:00
Delyan Angelov c900dc1053
ci: use -Wno-excess-initializers for clang -cstrict, cleanup cgen 2021-12-14 17:14:45 +02:00
Delyan Angelov 96e9cc62b0
ci: fix clang macos build 2021-12-14 17:06:57 +02:00
Delyan Angelov 70564ae8b2
ci: fix generics test 2021-12-14 17:04:37 +02:00
Delyan Angelov 73e097c1cb
Revert "ci: fix clang build error on macos/freebsd"
This reverts commit d7abdd314d.
2021-12-14 16:57:47 +02:00
Delyan Angelov d7abdd314d
ci: fix clang build error on macos/freebsd 2021-12-14 15:39:08 +02:00
yuyi eeb7d4a7fd
cgen: fix embedded struct init with complex fields (#12831) 2021-12-14 14:55:58 +02:00
Thomas Mangin 99f14a7ead
transformer: only enable array optimisation with -prod (#12833) 2021-12-14 13:05:54 +02:00
zakuro eed882950c
fmt: remove extra comma of branch instead of parse error (#12814) 2021-12-14 08:14:43 +02:00
yuyi 731015cd9b
ci: revert "cgen: fix embedded struct init with complex fields (fix #12823) (#12825)" (#12830)
This reverts commit b4b2a21453.
2021-12-14 08:11:11 +02:00
yuyi b4b2a21453
cgen: fix embedded struct init with complex fields (fix #12823) (#12825) 2021-12-14 07:15:23 +03:00
Larpon 2a5356670b
toml: add `as_strings()` method to map of `Any` (#12824) 2021-12-13 21:43:33 +02:00
Benjamin Stigsen 76f6f99bce
gg: add draw_ring() (#12817) 2021-12-13 21:03:42 +02:00
playX cb4c67588c
os: add support for signal handling on JS backend (#12818) 2021-12-13 20:18:12 +02:00
yuyi d5c0bdf954
cgen: clean up interface_table() (#12816) 2021-12-13 13:45:27 +02:00
yuyi be5823069a
cgen: clean up struct_init (#12815) 2021-12-13 13:01:36 +02:00
yuyi b303588491
cgen: fix struct init with interface field (#12820) 2021-12-13 12:55:46 +02:00
Delyan Angelov 3afbb9e90a
all: split all backends into cmd/tools/builders (#12811) 2021-12-12 22:10:43 +03:00
yuyi 57c1faadbe
cgen: fix multiple nested embed struct with duplicate field init (#12805) 2021-12-12 19:54:29 +02:00
yuyi f407d6de02
ast, checker, cgen: fix generics multiple type comptime call (fix #12777) (#12806) 2021-12-12 19:42:40 +02:00
Benjamin Stigsen ab6e93394f
gg: add draw_empty_triangle() (#12804) 2021-12-12 19:41:27 +02:00
Leo Developer 8c1c70db04
checker: fix x.$(field.name) not working outside of $if (#12802) 2021-12-12 03:18:29 +02:00
Delyan Angelov 79de408ef0
parser,checker: support `[generated] module xyz` (turns off notices). Use it for `infix.v`. 2021-12-12 00:58:38 +02:00
Delyan Angelov 9b7a50b1a2
v: split the interpreter to cmd/tools/vinterpret.v 2021-12-12 00:06:44 +02:00
Delyan Angelov adf353702e
v.eval: show `sumtype or interface casts return void currently` only with -v 2021-12-11 23:45:54 +02:00
Leo Developer 2ced182816
cgen: fix order of comptime reflection fields (#12799) 2021-12-11 22:09:47 +02:00