From 05ce6ad3f975b21707f42bf5e3496d09c5dfc671 Mon Sep 17 00:00:00 2001 From: Ellen Wittingen Date: Thu, 7 Dec 2023 10:41:41 +0100 Subject: [PATCH] Small bugfixes --- src/rewrite/vct/rewrite/lang/LangCPPToCol.scala | 9 +++++++++ src/rewrite/vct/rewrite/lang/LangSpecificToCol.scala | 2 +- src/rewrite/vct/rewrite/lang/ReplaceSYCLTypes.scala | 9 ++++----- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/rewrite/vct/rewrite/lang/LangCPPToCol.scala b/src/rewrite/vct/rewrite/lang/LangCPPToCol.scala index 86b500de78..6a78c9370d 100644 --- a/src/rewrite/vct/rewrite/lang/LangCPPToCol.scala +++ b/src/rewrite/vct/rewrite/lang/LangCPPToCol.scala @@ -27,6 +27,11 @@ case object LangCPPToCol { decl.o.messageInContext(s"This declaration has a type that is not supported.") } + case class LambdaDefinitionUnsupported(lambda: CPPLambdaDefinition[_]) extends UserError { + override def text: String = lambda.o.messageInContext("Lambda expressions are only supported as parameters for invocations of SYCL's submit and parallel_for methods.") + override def code: String = "unsupportedLambdaDefinition" + } + private case class CPPDoubleContracted(decl: CPPGlobalDeclaration[_], defn: CPPFunctionDefinition[_]) extends UserError { override def code: String = "multipleContracts" override def text: String = @@ -491,6 +496,10 @@ case class LangCPPToCol[Pre <: Generation](rw: LangSpecificToCol[Pre]) extends L rw.variables.declare(v) } + def rewriteLambdaDefinition(lambda: CPPLambdaDefinition[Pre]): Expr[Post] = { + throw LambdaDefinitionUnsupported(lambda) + } + def checkPredicateFoldingAllowed(predRes: Expr[Pre]): Unit = predRes match { case CPPInvocation(CPPLocal("sycl::buffer::exclusive_hostData_access", Seq()), _, _, _) => throw SYCLPredicateFoldingNotAllowed(predRes) case _ => diff --git a/src/rewrite/vct/rewrite/lang/LangSpecificToCol.scala b/src/rewrite/vct/rewrite/lang/LangSpecificToCol.scala index 82785f6c3f..26bf39168b 100644 --- a/src/rewrite/vct/rewrite/lang/LangSpecificToCol.scala +++ b/src/rewrite/vct/rewrite/lang/LangSpecificToCol.scala @@ -234,7 +234,7 @@ case class LangSpecificToCol[Pre <: Generation](veymontGeneratePermissions: Bool case deref: CPPClassMethodOrFieldAccess[Pre] => cpp.deref(deref) case inv: CPPInvocation[Pre] => cpp.invocation(inv) case preAssign@PreAssignExpression(local@CPPLocal(_, _), _) => cpp.preAssignExpr(preAssign, local) - case _: CPPLambdaDefinition[Pre] => ??? + case lambda: CPPLambdaDefinition[Pre] => cpp.rewriteLambdaDefinition(lambda) case arrSub@AmbiguousSubscript(_, _) => cpp.rewriteSubscript(arrSub) case unfolding: Unfolding[Pre] => { cpp.checkPredicateFoldingAllowed(unfolding.res) diff --git a/src/rewrite/vct/rewrite/lang/ReplaceSYCLTypes.scala b/src/rewrite/vct/rewrite/lang/ReplaceSYCLTypes.scala index e1d47745cd..c13bf85659 100644 --- a/src/rewrite/vct/rewrite/lang/ReplaceSYCLTypes.scala +++ b/src/rewrite/vct/rewrite/lang/ReplaceSYCLTypes.scala @@ -9,9 +9,8 @@ case object ReplaceSYCLTypes extends RewriterBuilder { } case class ReplaceSYCLTypes[Pre <: Generation]() extends Rewriter[Pre] { -// override def dispatch(t: Type[Pre]): Type[Post] = t match { -// case _: CPPTLambda[Pre] => TRef() -// case _: SYCLTClass[Pre] => TRef() -// case _ => rewriteDefault(t) -// } + override def dispatch(t: Type[Pre]): Type[Post] = t match { + case _: SYCLTClass[Pre] => TRef() + case _ => rewriteDefault(t) + } }