Parent nodes may introduce some kind of context to their children. For example, type parameters.
Because of that we wrap all extension functions into MappingExtensions class.
ClassStubs are containers themselves. Thus we need to make metadata emitter recursive and:
1. Pass context from parent nodes to children.
2. Return result of translation from children back to parent.
1. Add `isMeta` to StubOrigin.ObjCClass and StubOrigin.ObjCProtocol. It allows to provide proper UniqId to corresponding ClassStubs.
2. Rename StubOrigin.None to StubOrigin.Synthetic because it is makes name self-explaining.
1. Add explicit primary constructor
2. Add constructor to the companion object
All these changes are required to make ClassStub translation to KmClass easier.
Public declaration's UniqId should have MSB == 1.
Despite we using our own mangling scheme we still need to respect this convention.
Otherwise IrLinker will go crazy searching for missing local declaration.
Mapping type aliases from stub ir to metadata is kinda tricky.
We need to preserve references to type alias declarations when translating
expanded types. The problem is that we translate C declarations and types independently.
In the most cases these processes are coherent. But not for type aliases to pointers to type aliases.
This commit fixes it.
Because metadata mode doesn't call compiler we need to
resolve dependencies (including stdlib) by hand. This logic was partially
implemented in `InteropCompiler.kt`. So we move it into `processCLib`.
To be able to reference external declarations from KLIBs we need to compute UniqId
for them. Thus we add InteropMangler that can compute mangle
(which in turn is used for UniqId) for declarations from NativeIndex.
* [watchOS] Add support of watch_arm64 target.
Since there is no support of `arm64_32` in LLVM 8
we compile bitcode that was generated for `watchos_arm32` to `arm64_32-apple-watchos`.
Issue:
SIGSEGV in Throwable.printStackTrace when terminating after ObjC alloc exception
Root-cause:
Corrupted kotlin.Throwable has been sent as ReportUnhandledException() parameter
Fix:
Use @FilterException which terminates correctly with objc_terminate
Linking two interop libraries containing the same declaration
causes a 'symbol multiply defined' error. This patch fixes it
by using FQ-names for wrapper functions.