mirror of
https://github.com/irmen/prog8.git
synced 2024-12-24 01:29:28 +00:00
fix compiler crash
This commit is contained in:
parent
9633c0b07a
commit
81b3d2db4f
@ -78,8 +78,10 @@ internal class AstChecker(private val program: Program,
|
||||
if(!valueDt.isKnown) {
|
||||
errors.err("return value type mismatch or unknown symbol", returnStmt.value!!.position)
|
||||
} else {
|
||||
if (expectedReturnValues[0] != valueDt.getOr(DataType.UNDEFINED))
|
||||
errors.err("type $valueDt of return value doesn't match subroutine's return type ${expectedReturnValues[0]}", returnStmt.value!!.position)
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
super.visit(returnStmt)
|
||||
|
@ -51,6 +51,7 @@ fun getTempRegisterName(dt: InferredTypes.InferredType): List<String> {
|
||||
return when {
|
||||
// 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.BOOL -> listOf("cx16", "r9L")
|
||||
dt istype DataType.BYTE -> listOf("cx16", "r9sL")
|
||||
dt istype DataType.UWORD -> listOf("cx16", "r9")
|
||||
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) {
|
||||
is TypecastExpression -> InferredTypes.InferredType.known((parent as TypecastExpression).type)
|
||||
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")
|
||||
|
||||
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()
|
||||
if(arraySize==null)
|
||||
throw CannotEvaluateException("len", "arraysize unknown")
|
||||
|
@ -28,7 +28,7 @@ main {
|
||||
ubyte nextBlock
|
||||
ubyte speedlevel
|
||||
ubyte holding
|
||||
ubyte holdingAllowed
|
||||
bool holdingAllowed
|
||||
|
||||
|
||||
sub start() {
|
||||
@ -520,21 +520,21 @@ blocklogic {
|
||||
; The full play area is bordered by (in)visible characters that will collide.
|
||||
; Collision is determined by reading the screen data directly.
|
||||
|
||||
sub canRotateCW(ubyte xpos, ubyte ypos) -> ubyte {
|
||||
sub canRotateCW(ubyte xpos, ubyte ypos) -> bool {
|
||||
rotateCW()
|
||||
ubyte nocollision = noCollision(xpos, ypos)
|
||||
bool nocollision = noCollision(xpos, ypos)
|
||||
rotateCCW()
|
||||
return nocollision
|
||||
}
|
||||
|
||||
sub canRotateCCW(ubyte xpos, ubyte ypos) -> ubyte {
|
||||
sub canRotateCCW(ubyte xpos, ubyte ypos) -> bool {
|
||||
rotateCCW()
|
||||
ubyte nocollision = noCollision(xpos, ypos)
|
||||
bool nocollision = noCollision(xpos, ypos)
|
||||
rotateCW()
|
||||
return nocollision
|
||||
}
|
||||
|
||||
sub noCollision(ubyte xpos, ubyte ypos) -> ubyte {
|
||||
sub noCollision(ubyte xpos, ubyte ypos) -> bool {
|
||||
ubyte @zp i
|
||||
for i in 15 downto 0 {
|
||||
if currentBlock[i] and txt.getchr(xpos + (i&3), ypos+i/4)!=32
|
||||
@ -543,14 +543,14 @@ blocklogic {
|
||||
return true
|
||||
}
|
||||
|
||||
sub isGameOver(ubyte xpos, ubyte ypos) -> ubyte {
|
||||
sub isGameOver(ubyte xpos, ubyte ypos) -> bool {
|
||||
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)
|
||||
return result
|
||||
}
|
||||
|
||||
sub isLineFull(ubyte ypos) -> ubyte {
|
||||
sub isLineFull(ubyte ypos) -> bool {
|
||||
ubyte x
|
||||
for x in main.boardOffsetX to main.boardOffsetX+main.boardWidth-1 {
|
||||
if txt.getchr(x, ypos)==32
|
||||
|
Loading…
Reference in New Issue
Block a user