mirror of
https://github.com/GayPizzaSpecifications/pork.git
synced 2025-08-03 21:21:33 +00:00
global: a working virtual machine for some of the use cases. APIs and validation still WIP.
This commit is contained in:
@ -4,6 +4,13 @@ import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class Constant(val id: UInt, val tag: ConstantTag, val value: ByteArray) {
|
||||
fun readAsString(): String {
|
||||
if (tag != ConstantTag.String) {
|
||||
throw RuntimeException("Constant $id is not tagged as a string")
|
||||
}
|
||||
return String(value)
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
other as Constant
|
||||
|
@ -3,4 +3,6 @@ package gay.pizza.pork.bytecode
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class ConstantPool(val constants: List<Constant>)
|
||||
data class ConstantPool(val constants: List<Constant>) {
|
||||
fun read(index: UInt): Constant = constants[index.toInt()]
|
||||
}
|
||||
|
Reference in New Issue
Block a user