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

This commit is contained in:
alex committed 2025-03-18 19:57:27 -07:00
1 parent 10308eae5c
commit d2eaffafcc
8 files changed
+83 -38

No files matched your search

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