Commit Graph

580 Commits (31c234485a6bd0ce1dd9dc4ee726d065b5d52a0f)

Author SHA1 Message Date
Benjamin Stigsen ceb05b163a
strings: rename Builder.write_b() to Builder.write_byte(), add deprecation (#13313) 2022-01-28 20:34:44 +02:00
yuyi 3bd528b218
ast, checker, cgen: fix error for map sumtype value init (#13290) 2022-01-27 09:44:34 +02:00
yuyi 291a1ffd8d
token: rename Position to Pos, rename position() to pos() (#13279) 2022-01-26 12:36:28 +02:00
yuyi ca1f675dba
ast, checker, cgen: implement if guard with multi return optional (#13273) 2022-01-25 14:36:33 +02:00
Delyan Angelov 5f38ba896e
parser,cgen: handle `const x = $embed_file("file.txt").to_string()` 2022-01-25 11:40:07 +02:00
crthpl cbd3c14e83
cgen: fix codegen for struct field with a shared array of points (#13222) 2022-01-21 17:08:19 +02:00
Delyan Angelov 295156e054
checker,cgen: implement v.profile.on/1, support `[if profile]` and `-d no_profile_startup` (#13232) 2022-01-21 03:26:05 +02:00
yuyi 7c9cd855b4
cgen: fix fn call with fixed array literal arguments (#13225) 2022-01-20 15:04:16 +03:00
Tim Basel d714dcef75
cgen: fix return of mut symtype (#13214) 2022-01-19 14:37:40 +02:00
yuyi 851f265a5e
cgen: minor cleanup in match_expr() (#13192) 2022-01-17 11:26:20 +02:00
yuyi 315b2deda9
cgen: fix match sumtype var returning sumtype value (#13184) 2022-01-16 13:12:27 +02:00
Delyan Angelov b658b65774
scanner,cgen,vfmt: keep original when using byte char literals, test all 256 byte values in the C backend 2022-01-12 14:45:38 +02:00
jeffmikels f99b79480d
cgen: reduce memory allocation and improve performance of cescape_nonascii (#13141) 2022-01-12 10:58:37 +02:00
jeffmikels ab642cac43
scanner, cgen: improve support for escape codes in backticks/runes (#13127) 2022-01-11 22:36:18 +02:00
yuyi 1e52b2c134
cgen: fix cast in the index of reference fixed array (fix #13128) (#13131) 2022-01-11 10:55:29 +02:00
playX c07ce3ff15
cgen,json2: improve -nofloat support (#13117) 2022-01-10 12:42:41 +02:00
playX 4d166e3b55
all: add support for `-os wasm32` (needs clang-12 installed for now) (#13094) 2022-01-08 11:06:32 +02:00
playX ec91de3504
builtin: use dlmalloc for `-freestanding` (#13054) 2022-01-06 14:10:37 +02:00
yuyi fb66ec7cfb
cgen: fix codegen for aliases of fixed arrays of structs (fix #13037) (#13049) 2022-01-06 11:54:22 +02:00
Tim Basel 897bbb7da5
cgen: fix cgen removing random chars from parameter_name (#13038) 2022-01-05 13:06:06 +02:00
yuyi 6c1ae4f689
ast: simplify mktyp() (#13028) 2022-01-04 18:37:18 +02:00
yuyi 054bb272df
cgen: fix const fixed array of reference var using correct pointer (#13023) 2022-01-04 11:34:07 +02:00
Alexander Medvednikov 59ed4be49a all: update copyright year 2022-01-04 12:21:12 +03:00
yuyi 00a0c1886e
ast, cgen: fix const fixed array of reference value (#13022) 2022-01-04 11:36:29 +03:00
Delyan Angelov 93c40e696d
all: add support for `type MyEnumAlias = MyEnum` 2021-12-30 13:42:06 +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
Delyan Angelov 43fee6b3d5
all: fix registration of methods with the same name on different generic structs 2021-12-28 21:42:48 +02:00
Alexander Medvednikov 6176ce9f03 all: c2v fixes 2021-12-28 08:00:56 +03:00
Toby Webb 35418b8413
cgen: fix compile error on locking interface value (#12883) 2021-12-26 20:01:00 +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
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
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
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 5e5c78ed37
cgen: minor cleanup of the field order in the Gen struct definition (#12890) 2021-12-18 17:52:33 +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
zakuro 2f7ac7e407
cgen: fix c error when use reserved keyword as if guard var (#12871) 2021-12-17 04:50:52 +02:00
yuyi d8a333058d
checker, cgen: fix generic map with generic type key (#12859) 2021-12-16 09:53:05 +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
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
yuyi eeb7d4a7fd
cgen: fix embedded struct init with complex fields (#12831) 2021-12-14 14:55:58 +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
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
yuyi 57c1faadbe
cgen: fix multiple nested embed struct with duplicate field init (#12805) 2021-12-12 19:54:29 +02:00
Delyan Angelov fe14e2fceb
cgen: use `c_name()` for escaping goto label names too 2021-12-11 19:41:44 +02:00
Delyan Angelov 24bc2ae406
cgen: add `small` to c_reserved 2021-12-11 19:14:26 +02:00
yuyi ade2a4cd01
cgen: fix multiple embed struct init (#12791) 2021-12-11 10:28:32 +03:00
yuyi 9b4329d2f6
ast, checker, cgen: fix interface method with struct embed (#12783) 2021-12-10 14:56:13 +02:00
yuyi 36fbd3c4fa
checker: check sumtype as mismatched type (#12743) 2021-12-07 01:31:47 +03:00
yuyi d85111e3dd
cgen: fix comptime for_in methods call (#12741) 2021-12-06 10:55:27 +02:00
Delyan Angelov e4850a007c
strings: add Builder.drain_builder/1 utility method 2021-12-05 11:59:18 +02:00
Delyan Angelov 229d2fb667
v.util.timers: improve tracing by supporting `-d trace_timers_creation` 2021-12-05 11:55:41 +02:00
Leo Developer ace63594bf
all: support `$embed_file('embed.vv', .zlib)` (#12654) 2021-12-04 19:43:19 +02:00
yuyi 0f50ac3260
ast: cleanup struct embeds related methods (#12719) 2021-12-04 18:46:41 +02:00
yuyi 2d43fdb42a
ast, checker, cgen: fix nested struct embed error (fix #12659) (#12712) 2021-12-04 11:19:19 +03:00
Delyan Angelov 4624de6cb5
cgen: support `-d no_segfault_handler` and `-d no_main`. Cleanup `-d trace_xxx` descriptions in CONTRIBUTING.md 2021-12-03 19:01:45 +02:00
yuyi 66a67de8c0
checker, cgen: fix match expr returning optional with error (fix #12556) (#12645) 2021-12-02 12:22:48 +02:00
Delyan Angelov 47aa2b1f93
all: fix casting of `string(MyString('abc'))` and `byte(MyByte(123))`; improve TypeSymbol handling (#12617) 2021-12-01 09:50:53 +02:00
yuyi d1b0ce9e0c
cgen: fix error of the interface str method (fix #12538) (#12620) 2021-11-30 15:03:44 +02:00
Delyan Angelov 6d97b0a407
checker: improve checking of a << b, when a and b are numbers (#12589) 2021-11-29 03:48:49 +03:00
yuyi 6f46fc2170
checker, cgen: fix for_in_mut iterator val (#12563) 2021-11-24 14:43:37 +02:00
Delyan Angelov 1aaac13a60
cgen: make `os` less special, fix an -autofree leak on just `import os`
* Improve documentation of v.util.Surrounder

* Remove `os` from the list of "no auto free" `builtin` mods

* Fix -autofree freeing of `const x = []string{}`.

* Add a valgrind regression test.

* Implement os.getenv_opt in vlib/os/environment.js.v too.
2021-11-21 21:50:10 +02:00
Delyan Angelov b576181a66
cgen: fix `const x := opt() or {}` side effect interference when the consts are in different files in the same module too 2021-11-19 19:02:33 +02:00
Delyan Angelov e275220f05
cgen: fix `const x := opt() or {}` side effect interference with parallel cgen 2021-11-19 18:15:06 +02:00
yuyi c2eb909c9b
cgen: fix multiple matches in one expr (#12516) 2021-11-19 13:52:28 +02:00
Delyan Angelov 3caeadfa0d
cgen,vfmt: support `[weak]` tags for functions and globals 2021-11-18 18:32:39 +02:00
Alexander Medvednikov 5bf28c5287 cgen: handle c2v fn casts 2021-11-18 11:58:00 +03:00
yuyi 5a89c0a480
ast: change CompFor to ComptimeFor (#12482) 2021-11-17 08:29:43 +02:00
Delyan Angelov 3fab0a5d05
cgen: fix codegen for `for k,v in map_of_pointers {` 2021-11-16 17:03:58 +02:00
yuyi c28041cecc
all: cleanup/rename all `comp_` names to be `comptime_` (#12467) 2021-11-15 15:47:29 +02:00
zakuro 5e75c89b71
checker: allow noreturn in if expr (#12462) 2021-11-15 10:29:58 +02:00
yuyi d8479f107f
cgen: fix typeof comptime selector (fix #12461) (#12463) 2021-11-15 10:23:49 +02:00
yuyi 3bb1c3f930
checker, cgen: fix for in iterator of generic struct (#12441) 2021-11-12 14:29:01 +02:00
yuyi 1211029926
cgen: avoid generating typedef generic array type (#12407) 2021-11-07 21:24:30 +02:00
yuyi 59e21c2068
cgen: fix array of threads wait (fix #12350) (#12378) 2021-11-04 14:24:58 +02:00
Delyan Angelov a27833ed0d
all: support `volatile field Type` in struct declarations 2021-11-04 09:45:50 +02:00
yuyi 3fdbfca202
cgen: fix `for in` with mutable structs (#12368) 2021-11-02 18:40:13 +03:00
Delyan Angelov a7d4236337
sync,strings,cgen: reduce memory consumption in cgen 2021-10-29 22:29:56 +03:00
yuyi d5642b6134
cgen: fix error of nested match expr (#12334) 2021-10-29 17:14:49 +03:00
ChAoS_UnItY 8cd01e0eac
cgen: fix error caused by fixed size array init syntax with variable it (#12314) 2021-10-28 02:20:49 +03:00
Delyan Angelov c340906280
cgen: cleanup vinit_string_literals, _vcleanup and reload_so declarations 2021-10-24 15:29:42 +03:00
Delyan Angelov 008d15dcb5
builder,pref: add support for `-no-builtin` (useful for writing Linux kernel modules) 2021-10-23 12:53:53 +03:00
ChAoS_UnItY 5b69593766
cgen,js: fix missing break in switch case, generated by match with range branches (#12260) 2021-10-21 22:30:05 +03:00
05st 3e52d54586
cgen: fix match expr when evaluating to sumtype (#12237) 2021-10-20 11:52:11 +03:00
ChAoS_UnItY ab350d52ec
cgen: support RangeExpr while emitting enum switch case (#12226) 2021-10-19 17:02:22 +03:00
ChAoS_UnItY 53c2e262f1
cgen & jsgen: generate when possible a `switch` from `match x {` (#12216) 2021-10-18 10:59:52 +03:00
05st fd3a10ab43
checker: fix mut check bypass with for in loops (#12208) 2021-10-17 06:41:39 +03:00
yuyi 27cd21e459
cgen: fix infix ops, for cross assignments of types with overloaded operators (#12192) 2021-10-15 11:32:58 +03:00
yuyi 05885059bd
cgen: remove the extra generated parentheses of single in_expr (fix #12158) (#12168) 2021-10-14 11:38:16 +03:00
ChAoS_UnItY d0c961ebc0
transformer: eliminate unreachable branches in IfExpr and fold more expressions and statements (#12135)
* v: fix using constant as length in fixed array

* format test file

* v/trasnformer: discard unreachable if branches

* transform more expressions and statements

* replace IfExpr with EmptyExpr when all branches were eliminated

* fix typo

* fix gens

* only allows branch elimination on if expression statement

* fix native gen

* fix handling of multi branch ifs in the native backend, also allow for `if true {}`

Co-authored-by: KyleLin921021 <43753315+KyleLin921021@users.noreply.github.com>
Co-authored-by: Delyan Angelov <delian66@gmail.com>
2021-10-11 14:29:17 +03:00
05st e69df54a36
cgen: fix multi-return in if/match exprs (#12139) 2021-10-11 02:45:01 +03:00
yuyi 3c7c11e55b
cgen: fix sumtype with none type (fix #12101) (#12102) 2021-10-09 03:32:37 +03:00
Delyan Angelov e53682320c
v.gen.c: fix compiling `go f(x)` for `x` of the same struct in different .v files with parallel cgen 2021-10-06 22:12:21 +03:00
yuyi f1742a6f62
v.ast: change 'type.to_ptr()' to 'type.ref()' (#12086) 2021-10-06 20:49:39 +03:00
Wertzui123 77c18f4435
cgen: fix alphabetic order of ast statement generation (#12080) 2021-10-06 14:32:42 +03:00
Delyan Angelov aa8915bdf6
v.gen.c: fix `[console]` handling for `sokol` programs on windows with parallel cgen 2021-10-05 23:57:14 +03:00
Delyan Angelov 6d2c1f7e2c
v.gen.c: enable again parallel cgen for `-g`, make `-g` more robust 2021-10-05 21:51:49 +03:00
crthpl 7cf9c198fe
asm: add segment addressing and fix [10] (#12068) 2021-10-05 18:57:15 +03:00
Delyan Angelov 92f2e5bad2
v.gen.c: fix compilation with `-prod`, for files using `$embed_file()` (regression after parallel cgen in 85b58b0) 2021-10-05 15:06:17 +03:00
05st 7555b337b9
cgen: fix expr_as_cast for int/float literals (#12067) 2021-10-05 09:53:05 +03:00
yuyi e94e08475d
cgen: format shared structs (#12062) 2021-10-04 18:27:38 +03:00
yuyi 82e6d6e51d
cgen: fix threads array wait without go calls (fix #12009) (#12050) 2021-10-03 18:24:44 +03:00
yuyi 10caf4a84a
cgen: cleanup generated thread wait code (#12048) 2021-10-03 10:52:29 +03:00
05st cc4af235f3
cgen: fix if-expression code generation if it evaluates to propagating optional / or block (#12032) 2021-10-02 14:30:04 +03:00
Delyan Angelov 149517ced4
v.builder,v.gen: time Builder.front_stages.parse_files, Builder.resolve_deps, Gen.sort_structs 2021-09-30 20:49:19 +03:00
Alexander Medvednikov d4b3c65c45 cgen: a minor optimization; checker: a c2v fix 2021-09-30 12:51:53 +03:00
yuyi f2c710d306
cgen: fix fn mut args with interface type (#12012) 2021-09-29 13:54:23 +03:00
Delyan Angelov 24c1d552d7
ci: vfmt vlib/v/gen/c/cgen.v 2021-09-29 08:58:27 +03:00
André Diego Piske 8dde9d4a7b
cgen: fixes for ... in with index (#11995) 2021-09-28 19:35:07 +03:00
yuyi 5d3795e876
cgen: fix the C codegen error for '_ = map[key]' (fix #11999) (#12000) 2021-09-28 18:45:50 +03:00
Delyan Angelov d07a96ede8
v.gen.c: fix `v examples/hello_world.v` on FreeBSD 2021-09-28 12:00:34 +03:00
crthpl 85b58b03a3
cgen: parallelize (#10844) 2021-09-28 10:28:04 +03:00
yuyi 4c01627e00
cgen: cleanup stmt_path_pos processing (#11983) 2021-09-26 15:51:18 +03:00
yuyi d93737dd34
cgen: fix assign map get to blank (fix #11508) (#11982) 2021-09-26 13:07:51 +03:00
Delyan Angelov ece5fa183c
fast.v: freebsd fixes 2021-09-23 13:48:41 +03:00
Alexander Medvednikov 27f5c35bde autofree: test returning optionals 2021-09-23 09:18:01 +03:00
Alexander Medvednikov 7b60367512 autofree: free reference types with -experimental for now 2021-09-23 04:35:09 +03:00
Delyan Angelov bf2569a9a8
all: support `mut volatile x := 123` declarations (#11940) 2021-09-22 13:06:30 +03:00
Alexander Ivanov b9720f5d9e
cgen: fix struct init with multiple branches, fixes #11564 (#11570) 2021-09-22 00:46:07 +03:00
yuyi 108a01d65f
fmt: fix unnecessary line break in array init (fix #11448) (#11562) 2021-09-21 16:20:09 +03:00
Enzo b2ecca3966
all: remove `size_t` (#11478) 2021-09-21 02:12:38 +03:00
El Koulali András 9c4507d115
cgen: fix illegal character encoding with rune consts above 127 (#11550) 2021-09-20 10:45:42 +03:00
05st f9f4867c25
tmpl: fix $tmpl comptime operation only working in return statement (#11541) 2021-09-19 23:22:26 +03:00
Alexander Medvednikov 219a764a83 autofree: only free user reference types 2021-09-18 06:32:25 +03:00
Alexander Medvednikov 6d47dd22df autofree: free references 2021-09-18 04:19:16 +03:00
yuyi 467afad065
cgen: use `if foo in [TypeA, TypeB]` in cgen.v (#11518) 2021-09-16 19:26:53 +03:00
yuyi d5e00b0920
checker, cgen: fix generic arrays sum() (#11502) 2021-09-16 07:08:28 +03:00
yuyi 9554470985
checker, cgen: fix generic operator overload of 'cmp' (#11489) 2021-09-14 16:20:02 +03:00
Alexander Medvednikov ae41d1d3c6 builtin, cgen: more -nofloat fixes 2021-09-13 19:06:19 +03:00
Alexander Medvednikov 5c4385a472 cgen: nofloat for kernel code 2021-09-10 20:54:48 +03:00
Enzo cc8ee5fb84
all: introduce `isize` and `usize` (#11437) 2021-09-08 05:53:39 +03:00
yuyi 6084c0fc54
checker, cgen: fix complex generic sumtype (fix #11392) (#11400) 2021-09-06 03:15:53 +03:00
yuyi 87934ecf39
cgen: fix variable name are 'array' or 'string' (fix #10991 #11343) (#11378) 2021-09-04 19:51:45 +03:00
Enzo d1974f500f
cgen: cleanup `Gen.cc_type` (#11357) 2021-08-31 23:55:37 +03:00
Daniel Däschle ac442abc11
checker: allow noreturn in match expr (#11126) 2021-08-29 11:57:11 +03:00
yuyi a440b43630
checker, cgen: fix generic struct with non_generic interface (#11240) 2021-08-20 01:13:48 +03:00
spaceface 67e8031a08
cgen: fix interface parameters in fn type aliases (#11247) 2021-08-20 01:12:31 +03:00
spaceface 09e854c064
cgen: small interface conversion fix (#11229) 2021-08-18 13:47:57 +03:00