mirror of
https://github.com/GayPizzaSpecifications/pork.git
synced 2025-08-03 21:21:33 +00:00
implement a new native call bytecode mechanism that can be optimized by the vm
This commit is contained in:
@ -11,6 +11,25 @@ data class Constant(val id: UInt, val tag: ConstantTag, val value: ByteArray) {
|
||||
return String(value)
|
||||
}
|
||||
|
||||
fun readAsNativeDefinition(): List<String> {
|
||||
val defs = mutableListOf<String>()
|
||||
val buffer = mutableListOf<Byte>()
|
||||
for (b in value) {
|
||||
if (b == 0.toByte()) {
|
||||
defs.add(String(buffer.toByteArray()))
|
||||
buffer.clear()
|
||||
continue
|
||||
}
|
||||
buffer.add(b)
|
||||
}
|
||||
|
||||
if (buffer.isNotEmpty()) {
|
||||
defs.add(String(buffer.toByteArray()))
|
||||
}
|
||||
|
||||
return defs
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
other as Constant
|
||||
|
@ -4,5 +4,6 @@ import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
enum class ConstantTag {
|
||||
String
|
||||
String,
|
||||
NativeDefinition,
|
||||
}
|
||||
|
Reference in New Issue
Block a user