Set remapped type for previously undefined types for StructuredDataDef

This commit is contained in:
Jan 2022-03-22 12:14:30 +01:00
parent dc075847ff
commit 2fa1144425

View File

@ -47,7 +47,12 @@ namespace sdd::def_scope_sequences
if (existingType != state->m_def_types_by_name.end()) if (existingType != state->m_def_types_by_name.end())
{ {
if (existingType->second.m_category == CommonStructuredDataTypeCategory::UNKNOWN) if (existingType->second.m_category == CommonStructuredDataTypeCategory::UNKNOWN)
existingType->second = CommonStructuredDataType(CommonStructuredDataTypeCategory::ENUM, newEnumIndex); {
assert(existingType->second.m_info.type_index < state->m_undefined_types.size());
auto& undefinedType = state->m_undefined_types[existingType->second.m_info.type_index];
undefinedType.m_mapped_type = CommonStructuredDataType(CommonStructuredDataTypeCategory::ENUM, newEnumIndex);
existingType->second = undefinedType.m_mapped_type;
}
else else
throw ParsingException(nameToken.GetPos(), "Type with this name has already been defined"); throw ParsingException(nameToken.GetPos(), "Type with this name has already been defined");
} }
@ -89,7 +94,12 @@ namespace sdd::def_scope_sequences
if (existingType != state->m_def_types_by_name.end()) if (existingType != state->m_def_types_by_name.end())
{ {
if (existingType->second.m_category == CommonStructuredDataTypeCategory::UNKNOWN) if (existingType->second.m_category == CommonStructuredDataTypeCategory::UNKNOWN)
existingType->second = CommonStructuredDataType(CommonStructuredDataTypeCategory::STRUCT, newStructIndex); {
assert(existingType->second.m_info.type_index < state->m_undefined_types.size());
auto& undefinedType = state->m_undefined_types[existingType->second.m_info.type_index];
undefinedType.m_mapped_type = CommonStructuredDataType(CommonStructuredDataTypeCategory::STRUCT, newStructIndex);
existingType->second = undefinedType.m_mapped_type;
}
else else
throw ParsingException(nameToken.GetPos(), "Type with this name has already been defined"); throw ParsingException(nameToken.GetPos(), "Type with this name has already been defined");
} }