mirror of
https://github.com/KarolS/millfork.git
synced 2025-01-11 12:29:46 +00:00
Fix badly handled stack overflow
This commit is contained in:
parent
df71435c78
commit
30c979cc39
@ -33,6 +33,7 @@ class ConsoleLogger extends Logger {
|
||||
}
|
||||
}
|
||||
|
||||
@inline
|
||||
def f(position: Option[Position]): String = position.fold("")(p => s"(${p.moduleName}:${p.line}:${p.column}) ")
|
||||
|
||||
override def info(msg: String, position: Option[Position] = None): Unit = {
|
||||
|
@ -79,7 +79,13 @@ abstract class AbstractAssembler[T <: AbstractCode](private val program: Program
|
||||
}
|
||||
}
|
||||
|
||||
var stackProbeCount = 0
|
||||
|
||||
def deepConstResolve(c: Constant): Long = {
|
||||
def stackProbe(n: Int): Int = {
|
||||
stackProbeCount += 1
|
||||
if (n == 0) 0 else stackProbe(n - 1) + 1
|
||||
}
|
||||
c match {
|
||||
case NumericConstant(v, _) => v
|
||||
case AssertByte(inner) =>
|
||||
@ -100,6 +106,7 @@ abstract class AbstractAssembler[T <: AbstractCode](private val program: Program
|
||||
val x5 = env.maybeGet[RelativeVariable](th.name).map(_.address)
|
||||
val x6 = env.maybeGet[ConstantThing](th.name.stripSuffix(".array") + ".addr").map(_.value)
|
||||
val x = x1.orElse(x2).orElse(x3).orElse(x4).orElse(x5).orElse(x6)
|
||||
stackProbe(700)
|
||||
x match {
|
||||
case Some(cc) =>
|
||||
deepConstResolve(cc)
|
||||
|
Loading…
x
Reference in New Issue
Block a user