Added StringTrimLowering to pipeline (#4647)
This commit is contained in:
committed by
Nikolay Krasko
parent
73297a4ef3
commit
71f44dce0f
+6
@@ -379,4 +379,10 @@ internal val foldConstantLoweringPhase = makeKonanFileOpPhase(
|
||||
name = "FoldConstantLowering",
|
||||
description = "Constant Folding",
|
||||
prerequisite = setOf(flattenStringConcatenationPhase)
|
||||
)
|
||||
|
||||
internal val computeStringTrimPhase = makeKonanFileLoweringPhase(
|
||||
::StringTrimLowering,
|
||||
name = "StringTrimLowering",
|
||||
description = "Compute trimIndent and trimMargin operations on constant strings"
|
||||
)
|
||||
+1
@@ -221,6 +221,7 @@ internal val allLoweringsPhase = NamedCompilerPhase(
|
||||
forLoopsPhase,
|
||||
flattenStringConcatenationPhase,
|
||||
foldConstantLoweringPhase,
|
||||
computeStringTrimPhase,
|
||||
stringConcatenationPhase,
|
||||
enumConstructorsPhase,
|
||||
initializersPhase,
|
||||
|
||||
@@ -813,6 +813,10 @@ task hello0(type: KonanLocalTest) {
|
||||
source = "runtime/basic/hello0.kt"
|
||||
}
|
||||
|
||||
task stringTrim(type: KonanLocalTest) {
|
||||
source = "codegen/stringTrim/stringTrim.kt"
|
||||
}
|
||||
|
||||
standaloneTest("hello1") {
|
||||
goldValue = "Hello World"
|
||||
testData = "Hello World\n"
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.stringTrim.stringTrim
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// TODO: check IR
|
||||
fun constantIndent(): String {
|
||||
return """
|
||||
Hello,
|
||||
World
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
fun constantMargin(): String {
|
||||
return """
|
||||
|Hello,
|
||||
|World
|
||||
""".trimMargin()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun runTest() {
|
||||
assertTrue(constantIndent() === constantIndent())
|
||||
assertTrue(constantMargin() === constantMargin())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user