Skip to content
396 changes: 38 additions & 358 deletions be-js/src/commonMain/kotlin/lang/temper/be/js/JsBackend.kt

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion be-js/src/commonMain/kotlin/lang/temper/be/js/JsNames.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,19 @@ internal class JsNames {
}
}

fun jsNameNotThis(name: ResolvedName): JsIdentifierName {
fun jsNameNotThis(name: ResolvedName, cachePretty: Boolean = false): JsIdentifierName {
if (name in monitoredCalls) {
monitoredCalls[name] = monitoredCalls[name]!! + 1
}
return when (name) {
is ExportedName if name.comesFrom(origin) -> {
JsIdentifierName.escaped(name.baseName.nameText)
}
else if cachePretty -> {
JsIdentifierName.escaped(name.prefix()).also {
tmpLNameToJsName[name] = it
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use this for designing and remembering pretty type names, even for non-exported types, so connected code can reference them.

We'll want the same for unexported functions. I think we should change our naming so that all names go unsuffixed (but possibly _prefixed in some backends) whenever possible. I'm unsure how that relates to our general name selection strategy, but I think we really should do this not just for connected code but also to scare away fewer potential Temper users.

in localAliases -> localAliases.getValue(name)
in availableAliases -> {
val localName = unusedName(toSafePattern(name))
Expand Down
378 changes: 282 additions & 96 deletions be-js/src/commonMain/kotlin/lang/temper/be/js/JsTranslator.kt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ class DocJsTranslatorTest {

@Test
fun stringConcat() = assertGeneratedDocs(
"""
$$"""
|export let bar: String;
|;;;
|"foo ${'$'}{ bar }"
|"foo ${bar}"
""".trimMargin(),
want = """
want = $$"""
|// #region __BOILERPLATE__ {{{
|/** @type {string} */
|export let bar;
|// #endregion }}}
|`foo ${'$'}{ bar }`;
|`foo ${ bar }`;
""".trimMargin(),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got into this file when it was failing before exempting doc genre from internal modules. But I kept these cleanups even after repairing doc genre behavior.

)

Expand Down
Loading
Loading