Skip to content

Commit

Permalink
Consider the if key in the sizeof calculations. Probably resolve #927
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingun committed Mar 8, 2024
1 parent db4a1ad commit 4346a1f
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,23 @@ object CalculateSeqSizes {
var seqPos: Option[Int] = Some(0)
curClass.seq.foreach { attr =>
val sizeElement = dataTypeBitsSize(attr.dataType)
val sizeContainer = sizeMultiply(sizeElement, attr.cond.repeat, attr.path)
val size = sizeMultiply(sizeElement, attr.cond.repeat, attr.path)
val sizeContainer = attr.cond.ifExpr match {
case Some(expr) => expr.evaluateBoolConst match {
case Some(true) => {
//TODO: add user visible warning
Log.seqSizes.warn(() => s"${attr.path}: condition is always `true`")
size
}
case Some(false) => {
//TODO: add user visible warning
Log.seqSizes.warn(() => s"${attr.path}: condition is always `false`")
FixedSized(0)
}
case None => DynamicSized
}
case None => size
}

op(attr, seqPos, sizeElement, sizeContainer)

Expand Down

0 comments on commit 4346a1f

Please sign in to comment.