Enable fast local refs behind compiler flag
This commit is contained in:
1 parent
f0dc0d2396
commit
541738646f
5 files changed
+127
-7
No files matched your search
@@ -16,8 +16,13 @@
|
||||
*/
|
||||
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import net.sergeych.lyng.Compiler
|
||||
import net.sergeych.lyng.Script
|
||||
import net.sergeych.lyng.Source
|
||||
import net.sergeych.lyng.eval
|
||||
import net.sergeych.lyng.obj.toInt
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class BytecodeRecentOpsTest {
|
||||
|
||||
@@ -154,4 +159,23 @@ class BytecodeRecentOpsTest {
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun fastLocalVarRefRead() = runTest {
|
||||
val code = """
|
||||
fun addOne(x) {
|
||||
val y = x + 1
|
||||
y
|
||||
}
|
||||
addOne(1)
|
||||
""".trimIndent()
|
||||
val script = Compiler.compileWithResolution(
|
||||
Source("<fast-local>", code),
|
||||
Script.defaultImportManager,
|
||||
useBytecodeStatements = true,
|
||||
useFastLocalRefs = true
|
||||
)
|
||||
val result = script.execute(Script.defaultImportManager.newStdScope())
|
||||
assertEquals(2, result.toInt())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user