diff --git a/codeCore/src/prog8/code/core/DataTypes.kt b/codeCore/src/prog8/code/core/DataTypes.kt index 00e89f6ce..1616116e9 100644 --- a/codeCore/src/prog8/code/core/DataTypes.kt +++ b/codeCore/src/prog8/code/core/DataTypes.kt @@ -191,7 +191,10 @@ class DataType private constructor( require(!elementDt.isPointer) { "use other array constructor for arrays of pointers" } // TODO: on 32-bit targets (m68k), str arrays should be arrays of LONG (4-byte pointers), // but this requires systematically handling str as a 4-byte type across the entire compiler. - val actualElementDt = if(elementDt==BaseDataType.STR) BaseDataType.UWORD else elementDt + val actualElementDt = if(elementDt==BaseDataType.STR) { + val target = memsizer as? ICompilationTarget + if(target != null && target.POINTER_MEM_SIZE > 2u) BaseDataType.LONG else BaseDataType.UWORD + } else elementDt if(actualElementDt.isNumericOrBool) return DataType(BaseDataType.ARRAY, actualElementDt, null) else diff --git a/compiler/src/prog8/compiler/astprocessing/M68kAstChecker.kt b/compiler/src/prog8/compiler/astprocessing/M68kAstChecker.kt index e5238dcf4..d444d42b7 100644 --- a/compiler/src/prog8/compiler/astprocessing/M68kAstChecker.kt +++ b/compiler/src/prog8/compiler/astprocessing/M68kAstChecker.kt @@ -77,7 +77,7 @@ internal class M68kAstChecker(private val errors: IErrorReporter) : IAstVisitor ZeropageWish.DONTCARE -> {} } if (decl.splitwordarray == SplitWish.NOSPLIT) { - errors.info("@nosplit is redundant on the m68k target", decl.position) + errors.info("@nosplit is redundant here", decl.position) } if (decl.datatype.isSplitWordArray && decl.splitwordarray != SplitWish.DONTCARE) { errors.err("split word arrays are not supported on the m68k target", decl.position) diff --git a/compiler/src/prog8/compiler/astprocessing/VariousCleanups.kt b/compiler/src/prog8/compiler/astprocessing/VariousCleanups.kt index 5ed61e78b..6342fcf19 100644 --- a/compiler/src/prog8/compiler/astprocessing/VariousCleanups.kt +++ b/compiler/src/prog8/compiler/astprocessing/VariousCleanups.kt @@ -82,8 +82,13 @@ internal class VariousCleanups(val program: Program, val errors: IErrorReporter, // check splitting of word arrays if(decl.splitwordarray != SplitWish.DONTCARE && !decl.datatype.isWordArray && !decl.datatype.isPointerArray) { - if(decl.origin != VarDeclOrigin.ARRAYLITERAL) - errors.err("@nosplit is for word or pointer arrays only", decl.position) + if(decl.origin != VarDeclOrigin.ARRAYLITERAL) { + if(decl.datatype.isLongArray) { + errors.info("@nosplit is redundant here", decl.position) + } + else + errors.err("@nosplit is for word or pointer arrays only", decl.position) + } } if(decl.datatype.isWordArray) { diff --git a/compilerAst/src/prog8/ast/expressions/AstExpressions.kt b/compilerAst/src/prog8/ast/expressions/AstExpressions.kt index 4e60e1463..edb42ec0f 100644 --- a/compilerAst/src/prog8/ast/expressions/AstExpressions.kt +++ b/compilerAst/src/prog8/ast/expressions/AstExpressions.kt @@ -1284,8 +1284,8 @@ class ArrayLiteral(val type: InferredTypes.InferredType, // inferred because } return when { dts.any { it.isFloat } -> InferredTypes.knownFor(DataType.arrayFor(BaseDataType.FLOAT, program.target)) - // TODO: on 32-bit targets (m68k), str arrays should be arrays of LONG (4-byte pointers) - dts.any { it.isString } -> InferredTypes.knownFor(DataType.arrayFor(BaseDataType.UWORD, program.target)) + dts.any { it.isString } -> InferredTypes.knownFor(DataType.arrayFor(BaseDataType.STR, program.target)) + dts.any { it.isLong } -> InferredTypes.knownFor(DataType.arrayFor(BaseDataType.LONG, program.target)) dts.any { it.isSignedWord } -> InferredTypes.knownFor(DataType.arrayFor(BaseDataType.WORD, program.target)) dts.any { it.isUnsignedWord } -> InferredTypes.knownFor(DataType.arrayFor(BaseDataType.UWORD, program.target)) dts.any { it.isSignedByte } -> InferredTypes.knownFor(DataType.arrayFor(BaseDataType.BYTE, program.target)) diff --git a/examples/m68k/textelite.p8 b/examples/m68k/textelite.p8 index bf46450c7..72bdaf743 100644 --- a/examples/m68k/textelite.p8 +++ b/examples/m68k/textelite.p8 @@ -954,15 +954,15 @@ planet { txt.chrout(strings.upperchar(c)) } - sub getword(ubyte listnum, ubyte wordidx) -> uword { + sub getword(ubyte listnum, ubyte wordidx) -> pointer { if sys.SIZEOF_POINTER==4 { ; on 32-bit targets, the array stores flat 4-byte pointers long wordlist_base = &wordlists long addr = peekl(wordlist_base + (listnum-$81) * 4) - return peekw(addr + wordidx*2) + return peekl(addr + wordidx*4) as pointer } else { uword list = wordlists[listnum-$81] - return peekw(list + wordidx*2) ; this depends on the word list itself to be @nosplit ! + return peekw(list + wordidx*2) as pointer ; this depends on the word list itself to be @nosplit ! } } }