Skip to content

Commit

Permalink
✅ Pass static test
Browse files Browse the repository at this point in the history
  • Loading branch information
yhs0602 committed May 14, 2024
1 parent 5485d94 commit 471591c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/kotlin/vm/instruction/IfInstruction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ class IfEqz(pc: Int, code: CodeItem) : Instruction._21t(pc, code) {
return pc + insnLength // Always false
}

is RegisterValue.StringRef -> {
return pc + insnLength // Always false
}

else -> {
memory.exception = ExceptionValue("IfEqz: Not an integer or object reference")
return pc + insnLength
Expand Down Expand Up @@ -227,6 +231,10 @@ class IfNez(pc: Int, code: CodeItem) : Instruction._21t(pc, code) {
return pc + offset
}

is RegisterValue.StringRef -> {
return pc + offset
}

else -> {
memory.exception = ExceptionValue("IfNez: Not an integer or object reference")
return pc + insnLength
Expand Down
2 changes: 2 additions & 0 deletions src/test/kotlin/AdvancedTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import com.yhs0602.vm.Environment
import com.yhs0602.vm.GeneralMockedClass
import com.yhs0602.vm.RegisterValue
import com.yhs0602.vm.executeMethod
import java.io.PrintStream
import java.nio.file.Paths
import kotlin.jvm.internal.Intrinsics
import kotlin.test.BeforeTest
Expand Down Expand Up @@ -80,6 +81,7 @@ class AdvancedTest {
GeneralMockedClass(System::class.java),
GeneralMockedClass(Intrinsics::class.java),
GeneralMockedClass(Object::class.java),
GeneralMockedClass(PrintStream::class.java)
)
)
}
Expand Down

0 comments on commit 471591c

Please sign in to comment.