diff --git a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/UnsupportedFrontendElementException.java b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/UnsupportedFrontendElementException.java new file mode 100644 index 0000000000..e3bef460e0 --- /dev/null +++ b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/UnsupportedFrontendElementException.java @@ -0,0 +1,23 @@ +/* + * Copyright 2024 Budapest University of Technology and Economics + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package hu.bme.mit.theta.frontend; + +public class UnsupportedFrontendElementException extends RuntimeException { + public UnsupportedFrontendElementException(String message) { + super(message); + } +} diff --git a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/grammar/expression/ExpressionVisitor.java b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/grammar/expression/ExpressionVisitor.java index 60a7ff7609..d714b8693a 100644 --- a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/grammar/expression/ExpressionVisitor.java +++ b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/grammar/expression/ExpressionVisitor.java @@ -18,13 +18,7 @@ import hu.bme.mit.theta.c.frontend.dsl.gen.CBaseVisitor; import hu.bme.mit.theta.c.frontend.dsl.gen.CParser; -import hu.bme.mit.theta.c.frontend.dsl.gen.CParser.PostfixExpressionAccessContext; -import hu.bme.mit.theta.c.frontend.dsl.gen.CParser.PostfixExpressionBracesContext; -import hu.bme.mit.theta.c.frontend.dsl.gen.CParser.PostfixExpressionBracketsContext; -import hu.bme.mit.theta.c.frontend.dsl.gen.CParser.PostfixExpressionDecrementContext; -import hu.bme.mit.theta.c.frontend.dsl.gen.CParser.PostfixExpressionIncrementContext; -import hu.bme.mit.theta.c.frontend.dsl.gen.CParser.PostfixExpressionMemberAccessContext; -import hu.bme.mit.theta.c.frontend.dsl.gen.CParser.PostfixExpressionPtrMemberAccessContext; +import hu.bme.mit.theta.c.frontend.dsl.gen.CParser.*; import hu.bme.mit.theta.common.Tuple2; import hu.bme.mit.theta.common.logging.Logger; import hu.bme.mit.theta.common.logging.Logger.Level; @@ -35,33 +29,22 @@ import hu.bme.mit.theta.core.type.abstracttype.AbstractExprs; import hu.bme.mit.theta.core.type.abstracttype.DivExpr; import hu.bme.mit.theta.core.type.abstracttype.ModExpr; -import hu.bme.mit.theta.core.type.anytype.Dereference; -import hu.bme.mit.theta.core.type.anytype.Exprs; -import hu.bme.mit.theta.core.type.anytype.IteExpr; -import hu.bme.mit.theta.core.type.anytype.RefExpr; -import hu.bme.mit.theta.core.type.anytype.Reference; +import hu.bme.mit.theta.core.type.anytype.*; import hu.bme.mit.theta.core.type.booltype.BoolExprs; import hu.bme.mit.theta.core.type.booltype.BoolType; -import hu.bme.mit.theta.core.type.bvtype.BvAndExpr; -import hu.bme.mit.theta.core.type.bvtype.BvExprs; -import hu.bme.mit.theta.core.type.bvtype.BvOrExpr; -import hu.bme.mit.theta.core.type.bvtype.BvType; -import hu.bme.mit.theta.core.type.bvtype.BvXorExpr; +import hu.bme.mit.theta.core.type.bvtype.*; import hu.bme.mit.theta.core.type.fptype.FpLitExpr; import hu.bme.mit.theta.core.type.inttype.IntType; import hu.bme.mit.theta.core.utils.BvUtils; import hu.bme.mit.theta.core.utils.FpUtils; import hu.bme.mit.theta.frontend.ParseContext; +import hu.bme.mit.theta.frontend.UnsupportedFrontendElementException; import hu.bme.mit.theta.frontend.transformation.ArchitectureConfig; import hu.bme.mit.theta.frontend.transformation.grammar.function.FunctionVisitor; import hu.bme.mit.theta.frontend.transformation.grammar.preprocess.TypedefVisitor; import hu.bme.mit.theta.frontend.transformation.grammar.type.TypeVisitor; import hu.bme.mit.theta.frontend.transformation.model.declaration.CDeclaration; -import hu.bme.mit.theta.frontend.transformation.model.statements.CAssignment; -import hu.bme.mit.theta.frontend.transformation.model.statements.CCall; -import hu.bme.mit.theta.frontend.transformation.model.statements.CCompound; -import hu.bme.mit.theta.frontend.transformation.model.statements.CExpr; -import hu.bme.mit.theta.frontend.transformation.model.statements.CStatement; +import hu.bme.mit.theta.frontend.transformation.model.statements.*; import hu.bme.mit.theta.frontend.transformation.model.types.complex.CComplexType; import hu.bme.mit.theta.frontend.transformation.model.types.complex.compound.CArray; import hu.bme.mit.theta.frontend.transformation.model.types.complex.compound.CPointer; @@ -70,23 +53,14 @@ import org.kframework.mpfr.BinaryMathContext; import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Deque; -import java.util.List; -import java.util.Map; -import java.util.Optional; +import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; import static com.google.common.base.Preconditions.checkState; -import static hu.bme.mit.theta.core.type.abstracttype.AbstractExprs.Add; import static hu.bme.mit.theta.core.type.abstracttype.AbstractExprs.Div; -import static hu.bme.mit.theta.core.type.abstracttype.AbstractExprs.Eq; -import static hu.bme.mit.theta.core.type.abstracttype.AbstractExprs.Geq; -import static hu.bme.mit.theta.core.type.abstracttype.AbstractExprs.Ite; import static hu.bme.mit.theta.core.type.abstracttype.AbstractExprs.Mod; -import static hu.bme.mit.theta.core.type.abstracttype.AbstractExprs.Neq; -import static hu.bme.mit.theta.core.type.abstracttype.AbstractExprs.Sub; +import static hu.bme.mit.theta.core.type.abstracttype.AbstractExprs.*; import static hu.bme.mit.theta.core.type.anytype.Exprs.Reference; import static hu.bme.mit.theta.core.type.fptype.FpExprs.FpType; import static hu.bme.mit.theta.core.type.inttype.IntExprs.Int; @@ -310,7 +284,7 @@ public Expr visitRelationalExpression(CParser.RelationalExpressionContext ctx guard = AbstractExprs.Geq(leftExpr, rightExpr); break; default: - throw new IllegalStateException("Unexpected value: " + ctx.signs.get(i).getText()); + throw new UnsupportedFrontendElementException("Unexpected relational expression sign: " + ctx.signs.get(i).getText()); } // MaxEnumAnalyzer.instance.consume(guard); TODO: handle circular dependency CComplexType signedInt = CComplexType.getSignedInt(parseContext); @@ -415,7 +389,7 @@ public Expr visitMultiplicativeExpression(CParser.MultiplicativeExpressionCon } break; default: - throw new IllegalStateException("Unexpected value: " + ctx.signs.get(i).getText()); + throw new UnsupportedFrontendElementException("Unexpected multiplicative expression sign: " + ctx.signs.get(i).getText()); } parseContext.getMetadata().create(expr, "cType", smallestCommonType); expr = smallestCommonType.castTo(expr); @@ -665,9 +639,9 @@ public Expr visitPrimaryExpressionConstant(CParser.PrimaryExpressionConstantC BigFloat bigFloat; if (text.startsWith("0x")) { - throw new UnsupportedOperationException("Hexadecimal FP constants are not yet supported!"); + throw new UnsupportedFrontendElementException("Hexadecimal FP constants are not yet supported!"); } else if (text.startsWith("0b")) { - throw new UnsupportedOperationException("Binary FP constants are not yet supported!"); + throw new UnsupportedFrontendElementException("Binary FP constants are not yet supported!"); } else { bigFloat = new BigFloat(text, new BinaryMathContext(significand - 1, exponent)); } diff --git a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/grammar/expression/UnsupportedInitializer.java b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/grammar/expression/UnsupportedInitializer.java index 121f0a9bba..b11b230c07 100644 --- a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/grammar/expression/UnsupportedInitializer.java +++ b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/grammar/expression/UnsupportedInitializer.java @@ -20,6 +20,7 @@ import hu.bme.mit.theta.core.type.LitExpr; import hu.bme.mit.theta.core.type.NullaryExpr; import hu.bme.mit.theta.core.type.inttype.IntType; +import hu.bme.mit.theta.frontend.UnsupportedFrontendElementException; import static hu.bme.mit.theta.core.type.inttype.IntExprs.Int; @@ -32,7 +33,7 @@ public IntType getType() { @Override public LitExpr eval(Valuation val) { - throw new UnsupportedOperationException("UnsupportedInitializer expressions are not supported."); + throw new UnsupportedFrontendElementException("UnsupportedInitializer expressions are not supported."); } @Override diff --git a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/grammar/type/DeclarationVisitor.java b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/grammar/type/DeclarationVisitor.java index f752eb7ef8..84be79414d 100644 --- a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/grammar/type/DeclarationVisitor.java +++ b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/grammar/type/DeclarationVisitor.java @@ -22,6 +22,7 @@ import hu.bme.mit.theta.common.logging.Logger.Level; import hu.bme.mit.theta.core.type.Expr; import hu.bme.mit.theta.frontend.ParseContext; +import hu.bme.mit.theta.frontend.UnsupportedFrontendElementException; import hu.bme.mit.theta.frontend.transformation.grammar.expression.UnsupportedInitializer; import hu.bme.mit.theta.frontend.transformation.grammar.function.FunctionVisitor; import hu.bme.mit.theta.frontend.transformation.grammar.preprocess.TypedefVisitor; @@ -140,7 +141,7 @@ public CDeclaration visitStructDeclaratorSimple(CParser.StructDeclaratorSimpleCo @Override public CDeclaration visitStructDeclaratorConstant(CParser.StructDeclaratorConstantContext ctx) { - throw new UnsupportedOperationException("Not yet supported!"); + throw new UnsupportedFrontendElementException("Not yet supported!"); } @Override @@ -191,17 +192,17 @@ public CDeclaration visitDirectDeclaratorArray1(CParser.DirectDeclaratorArray1Co @Override public CDeclaration visitDirectDeclaratorArray2(CParser.DirectDeclaratorArray2Context ctx) { - throw new UnsupportedOperationException("Not yet implemented!"); + throw new UnsupportedFrontendElementException("Not yet implemented!"); } @Override public CDeclaration visitDirectDeclaratorArray3(CParser.DirectDeclaratorArray3Context ctx) { - throw new UnsupportedOperationException("Not yet implemented!"); + throw new UnsupportedFrontendElementException("Not yet implemented!"); } @Override public CDeclaration visitDirectDeclaratorArray4(CParser.DirectDeclaratorArray4Context ctx) { - throw new UnsupportedOperationException("Not yet implemented!"); + throw new UnsupportedFrontendElementException("Not yet implemented!"); } @Override diff --git a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/grammar/type/TypeVisitor.java b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/grammar/type/TypeVisitor.java index 5fbaf45690..8fad36f961 100644 --- a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/grammar/type/TypeVisitor.java +++ b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/grammar/type/TypeVisitor.java @@ -25,6 +25,7 @@ import hu.bme.mit.theta.common.logging.Logger.Level; import hu.bme.mit.theta.core.type.Expr; import hu.bme.mit.theta.frontend.ParseContext; +import hu.bme.mit.theta.frontend.UnsupportedFrontendElementException; import hu.bme.mit.theta.frontend.transformation.grammar.preprocess.TypedefVisitor; import hu.bme.mit.theta.frontend.transformation.model.declaration.CDeclaration; import hu.bme.mit.theta.frontend.transformation.model.types.complex.CComplexType; @@ -194,15 +195,15 @@ public CSimpleType visitStorageClassSpecifier(CParser.StorageClassSpecifierConte case "auto": case "register": case "_Thread_local": - throw new UnsupportedOperationException("Not yet implemented"); + throw new UnsupportedFrontendElementException("Not yet implemented (" + ctx.getText() + ")"); } - throw new UnsupportedOperationException( + throw new UnsupportedFrontendElementException( "Storage class specifier not expected: " + ctx.getText()); } @Override public CSimpleType visitTypeSpecifierAtomic(CParser.TypeSpecifierAtomicContext ctx) { - throw new UnsupportedOperationException("Not yet implemented"); + throw new UnsupportedFrontendElementException("Not yet implemented"); } @Override @@ -212,7 +213,7 @@ public CSimpleType visitTypeSpecifierCompound(CParser.TypeSpecifierCompoundConte @Override public CSimpleType visitTypeSpecifierFunctionPointer(CParser.TypeSpecifierFunctionPointerContext ctx) { - throw new UnsupportedOperationException("Function pointers not yet implemented"); + throw new UnsupportedFrontendElementException("Function pointers not yet implemented"); } @Override @@ -285,7 +286,7 @@ public CSimpleType visitEnumUsage(CParser.EnumUsageContext ctx) { @Override public CSimpleType visitTypeSpecifierExtension(CParser.TypeSpecifierExtensionContext ctx) { - throw new UnsupportedOperationException("Not yet implemented"); + throw new UnsupportedFrontendElementException("Not yet implemented typeSpecifierExtension"); } @Override @@ -348,7 +349,7 @@ public CSimpleType visitTypeSpecifierTypedefName(CParser.TypeSpecifierTypedefNam @Override public CSimpleType visitTypeSpecifierTypeof(CParser.TypeSpecifierTypeofContext ctx) { - throw new UnsupportedOperationException("Not yet implemented"); + throw new UnsupportedFrontendElementException("Not yet implemented typeSpecifierTypeof"); } @Override @@ -357,13 +358,13 @@ public CSimpleType visitTypeQualifier(CParser.TypeQualifierContext ctx) { case "const": return null; case "restrict": - throw new UnsupportedOperationException("Not yet implemented!"); + throw new UnsupportedFrontendElementException("Not yet implemented 'restrict'!"); case "volatile": return Volatile(); case "_Atomic": return Atomic(); } - throw new UnsupportedOperationException( + throw new UnsupportedFrontendElementException( "Type qualifier " + ctx.getText() + " not expected!"); } diff --git a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/statements/CAssignment.java b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/statements/CAssignment.java index 748b919252..8d285f2d04 100644 --- a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/statements/CAssignment.java +++ b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/statements/CAssignment.java @@ -21,6 +21,7 @@ import hu.bme.mit.theta.core.type.bvtype.BvExprs; import hu.bme.mit.theta.core.type.bvtype.BvType; import hu.bme.mit.theta.frontend.ParseContext; +import hu.bme.mit.theta.frontend.UnsupportedFrontendElementException; import hu.bme.mit.theta.frontend.transformation.model.types.complex.CComplexType; import java.util.List; @@ -99,7 +100,7 @@ public Expr getrExpression() { ret = BvExprs.Or(List.of((Expr) type.castTo(lValue), (Expr) type.castTo(rExpression))); break; default: - throw new RuntimeException("Bad operator: " + operator); + throw new UnsupportedFrontendElementException("Unsupported operator: " + operator); } parseContext.getMetadata().create(ret, "cType", CComplexType.getType(lValue, parseContext)); ret = CComplexType.getType(lValue, parseContext).castTo(ret); diff --git a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/statements/CInitializerList.java b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/statements/CInitializerList.java index 4d7670b096..d12151fe4b 100644 --- a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/statements/CInitializerList.java +++ b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/statements/CInitializerList.java @@ -19,6 +19,7 @@ import hu.bme.mit.theta.common.Tuple2; import hu.bme.mit.theta.core.type.Expr; import hu.bme.mit.theta.frontend.ParseContext; +import hu.bme.mit.theta.frontend.UnsupportedFrontendElementException; import hu.bme.mit.theta.frontend.transformation.model.types.complex.CComplexType; import java.util.ArrayList; @@ -38,7 +39,7 @@ public CInitializerList(CComplexType type, ParseContext parseContext) { @Override public Expr getExpression() { - throw new UnsupportedOperationException("Cannot create expression of initializer list."); + throw new UnsupportedFrontendElementException("Cannot create expression of initializer list."); } @Override diff --git a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/statements/CStatement.java b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/statements/CStatement.java index 44f8087a79..93a2199239 100644 --- a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/statements/CStatement.java +++ b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/statements/CStatement.java @@ -18,6 +18,7 @@ import hu.bme.mit.theta.core.type.Expr; import hu.bme.mit.theta.frontend.ParseContext; +import hu.bme.mit.theta.frontend.UnsupportedFrontendElementException; /** * Every Program, Function and Statement is a subclass of this base class. @@ -60,7 +61,7 @@ public void setId(String id) { * @return The expression associated with the statement. */ public Expr getExpression() { - throw new RuntimeException("Cannot get expression!"); + throw new UnsupportedFrontendElementException("Cannot get expression!"); } public CStatement getPostStatements() { @@ -68,7 +69,7 @@ public CStatement getPostStatements() { } public void setPostStatements(CStatement postStatements) { - throw new UnsupportedOperationException("Only CCompounds shall currently have pre- and post statements!"); + throw new UnsupportedFrontendElementException("Only CCompounds shall currently have pre- and post statements!"); } public CStatement getPreStatements() { @@ -76,7 +77,7 @@ public CStatement getPreStatements() { } public void setPreStatements(CStatement preStatements) { - throw new UnsupportedOperationException("Only CCompounds shall currently have pre- and post statements!"); + throw new UnsupportedFrontendElementException("Only CCompounds shall currently have pre- and post statements!"); } public abstract R accept(CStatementVisitor visitor, P param); diff --git a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/complex/CComplexType.java b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/complex/CComplexType.java index 32b8c4b0e4..1f54441d28 100644 --- a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/complex/CComplexType.java +++ b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/complex/CComplexType.java @@ -26,11 +26,8 @@ import hu.bme.mit.theta.core.type.fptype.FpType; import hu.bme.mit.theta.core.type.inttype.IntType; import hu.bme.mit.theta.frontend.ParseContext; -import hu.bme.mit.theta.frontend.transformation.model.types.complex.compound.CArray; -import hu.bme.mit.theta.frontend.transformation.model.types.complex.compound.CCompound; -import hu.bme.mit.theta.frontend.transformation.model.types.complex.compound.CFunction; -import hu.bme.mit.theta.frontend.transformation.model.types.complex.compound.CPointer; -import hu.bme.mit.theta.frontend.transformation.model.types.complex.compound.CStruct; +import hu.bme.mit.theta.frontend.UnsupportedFrontendElementException; +import hu.bme.mit.theta.frontend.transformation.model.types.complex.compound.*; import hu.bme.mit.theta.frontend.transformation.model.types.complex.integer.CInteger; import hu.bme.mit.theta.frontend.transformation.model.types.complex.integer.Fitsall; import hu.bme.mit.theta.frontend.transformation.model.types.complex.integer.c128.C128; @@ -62,12 +59,7 @@ import java.util.Map.Entry; import java.util.Optional; -import static hu.bme.mit.theta.frontend.transformation.ArchitectureConfig.getCastVisitor; -import static hu.bme.mit.theta.frontend.transformation.ArchitectureConfig.getLimitVisitor; -import static hu.bme.mit.theta.frontend.transformation.ArchitectureConfig.getNullValueVisitor; -import static hu.bme.mit.theta.frontend.transformation.ArchitectureConfig.getTypeVisitor; -import static hu.bme.mit.theta.frontend.transformation.ArchitectureConfig.getUnitValueVisitor; -import static hu.bme.mit.theta.frontend.transformation.ArchitectureConfig.getValueVisitor; +import static hu.bme.mit.theta.frontend.transformation.ArchitectureConfig.*; public abstract class CComplexType { private final CSimpleType origin; @@ -208,7 +200,7 @@ private static CComplexType getType(Type type, ParseContext parseContext) { if (longDoubleType.equals(type)) { return new CFloat(null, parseContext); } - throw new RuntimeException("No suitable size found for type: " + type); + throw new UnsupportedFrontendElementException("No suitable size found for type: " + type); } else if (type instanceof BvType) { for (Entry entry : parseContext.getArchitecture().standardTypeSizes.entrySet()) { String s = entry.getKey(); @@ -230,9 +222,9 @@ private static CComplexType getType(Type type, ParseContext parseContext) { } } } - throw new RuntimeException("No suitable width found for type: " + type); + throw new UnsupportedFrontendElementException("No suitable width found for type: " + type); } else { - throw new RuntimeException("Not yet implemented for type: " + type); + throw new UnsupportedFrontendElementException("Not yet implemented for type: " + type); } } @@ -307,7 +299,7 @@ public R accept(CComplexTypeVisitor visitor, T param) { public static class CComplexTypeVisitor { public R visit(CComplexType type, T param) { - throw new UnsupportedOperationException("Not (yet) implemented (" + type.getClass().getSimpleName() + " in " + this.getClass().getName() + ")"); + throw new UnsupportedFrontendElementException("Not (yet) implemented (" + type.getClass().getSimpleName() + " in " + this.getClass().getName() + ")"); } public R visit(CVoid type, T param) { diff --git a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/complex/integer/Fitsall.java b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/complex/integer/Fitsall.java index 6550e48040..8cb56130a7 100644 --- a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/complex/integer/Fitsall.java +++ b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/complex/integer/Fitsall.java @@ -41,7 +41,7 @@ public String getTypeName() { @Override public CInteger getSignedVersion() { - throw new RuntimeException("Bool does not have a signed version!"); + throw new RuntimeException("Fitsall does not have a signed version!"); } @Override diff --git a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/complex/visitors/bitvector/CastVisitor.java b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/complex/visitors/bitvector/CastVisitor.java index ab2fd3faa7..6187ff3391 100644 --- a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/complex/visitors/bitvector/CastVisitor.java +++ b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/complex/visitors/bitvector/CastVisitor.java @@ -25,6 +25,7 @@ import hu.bme.mit.theta.core.type.fptype.FpRoundingMode; import hu.bme.mit.theta.core.type.fptype.FpType; import hu.bme.mit.theta.frontend.ParseContext; +import hu.bme.mit.theta.frontend.UnsupportedFrontendElementException; import hu.bme.mit.theta.frontend.transformation.model.types.complex.CComplexType; import hu.bme.mit.theta.frontend.transformation.model.types.complex.CVoid; import hu.bme.mit.theta.frontend.transformation.model.types.complex.compound.CPointer; @@ -89,7 +90,7 @@ private Expr handleSignedConversion(CInteger type, Expr param } } } else { - throw new IllegalStateException("Compound types are not directly supported!"); + throw new UnsupportedFrontendElementException("Compound types are not directly supported!"); } } @@ -119,7 +120,7 @@ private Expr handleUnsignedConversion(CInteger type, Expr par } } } else { - throw new IllegalStateException("Compound types are not directly supported!"); + throw new UnsupportedFrontendElementException("Compound types are not directly supported!"); } } diff --git a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/simple/NamedType.java b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/simple/NamedType.java index 2cbc83220d..2ff2c5fdb0 100644 --- a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/simple/NamedType.java +++ b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/transformation/model/types/simple/NamedType.java @@ -19,6 +19,7 @@ import hu.bme.mit.theta.common.logging.Logger; import hu.bme.mit.theta.common.logging.Logger.Level; import hu.bme.mit.theta.frontend.ParseContext; +import hu.bme.mit.theta.frontend.UnsupportedFrontendElementException; import hu.bme.mit.theta.frontend.transformation.model.types.complex.CComplexType; import hu.bme.mit.theta.frontend.transformation.model.types.complex.CVoid; import hu.bme.mit.theta.frontend.transformation.model.types.complex.compound.CPointer; @@ -169,7 +170,7 @@ protected void patch(CSimpleType cSimpleType) { break; default: if (!cSimpleType.isTypedef()) { - throw new RuntimeException( + throw new UnsupportedFrontendElementException( "namedType should be short or long or type specifier, instead it is " + namedType); } diff --git a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/params/ExitCodes.kt b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/params/ExitCodes.kt index 563a7abaa3..1ecf5e665a 100644 --- a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/params/ExitCodes.kt +++ b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/params/ExitCodes.kt @@ -18,6 +18,7 @@ package hu.bme.mit.theta.xcfa.cli.params import com.microsoft.z3.Z3Exception import hu.bme.mit.theta.common.exception.NotSolvableException +import hu.bme.mit.theta.frontend.UnsupportedFrontendElementException import hu.bme.mit.theta.solver.UnknownSolverStatusException import hu.bme.mit.theta.solver.javasmt.JavaSMTSolverException import hu.bme.mit.theta.solver.smtlib.solver.SmtLibSolverException @@ -32,6 +33,7 @@ enum class ExitCodes(val code: Int) { SERVER_ERROR(202), PORTFOLIO_ERROR(203), + UNSUPPORTED_ELEMENT(209), FRONTEND_FAILED(210), INVALID_PARAM(211), @@ -59,6 +61,9 @@ fun exitOnError(stacktrace: Boolean, throwDontExit: Boolean, body: () -> T): } catch (e: ErrorCodeException) { e.printStackTrace() exitProcess(throwDontExit, e, e.code) + } catch (e: UnsupportedFrontendElementException) { + e.printCauseAndTrace(stacktrace) + exitProcess(throwDontExit, e, ExitCodes.UNSUPPORTED_ELEMENT.code) } catch (e: SmtLibSolverException) { e.printCauseAndTrace(stacktrace) exitProcess(throwDontExit, e, ExitCodes.SOLVER_ERROR.code)