Sergej Jaskiewicz
54de11cb58
[FIR/IR generator] Generate kDocs for visitor classes
2023-11-02 23:05:18 +00:00
Sergej Jaskiewicz
570422dbd4
[FIR/IR generator] Print visitor method expression bodies on new line
...
This helps to avoid long lines in visitor classes.
2023-11-02 23:05:18 +00:00
Sergej Jaskiewicz
c5f519f7c7
[FIR/IR generator] Commonize visitor printing logic
...
This is a step towards commonizing the code generator between
FIR and IR: KT-61970
Also, don't use kotlinpoet for generating IR visitors (KT-61703)
2023-11-02 23:05:18 +00:00
Sergej Jaskiewicz
325b152efa
[FIR generator] Remove unused class ImplementationWithArg
2023-10-26 17:33:59 +00:00
Sergej Jaskiewicz
7b7bcb8ffa
[FIR/IR generator] Introduce ImportCollector
...
This class enables printing the import list in generated files
in a smarter way.
Also, refactor `Importable` interface hierarchy, namely, don't inherit
`TypeRef` from `Importable`, since we have types like `TypeRef.Star`
which are not really importable.
Replace the `Importable#typeWithArguments` property with
the `TypeRef#render` method to utilize `ImportCollector` while rendering
types.
2023-10-26 17:33:59 +00:00
Sergej Jaskiewicz
aaf7ccbebd
[util] Introduce IndentingPrinter interface
...
This interface is more convenient to pass around so that it's easier
to replace different printer implementations.
2023-10-25 13:04:15 +00:00
Sergej Jaskiewicz
895d107ac5
[util] Convert Printer from Java to Kotlin
2023-10-25 13:04:14 +00:00
Sergej Jaskiewicz
c442d0e159
[util] Rename Printer.java to Printer.kt before converting it to Kotlin
...
This is to preserve the Git history of the file.
2023-10-25 13:04:14 +00:00
Sergej Jaskiewicz
9eacdb3314
[FIR generator] Print builder property name in generated classes' KDocs
...
Just like we do when generating the IR tree
2023-10-24 10:29:43 +00:00
Sergej Jaskiewicz
fa20e401f8
[IR generator] Rename kdoc -> kDoc property in FieldConfig
2023-10-24 10:29:43 +00:00
Sergej Jaskiewicz
7e7f4811bd
[FIR/IR generator] Add kDoc property to AbstractElement & AbstractField
2023-10-24 10:29:43 +00:00
Sergej Jaskiewicz
f2bb988e68
[FIR/IR generator] Replace getTypeWithArguments with a property
...
The `notNull` of that method was never used.
2023-10-20 10:49:20 +00:00
Sergej Jaskiewicz
de4e39906c
[FIR/IR generator] Use TypeRef for working with types in fields
...
- Don't inherit `AbstractField` from `Importable`, because it really
is not
- Remove the `arguments` and `nullable` properties from `AbstractField`.
Both properties can be derived from the field's `typeRef`.
- Make `AbstractField`'s `typeRef` property of type
`TypeRefWithNullability` instead of just `TypeRef`, because fields
can always be nullable.
2023-10-20 10:49:20 +00:00
Sergej Jaskiewicz
f30bf0e7e2
[FIR generator] Remove unused customType property from SimpleField
2023-10-20 10:49:20 +00:00
Sergej Jaskiewicz
75b509c185
[FIR/IR generator] Share visitor-related properties between FIR & IR
2023-10-20 06:41:12 +00:00
Sergej Jaskiewicz
04c5ac0eb6
[FIR/IR generator] Factor out adding pure abstract element as parent
2023-10-19 12:00:25 +00:00
Sergej Jaskiewicz
5798021e4b
[FIR/IR generator] Refactor element parents
...
- Move `elementParents` and `otherParents` properties
to `AbstractElement`
- Use `elementParents` instead of `parentRefs` where needed
2023-10-19 12:00:25 +00:00
Sergej Jaskiewicz
417aa236fb
[FIR/IR generator] Factor out printing the preamble in generated files
2023-10-18 18:42:40 +00:00
Sergej Jaskiewicz
8c6da9fddb
[FIR/IR generator] Deduplicate interface/abstract class configuration
2023-10-18 12:39:39 +00:00
Sergej Jaskiewicz
9a4c28498c
[FIR generator] Deduplicate the logic of needPureAbstractElement
2023-10-18 11:12:55 +00:00
Sergej Jaskiewicz
7ab4ca6f51
[IR generator] Inherit Element from AbstractElement
...
This is a step towards commonizing the code generator between
FIR and IR: KT-61970
2023-10-16 22:56:36 +00:00
Sergej Jaskiewicz
f9d17a2d51
[IR generator] Inherit Field from AbstractField
...
This is a step towards commonizing the code generator between
FIR and IR: KT-61970
2023-10-16 22:56:36 +00:00
Sergej Jaskiewicz
15751333e3
[IR generator] Introduce constants for List-like types
2023-10-16 22:56:36 +00:00
Sergej Jaskiewicz
df0f86bf8d
[FIR generator] Use a single list of parent TypeRefs for elements
...
(Instead of storing the list of parent elements + the map of parent
arguments)
2023-10-13 10:11:38 +00:00
Sergej Jaskiewicz
04c0cc5a5c
[FIR generator] In properties always print get() ... on new line
...
This is to unify the code formatting with IR classes.
2023-10-12 11:45:55 +00:00
Sergej Jaskiewicz
4507615c69
[FIR generator] Print accept method's body on new line
...
This is to unify the code formatting with IR classes
2023-10-12 11:45:55 +00:00
Sergej Jaskiewicz
04ac4b71a3
[FIR generator] Replace AbstractElement with ElemenOrRef
...
In the FIR generator, the `AbstractElement` class was used to
represent either an element type without type arguments applied
(using the `Element` subclass), or an element type with applied type
arguments (using the `ElementWithArguments` subclass).
Instead, it is more logical to use the `Element` class to always
represent a non-parameterized element type, and for a parameterized
element type use the `ElementRef` class, just like we do
in the IR generator.
2023-10-12 11:36:20 +00:00
Sergej Jaskiewicz
a909a28f29
[FIR generator] Use more type-safe field builders
2023-10-12 08:24:12 +00:00
Sergej Jaskiewicz
8be455649c
[FIR generator] Use TypeVariable instead of TypeArgument for TPs
...
This is a step towards commonizing the code generator between
FIR and IR: KT-61970
2023-10-12 08:24:12 +00:00
Sergej Jaskiewicz
8798fdeb82
[FIR generator] Use TypeRef for denoting types
...
(instead of `Type` and `Importable`)
This is a step towards commonizing the code generator between
FIR and IR: KT-61970
2023-10-11 11:16:08 +00:00
Sergej Jaskiewicz
59129501cb
[FIR/IR generator] Remove unused properties of Type
2023-09-22 19:46:14 +00:00
Sergej Jaskiewicz
3a5e69d651
[FIR/IR generator] Inherit TypeRef from Importable
...
This is the first step to replace the usages of `Importable`
in the FIR generator with `TypeRef`.
This is a step towards commonizing the code generator between
FIR and IR: KT-61970
2023-09-22 19:46:14 +00:00
Sergej Jaskiewicz
d86161bccb
[FIR generator] Remove Type#firType property as it has no effect
2023-09-22 19:46:14 +00:00
Sergej Jaskiewicz
a995c522f7
[IR generator] Factor out TypeRef to common module
...
This is a step towards commonizing the code generator between
FIR and IR: KT-61970
2023-09-22 19:46:14 +00:00
Sergej Jaskiewicz
d5394db185
[FIR generator] Factor out AbstractElement to common module
...
This is a step towards commonizing the code generator between
FIR and IR: KT-61970
2023-09-22 19:46:14 +00:00
Sergej Jaskiewicz
977e316489
[FIR generator] Factor out TypeArgument to common module
...
This is a step towards commonizing the code generator between
FIR and IR: KT-61970
2023-09-22 19:46:14 +00:00
Sergej Jaskiewicz
88c308dfd3
[FIR generator] Don't print extra space in the where clause
2023-09-20 15:39:40 +00:00
Sergej Jaskiewicz
00fa09dbf3
[IR generator] Use ImplementationKind instead of Element.Kind
...
This is a step towards commonizing the code generator between
FIR and IR: KT-61970
2023-09-19 22:19:37 +00:00
Sergej Jaskiewicz
af5a93f5ff
[IR generator] Use TypeKind from the common module, share it with FIR
...
This is a step towards commonizing the code generator between
FIR and IR: KT-61970
2023-09-19 22:19:37 +00:00
Sergej Jaskiewicz
0dd01279da
[FIR generator] Move Implementation.Kind to common module
...
This is a step towards commonizing the code generator between
FIR and IR: KT-61970
2023-09-19 22:19:37 +00:00
Sergej Jaskiewicz
e62343427d
[FIR generator] Move Field and FieldContainer to common module
...
This is a step towards commonizing the code generator between
FIR and IR: KT-61970
2023-09-19 22:19:37 +00:00
Sergej Jaskiewicz
982b9221b4
[FIR generator] Move ArbitrarilyImportable class to common module
...
This is a step towards commonizing the code generator between
FIR and IR: KT-61970
2023-09-19 22:19:37 +00:00
Sergej Jaskiewicz
7a6bffaabb
[FIR generator] Move Importable interface to common module
...
This is a step towards commonizing the code generator between
FIR and IR: KT-61970
2023-09-19 22:19:37 +00:00
Sergej Jaskiewicz
314fcc1ad2
[IR generator] Remove unused suppressPrint property
2023-09-19 07:25:30 +00:00
Sergej Jaskiewicz
14e23a7d84
[K/N] Cache FqNames computed from ClassIds in KonanMangler
2023-09-13 14:25:13 +00:00
Sergej Jaskiewicz
904f8706ee
[K/N] Don't use reflection in irText tests for obtaining manglers
...
See KT-61248
2023-09-13 14:25:12 +00:00
Sergej Jaskiewicz
9eba17d631
[K/N] Move Native-specific mangle constants to more suitable places
...
They shouldn't be mixed with target-independent constants.
2023-09-13 14:25:12 +00:00
Sergej Jaskiewicz
08a9e7eae9
[IR] Outline the main logic in annotation-related helpers
...
Prefer smaller inline functions, because otherwise if they become
hot spots, they will complicate performance analysis, and actually
might make everything slower because of low inlining threshold in
HotSpot.
2023-09-13 14:25:11 +00:00
Sergej Jaskiewicz
157ab48fde
[K/N] Delete unused methods in ObjCInterop.kt
2023-09-13 14:25:11 +00:00
Sergej Jaskiewicz
e3b5dc509c
[K/N] De-duplicate code for mangling objc interop function names
...
Extract the duplicated functionality to the
`ObjCFunctionNameMangleComputer` class.
2023-09-13 14:25:11 +00:00
Sergej Jaskiewicz
0fd4f10f6c
[K/N] Avoid magic strings in KonanMangler
2023-09-13 14:25:10 +00:00
Sergej Jaskiewicz
ddfd94b3b2
[K/N] Move KonanMangler to a new common module
...
^KT-61248 Fixed
2023-09-13 14:25:10 +00:00
Sergej Jaskiewicz
d1127f1a31
[K/N] Move IR-related ObjC interop helpers to a new common module
...
This is a step towards KT-61248. We need those helpers to be available
in non-Native-specific code.
2023-09-13 14:25:09 +00:00
Sergej Jaskiewicz
5cb252fe49
[descriptors] Move DeclarationDescriptor#findPackage helper to core
...
There is nothing serialization-specific about this function
2023-09-13 14:25:09 +00:00
Sergej Jaskiewicz
dff2d2ed60
[descriptors] Move some annotation-related utilities to the core module
...
- AnnotationDescriptor#argumentValue is not frontend-specific
- AnnotationDescriptor#getAnnotationStringValue is not Native-specific
We are going to need these functions in the IR code, so it makes
sense to factor them out to the core module.
2023-09-13 14:25:08 +00:00
Sergej Jaskiewicz
56cb0bf071
[utils] Move atMostOne to core/util.runtime
...
There is nothing backend-specific about this helper function.
2023-09-13 14:25:08 +00:00
Sergej Jaskiewicz
2727163a63
[test] Introduce DeserializedIrBackend backend kind
...
We have `BackendKinds.IrBackend` for IR emitted by the frontend.
We need a different backend kind for IR deserialized from klibs.
We cannot use `BackendKinds.IrBackend` for that purpose, because we
cannot have two different `IrBackendInput` subclasses with the same
kind.
We need a different `IrBackendInput` subclass for deserialized IR
because the `IrBackendInput` for frontend-emitted IR contains some
properties like `sourceFiles` which don't make sense for
deserialized IR.
Since we now have two backend kinds for IR artifacts, we need to make
certain functions and classes in the test infrastructure generic
over backend kinds.
Note: the JsIrDeserializedFromKlibBackendInput class is not used
anywhere yet. We will use it in the coming commits.
2023-07-28 11:19:21 +00:00
Sergej Jaskiewicz
f5a00c788a
[klib] Disable ManglerChecker on K2
...
`ManglerChecker` is a class that verifies that for each IR declaration
(except some, see its `needsChecking` property) its mangled name
(computed from IR) is the same as the mangled name computed from its
frontend representation — `DeclarationDescriptor` on K1 or
`FirDeclaration` on K2.
The way it does it is as follows.
On K1, `ManglerChecker` looks if the declaration has a true,
non-IR-based descriptor, it if it does, then it checks it
(see ManglerChecker.Companion#hasDescriptor).
On K2, since we don’t have any descriptors, `ManglerChecker` looks if
the declaration’s metadata property is `null` (because the corresponding
`FirDeclaration` is stored there). If it’s not, it checks it
(see ManglerChecker.Companion#hasMetadata).
The issue is that those two conditions are not equivalent.
When the Compose compiler plugin transforms an IR function, it copies
its `metadata` property (as it should, because `metadata` can contain
anything, not necessarily the frontend representation), but doesn't set
the descriptor. Because of that, on K1 that transformed function is
skipped in `ManglerChecker`, and on K2 it’s not.
The correct usage would be to properly distinguish which declarations
come from the FE as is, and which are transformed/synthesized,
and skip the latter. But it is unclear how to implement this.
For now, the easiest way to fix this on K2 is to not run ManglerChecker
at all.
KT-60648
^KT-59448 Fixed
2023-07-24 19:29:17 +00:00
Sergej Jaskiewicz
d77af3c43d
[IR] Remove unnecessary ReplaceWith from deprecated methods in IrFactory
...
ReplaceWith doesn't do anything when deprecation level is HIDDEN.
2023-07-24 17:42:45 +00:00
Sergej Jaskiewicz
8aa0b6a562
[IR] Automatically generate IrFactory interface
...
^KT-59308 Fixed
2023-07-24 17:42:45 +00:00
Sergej Jaskiewicz
c2a8d46867
[IR] Restore compatibility for IrFactory#createPropertyWithLateBinding
...
This is a follow-up to b4335c86c8 .
2023-07-24 17:42:45 +00:00
Sergej Jaskiewicz
b57b4e055e
[klib] Move some duplicated code from subclasses to IdSignatureBuilder
2023-07-24 16:40:15 +00:00
Sergej Jaskiewicz
ce6e904b70
[klib] Don't forget to set signatures' descriptions before serialization
...
Ensure that in IdSignatureBuilder hashId/hashIdAcc is only set
together with the description.
In 6142d75bb4 we implemented setting
descriptions when building signatures from descriptors, but forgot to
do the same for building signatures from IR, resulting in missing
descriptions in klibs.
See also: KT-59486
2023-07-24 16:40:14 +00:00
Sergej Jaskiewicz
f061215ee9
[IR] Reorder parameters in IrFactory#createFunctionWithLateBinding
...
This is to prepare for IrFactory auto-generation (KT-59308).
2023-07-21 13:12:37 +00:00
Sergej Jaskiewicz
3828552a1c
[IR] Make IrFunctionWithLateBinding a subclass of IrSimpleFunction
2023-07-21 13:12:37 +00:00
Sergej Jaskiewicz
c624bba8cd
[klib] Introduce the "ir_signature_versions" in klib manifests
...
^KT-60576 Fixed
2023-07-21 12:51:47 +00:00
Sergej Jaskiewicz
d16445aef2
[klib] Drop the addDebugInfo setting that was always true
2023-07-21 12:51:47 +00:00
Sergej Jaskiewicz
b4335c86c8
[IR] Add a new parameter to IrFactory#createPropertyWithLateBinding
...
This is to prepare for IrFactory auto-generation (KT-59308).
2023-07-20 19:58:47 +00:00
Sergej Jaskiewicz
212c10e674
[IR] Restore source compatibility for IrFactory methods
...
Previous commits:
c2fde1a915 ,
0b7db067e6 ,
0ae95b39c3 ,
f46761a241 ,
b1f7b5e982 ,
2b4a08524d ,
5b8b3644fc ,
7b77ec9930 ,
30cd2c3025 ,
9fcdc10019
have reordered parameters in IrFactory methods.
Restore and deprecate the original methods to
preserve source compatibility for compiler plugins.
KTIJ-26314
^KT-59772 Fixed
2023-07-20 09:36:05 +00:00
Sergej Jaskiewicz
e6c4a8957d
[IR] Make IrPropertyWithLateBinding a subclass of IrProperty
2023-07-18 10:19:27 +00:00
Sergej Jaskiewicz
5e63f7627f
[klib] Test signature descriptions in irText tests
...
KT-59486
2023-07-14 20:26:45 +00:00
Sergej Jaskiewicz
6142d75bb4
[klib] Serialized mangled names of declarations along with signatures
...
^KT-59486 Fixed
2023-07-14 20:26:45 +00:00
Sergej Jaskiewicz
10aa5fc7ef
[mangling] Add kdocs to some KotlinMangler methods
2023-07-14 20:26:45 +00:00
Sergej Jaskiewicz
341f61428b
[klib] Restore compatibility for IdSignature.CommonSignature constructor
...
^KT-59771 Fixed
2023-07-10 16:27:47 +00:00
Sergej Jaskiewicz
6281faa063
[IR] Move IrFactory#createBlockBody overloads to extension methods
...
This is to prepare for IrFactory auto-generation (KT-59308).
2023-07-04 15:19:28 +00:00
Sergej Jaskiewicz
9fcdc10019
[IR] Reorder parameters in IrFactory#createValueParameter
...
This is to prepare for IrFactory auto-generation (KT-59308).
2023-06-30 12:41:02 +00:00
Sergej Jaskiewicz
3f6420c5b9
[IR] Move IrFactory#createExpressionBody overloads to extension methods
...
This is to prepare for IrFactory auto-generation (KT-59308).
2023-06-30 11:06:09 +00:00
Sergej Jaskiewicz
f14a713e49
[mangling] Remove the unused fqnString method from KotlinMangler
2023-06-29 13:04:25 +00:00
Sergej Jaskiewicz
30cd2c3025
[IR] Reorder parameters in IrFactory#createProperty
...
This is to prepare for IrFactory auto-generation (KT-59308).
2023-06-28 13:21:55 +00:00
Sergej Jaskiewicz
7b77ec9930
[IR] Reorder parameters in IrFactory#createFunction
...
This is to prepare for IrFactory auto-generation (KT-59308).
2023-06-28 10:13:09 +00:00
Sergej Jaskiewicz
5b8b3644fc
[IR] Reorder parameters in IrFactory#createLocalDelegatedProperty
...
This is to prepare for IrFactory auto-generation (KT-59308).
2023-06-27 10:22:54 +00:00
Sergej Jaskiewicz and Alexander Udalov
addb048ce9
[FIR] Generate signatures for synthesized class delegation fields
...
This is to align the behavior with K1.
^KT-57754 Fixed
Co-authored-by: Alexander Udalov <alexander.udalov@jetbrains.com >
2023-06-26 12:39:37 +00:00
Sergej Jaskiewicz
1ac3355a41
[FIR] Don't mangle FirFields as properties
...
The correct way to mangle a field is to just use its name.
This is a step towards fixing KT-57754. It will be fixed in
the next commit.
2023-06-26 12:39:37 +00:00
Sergej Jaskiewicz
d73e44b89b
[FIR] Set metadata for IrFields generated from FirFields
...
This is useful for signature tests (see how
IrMangledNameAndSignatureDumpHandler uses `metadata` to retrieve
the original FIR declaration)
2023-06-26 12:39:37 +00:00
Sergej Jaskiewicz
2b4a08524d
[IR] Reorder parameters in IrFactory#createTypeParameter
...
This is to prepare for IrFactory auto-generation (KT-59308).
2023-06-26 09:52:11 +00:00
Sergej Jaskiewicz
b1f7b5e982
[IR] Reorder parameters in IrFactory#createTypeAlias
...
This is to prepare for IrFactory auto-generation (KT-59308).
2023-06-26 09:34:41 +00:00
Sergej Jaskiewicz
f46761a241
[IR] Reorder parameters in IrFactory#createClass
...
This is to prepare for IrFactory auto-generation (KT-59308).
2023-06-23 13:25:34 +00:00
Sergej Jaskiewicz
0ae95b39c3
[IR] Reorder parameters in IrFactory#createConstructor
...
This is to prepare for IrFactory auto-generation (KT-59308).
2023-06-22 16:31:17 +00:00
Sergej Jaskiewicz
0b7db067e6
[IR] Reorder parameters in IrFactory#createField
...
This is to prepare for IrFactory auto-generation (KT-59308).
2023-06-22 15:55:02 +00:00
Sergej Jaskiewicz
487847bedc
fixup! [IR] Add the description field to CommonIdSignature
2023-06-20 15:31:46 +00:00
Sergej Jaskiewicz
e0b8cf827a
fixup! [IR] Add the description field to CommonIdSignature
2023-06-20 15:31:46 +00:00
Sergej Jaskiewicz
3a30d74096
[IR] Add the description field to CommonIdSignature
...
This field shall be used for storing a human-readable representation
of the declaration, that would be a mangled name for now.
This field is not yet serialized. Serialization will be implemented in
follow-up commits.
See KT-59486
2023-06-20 15:31:45 +00:00
Sergej Jaskiewicz
c2fde1a915
[IR] Reorder parameters in IrFactory#createEnumEntry
...
This is to prepare for IrFactory auto-generation (KT-59308).
2023-06-20 14:12:58 +00:00
Sergej Jaskiewicz
fd094835a4
[test] Add the NATIVE backend to non-JVM check blocks in signature tests
...
(see KT-59204)
2023-06-16 10:01:54 +00:00
Sergej Jaskiewicz
6064012efa
[test] Print NATIVE for newly generated check blocks in signature tests
...
Since we know that in most cases signatures for JS and NATIVE are
the same, when running a signature test for the first time, let's print
`// CHECK JS NATIVE:` instead of `// CHECK JS:` or `// CHECK NATIVE:`.
^KT-59204 Fixed
2023-06-16 10:01:54 +00:00
Sergej Jaskiewicz
f2031ae642
[IR] Don't print multifile/synthetic facade class names in irText tests
...
This only applies to JVM and fq-names in declaration references
in IR dumps.
This enables us to run more irText tests on platforms other than JVM
(see KT-58605).
2023-06-05 10:40:17 +00:00
Sergej Jaskiewicz
5f59de23c5
[FIR] Fix computing mangled names for top-level functions and properties
...
^KT-57433 Fixed
2023-06-02 10:05:34 +00:00
Sergej Jaskiewicz
56b729f181
[test] Fix failing IR dump test
2023-06-01 13:22:01 +00:00
Sergej Jaskiewicz
fd76a34277
[IR] Don't print flags in declaration references in irText tests
...
This doesn't reduce the quality of tests, because the flags are still
printed for declarations themselves. We only omit them in references.
However, this makes the tests more compatible with non-JVM backends
(see KT-58605), because flags of referenced stdlib declarations may
differ among target platforms.
2023-05-30 17:26:30 +00:00
Sergej Jaskiewicz
28ead4118c
[test] Unmute a couple of irText tests that no longer fail on K2
2023-05-29 09:24:43 +00:00