PseudocodeLabel: add slightly better exception diagnostics
This commit is contained in:
committed by
Mikhail Glukhikh
parent
9a5b5393f5
commit
ab0e734e7d
@@ -34,11 +34,16 @@ class PseudocodeLabel internal constructor(
|
|||||||
|
|
||||||
override fun resolveToInstruction(): Instruction {
|
override fun resolveToInstruction(): Instruction {
|
||||||
val index = targetInstructionIndex
|
val index = targetInstructionIndex
|
||||||
if (index < 0 || index >= instructionList.size) {
|
when {
|
||||||
error("resolveToInstruction: incorrect index $index for label $name " +
|
index < 0 ->
|
||||||
"in subroutine ${correspondingElement.text} with instructions $instructionList")
|
error("resolveToInstruction: unbound label $name " +
|
||||||
|
"in subroutine ${correspondingElement.text} with instructions $instructionList")
|
||||||
|
index >= instructionList.size ->
|
||||||
|
error("resolveToInstruction: incorrect index $index for label $name " +
|
||||||
|
"in subroutine ${correspondingElement.text} with instructions $instructionList")
|
||||||
|
else ->
|
||||||
|
return instructionList[index]
|
||||||
}
|
}
|
||||||
return instructionList[index]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun copy(newPseudocode: PseudocodeImpl, newLabelIndex: Int): PseudocodeLabel =
|
fun copy(newPseudocode: PseudocodeImpl, newLabelIndex: Int): PseudocodeLabel =
|
||||||
|
|||||||
Reference in New Issue
Block a user