Skip to content
Snippets Groups Projects
Commit 30078391 authored by Emmanouil (Manos) Koukoutos's avatar Emmanouil (Manos) Koukoutos Committed by Etienne Kneuss
Browse files

Restore FunDef.orig

parent a0474680
No related branches found
No related tags found
No related merge requests found
...@@ -351,6 +351,9 @@ object Definitions { ...@@ -351,6 +351,9 @@ object Definitions {
val defType : DefType val defType : DefType
) extends Definition { ) extends Definition {
// A copy of the original function before Xlang elimination
var orig : Option[FunDef] = None
private var fullBody_ : Expr = NoTree(returnType) private var fullBody_ : Expr = NoTree(returnType)
def fullBody = fullBody_ def fullBody = fullBody_
def fullBody_= (e : Expr) { def fullBody_= (e : Expr) {
...@@ -385,8 +388,7 @@ object Definitions { ...@@ -385,8 +388,7 @@ object Definitions {
def copyContentFrom(from : FunDef) { def copyContentFrom(from : FunDef) {
this.fullBody = from.fullBody this.fullBody = from.fullBody
//this.parent = from.parent this.orig = from.orig
//this.orig = from.orig
this.origOwner = from.origOwner this.origOwner = from.origOwner
this.addAnnotation(from.annotations.toSeq : _*) this.addAnnotation(from.annotations.toSeq : _*)
} }
......
...@@ -64,7 +64,7 @@ object FunctionClosure extends TransformationPhase { ...@@ -64,7 +64,7 @@ object FunctionClosure extends TransformationPhase {
newFunDef.addAnnotation(fd.annotations.toSeq:_*) //TODO: this is still some dangerous side effects newFunDef.addAnnotation(fd.annotations.toSeq:_*) //TODO: this is still some dangerous side effects
newFunDef.setOwner(parent) newFunDef.setOwner(parent)
fd .setOwner(parent) fd .setOwner(parent)
newFunDef.origOwner = Some(fd) newFunDef.orig = Some(fd)
def introduceLets(expr: Expr, fd2FreshFd: Map[FunDef, (FunDef, Seq[Variable])]): Expr = { def introduceLets(expr: Expr, fd2FreshFd: Map[FunDef, (FunDef, Seq[Variable])]): Expr = {
val (newExpr, _) = enclosingLets.foldLeft((expr, Map[Identifier, Identifier]()))((acc, p) => { val (newExpr, _) = enclosingLets.foldLeft((expr, Map[Identifier, Identifier]()))((acc, p) => {
......
...@@ -21,8 +21,8 @@ object XlangAnalysisPhase extends LeonPhase[Program, VerificationReport] { ...@@ -21,8 +21,8 @@ object XlangAnalysisPhase extends LeonPhase[Program, VerificationReport] {
val (pgm3, wasLoop) = ImperativeCodeElimination.run(ctx)(pgm2) val (pgm3, wasLoop) = ImperativeCodeElimination.run(ctx)(pgm2)
val pgm4 = purescala.FunctionClosure.run(ctx)(pgm3) val pgm4 = purescala.FunctionClosure.run(ctx)(pgm3)
def functionWasLoop(fd: FunDef): Boolean = fd.origOwner match { def functionWasLoop(fd: FunDef): Boolean = fd.orig match {
case Some(nested : FunDef) => // was a nested function case Some(nested) => // could have been a LetDef originally
wasLoop.contains(nested) wasLoop.contains(nested)
case _ => false //meaning, this was a top level function case _ => false //meaning, this was a top level function
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment