From 3da9404c2d8814da42ad34a9bfc3317929f8b257 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Fri, 29 Oct 2021 23:25:18 +0200 Subject: [PATCH] removed memsizer arg from all builtin functions --- .../codegen/assignment/AsmAssignment.kt | 2 +- codeGeneration/test/helpers/Dummies.kt | 3 +- compiler/src/prog8/compiler/Compiler.kt | 4 +- compiler/test/helpers/Dummies.kt | 3 +- compilerAst/src/prog8/ast/AstToplevel.kt | 2 +- .../src/prog8/ast/IBuiltinFunctions.kt | 3 +- .../prog8/ast/expressions/AstExpressions.kt | 4 +- compilerAst/src/prog8/compiler/IMemSizer.kt | 7 -- .../src/prog8/compilerinterface/IMemSizer.kt | 11 +++ compilerAst/test/helpers/Dummies.kt | 3 +- .../compilerinterface/BuiltinFunctions.kt | 88 +++++++++---------- .../compilerinterface/ICompilationTarget.kt | 2 - 12 files changed, 63 insertions(+), 69 deletions(-) delete mode 100644 compilerAst/src/prog8/compiler/IMemSizer.kt create mode 100644 compilerAst/src/prog8/compilerinterface/IMemSizer.kt diff --git a/codeGeneration/src/prog8/compiler/target/cpu6502/codegen/assignment/AsmAssignment.kt b/codeGeneration/src/prog8/compiler/target/cpu6502/codegen/assignment/AsmAssignment.kt index cf37b2f1d..50dab25eb 100644 --- a/codeGeneration/src/prog8/compiler/target/cpu6502/codegen/assignment/AsmAssignment.kt +++ b/codeGeneration/src/prog8/compiler/target/cpu6502/codegen/assignment/AsmAssignment.kt @@ -4,7 +4,7 @@ import prog8.ast.Program import prog8.ast.base.* import prog8.ast.expressions.* import prog8.ast.statements.* -import prog8.compiler.IMemSizer +import prog8.compilerinterface.IMemSizer import prog8.compiler.target.AssemblyError import prog8.compiler.target.cpu6502.codegen.AsmGen diff --git a/codeGeneration/test/helpers/Dummies.kt b/codeGeneration/test/helpers/Dummies.kt index 82b7553d1..abcf1f8fe 100644 --- a/codeGeneration/test/helpers/Dummies.kt +++ b/codeGeneration/test/helpers/Dummies.kt @@ -5,7 +5,7 @@ import prog8.ast.base.Position import prog8.ast.expressions.Expression import prog8.ast.expressions.InferredTypes import prog8.ast.expressions.NumericLiteralValue -import prog8.compiler.IMemSizer +import prog8.compilerinterface.IMemSizer import prog8.ast.base.DataType @@ -16,7 +16,6 @@ internal val DummyFunctions = object : IBuiltinFunctions { name: String, args: List, position: Position, - memsizer: IMemSizer ): NumericLiteralValue? = null override fun returnType(name: String, args: MutableList) = InferredTypes.InferredType.unknown() diff --git a/compiler/src/prog8/compiler/Compiler.kt b/compiler/src/prog8/compiler/Compiler.kt index 86b611d43..c09a9ef4f 100644 --- a/compiler/src/prog8/compiler/Compiler.kt +++ b/compiler/src/prog8/compiler/Compiler.kt @@ -125,13 +125,13 @@ private class BuiltinFunctionsFacade(functions: Map): IBuilt override val names = functions.keys override val purefunctionNames = functions.filter { it.value.pure }.map { it.key }.toSet() - override fun constValue(name: String, args: List, position: Position, memsizer: IMemSizer): NumericLiteralValue? { + override fun constValue(name: String, args: List, position: Position): NumericLiteralValue? { val func = BuiltinFunctions[name] if(func!=null) { val exprfunc = func.constExpressionFunc if(exprfunc!=null) { return try { - exprfunc(args, position, program, memsizer) + exprfunc(args, position, program) } catch(x: NotConstArgumentException) { // const-evaluating the builtin function call failed. null diff --git a/compiler/test/helpers/Dummies.kt b/compiler/test/helpers/Dummies.kt index 47b3411fa..c0209f950 100644 --- a/compiler/test/helpers/Dummies.kt +++ b/compiler/test/helpers/Dummies.kt @@ -6,7 +6,7 @@ import prog8.ast.base.Position import prog8.ast.expressions.Expression import prog8.ast.expressions.InferredTypes import prog8.ast.expressions.NumericLiteralValue -import prog8.compiler.IMemSizer +import prog8.compilerinterface.IMemSizer internal val DummyFunctions = object : IBuiltinFunctions { override val names: Set = emptySet() @@ -15,7 +15,6 @@ internal val DummyFunctions = object : IBuiltinFunctions { name: String, args: List, position: Position, - memsizer: IMemSizer ): NumericLiteralValue? = null override fun returnType(name: String, args: MutableList) = InferredTypes.InferredType.unknown() diff --git a/compilerAst/src/prog8/ast/AstToplevel.kt b/compilerAst/src/prog8/ast/AstToplevel.kt index ff7103278..91d97cab7 100644 --- a/compilerAst/src/prog8/ast/AstToplevel.kt +++ b/compilerAst/src/prog8/ast/AstToplevel.kt @@ -7,7 +7,7 @@ import prog8.ast.expressions.StringLiteralValue import prog8.ast.statements.* import prog8.ast.walk.AstWalker import prog8.ast.walk.IAstVisitor -import prog8.compiler.IMemSizer +import prog8.compilerinterface.IMemSizer import prog8.parser.SourceCode const val internedStringsModuleName = "prog8_interned_strings" diff --git a/compilerAst/src/prog8/ast/IBuiltinFunctions.kt b/compilerAst/src/prog8/ast/IBuiltinFunctions.kt index f4473a1d6..1e709bcb6 100644 --- a/compilerAst/src/prog8/ast/IBuiltinFunctions.kt +++ b/compilerAst/src/prog8/ast/IBuiltinFunctions.kt @@ -4,11 +4,10 @@ import prog8.ast.base.Position import prog8.ast.expressions.Expression import prog8.ast.expressions.InferredTypes import prog8.ast.expressions.NumericLiteralValue -import prog8.compiler.IMemSizer interface IBuiltinFunctions { val names: Set val purefunctionNames: Set - fun constValue(name: String, args: List, position: Position, memsizer: IMemSizer): NumericLiteralValue? + fun constValue(name: String, args: List, position: Position): NumericLiteralValue? fun returnType(name: String, args: MutableList): InferredTypes.InferredType } diff --git a/compilerAst/src/prog8/ast/expressions/AstExpressions.kt b/compilerAst/src/prog8/ast/expressions/AstExpressions.kt index c178c3b68..5a47e0665 100644 --- a/compilerAst/src/prog8/ast/expressions/AstExpressions.kt +++ b/compilerAst/src/prog8/ast/expressions/AstExpressions.kt @@ -6,7 +6,7 @@ import prog8.ast.base.* import prog8.ast.statements.* import prog8.ast.walk.AstWalker import prog8.ast.walk.IAstVisitor -import prog8.compiler.IMemSizer +import prog8.compilerinterface.IMemSizer import java.util.* @@ -816,7 +816,7 @@ class FunctionCall(override var target: IdentifierReference, // lenghts of arrays and strings are constants that are determined at compile time! if(target.nameInSource.size>1) return null - val resultValue: NumericLiteralValue? = program.builtinFunctions.constValue(target.nameInSource[0], args, position, program.memsizer) + val resultValue: NumericLiteralValue? = program.builtinFunctions.constValue(target.nameInSource[0], args, position) if(withDatatypeCheck) { val resultDt = this.inferType(program) if(resultValue==null || resultDt istype resultValue.type) diff --git a/compilerAst/src/prog8/compiler/IMemSizer.kt b/compilerAst/src/prog8/compiler/IMemSizer.kt deleted file mode 100644 index b0bf03dbf..000000000 --- a/compilerAst/src/prog8/compiler/IMemSizer.kt +++ /dev/null @@ -1,7 +0,0 @@ -package prog8.compiler - -import prog8.ast.base.DataType - -interface IMemSizer { - fun memorySize(dt: DataType): Int -} diff --git a/compilerAst/src/prog8/compilerinterface/IMemSizer.kt b/compilerAst/src/prog8/compilerinterface/IMemSizer.kt new file mode 100644 index 000000000..7a385d1f2 --- /dev/null +++ b/compilerAst/src/prog8/compilerinterface/IMemSizer.kt @@ -0,0 +1,11 @@ +package prog8.compilerinterface + +import prog8.ast.base.DataType + + +// note: this is a separate interface in the compilerAst module because +// otherwise a cyclic dependency with the compilerInterfaces module would be needed. + +interface IMemSizer { + fun memorySize(dt: DataType): Int +} diff --git a/compilerAst/test/helpers/Dummies.kt b/compilerAst/test/helpers/Dummies.kt index 42b76552a..b0e2148f5 100644 --- a/compilerAst/test/helpers/Dummies.kt +++ b/compilerAst/test/helpers/Dummies.kt @@ -6,7 +6,7 @@ import prog8.ast.base.Position import prog8.ast.expressions.Expression import prog8.ast.expressions.InferredTypes import prog8.ast.expressions.NumericLiteralValue -import prog8.compiler.IMemSizer +import prog8.compilerinterface.IMemSizer internal val DummyFunctions = object : IBuiltinFunctions { override val names: Set = emptySet() @@ -15,7 +15,6 @@ internal val DummyFunctions = object : IBuiltinFunctions { name: String, args: List, position: Position, - memsizer: IMemSizer ): NumericLiteralValue? = null override fun returnType(name: String, args: MutableList) = InferredTypes.InferredType.unknown() diff --git a/compilerInterfaces/src/prog8/compilerinterface/BuiltinFunctions.kt b/compilerInterfaces/src/prog8/compilerinterface/BuiltinFunctions.kt index 0ba58f914..9471e5fe3 100644 --- a/compilerInterfaces/src/prog8/compilerinterface/BuiltinFunctions.kt +++ b/compilerInterfaces/src/prog8/compilerinterface/BuiltinFunctions.kt @@ -4,14 +4,10 @@ import prog8.ast.Program import prog8.ast.base.* import prog8.ast.expressions.* import prog8.ast.statements.VarDecl -import prog8.compiler.IMemSizer import kotlin.math.* -class FParam(val name: String, val possibleDatatypes: Array) - - -typealias ConstExpressionCaller = (args: List, position: Position, program: Program, memsizer: IMemSizer) -> NumericLiteralValue +private typealias ConstExpressionCaller = (args: List, position: Position, program: Program) -> NumericLiteralValue class ReturnConvention(val dt: DataType, val reg: RegisterOrPair?, val floatFac1: Boolean) class ParamConvention(val dt: DataType, val reg: RegisterOrPair?, val variable: Boolean) @@ -34,6 +30,7 @@ class CallConvention(val params: List, val returns: ReturnConve } } +class FParam(val name: String, val possibleDatatypes: Array) class FSignature(val name: String, val pure: Boolean, // does it have side effects? @@ -99,39 +96,39 @@ private val functionSignatures: List = listOf( FSignature("reverse" , false, listOf(FParam("array", ArrayDatatypes)), null), FSignature("cmp" , false, listOf(FParam("value1", IntegerDatatypes), FParam("value2", NumericDatatypes)), null), // these few have a return value depending on the argument(s): - FSignature("max" , true, listOf(FParam("values", ArrayDatatypes)), null) { a, p, prg, ct -> collectionArg(a, p, prg, ::builtinMax) }, // type depends on args - FSignature("min" , true, listOf(FParam("values", ArrayDatatypes)), null) { a, p, prg, ct -> collectionArg(a, p, prg, ::builtinMin) }, // type depends on args - FSignature("sum" , true, listOf(FParam("values", ArrayDatatypes)), null) { a, p, prg, ct -> collectionArg(a, p, prg, ::builtinSum) }, // type depends on args + FSignature("max" , true, listOf(FParam("values", ArrayDatatypes)), null) { a, p, prg -> collectionArg(a, p, prg, ::builtinMax) }, // type depends on args + FSignature("min" , true, listOf(FParam("values", ArrayDatatypes)), null) { a, p, prg -> collectionArg(a, p, prg, ::builtinMin) }, // type depends on args + FSignature("sum" , true, listOf(FParam("values", ArrayDatatypes)), null) { a, p, prg -> collectionArg(a, p, prg, ::builtinSum) }, // type depends on args FSignature("abs" , true, listOf(FParam("value", NumericDatatypes)), null, ::builtinAbs), // type depends on argument FSignature("len" , true, listOf(FParam("values", IterableDatatypes)), null, ::builtinLen), // type is UBYTE or UWORD depending on actual length FSignature("sizeof" , true, listOf(FParam("object", DataType.values())), DataType.UBYTE, ::builtinSizeof), // normal functions follow: FSignature("sgn" , true, listOf(FParam("value", NumericDatatypes)), DataType.BYTE, ::builtinSgn ), - FSignature("sin" , true, listOf(FParam("rads", arrayOf(DataType.FLOAT))), DataType.FLOAT) { a, p, prg, ct -> oneDoubleArg(a, p, prg, Math::sin) }, + FSignature("sin" , true, listOf(FParam("rads", arrayOf(DataType.FLOAT))), DataType.FLOAT) { a, p, prg -> oneDoubleArg(a, p, prg, Math::sin) }, FSignature("sin8" , true, listOf(FParam("angle8", arrayOf(DataType.UBYTE))), DataType.BYTE, ::builtinSin8 ), FSignature("sin8u" , true, listOf(FParam("angle8", arrayOf(DataType.UBYTE))), DataType.UBYTE, ::builtinSin8u ), FSignature("sin16" , true, listOf(FParam("angle8", arrayOf(DataType.UBYTE))), DataType.WORD, ::builtinSin16 ), FSignature("sin16u" , true, listOf(FParam("angle8", arrayOf(DataType.UBYTE))), DataType.UWORD, ::builtinSin16u ), - FSignature("cos" , true, listOf(FParam("rads", arrayOf(DataType.FLOAT))), DataType.FLOAT) { a, p, prg, ct -> oneDoubleArg(a, p, prg, Math::cos) }, + FSignature("cos" , true, listOf(FParam("rads", arrayOf(DataType.FLOAT))), DataType.FLOAT) { a, p, prg -> oneDoubleArg(a, p, prg, Math::cos) }, FSignature("cos8" , true, listOf(FParam("angle8", arrayOf(DataType.UBYTE))), DataType.BYTE, ::builtinCos8 ), FSignature("cos8u" , true, listOf(FParam("angle8", arrayOf(DataType.UBYTE))), DataType.UBYTE, ::builtinCos8u ), FSignature("cos16" , true, listOf(FParam("angle8", arrayOf(DataType.UBYTE))), DataType.WORD, ::builtinCos16 ), FSignature("cos16u" , true, listOf(FParam("angle8", arrayOf(DataType.UBYTE))), DataType.UWORD, ::builtinCos16u ), - FSignature("tan" , true, listOf(FParam("rads", arrayOf(DataType.FLOAT))), DataType.FLOAT) { a, p, prg, ct -> oneDoubleArg(a, p, prg, Math::tan) }, - FSignature("atan" , true, listOf(FParam("rads", arrayOf(DataType.FLOAT))), DataType.FLOAT) { a, p, prg, ct -> oneDoubleArg(a, p, prg, Math::atan) }, - FSignature("ln" , true, listOf(FParam("value", arrayOf(DataType.FLOAT))), DataType.FLOAT) { a, p, prg, ct -> oneDoubleArg(a, p, prg, Math::log) }, - FSignature("log2" , true, listOf(FParam("value", arrayOf(DataType.FLOAT))), DataType.FLOAT) { a, p, prg, ct -> oneDoubleArg(a, p, prg, ::log2) }, - FSignature("sqrt16" , true, listOf(FParam("value", arrayOf(DataType.UWORD))), DataType.UBYTE) { a, p, prg, ct -> oneIntArgOutputInt(a, p, prg) { sqrt(it.toDouble()).toInt() } }, - FSignature("sqrt" , true, listOf(FParam("value", arrayOf(DataType.FLOAT))), DataType.FLOAT) { a, p, prg, ct -> oneDoubleArg(a, p, prg, Math::sqrt) }, - FSignature("rad" , true, listOf(FParam("value", arrayOf(DataType.FLOAT))), DataType.FLOAT) { a, p, prg, ct -> oneDoubleArg(a, p, prg, Math::toRadians) }, - FSignature("deg" , true, listOf(FParam("value", arrayOf(DataType.FLOAT))), DataType.FLOAT) { a, p, prg, ct -> oneDoubleArg(a, p, prg, Math::toDegrees) }, - FSignature("round" , true, listOf(FParam("value", arrayOf(DataType.FLOAT))), DataType.FLOAT) { a, p, prg, ct -> oneDoubleArgOutputWord(a, p, prg, Math::round) }, - FSignature("floor" , true, listOf(FParam("value", arrayOf(DataType.FLOAT))), DataType.FLOAT) { a, p, prg, ct -> oneDoubleArgOutputWord(a, p, prg, Math::floor) }, - FSignature("ceil" , true, listOf(FParam("value", arrayOf(DataType.FLOAT))), DataType.FLOAT) { a, p, prg, ct -> oneDoubleArgOutputWord(a, p, prg, Math::ceil) }, - FSignature("any" , true, listOf(FParam("values", ArrayDatatypes)), DataType.UBYTE) { a, p, prg, ct -> collectionArg(a, p, prg, ::builtinAny) }, - FSignature("all" , true, listOf(FParam("values", ArrayDatatypes)), DataType.UBYTE) { a, p, prg, ct -> collectionArg(a, p, prg, ::builtinAll) }, - FSignature("lsb" , true, listOf(FParam("value", arrayOf(DataType.UWORD, DataType.WORD))), DataType.UBYTE) { a, p, prg, ct -> oneIntArgOutputInt(a, p, prg) { x: Int -> x and 255 } }, - FSignature("msb" , true, listOf(FParam("value", arrayOf(DataType.UWORD, DataType.WORD))), DataType.UBYTE) { a, p, prg, ct -> oneIntArgOutputInt(a, p, prg) { x: Int -> x ushr 8 and 255} }, + FSignature("tan" , true, listOf(FParam("rads", arrayOf(DataType.FLOAT))), DataType.FLOAT) { a, p, prg -> oneDoubleArg(a, p, prg, Math::tan) }, + FSignature("atan" , true, listOf(FParam("rads", arrayOf(DataType.FLOAT))), DataType.FLOAT) { a, p, prg -> oneDoubleArg(a, p, prg, Math::atan) }, + FSignature("ln" , true, listOf(FParam("value", arrayOf(DataType.FLOAT))), DataType.FLOAT) { a, p, prg -> oneDoubleArg(a, p, prg, Math::log) }, + FSignature("log2" , true, listOf(FParam("value", arrayOf(DataType.FLOAT))), DataType.FLOAT) { a, p, prg -> oneDoubleArg(a, p, prg, ::log2) }, + FSignature("sqrt16" , true, listOf(FParam("value", arrayOf(DataType.UWORD))), DataType.UBYTE) { a, p, prg -> oneIntArgOutputInt(a, p, prg) { sqrt(it.toDouble()).toInt() } }, + FSignature("sqrt" , true, listOf(FParam("value", arrayOf(DataType.FLOAT))), DataType.FLOAT) { a, p, prg -> oneDoubleArg(a, p, prg, Math::sqrt) }, + FSignature("rad" , true, listOf(FParam("value", arrayOf(DataType.FLOAT))), DataType.FLOAT) { a, p, prg -> oneDoubleArg(a, p, prg, Math::toRadians) }, + FSignature("deg" , true, listOf(FParam("value", arrayOf(DataType.FLOAT))), DataType.FLOAT) { a, p, prg -> oneDoubleArg(a, p, prg, Math::toDegrees) }, + FSignature("round" , true, listOf(FParam("value", arrayOf(DataType.FLOAT))), DataType.FLOAT) { a, p, prg -> oneDoubleArgOutputWord(a, p, prg, Math::round) }, + FSignature("floor" , true, listOf(FParam("value", arrayOf(DataType.FLOAT))), DataType.FLOAT) { a, p, prg -> oneDoubleArgOutputWord(a, p, prg, Math::floor) }, + FSignature("ceil" , true, listOf(FParam("value", arrayOf(DataType.FLOAT))), DataType.FLOAT) { a, p, prg -> oneDoubleArgOutputWord(a, p, prg, Math::ceil) }, + FSignature("any" , true, listOf(FParam("values", ArrayDatatypes)), DataType.UBYTE) { a, p, prg -> collectionArg(a, p, prg, ::builtinAny) }, + FSignature("all" , true, listOf(FParam("values", ArrayDatatypes)), DataType.UBYTE) { a, p, prg -> collectionArg(a, p, prg, ::builtinAll) }, + FSignature("lsb" , true, listOf(FParam("value", arrayOf(DataType.UWORD, DataType.WORD))), DataType.UBYTE) { a, p, prg -> oneIntArgOutputInt(a, p, prg) { x: Int -> x and 255 } }, + FSignature("msb" , true, listOf(FParam("value", arrayOf(DataType.UWORD, DataType.WORD))), DataType.UBYTE) { a, p, prg -> oneIntArgOutputInt(a, p, prg) { x: Int -> x ushr 8 and 255} }, FSignature("mkword" , true, listOf(FParam("msb", arrayOf(DataType.UBYTE)), FParam("lsb", arrayOf(DataType.UBYTE))), DataType.UWORD, ::builtinMkword), FSignature("peek" , true, listOf(FParam("address", arrayOf(DataType.UWORD))), DataType.UBYTE), FSignature("peekw" , true, listOf(FParam("address", arrayOf(DataType.UWORD))), DataType.UWORD), @@ -150,16 +147,15 @@ private val functionSignatures: List = listOf( val BuiltinFunctions = functionSignatures.associateBy { it.name } -fun builtinMax(array: List): Number = array.maxByOrNull { it.toDouble() }!! +private fun builtinMax(array: List): Number = array.maxByOrNull { it.toDouble() }!! -fun builtinMin(array: List): Number = array.minByOrNull { it.toDouble() }!! +private fun builtinMin(array: List): Number = array.minByOrNull { it.toDouble() }!! -fun builtinSum(array: List): Number = array.sumOf { it.toDouble() } +private fun builtinSum(array: List): Number = array.sumOf { it.toDouble() } -fun builtinAny(array: List): Number = if(array.any { it.toDouble()!=0.0 }) 1 else 0 - -fun builtinAll(array: List): Number = if(array.all { it.toDouble()!=0.0 }) 1 else 0 +private fun builtinAny(array: List): Number = if(array.any { it.toDouble()!=0.0 }) 1 else 0 +private fun builtinAll(array: List): Number = if(array.all { it.toDouble()!=0.0 }) 1 else 0 fun builtinFunctionReturnType(function: String, args: List, program: Program): InferredTypes.InferredType { @@ -275,7 +271,7 @@ private fun collectionArg(args: List, position: Position, program: P } @Suppress("UNUSED_PARAMETER") -private fun builtinAbs(args: List, position: Position, program: Program, memsizer: IMemSizer): NumericLiteralValue { +private fun builtinAbs(args: List, position: Position, program: Program): NumericLiteralValue { // 1 arg, type = float or int, result type= isSameAs as argument type if(args.size!=1) throw SyntaxError("abs requires one numeric argument", position) @@ -288,7 +284,7 @@ private fun builtinAbs(args: List, position: Position, program: Prog } } -private fun builtinSizeof(args: List, position: Position, program: Program, memsizer: IMemSizer): NumericLiteralValue { +private fun builtinSizeof(args: List, position: Position, program: Program): NumericLiteralValue { // 1 arg, type = anything, result type = ubyte if(args.size!=1) throw SyntaxError("sizeof requires one argument", position) @@ -304,10 +300,10 @@ private fun builtinSizeof(args: List, position: Position, program: P dt.isArray -> { val length = (target as VarDecl).arraysize!!.constIndex() ?: throw CannotEvaluateException("sizeof", "unknown array size") val elementDt = ArrayToElementTypes.getValue(dt.getOr(DataType.UNDEFINED)) - numericLiteral(memsizer.memorySize(elementDt) * length, position) + numericLiteral(program.memsizer.memorySize(elementDt) * length, position) } dt istype DataType.STR -> throw SyntaxError("sizeof str is undefined, did you mean len?", position) - else -> NumericLiteralValue(DataType.UBYTE, memsizer.memorySize(dt.getOr(DataType.UNDEFINED)), position) + else -> NumericLiteralValue(DataType.UBYTE, program.memsizer.memorySize(dt.getOr(DataType.UNDEFINED)), position) } } else { throw SyntaxError("sizeof invalid argument type", position) @@ -315,7 +311,7 @@ private fun builtinSizeof(args: List, position: Position, program: P } @Suppress("UNUSED_PARAMETER") -private fun builtinLen(args: List, position: Position, program: Program, memsizer: IMemSizer): NumericLiteralValue { +private fun builtinLen(args: List, position: Position, program: Program): NumericLiteralValue { // note: in some cases the length is > 255, and then we have to return a UWORD type instead of a UBYTE. if(args.size!=1) throw SyntaxError("len requires one argument", position) @@ -349,7 +345,7 @@ private fun builtinLen(args: List, position: Position, program: Prog @Suppress("UNUSED_PARAMETER") -private fun builtinMkword(args: List, position: Position, program: Program, memsizer: IMemSizer): NumericLiteralValue { +private fun builtinMkword(args: List, position: Position, program: Program): NumericLiteralValue { if (args.size != 2) throw SyntaxError("mkword requires msb and lsb arguments", position) val constMsb = args[0].constValue(program) ?: throw NotConstArgumentException() @@ -359,7 +355,7 @@ private fun builtinMkword(args: List, position: Position, program: P } @Suppress("UNUSED_PARAMETER") -private fun builtinSin8(args: List, position: Position, program: Program, memsizer: IMemSizer): NumericLiteralValue { +private fun builtinSin8(args: List, position: Position, program: Program): NumericLiteralValue { if (args.size != 1) throw SyntaxError("sin8 requires one argument", position) val constval = args[0].constValue(program) ?: throw NotConstArgumentException() @@ -368,7 +364,7 @@ private fun builtinSin8(args: List, position: Position, program: Pro } @Suppress("UNUSED_PARAMETER") -private fun builtinSin8u(args: List, position: Position, program: Program, memsizer: IMemSizer): NumericLiteralValue { +private fun builtinSin8u(args: List, position: Position, program: Program): NumericLiteralValue { if (args.size != 1) throw SyntaxError("sin8u requires one argument", position) val constval = args[0].constValue(program) ?: throw NotConstArgumentException() @@ -377,7 +373,7 @@ private fun builtinSin8u(args: List, position: Position, program: Pr } @Suppress("UNUSED_PARAMETER") -private fun builtinCos8(args: List, position: Position, program: Program, memsizer: IMemSizer): NumericLiteralValue { +private fun builtinCos8(args: List, position: Position, program: Program): NumericLiteralValue { if (args.size != 1) throw SyntaxError("cos8 requires one argument", position) val constval = args[0].constValue(program) ?: throw NotConstArgumentException() @@ -386,7 +382,7 @@ private fun builtinCos8(args: List, position: Position, program: Pro } @Suppress("UNUSED_PARAMETER") -private fun builtinCos8u(args: List, position: Position, program: Program, memsizer: IMemSizer): NumericLiteralValue { +private fun builtinCos8u(args: List, position: Position, program: Program): NumericLiteralValue { if (args.size != 1) throw SyntaxError("cos8u requires one argument", position) val constval = args[0].constValue(program) ?: throw NotConstArgumentException() @@ -395,7 +391,7 @@ private fun builtinCos8u(args: List, position: Position, program: Pr } @Suppress("UNUSED_PARAMETER") -private fun builtinSin16(args: List, position: Position, program: Program, memsizer: IMemSizer): NumericLiteralValue { +private fun builtinSin16(args: List, position: Position, program: Program): NumericLiteralValue { if (args.size != 1) throw SyntaxError("sin16 requires one argument", position) val constval = args[0].constValue(program) ?: throw NotConstArgumentException() @@ -404,7 +400,7 @@ private fun builtinSin16(args: List, position: Position, program: Pr } @Suppress("UNUSED_PARAMETER") -private fun builtinSin16u(args: List, position: Position, program: Program, memsizer: IMemSizer): NumericLiteralValue { +private fun builtinSin16u(args: List, position: Position, program: Program): NumericLiteralValue { if (args.size != 1) throw SyntaxError("sin16u requires one argument", position) val constval = args[0].constValue(program) ?: throw NotConstArgumentException() @@ -413,7 +409,7 @@ private fun builtinSin16u(args: List, position: Position, program: P } @Suppress("UNUSED_PARAMETER") -private fun builtinCos16(args: List, position: Position, program: Program, memsizer: IMemSizer): NumericLiteralValue { +private fun builtinCos16(args: List, position: Position, program: Program): NumericLiteralValue { if (args.size != 1) throw SyntaxError("cos16 requires one argument", position) val constval = args[0].constValue(program) ?: throw NotConstArgumentException() @@ -422,7 +418,7 @@ private fun builtinCos16(args: List, position: Position, program: Pr } @Suppress("UNUSED_PARAMETER") -private fun builtinCos16u(args: List, position: Position, program: Program, memsizer: IMemSizer): NumericLiteralValue { +private fun builtinCos16u(args: List, position: Position, program: Program): NumericLiteralValue { if (args.size != 1) throw SyntaxError("cos16u requires one argument", position) val constval = args[0].constValue(program) ?: throw NotConstArgumentException() @@ -431,7 +427,7 @@ private fun builtinCos16u(args: List, position: Position, program: P } @Suppress("UNUSED_PARAMETER") -private fun builtinSgn(args: List, position: Position, program: Program, memsizer: IMemSizer): NumericLiteralValue { +private fun builtinSgn(args: List, position: Position, program: Program): NumericLiteralValue { if (args.size != 1) throw SyntaxError("sgn requires one argument", position) val constval = args[0].constValue(program) ?: throw NotConstArgumentException() diff --git a/compilerInterfaces/src/prog8/compilerinterface/ICompilationTarget.kt b/compilerInterfaces/src/prog8/compilerinterface/ICompilationTarget.kt index 496ac65ab..f6a782c3b 100644 --- a/compilerInterfaces/src/prog8/compilerinterface/ICompilationTarget.kt +++ b/compilerInterfaces/src/prog8/compilerinterface/ICompilationTarget.kt @@ -1,7 +1,5 @@ package prog8.compilerinterface -import prog8.compiler.IMemSizer - interface ICompilationTarget: IStringEncoding, IMemSizer { val name: String val machine: IMachineDefinition