C++: Support attribute arguments that are expressions

This commit is contained in:
Jeroen Ketema
2023-12-22 20:40:47 +01:00
parent bbe3269b8c
commit ad2fb7c6d5
10 changed files with 9728 additions and 683 deletions

View File

@@ -281,6 +281,11 @@ class AttributeArgument extends Element, @attribute_arg {
attribute_arg_constant(underlyingElement(this), unresolveElement(result))
}
/**
* Gets the value of this argument, if its value is a expression.
*/
Expr getValueExpr() { attribute_arg_expr(underlyingElement(this), unresolveElement(result)) }
/**
* Gets the attribute to which this is an argument.
*/
@@ -308,7 +313,10 @@ class AttributeArgument extends Element, @attribute_arg {
else
if underlyingElement(this) instanceof @attribute_arg_constant_expr
then tail = this.getValueConstant().toString()
else tail = this.getValueText()
else
if underlyingElement(this) instanceof @attribute_arg_expr
then tail = this.getValueExpr().toString()
else tail = this.getValueText()
) and
result = prefix + tail
)

View File

@@ -937,6 +937,7 @@ case @attribute_arg.kind of
| 2 = @attribute_arg_constant
| 3 = @attribute_arg_type
| 4 = @attribute_arg_constant_expr
| 5 = @attribute_arg_expr
;
attribute_arg_value(
@@ -951,6 +952,10 @@ attribute_arg_constant(
unique int arg: @attribute_arg ref,
int constant: @expr ref
)
attribute_arg_expr(
unique int arg: @attribute_arg ref,
int expr: @expr ref
)
attribute_arg_name(
unique int arg: @attribute_arg ref,
string name: string ref

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,2 @@
description: Support expression attribute arguments
compatibility: backwards