C++: Support repeated initializers in dbscheme.

This commit is contained in:
Alexandre Boulgakov
2023-03-29 17:14:41 +01:00
parent 2b9daed26a
commit d0a77a8433
2 changed files with 11 additions and 8 deletions

View File

@@ -192,7 +192,8 @@ class ClassAggregateLiteral extends AggregateLiteral {
*/ */
Expr getFieldExpr(Field field) { Expr getFieldExpr(Field field) {
field = classType.getAField() and field = classType.getAField() and
aggregate_field_init(underlyingElement(this), unresolveElement(result), unresolveElement(field)) aggregate_field_init(underlyingElement(this), unresolveElement(result), unresolveElement(field),
_)
} }
/** /**
@@ -264,7 +265,7 @@ class ArrayOrVectorAggregateLiteral extends AggregateLiteral {
* element `elementIndex`, if present. * element `elementIndex`, if present.
*/ */
Expr getElementExpr(int elementIndex) { Expr getElementExpr(int elementIndex) {
aggregate_array_init(underlyingElement(this), unresolveElement(result), elementIndex) aggregate_array_init(underlyingElement(this), unresolveElement(result), elementIndex, _)
} }
/** /**

View File

@@ -1820,24 +1820,26 @@ new_array_allocated_type(
/** /**
* The field being initialized by an initializer expression within an aggregate * The field being initialized by an initializer expression within an aggregate
* initializer for a class/struct/union. * initializer for a class/struct/union. Position is used to sort repeated initializers.
*/ */
#keyset[aggregate, field] #keyset[aggregate, position]
aggregate_field_init( aggregate_field_init(
int aggregate: @aggregateliteral ref, int aggregate: @aggregateliteral ref,
int initializer: @expr ref, int initializer: @expr ref,
int field: @membervariable ref int field: @membervariable ref,
int position: int ref
); );
/** /**
* The index of the element being initialized by an initializer expression * The index of the element being initialized by an initializer expression
* within an aggregate initializer for an array. * within an aggregate initializer for an array. Position is used to sort repeated initializers.
*/ */
#keyset[aggregate, element_index] #keyset[aggregate, position]
aggregate_array_init( aggregate_array_init(
int aggregate: @aggregateliteral ref, int aggregate: @aggregateliteral ref,
int initializer: @expr ref, int initializer: @expr ref,
int element_index: int ref int element_index: int ref,
int position: int ref
); );
@ctorinit = @ctordirectinit @ctorinit = @ctordirectinit