mirror of
https://github.com/irmen/prog8.git
synced 2026-10-22 05:02:58 +00:00
fix m68k long/string arrays
This commit is contained in:
1 parent
f498f598bf
commit
f10a58ee1b
5 files changed
+17
-9
No files matched your search
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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 !
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user