public void Next() {
// From base_type to CurType.
List<ExprType> types = GetTypes(this.base_type, this.indices);
// We try to jump as many levels out as we can.
do {
Int32 index = this.indices.Last();
this.indices.RemoveAt(this.indices.Count - 1);
types.RemoveAt(types.Count - 1);
ExprType type = types.Last();
switch (type.Kind) {
case ExprTypeKind.ARRAY:
if (index < ((ArrayType)type).NumElems - 1) {
// There are more elements in the array.
this.indices.Add(index + 1);
return;
}
break;
case ExprTypeKind.INCOMPLETE_ARRAY:
this.indices.Add(index + 1);
return;
case ExprTypeKind.STRUCT_OR_UNION:
if (((StructOrUnionType)type).IsStruct && index < ((StructOrUnionType)type).Attribs.Count - 1) {
// There are more members in the struct.
// (not union, since we can only initialize the first member of a union)
this.indices.Add(index + 1);
return;
}
break;
default:
break;
}
} while (this.indices.Any());
}