Skip to content

Commit

Permalink
Do not complete missing fields in dynamic fields
Browse files Browse the repository at this point in the history
Co-authored-by: Can Oğuz <[email protected]>
  • Loading branch information
shamilatesoglu and candhyan committed Dec 26, 2022
1 parent 48f3fdf commit 81e2ae8
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions src/idl_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4520,27 +4520,10 @@ bool Parser::CompleteMissingField(FieldDef* absent_field, const StructDef &struc
break;
}
}
if (auto typeName = LookupDynamicFieldType(absent_field, &struct_def))
if (LookupDynamicFieldType(absent_field, &struct_def))
{
Type type;
if (ResolveDynamicType(typeName, type, absent_field))
{
if (type.struct_def && !type.struct_def->fixed)
{
return true;
}

// we want zero-initialized default pin data
Value val = absent_field->value;
std::vector<uint8_t> empty(type.base_type == BASE_TYPE_STRING ? 1 : InlineSize(type));
builder_.ForceVectorAlignment(empty.size(), sizeof(uint8_t), type.base_type == BASE_TYPE_STRING ? 1 : InlineAlignment(type));
auto off = builder_.CreateVector(empty);
val.constant = NumToString(off.o);

found = true;
fieldn_outer++;
field_stack_.insert(elem.base(), std::make_pair(val, absent_field));
}
// Do not complete dynamic fields any more.
return true;
}
// auto-complete missing fields of a struct
if (!found && struct_def.fixed)
Expand Down

0 comments on commit 81e2ae8

Please sign in to comment.