Merge pull request #12712 from github/sashabu/repeated-initializers

C++: Support repeated initializers in dbscheme.
This commit is contained in:
Alexandre Boulgakov
2023-04-03 14:46:17 +01:00
committed by GitHub
11 changed files with 12646 additions and 3285 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,4 @@
description: Revert support for repeated initializers, which are allowed in C with designated initializers.
compatibility: full
aggregate_field_init.rel: reorder aggregate_field_init.rel (int aggregate, int initializer, int field, int position) aggregate initializer field
aggregate_array_init.rel: reorder aggregate_array_init.rel (int aggregate, int initializer, int element_index, int position) aggregate initializer element_index

View File

@@ -192,7 +192,8 @@ class ClassAggregateLiteral extends AggregateLiteral {
*/
Expr getFieldExpr(Field field) {
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.
*/
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
* 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(
int aggregate: @aggregateliteral 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
* 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(
int aggregate: @aggregateliteral ref,
int initializer: @expr ref,
int element_index: int ref
int element_index: int ref,
int position: int ref
);
@ctorinit = @ctordirectinit

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
class AggregateLiteral extends @aggregateliteral {
string toString() { none() }
}
class Expr extends @expr {
string toString() { none() }
}
from AggregateLiteral al, Expr init, int index, int position
where exprparents(init, position, al) and aggregate_array_init(al, init, index)
select al, init, index, position

View File

@@ -0,0 +1,15 @@
class AggregateLiteral extends @aggregateliteral {
string toString() { none() }
}
class Expr extends @expr {
string toString() { none() }
}
class Field extends @membervariable {
string toString() { none() }
}
from AggregateLiteral al, Expr init, Field field, int position
where exprparents(init, position, al) and aggregate_field_init(al, init, field)
select al, init, field, position

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,4 @@
description: Support repeated initializers, which are allowed in C with designated initializers.
compatibility: full
aggregate_field_init.rel: run aggregate_field_init.qlo
aggregate_array_init.rel: run aggregate_array_init.qlo