mirror of
https://github.com/irmen/prog8.git
synced 2024-11-29 17:50:35 +00:00
error message for too large repeat iteration count
This commit is contained in:
parent
8f224afed9
commit
38a6c6a866
@ -365,6 +365,13 @@ internal class AstChecker(private val program: Program,
|
|||||||
super.visit(whileLoop)
|
super.visit(whileLoop)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun visit(repeatLoop: RepeatLoop) {
|
||||||
|
val iterations = repeatLoop.iterations?.constValue(program)
|
||||||
|
if(iterations != null && iterations.number.toInt() > 65535)
|
||||||
|
errors.err("repeat cannot go over 65535 iterations", iterations.position)
|
||||||
|
super.visit(repeatLoop)
|
||||||
|
}
|
||||||
|
|
||||||
override fun visit(assignment: Assignment) {
|
override fun visit(assignment: Assignment) {
|
||||||
if(assignment.value is FunctionCall) {
|
if(assignment.value is FunctionCall) {
|
||||||
val stmt = (assignment.value as FunctionCall).target.targetStatement(program.namespace)
|
val stmt = (assignment.value as FunctionCall).target.targetStatement(program.namespace)
|
||||||
|
@ -910,7 +910,7 @@ internal class AsmGen(private val program: Program,
|
|||||||
}
|
}
|
||||||
is NumericLiteralValue -> {
|
is NumericLiteralValue -> {
|
||||||
val iterations = (stmt.iterations as NumericLiteralValue).number.toInt()
|
val iterations = (stmt.iterations as NumericLiteralValue).number.toInt()
|
||||||
if(iterations<0 || iterations > 65536)
|
if(iterations<0 || iterations > 65535)
|
||||||
throw AssemblyError("invalid number of iterations")
|
throw AssemblyError("invalid number of iterations")
|
||||||
when {
|
when {
|
||||||
iterations == 0 -> {}
|
iterations == 0 -> {}
|
||||||
|
Loading…
Reference in New Issue
Block a user