Compare commits
3 Commits
54d882ce89
...
f2b99fe23b
| Author | SHA1 | Date | |
|---|---|---|---|
| f2b99fe23b | |||
| e2a8de97f5 | |||
| 70d05f7987 |
@ -194,6 +194,8 @@ class BytecodeCompiler(
|
||||
}
|
||||
is BinaryOpRef -> compileBinary(ref) ?: compileEvalRef(ref)
|
||||
is UnaryOpRef -> compileUnary(ref)
|
||||
is LogicalAndRef -> compileEvalRef(ref)
|
||||
is LogicalOrRef -> compileEvalRef(ref)
|
||||
is AssignRef -> compileAssign(ref) ?: compileEvalRef(ref)
|
||||
is AssignOpRef -> compileAssignOp(ref) ?: compileEvalRef(ref)
|
||||
is AssignIfNullRef -> compileAssignIfNull(ref)
|
||||
@ -295,7 +297,12 @@ class BytecodeCompiler(
|
||||
builder.emit(Opcode.NEG_REAL, a.slot, out)
|
||||
CompiledValue(out, SlotType.REAL)
|
||||
}
|
||||
else -> null
|
||||
else -> {
|
||||
val obj = ensureObjSlot(a)
|
||||
val methodId = builder.addConst(BytecodeConst.StringVal("negate"))
|
||||
builder.emit(Opcode.CALL_VIRTUAL, obj.slot, methodId, 0, 0, out)
|
||||
CompiledValue(out, SlotType.OBJ)
|
||||
}
|
||||
}
|
||||
UnaryOp.NOT -> {
|
||||
when (a.type) {
|
||||
@ -307,18 +314,24 @@ class BytecodeCompiler(
|
||||
}
|
||||
SlotType.OBJ, SlotType.UNKNOWN -> {
|
||||
val obj = ensureObjSlot(a)
|
||||
val tmp = allocSlot()
|
||||
builder.emit(Opcode.OBJ_TO_BOOL, obj.slot, tmp)
|
||||
builder.emit(Opcode.NOT_BOOL, tmp, out)
|
||||
val methodId = builder.addConst(BytecodeConst.StringVal("logicalNot"))
|
||||
val tmpObj = allocSlot()
|
||||
builder.emit(Opcode.CALL_VIRTUAL, obj.slot, methodId, 0, 0, tmpObj)
|
||||
builder.emit(Opcode.OBJ_TO_BOOL, tmpObj, out)
|
||||
}
|
||||
else -> return null
|
||||
}
|
||||
CompiledValue(out, SlotType.BOOL)
|
||||
}
|
||||
UnaryOp.BITNOT -> {
|
||||
if (a.type != SlotType.INT) return null
|
||||
if (a.type == SlotType.INT) {
|
||||
builder.emit(Opcode.INV_INT, a.slot, out)
|
||||
CompiledValue(out, SlotType.INT)
|
||||
return CompiledValue(out, SlotType.INT)
|
||||
}
|
||||
val obj = ensureObjSlot(a)
|
||||
val methodId = builder.addConst(BytecodeConst.StringVal("bitNot"))
|
||||
builder.emit(Opcode.CALL_VIRTUAL, obj.slot, methodId, 0, 0, out)
|
||||
CompiledValue(out, SlotType.OBJ)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1372,16 +1385,25 @@ class BytecodeCompiler(
|
||||
}
|
||||
}
|
||||
SlotType.UNKNOWN -> {
|
||||
val oneSlot = allocSlot()
|
||||
val oneId = builder.addConst(BytecodeConst.ObjRef(ObjInt.One))
|
||||
builder.emit(Opcode.CONST_OBJ, oneId, oneSlot)
|
||||
val current = allocSlot()
|
||||
builder.emit(Opcode.BOX_OBJ, slot, current)
|
||||
if (wantResult && ref.isPost) {
|
||||
val old = allocSlot()
|
||||
builder.emit(Opcode.MOVE_INT, slot, old)
|
||||
builder.emit(if (ref.isIncrement) Opcode.INC_INT else Opcode.DEC_INT, slot)
|
||||
updateSlotType(slot, SlotType.INT)
|
||||
CompiledValue(old, SlotType.INT)
|
||||
val result = allocSlot()
|
||||
val op = if (ref.isIncrement) Opcode.ADD_OBJ else Opcode.SUB_OBJ
|
||||
builder.emit(op, current, oneSlot, result)
|
||||
builder.emit(Opcode.MOVE_OBJ, result, slot)
|
||||
updateSlotType(slot, SlotType.OBJ)
|
||||
CompiledValue(current, SlotType.OBJ)
|
||||
} else {
|
||||
builder.emit(if (ref.isIncrement) Opcode.INC_INT else Opcode.DEC_INT, slot)
|
||||
updateSlotType(slot, SlotType.INT)
|
||||
CompiledValue(slot, SlotType.INT)
|
||||
val result = allocSlot()
|
||||
val op = if (ref.isIncrement) Opcode.ADD_OBJ else Opcode.SUB_OBJ
|
||||
builder.emit(op, current, oneSlot, result)
|
||||
builder.emit(Opcode.MOVE_OBJ, result, slot)
|
||||
updateSlotType(slot, SlotType.OBJ)
|
||||
CompiledValue(result, SlotType.OBJ)
|
||||
}
|
||||
}
|
||||
else -> null
|
||||
|
||||
@ -27,7 +27,7 @@ import kotlin.test.assertEquals
|
||||
import kotlin.test.assertIs
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
@Ignore("TODO(bytecode-only): uses fallback")
|
||||
@Ignore("TODO(bytecode-only): uses fallback (try/catch)")
|
||||
class EmbeddingExceptionTest {
|
||||
|
||||
@Test
|
||||
|
||||
@ -26,7 +26,7 @@ import kotlin.test.Test
|
||||
import kotlin.test.assertFails
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
@Ignore("TODO(bytecode-only): uses fallback")
|
||||
@Ignore("TODO(bytecode-only): uses fallback (cast failure message)")
|
||||
class MIDiagnosticsTest {
|
||||
|
||||
@Test
|
||||
|
||||
@ -6,7 +6,6 @@ import kotlin.test.Ignore
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertFailsWith
|
||||
|
||||
@Ignore("TODO(bytecode-only): uses fallback")
|
||||
class ObjectExpressionTest {
|
||||
|
||||
@Test
|
||||
|
||||
@ -24,7 +24,6 @@ import net.sergeych.lyng.eval
|
||||
import kotlin.test.Ignore
|
||||
import kotlin.test.Test
|
||||
|
||||
@Ignore("TODO(bytecode-only): uses fallback")
|
||||
class ParallelLocalScopeTest {
|
||||
|
||||
@Test
|
||||
|
||||
@ -37,7 +37,7 @@ import kotlin.test.Test
|
||||
*
|
||||
*/
|
||||
|
||||
@Ignore("TODO(bytecode-only): uses fallback")
|
||||
@Ignore("TODO(bytecode-only): uses fallback (MI tests)")
|
||||
class TestInheritance {
|
||||
|
||||
@Test
|
||||
|
||||
@ -4,7 +4,6 @@ import kotlinx.coroutines.test.runTest
|
||||
import kotlin.test.Ignore
|
||||
import kotlin.test.Test
|
||||
|
||||
@Ignore("TODO(bytecode-only): uses fallback")
|
||||
class OperatorOverloadingTest {
|
||||
@Test
|
||||
fun testBinaryOverloading() = runTest {
|
||||
|
||||
@ -4,7 +4,6 @@ import kotlinx.coroutines.test.runTest
|
||||
import kotlin.test.Ignore
|
||||
import kotlin.test.Test
|
||||
|
||||
@Ignore("TODO(bytecode-only): uses fallback")
|
||||
class PropsTest {
|
||||
|
||||
@Test
|
||||
|
||||
@ -30,7 +30,6 @@ import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFalse
|
||||
import kotlin.test.assertNotNull
|
||||
|
||||
@Ignore("TODO(bytecode-only): uses fallback")
|
||||
class TransientTest {
|
||||
|
||||
@Test
|
||||
|
||||
@ -31,7 +31,7 @@ import kotlin.test.assertContentEquals
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
@Ignore("TODO(bytecode-only): uses fallback")
|
||||
@Ignore("TODO(bytecode-only): uses fallback (unary minus, MI, simple types)")
|
||||
class LynonTests {
|
||||
|
||||
@Test
|
||||
@ -794,5 +794,3 @@ class Wallet( id, ownerKey, balance=0, createdAt=Instant.now().truncateToSecond(
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -26,7 +26,6 @@ import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
@Ignore("TODO(bytecode-only): uses fallback")
|
||||
class PicInvalidationJvmTest {
|
||||
@Test
|
||||
fun fieldPicInvalidatesOnClassLayoutChange() = runBlocking {
|
||||
|
||||
@ -24,7 +24,6 @@ import kotlin.test.Ignore
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@Ignore("TODO(bytecode-only): uses fallback")
|
||||
class ScriptSubsetJvmTest {
|
||||
private suspend fun evalInt(code: String): Long = (Scope().eval(code) as ObjInt).value
|
||||
private suspend fun evalList(code: String): List<Any?> = (Scope().eval(code) as ObjList).list.map { (it as? ObjInt)?.value ?: it }
|
||||
|
||||
@ -28,7 +28,7 @@ import kotlin.test.assertEquals
|
||||
/**
|
||||
* JVM-only fast functional subset additions. Keep each test quick (< ~1s) and deterministic.
|
||||
*/
|
||||
@Ignore("TODO(bytecode-only): uses fallback")
|
||||
@Ignore("TODO(bytecode-only): uses fallback (when/try)")
|
||||
class ScriptSubsetJvmTest_Additions3 {
|
||||
private suspend fun evalInt(code: String): Long = (Scope().eval(code) as ObjInt).value
|
||||
private suspend fun evalBool(code: String): Boolean = (Scope().eval(code) as ObjBool).value
|
||||
|
||||
@ -29,7 +29,7 @@ import kotlin.test.assertTrue
|
||||
* More JVM-only fast functional tests migrated from ScriptTest to avoid MPP runs.
|
||||
* Keep each test fast (<1s) and deterministic.
|
||||
*/
|
||||
@Ignore("TODO(bytecode-only): uses fallback")
|
||||
@Ignore("TODO(bytecode-only): uses fallback (when/try/pooling)")
|
||||
class ScriptSubsetJvmTest_Additions4 {
|
||||
private suspend fun evalInt(code: String): Long = (Scope().eval(code) as ObjInt).value
|
||||
private suspend fun evalList(code: String): List<Any?> = (Scope().eval(code) as ObjList).list.map { (it as? ObjInt)?.value ?: it }
|
||||
|
||||
@ -28,7 +28,6 @@ import kotlin.test.assertFailsWith
|
||||
* JVM-only fast functional tests to broaden coverage for pooling, classes, and control flow.
|
||||
* Keep each test fast (<1s) and deterministic.
|
||||
*/
|
||||
@Ignore("TODO(bytecode-only): uses fallback")
|
||||
class ScriptSubsetJvmTest_Additions5 {
|
||||
private suspend fun evalInt(code: String): Long = (Scope().eval(code) as ObjInt).value
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ import kotlin.test.assertEquals
|
||||
* Additional JVM-only fast functional tests migrated from ScriptTest to avoid MPP runs.
|
||||
* Keep each test fast (<1s) and with clear assertions.
|
||||
*/
|
||||
@Ignore("TODO(bytecode-only): uses fallback")
|
||||
@Ignore("TODO(bytecode-only): uses fallback (logical ops/binarySearch)")
|
||||
class ScriptSubsetJvmTest_Additions {
|
||||
private suspend fun evalInt(code: String): Long = (Scope().eval(code) as ObjInt).value
|
||||
private suspend fun evalList(code: String): List<Any?> = (Scope().eval(code) as ObjList).list.map { (it as? ObjInt)?.value ?: it }
|
||||
|
||||
@ -24,7 +24,6 @@ import kotlin.test.assertFalse
|
||||
import kotlin.test.assertNotNull
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
@Ignore("TODO(bytecode-only): uses fallback")
|
||||
class CompletionEngineLightTest {
|
||||
|
||||
private fun names(items: List<CompletionItem>): List<String> = items.map { it.name }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user