2021-10-29 14:20:53 +00:00
|
|
|
package prog8tests.helpers
|
2021-07-30 15:39:43 +00:00
|
|
|
|
|
|
|
import prog8.ast.IBuiltinFunctions
|
2021-10-29 14:20:53 +00:00
|
|
|
import prog8.ast.base.DataType
|
2021-07-30 15:39:43 +00:00
|
|
|
import prog8.ast.base.Position
|
|
|
|
import prog8.ast.expressions.Expression
|
|
|
|
import prog8.ast.expressions.InferredTypes
|
2022-02-10 23:21:40 +00:00
|
|
|
import prog8.ast.expressions.NumericLiteral
|
2022-02-10 01:47:46 +00:00
|
|
|
import prog8.ast.statements.Block
|
2022-01-18 20:21:49 +00:00
|
|
|
import prog8.ast.statements.RegisterOrStatusflag
|
|
|
|
import prog8.ast.statements.Subroutine
|
2022-02-06 16:07:03 +00:00
|
|
|
import prog8.ast.statements.VarDecl
|
2022-01-18 20:21:49 +00:00
|
|
|
import prog8.compilerinterface.*
|
2021-07-30 15:39:43 +00:00
|
|
|
|
2022-02-06 21:56:17 +00:00
|
|
|
internal object DummyFunctions : IBuiltinFunctions {
|
2021-07-30 15:39:43 +00:00
|
|
|
override val names: Set<String> = emptySet()
|
|
|
|
override val purefunctionNames: Set<String> = emptySet()
|
|
|
|
override fun constValue(
|
|
|
|
name: String,
|
|
|
|
args: List<Expression>,
|
|
|
|
position: Position,
|
2022-02-10 23:21:40 +00:00
|
|
|
): NumericLiteral? = null
|
2021-07-30 15:39:43 +00:00
|
|
|
|
|
|
|
override fun returnType(name: String, args: MutableList<Expression>) = InferredTypes.InferredType.unknown()
|
2021-10-29 00:42:10 +00:00
|
|
|
}
|
2021-10-29 14:20:53 +00:00
|
|
|
|
2022-02-06 21:56:17 +00:00
|
|
|
internal object DummyMemsizer : IMemSizer {
|
2021-11-20 23:48:23 +00:00
|
|
|
override fun memorySize(dt: DataType) = 0
|
2022-02-06 16:07:03 +00:00
|
|
|
override fun memorySize(decl: VarDecl) = 0
|
2021-10-29 14:20:53 +00:00
|
|
|
}
|
2021-10-29 22:05:55 +00:00
|
|
|
|
2022-02-06 21:56:17 +00:00
|
|
|
internal object DummyStringEncoder : IStringEncoding {
|
2022-01-18 20:21:49 +00:00
|
|
|
override fun encodeString(str: String, encoding: Encoding): List<UByte> {
|
2021-10-29 22:05:55 +00:00
|
|
|
return emptyList()
|
|
|
|
}
|
|
|
|
|
2022-01-18 20:21:49 +00:00
|
|
|
override fun decodeString(bytes: List<UByte>, encoding: Encoding): String {
|
2021-10-29 22:05:55 +00:00
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
2021-12-04 17:20:22 +00:00
|
|
|
|
2022-02-06 21:56:17 +00:00
|
|
|
internal object AsciiStringEncoder : IStringEncoding {
|
2022-01-18 20:21:49 +00:00
|
|
|
override fun encodeString(str: String, encoding: Encoding): List<UByte> = str.map { it.code.toUByte() }
|
2021-12-04 17:20:22 +00:00
|
|
|
|
2022-01-18 20:21:49 +00:00
|
|
|
override fun decodeString(bytes: List<UByte>, encoding: Encoding): String {
|
2021-12-04 17:20:22 +00:00
|
|
|
return bytes.joinToString()
|
|
|
|
}
|
|
|
|
}
|
2022-01-18 20:21:49 +00:00
|
|
|
|
2022-02-06 21:56:17 +00:00
|
|
|
internal object DummyCompilationTarget : ICompilationTarget {
|
2022-01-18 20:21:49 +00:00
|
|
|
override val name: String = "dummy"
|
|
|
|
override val machine: IMachineDefinition
|
|
|
|
get() = throw NotImplementedError("dummy")
|
2022-02-15 00:39:12 +00:00
|
|
|
override val supportedEncodings = setOf(Encoding.PETSCII, Encoding.SCREENCODES, Encoding.ISO)
|
2022-02-21 22:38:53 +00:00
|
|
|
override val defaultEncoding = Encoding.PETSCII
|
|
|
|
override val defaultLauncherType = LauncherType.NONE
|
2022-01-18 20:21:49 +00:00
|
|
|
|
|
|
|
override fun encodeString(str: String, encoding: Encoding): List<UByte> {
|
|
|
|
throw NotImplementedError("dummy")
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun decodeString(bytes: List<UByte>, encoding: Encoding): String {
|
|
|
|
throw NotImplementedError("dummy")
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun asmsubArgsEvalOrder(sub: Subroutine): List<Int> {
|
|
|
|
throw NotImplementedError("dummy")
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun asmsubArgsHaveRegisterClobberRisk(args: List<Expression>,
|
|
|
|
paramRegisters: List<RegisterOrStatusflag>): Boolean {
|
|
|
|
throw NotImplementedError("dummy")
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun memorySize(dt: DataType): Int {
|
|
|
|
throw NotImplementedError("dummy")
|
|
|
|
}
|
2022-02-06 16:07:03 +00:00
|
|
|
|
|
|
|
override fun memorySize(decl: VarDecl): Int {
|
|
|
|
throw NotImplementedError("dummy")
|
|
|
|
}
|
2022-02-06 21:56:17 +00:00
|
|
|
}
|
2022-02-10 01:47:46 +00:00
|
|
|
|
|
|
|
internal object DummyVarsAndConsts : IVariablesAndConsts {
|
|
|
|
override val blockVars: Map<Block, Set<IVariablesAndConsts.StaticVariable>>
|
|
|
|
get() = throw NotImplementedError("dummy")
|
|
|
|
override val blockConsts: Map<Block, Set<IVariablesAndConsts.ConstantNumberSymbol>>
|
|
|
|
get() = throw NotImplementedError("dummy")
|
|
|
|
override val blockMemvars: Map<Block, Set<IVariablesAndConsts.MemoryMappedVariable>>
|
|
|
|
get() = throw NotImplementedError("dummy")
|
|
|
|
override val subroutineVars: Map<Subroutine, Set<IVariablesAndConsts.StaticVariable>>
|
|
|
|
get() = throw NotImplementedError("dummy")
|
|
|
|
override val subroutineConsts: Map<Subroutine, Set<IVariablesAndConsts.ConstantNumberSymbol>>
|
|
|
|
get() = throw NotImplementedError("dummy")
|
|
|
|
override val subroutineMemvars: Map<Subroutine, Set<IVariablesAndConsts.MemoryMappedVariable>>
|
|
|
|
get() = throw NotImplementedError("dummy")
|
|
|
|
|
|
|
|
override fun addIfUnknown(definingBlock: Block, variable: VarDecl) {
|
|
|
|
throw NotImplementedError("dummy")
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|