Fix array fields in certain contexts

This commit is contained in:
Karol Stasiak 2021-09-17 22:19:39 +02:00
parent b66435d06b
commit 7530b382a8
2 changed files with 5 additions and 6 deletions

View File

@ -407,12 +407,12 @@ object AbstractExpressionCompiler {
log.error(s"Type `$targetType` doesn't have field named `$actualFieldName`", expr.position)
ok = false
} else {
if (tuples.head.arrayIndexTypeAndSize.isDefined) ??? // TODO
val subv = tuples.head
pointerWrap match {
case 0 =>
currentType = tuples.head.typ
currentType = if (subv.arrayIndexTypeAndSize.isDefined) env.get[Type]("pointer." + subv.typ) else subv.typ
case 1 =>
currentType = env.get[Type]("pointer." + tuples.head.typ)
currentType = env.get[Type]("pointer." + subv.typ)
case 2 =>
currentType = env.get[Type]("pointer")
case 10 | 11 =>

View File

@ -2372,11 +2372,10 @@ class Environment(val parent: Option[Environment], val prefix: String, val cpuFa
builder.toList
case s: UnionType =>
val builder = new ListBuffer[Subvariable]
for(FieldDesc(typeName, fieldName, vol1, arraySize) <- s.fields) {
val typ = get[VariableType](typeName)
for(ResolvedFieldDesc(typ, fieldName, vol1, indexTypeAndCount) <- s.mutableFieldsWithTypes) {
val suffix = "." + fieldName
builder += Subvariable(suffix, 0, vol1, typ)
if (arraySize.isEmpty) {
if (indexTypeAndCount.isEmpty) {
builder ++= getSubvariables(typ).map {
case Subvariable(innerSuffix, innerOffset, vol2, innerType, innerSize) => Subvariable(suffix + innerSuffix, innerOffset, vol1 || vol2, innerType, innerSize)
}