implement a new native call bytecode mechanism that can be optimized by the vm

This commit is contained in:
Alex Zenla
2025-03-18 19:57:27 -07:00
parent 10308eae5c
commit d2eaffafcc
8 changed files with 83 additions and 38 deletions

View File

@ -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

View File

@ -4,5 +4,6 @@ import kotlinx.serialization.Serializable
@Serializable
enum class ConstantTag {
String
String,
NativeDefinition,
}