improved variable source line position

This commit is contained in:
Irmen de Jong committed 2026-10-19 22:16:53 +02:00
1 parent 31b5cddb96
commit da2288db93
3 files changed
+6 -7

No files matched your search

@@ -2,6 +2,7 @@ package prog8.codegen.intermediate
import prog8.code.*
import prog8.code.ast.PtStructField
import prog8.code.core.Position
import prog8.intermediate.*
/**
@@ -78,7 +79,7 @@ private class StToIrConverter(val romable: Boolean) {
val hasInit = initValue != null
val inBss = !hasInit || romable
val readonly = romable && hasInit
return IRStStaticVariable(name, variable.dt, initValue, variable.length, variable.zpwish, variable.align, variable.dirty, inBss, readonly, variable.shared)
return IRStStaticVariable(name, variable.dt, initValue, variable.length, variable.zpwish, variable.align, variable.dirty, inBss, readonly, variable.shared, variable.astNode?.position ?: Position.DUMMY)
}
fun convert(variable: StMemVar): IRStMemVar {
@@ -516,7 +516,7 @@ class StackFrameLayout(private val program: IRProgram, private val errors: IErro
locals += LocalLayout(name, elemDt, count, size, alignment, v.dirty, initialized, isFloat)
if (v.length != null && size > 8 && !v.dirty && v.initializationValue == null) {
val shortName = name.substringAfterLast('.').removePrefix("p8v_")
errors.warn("local array '$shortName' ($size bytes) in subroutine '${userName(sub)}' is zero-initialized on every call which can be costly; consider @dirty if you assign it before use", sub.position)
errors.warn("local array '$shortName' ($size bytes) in subroutine '${userName(sub)}' is zero-initialized on every call which can be costly; consider @dirty if you assign it before use", v.position)
}
}