mirror of
https://github.com/irmen/prog8.git
synced 2024-12-28 12:32:34 +00:00
68 lines
2.2 KiB
Kotlin
68 lines
2.2 KiB
Kotlin
package prog8tests.helpers
|
|
|
|
import prog8.ast.IBuiltinFunctions
|
|
import prog8.ast.expressions.Expression
|
|
import prog8.ast.expressions.InferredTypes
|
|
import prog8.ast.expressions.NumericLiteral
|
|
import prog8.code.core.*
|
|
import prog8.code.target.virtual.VirtualMachineDefinition
|
|
|
|
|
|
internal object DummyFunctions : IBuiltinFunctions {
|
|
override val names: Set<String> = emptySet()
|
|
override val purefunctionNames: Set<String> = emptySet()
|
|
override fun constValue(
|
|
funcName: String,
|
|
args: List<Expression>,
|
|
position: Position,
|
|
): NumericLiteral? = null
|
|
|
|
override fun returnType(funcName: String) = InferredTypes.InferredType.unknown()
|
|
}
|
|
|
|
internal object DummyMemsizer : IMemSizer {
|
|
override fun memorySize(dt: DataType) = 0
|
|
override fun memorySize(arrayDt: DataType, numElements: Int) = 0
|
|
}
|
|
|
|
internal object DummyStringEncoder : IStringEncoding {
|
|
override fun encodeString(str: String, encoding: Encoding): List<UByte> {
|
|
return emptyList()
|
|
}
|
|
|
|
override fun decodeString(bytes: Iterable<UByte>, encoding: Encoding): String {
|
|
return ""
|
|
}
|
|
}
|
|
|
|
internal object AsciiStringEncoder : IStringEncoding {
|
|
override fun encodeString(str: String, encoding: Encoding): List<UByte> = str.map { it.code.toUByte() }
|
|
|
|
override fun decodeString(bytes: Iterable<UByte>, encoding: Encoding): String {
|
|
return bytes.joinToString()
|
|
}
|
|
}
|
|
|
|
internal object DummyCompilationTarget : ICompilationTarget {
|
|
override val name: String = "dummy"
|
|
override val machine: IMachineDefinition = VirtualMachineDefinition() // not really true but I don't want to implement a full dummy machinedef
|
|
override val supportedEncodings = setOf(Encoding.PETSCII, Encoding.SCREENCODES, Encoding.ISO)
|
|
override val defaultEncoding = Encoding.PETSCII
|
|
|
|
override fun encodeString(str: String, encoding: Encoding): List<UByte> {
|
|
throw NotImplementedError("dummy")
|
|
}
|
|
|
|
override fun decodeString(bytes: Iterable<UByte>, encoding: Encoding): String {
|
|
throw NotImplementedError("dummy")
|
|
}
|
|
|
|
override fun memorySize(dt: DataType): Int {
|
|
throw NotImplementedError("dummy")
|
|
}
|
|
|
|
override fun memorySize(arrayDt: DataType, numElements: Int): Int {
|
|
throw NotImplementedError("dummy")
|
|
}
|
|
}
|