Skip to content

Commit

Permalink
changed unary type transformation representation
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgenvinju committed Dec 21, 2023
1 parent df3de2f commit 3b10dfb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/lang/cpp/TypeSymbol.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ data TypeSymbol
| \functionSetType(loc decl, list[TypeSymbol] templateArguments)
| \functionSetTypePointer(loc decl, list[TypeSymbol] templateArguments)

| \unaryTypeTransformation(str operator, TypeSymbol operand)
| \transformToUnderlyingType(TypeSymbol operand)
| \unresolved()
| \any()

Expand Down
17 changes: 17 additions & 0 deletions src/lang/cpp/internal/AST.java
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,8 @@ public AST (IValueFactory vf) {
= tf.constructor(typestore,_TypeSymbol,"union",tf.sourceLocationType(),"decl");
private static final Type _TypeSymbol_float_0
= tf.constructor(typestore,_TypeSymbol,"float");
private static final Type _TypeSymbol_transformToUnderlyingType_1
= tf.constructor(typestore,_TypeSymbol,"transformToUnderlyingType",_TypeSymbol,"operand");
private static final Type _TypeSymbol_unspecified_0
= tf.constructor(typestore,_TypeSymbol,"unspecified");
private static final Type _TypeSymbol_eUnionTemplate_2
Expand Down Expand Up @@ -6225,6 +6227,21 @@ public IConstructor TypeSymbol_float() {
return vf.constructor(_TypeSymbol_float_0 ).asWithKeywordParameters().setParameters(kwParams);
}

public IConstructor TypeSymbol_transformToUnderlyingType(IConstructor $operand) {

if (!$operand.getType().isSubtypeOf(_TypeSymbol)) {
throw new IllegalArgumentException("Expected " + _TypeSymbol + " but got " + $operand.getType() + " for $operand:" + $operand);
}

Map<String, IValue> kwParams = new HashMap<String, IValue>();





return vf.constructor(_TypeSymbol_transformToUnderlyingType_1 , $operand).asWithKeywordParameters().setParameters(kwParams);
}

public IConstructor TypeSymbol_unspecified() {

Map<String, IValue> kwParams = new HashMap<String, IValue>();
Expand Down
5 changes: 3 additions & 2 deletions src/lang/cpp/internal/TypeResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -602,10 +602,11 @@ private IConstructor resolveICPPEnumerationSpecialization(ICPPEnumerationSpecial
}

private IConstructor resolveICPPUnaryTypeTransformation(ICPPUnaryTypeTransformation type, ISourceLocation origin) {
String op = type.getOperator().name();
assert type.getOperator().equals(org.eclipse.cdt.core.dom.ast.cpp.ICPPUnaryTypeTransformation.Operator.underlying_type);

IConstructor operand = resolveType(type.getOperand(), origin);

return builder.TypeSymbol_unaryTypeTransformation(op, operand);
return builder.TypeSymbol_transformToUnderlyingType(operand);
}

private IConstructor resolveICPPUnknownType(ICPPUnknownType type, ISourceLocation origin) {
Expand Down

0 comments on commit 3b10dfb

Please sign in to comment.