mirror of
https://github.com/irmen/prog8.git
synced 2024-11-25 19:31:36 +00:00
fix compiler crash
This commit is contained in:
parent
9633c0b07a
commit
81b3d2db4f
@ -78,10 +78,12 @@ internal class AstChecker(private val program: Program,
|
|||||||
if(!valueDt.isKnown) {
|
if(!valueDt.isKnown) {
|
||||||
errors.err("return value type mismatch or unknown symbol", returnStmt.value!!.position)
|
errors.err("return value type mismatch or unknown symbol", returnStmt.value!!.position)
|
||||||
} else {
|
} else {
|
||||||
if (expectedReturnValues[0] != valueDt.getOr(DataType.UNDEFINED))
|
if (expectedReturnValues[0] != valueDt.getOr(DataType.UNDEFINED)) {
|
||||||
|
if(expectedReturnValues[0] != DataType.BOOL || valueDt.isnot(DataType.UBYTE))
|
||||||
errors.err("type $valueDt of return value doesn't match subroutine's return type ${expectedReturnValues[0]}",returnStmt.value!!.position)
|
errors.err("type $valueDt of return value doesn't match subroutine's return type ${expectedReturnValues[0]}",returnStmt.value!!.position)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
super.visit(returnStmt)
|
super.visit(returnStmt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ fun getTempRegisterName(dt: InferredTypes.InferredType): List<String> {
|
|||||||
return when {
|
return when {
|
||||||
// TODO assume (hope) cx16.r9 isn't used for anything else during the use of this temporary variable...
|
// TODO assume (hope) cx16.r9 isn't used for anything else during the use of this temporary variable...
|
||||||
dt istype DataType.UBYTE -> listOf("cx16", "r9L")
|
dt istype DataType.UBYTE -> listOf("cx16", "r9L")
|
||||||
|
dt istype DataType.BOOL -> listOf("cx16", "r9L")
|
||||||
dt istype DataType.BYTE -> listOf("cx16", "r9sL")
|
dt istype DataType.BYTE -> listOf("cx16", "r9sL")
|
||||||
dt istype DataType.UWORD -> listOf("cx16", "r9")
|
dt istype DataType.UWORD -> listOf("cx16", "r9")
|
||||||
dt istype DataType.WORD -> listOf("cx16", "r9s")
|
dt istype DataType.WORD -> listOf("cx16", "r9s")
|
||||||
|
@ -191,7 +191,7 @@ class BinaryExpression(var left: Expression, var operator: String, var right: Ex
|
|||||||
return when (parent) {
|
return when (parent) {
|
||||||
is TypecastExpression -> InferredTypes.InferredType.known((parent as TypecastExpression).type)
|
is TypecastExpression -> InferredTypes.InferredType.known((parent as TypecastExpression).type)
|
||||||
is Assignment -> (parent as Assignment).target.inferType(program)
|
is Assignment -> (parent as Assignment).target.inferType(program)
|
||||||
else -> InferredTypes.InferredType.known(DataType.UBYTE) // note: don't use BOOL type here to avoid type errors later! Will be replaced anyway.
|
else -> InferredTypes.InferredType.known(DataType.BOOL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ private fun builtinLen(args: List<Expression>, position: Position, program: Prog
|
|||||||
?: throw CannotEvaluateException("len", "no target vardecl")
|
?: throw CannotEvaluateException("len", "no target vardecl")
|
||||||
|
|
||||||
return when(target.datatype) {
|
return when(target.datatype) {
|
||||||
DataType.ARRAY_UB, DataType.ARRAY_B, DataType.ARRAY_UW, DataType.ARRAY_W, DataType.ARRAY_F -> {
|
in ArrayDatatypes -> {
|
||||||
arraySize = target.arraysize?.constIndex()
|
arraySize = target.arraysize?.constIndex()
|
||||||
if(arraySize==null)
|
if(arraySize==null)
|
||||||
throw CannotEvaluateException("len", "arraysize unknown")
|
throw CannotEvaluateException("len", "arraysize unknown")
|
||||||
|
@ -28,7 +28,7 @@ main {
|
|||||||
ubyte nextBlock
|
ubyte nextBlock
|
||||||
ubyte speedlevel
|
ubyte speedlevel
|
||||||
ubyte holding
|
ubyte holding
|
||||||
ubyte holdingAllowed
|
bool holdingAllowed
|
||||||
|
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
@ -520,21 +520,21 @@ blocklogic {
|
|||||||
; The full play area is bordered by (in)visible characters that will collide.
|
; The full play area is bordered by (in)visible characters that will collide.
|
||||||
; Collision is determined by reading the screen data directly.
|
; Collision is determined by reading the screen data directly.
|
||||||
|
|
||||||
sub canRotateCW(ubyte xpos, ubyte ypos) -> ubyte {
|
sub canRotateCW(ubyte xpos, ubyte ypos) -> bool {
|
||||||
rotateCW()
|
rotateCW()
|
||||||
ubyte nocollision = noCollision(xpos, ypos)
|
bool nocollision = noCollision(xpos, ypos)
|
||||||
rotateCCW()
|
rotateCCW()
|
||||||
return nocollision
|
return nocollision
|
||||||
}
|
}
|
||||||
|
|
||||||
sub canRotateCCW(ubyte xpos, ubyte ypos) -> ubyte {
|
sub canRotateCCW(ubyte xpos, ubyte ypos) -> bool {
|
||||||
rotateCCW()
|
rotateCCW()
|
||||||
ubyte nocollision = noCollision(xpos, ypos)
|
bool nocollision = noCollision(xpos, ypos)
|
||||||
rotateCW()
|
rotateCW()
|
||||||
return nocollision
|
return nocollision
|
||||||
}
|
}
|
||||||
|
|
||||||
sub noCollision(ubyte xpos, ubyte ypos) -> ubyte {
|
sub noCollision(ubyte xpos, ubyte ypos) -> bool {
|
||||||
ubyte @zp i
|
ubyte @zp i
|
||||||
for i in 15 downto 0 {
|
for i in 15 downto 0 {
|
||||||
if currentBlock[i] and txt.getchr(xpos + (i&3), ypos+i/4)!=32
|
if currentBlock[i] and txt.getchr(xpos + (i&3), ypos+i/4)!=32
|
||||||
@ -543,14 +543,14 @@ blocklogic {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
sub isGameOver(ubyte xpos, ubyte ypos) -> ubyte {
|
sub isGameOver(ubyte xpos, ubyte ypos) -> bool {
|
||||||
main.drawBlock(xpos, ypos, 32)
|
main.drawBlock(xpos, ypos, 32)
|
||||||
ubyte result = ypos==main.startYpos and not noCollision(xpos, ypos+1)
|
bool result = ypos==main.startYpos and not noCollision(xpos, ypos+1)
|
||||||
main.drawBlock(xpos, ypos, 160)
|
main.drawBlock(xpos, ypos, 160)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
sub isLineFull(ubyte ypos) -> ubyte {
|
sub isLineFull(ubyte ypos) -> bool {
|
||||||
ubyte x
|
ubyte x
|
||||||
for x in main.boardOffsetX to main.boardOffsetX+main.boardWidth-1 {
|
for x in main.boardOffsetX to main.boardOffsetX+main.boardWidth-1 {
|
||||||
if txt.getchr(x, ypos)==32
|
if txt.getchr(x, ypos)==32
|
||||||
|
Loading…
Reference in New Issue
Block a user