Commit Graph

963 Commits

Author SHA1 Message Date
Anton Bannykh 46a23c70df [JS IR] hacky fix for local variables name binding 2021-11-19 00:38:03 +03:00
Anton Bannykh e4c668462c [JS IR] fix field namer 2021-11-19 00:38:00 +03:00
Anton Bannykh 5100cb058f [JS IR] local var clashes 2021-11-19 00:37:55 +03:00
Anton Bannykh 05e8bfcd2a [JS IR] split fqn-ish JsNames before resolving temporary names 2021-11-19 00:37:45 +03:00
Anton Bannykh a5d9cb0cc6 [JS IR] copy class models 2021-11-19 00:37:40 +03:00
Artem Kobzar d5dd35cb20 feat(@JsExport for interfaces): add ability to export interfaces in TypeScript. 2021-11-18 10:07:38 +00:00
Artem Kobzar af924fd3d1 feat: add implicit export support for Kotlin/JS 2021-11-16 16:59:18 +00:00
Igor Yakovlev ee7f4c7278 [WASM] Implementation typeOf support 2021-11-15 19:53:48 +03:00
Igor Yakovlev ce360bb10b [WASM] Implementation of Class references 2021-11-15 19:53:46 +03:00
Artem Kobzar 7aa8de55a5 fix(use strict): move global this polyfill after "use strict" pragma. 2021-11-12 15:59:27 +00:00
Ilya Goncharov d6112224b4 [JS IR] Generate references from fake override to body in case of generic superclass 2021-11-11 15:12:34 +00:00
Ivan Kylchik 701a10d643 Split some functions of js compiler to be able to use them in tests 2021-11-08 23:50:33 +03:00
Ilya Goncharov f22de86954 [JS IR] Possibility to use export for nested inside object
[JS IR] Fix test data after master rebase

[JS IR] Use stdlib's listOfNotNull

[JS IR] Possibility to use export for nested inside object

- Add tests for such cases

Merge-request: KT-MR-4883

^KT-49363 fixed
2021-11-03 09:56:22 +00:00
Sergej Jaskiewicz 42c213d950 [JS IR] Explicitly convert Long values to String in string concatenation
#KT-39891 Fixed
2021-11-02 10:42:28 +00:00
Ilya Goncharov 2584f45b1c [JS IR] Refactor export model generator
^KT-37916 fixed
^KT-44494 fixed
2021-11-01 13:28:24 +00:00
Ilya Goncharov 9fdb0a23cd [JS IR] Add literal and union types to TS generation, support them for enum
^KT-37916 fixed
^KT-44494 fixed
2021-11-01 13:28:24 +00:00
Ilya Goncharov 4fa2fa6c26 [JS IR] Export name and ordinal for enum classes
^KT-37916 fixed
^KT-44494 fixed
2021-11-01 13:28:24 +00:00
Ilya Goncharov 69f6dc059d [JS IR] Export type for enum class and not extends kotlin.Enum in TS
^KT-37916 fixed
^KT-44494 fixed
2021-11-01 13:28:22 +00:00
Ilya Goncharov 9bd44e01f5 [JS IR] Export enum members like from usual classes
^KT-37916 fixed
^KT-44494 fixed
2021-11-01 13:28:20 +00:00
Ilya Goncharov 42cb0e60d7 [JS IR] Process enum classes correctly in export model generator
^KT-37916 fixed
^KT-44494 fixed
2021-11-01 13:28:20 +00:00
Ilya Goncharov 025e335b0f [JS IR] Add more granularity to find enum related declarations
^KT-37916 fixed
^KT-44494 fixed
2021-11-01 13:28:20 +00:00
Artem Kobzar 979e9f94ef feat(Escaped Identifiers): add ability to use any symbol wrapped in back ticks. 2021-10-29 17:55:59 +00:00
Artem Kobzar 102072a229 fix(KT-40236): compute JsName from overridden symbols. 2021-10-29 14:09:31 +00:00
Artem Kobzar 790e8843f9 fix(JS_IR): add outer classes resolving inside the function inliner. 2021-10-28 17:34:58 +00:00
Artem Kobzar 7f7aa9a921 feat(Inner Classes): generate typescript type definitions and JS for Inner Classes. 2021-10-28 17:33:41 +00:00
Roman Artemev 9f52326d14 [JS IR] Fix default arguments in suspend functions
Don't forget to remap parameter references in default arg expressions

The issue originally discovered in kotlinx.coroutines tests.

 - add test
2021-10-25 12:56:16 +00:00
Roman Artemev 1d58fd159a [IR] Replace adhoc remappers to common one ValueRemapper 2021-10-25 12:56:16 +00:00
Ivan Kylchik 3e1563d46e [JS TESTS] Rename JS_TESTS module to main 2021-10-25 00:14:19 +03:00
Ilya Goncharov f6ba2a958a [JS IR] No generate exportness for overridden properties
[JS IR] Add check on existence of overridden property in tests

^KT-49326 fixed

[JS IR] Add details to comment with exporting properties

^KT-49326 fixed

[JS IR] No generate exportness for overridden properties,

if only no override val -> var

^KT-49326 fixed

Merge-request: KT-MR-4810
2021-10-21 10:52:48 +00:00
Artem Kobzar 876d358fe6 fix(KT-46961): add support of nested external enums. 2021-10-21 06:40:00 +00:00
Artem Kobzar 3dbf996ec6 fix(KT-49225): remove unnecessery boxing. 2021-10-21 06:38:42 +00:00
Sergej Jaskiewicz 9e5520bba8 [JS IR & WASM] Fix executing init blocks for enums with nested objects 2021-10-18 13:37:16 +00:00
Anton Bannykh 283e37c741 [JS IR] fix warnings 2021-10-15 20:14:54 +03:00
Anton Bannykh c2f7ed2fff [JS IR] added a directive to skip IC checks in IR 2021-10-15 20:14:53 +03:00
Anton Bannykh 94ed6a1dbd [JS IR] bring back old ir2js to work alongside with the new one
Should be removed when we're sure the new one is OK
2021-10-15 20:14:53 +03:00
Anton Bannykh 546ce501cb [JS IR] run IC box tests 2021-10-15 20:14:51 +03:00
Anton Bannykh b1b88a0d11 [JS IR] JS AST serialization 2021-10-15 20:14:50 +03:00
Anton Bannykh 95ab5e1b7e [JS IR] generate JS separately for each file and link at the end
Name clashes are handled as a post-processing step
2021-10-15 20:14:50 +03:00
Anton Bannykh 936383254a [JS IR] explicitly mark JsName's temporary or not 2021-10-15 20:14:49 +03:00
Anton Bannykh 7e7c84fcfb [JS IR] move fragment generation closer to the beginning 2021-10-15 20:14:48 +03:00
Anton Bannykh b1b263615c [JS IR] handle exports per-file 2021-10-15 20:14:47 +03:00
Anton Bannykh aec743d7a6 [JS IR] handle tests per-file 2021-10-15 20:14:47 +03:00
Anton Bannykh 9f2762cfa6 [JS IR] handle main function per-file 2021-10-15 20:14:46 +03:00
Anton Bannykh 1af1d13cf3 [JS IR] split resulting code into fragments 2021-10-15 20:14:45 +03:00
Anton Bannykh d595264cc8 [JS IR] move JsGenerationContext towards it's use 2021-10-15 20:14:43 +03:00
Igor Laevsky 50ca86838f [WASM] Fix build 2021-10-14 17:24:07 +03:00
Igor Laevsky bede039c08 [Wasm] Add compiler support for the kotlin.test library 2021-10-14 17:24:05 +03:00
Sergej Jaskiewicz 55ae6d1f3e [JS IR] Optimize pattern-matching of enums into comparing their ordinals
For this code:
```
enum class Season {
    WINTER,
    SPRING,
    SUMMER,
    AUTUMN
}

fun bar1(x : Season) : String {
    return when (x) {
        Season.WINTER, Season.SPRING -> "winter_spring"
        Season.SUMMER -> "summer"
        else -> "autumn"
    }
}
```

previously we generated this:
```
function foo(x) {
    var tmp0_subject = x;
    return (tmp0_subject.equals(Season_WINTER_getInstance())
        ? true
        : tmp0_subject.equals(Season_SPRING_getInstance()))
            ? 'winter_spring'
            : tmp0_subject.equals(Season_SUMMER_getInstance())
                ? 'summer'
                : 'autumn';
}
```

And now we generated this:
```
function bar2(x) {
  var tmp0_subject = x;
  var tmp0 = tmp0_subject._get_ordinal__0_k$();
  var tmp;
  switch (tmp0) {
    case 0:
    case 1:
      tmp = 'winter_spring';
      break;
    case 2:
      tmp = 'summer';
      break;
    case 3:
      tmp = 'autumn';
      break;
    default:
      noWhenBranchMatchedException();
      break;
  }
  return tmp;
}
```
2021-10-14 11:44:01 +00:00
Pavel Kunyavskiy 2fe9420ca1 Compatibility hack for instantiating annotations from old klibs
^KT-49181
2021-10-14 11:03:17 +00:00
Artem Kobzar f645c89ebf fix(KT-43191): add static qualifier for Companion and non-inner objects. 2021-10-13 11:09:59 +00:00