JS BE: expose imported modules via $$importsForInline$$ property

... and use it as prefix to FQN in inline functions. This allows
to properly inline function declared in module A to module B,
when this function calls another function in module C.

See KT-18201
This commit is contained in:
Alexey Andreev
2017-05-31 17:49:25 +03:00
parent 978661c53d
commit 1df6f2f9a0
13 changed files with 346 additions and 50 deletions
@@ -349,25 +349,30 @@ class NameSuggestion {
val first = name.first().let { if (it.isES5IdentifierStart()) it else '_' }
return first.toString() + name.drop(1).map { if (it.isES5IdentifierPart()) it else '_' }.joinToString("")
}
// See ES 5.1 spec: https://www.ecma-international.org/ecma-262/5.1/#sec-7.6
private fun Char.isES5IdentifierStart() =
Character.isLetter(this) || // Lu | Ll | Lt | Lm | Lo
Character.getType(this).toByte() == Character.LETTER_NUMBER ||
// Nl which is missing in Character.isLetter, but present in UnicodeLetter in spec
this == '_' ||
this == '$'
private fun Char.isES5IdentifierPart() =
isES5IdentifierStart() ||
when (Character.getType(this).toByte()) {
Character.NON_SPACING_MARK,
Character.COMBINING_SPACING_MARK,
Character.DECIMAL_DIGIT_NUMBER,
Character.CONNECTOR_PUNCTUATION -> true
else -> false
} ||
this == '\u200C' || // Zero-width non-joiner
this == '\u200D' // Zero-width joiner
}
}
// See ES 5.1 spec: https://www.ecma-international.org/ecma-262/5.1/#sec-7.6
fun Char.isES5IdentifierStart() =
Character.isLetter(this) || // Lu | Ll | Lt | Lm | Lo
Character.getType(this).toByte() == Character.LETTER_NUMBER ||
// Nl which is missing in Character.isLetter, but present in UnicodeLetter in spec
this == '_' ||
this == '$'
fun Char.isES5IdentifierPart() =
isES5IdentifierStart() ||
when (Character.getType(this).toByte()) {
Character.NON_SPACING_MARK,
Character.COMBINING_SPACING_MARK,
Character.DECIMAL_DIGIT_NUMBER,
Character.CONNECTOR_PUNCTUATION -> true
else -> false
} ||
this == '\u200C' || // Zero-width non-joiner
this == '\u200D' // Zero-width joiner
fun String.isValidES5Identifier() =
isNotEmpty() &&
first().isES5IdentifierStart() &&
drop(1).all { it.isES5IdentifierPart() }