Skip to content

Conversation

samuelchassot
Copy link
Collaborator

No description provided.

@samuelchassot samuelchassot changed the title Support for throw new Exception encoded as assert(false) Draft: Support for throw new Exception encoded as assert(false) May 8, 2024
@samuelchassot samuelchassot marked this pull request as draft May 8, 2024 11:10
@samuelchassot
Copy link
Collaborator Author

samuelchassot commented May 8, 2024

TODO:

  • add tests
  • update doc to add the new phase

@vkuncak
Copy link
Collaborator

vkuncak commented May 8, 2024

Also rebase so we see changes more easily. :)

@@ -31,10 +31,8 @@ class ExceptionLifting(override val s: Trees, override val t: imperative.Trees)

override def transform(e: s.Expr): t.Expr = e match {
case s.Throw(exc) =>
println("SAM IN TRANSFORM THROW CASE")
t.Assert(t.BooleanLiteral(false), Some(f"throw $exc"), t.UnitLiteral())
t.Assert(t.BooleanLiteral(false).setPos(e), Some(f"throw $exc unreachable"), t.NoTree(transform(fd.returnType)).setPos(e)).setPos(e)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mario-bucev can you have a look at these setPos? When we only do setPos on the outer tree, the position is not reported. Hence this puts it everywhere, but that seems a bit brute force. Is there some guideline which position needs to be set for assert to report a meaningful line number?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the VC position, it's the condition position that matters. However, it's also a good practice to put the position on the outer tree as well since later phases will rely on its position (not only that, but it's also easier to debug).

@vkuncak vkuncak changed the title Draft: Support for throw new Exception encoded as assert(false) Draft: Support for throw new Exception encoded as assert(false) fixes #1512 May 8, 2024
@vkuncak vkuncak changed the title Draft: Support for throw new Exception encoded as assert(false) fixes #1512 Draft: Support for throw new Exception encoded as assert(false) May 8, 2024
@vkuncak vkuncak changed the title Draft: Support for throw new Exception encoded as assert(false) Draft: Support for throw new Exception encoded as assert(false) fixes #1512 May 8, 2024
@samuelchassot samuelchassot force-pushed the sam/throwFull branch 2 times, most recently from 6a1104e to c7b14a1 Compare May 13, 2024 06:14
@samuelchassot samuelchassot marked this pull request as ready for review May 13, 2024 06:59
@vkuncak
Copy link
Collaborator

vkuncak commented May 13, 2024

You need to fix i800b.scala since the message for throw is changed.

@vkuncak vkuncak merged commit d297e0f into epfl-lara:main May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants