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 Jul 16, 2024
1 parent 1d9b163 commit c33618e
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 c33618e

Please sign in to comment.