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)
}
}
@@ -2,10 +2,7 @@ package prog8.intermediate
import prog8.code.PROG8_CONTAINER_MODULES
import prog8.code.SymbolNames
import prog8.code.core.BaseDataType
import prog8.code.core.DataType
import prog8.code.core.Encoding
import prog8.code.core.ZeropageWish
import prog8.code.core.*
// In the Intermediate Representation, all nesting has been removed.
@@ -132,7 +129,8 @@ class IRStStaticVariable(name: String,
val dirty: Boolean,
val inBss: Boolean = false, // variable should be placed in BSS (RAM), not inline with code
val readonly: Boolean = false, // variable should be treated as read-only
val shared: Boolean = false // the @shared tag: keep the variable in program-static storage
val shared: Boolean = false, // the @shared tag: keep the variable in program-static storage
val position: Position = Position.DUMMY
) : IRStNode(name, IRStNodeType.STATICVAR) {
init {
if(align > 0u) {