Skip to content
Snippets Groups Projects
Commit 30354146 authored by Manos Koukoutos's avatar Manos Koukoutos
Browse files

Fixes

parent 4f4d8cea
No related branches found
No related tags found
No related merge requests found
......@@ -9,9 +9,7 @@ import purescala.Expressions._
import purescala.ExprOps.{simplestValue, matchToIfThenElse}
import purescala.Types._
import purescala.Constructors._
import purescala.TypeOps.instantiateType
import purescala.Extractors._
import utils._
import cafebabe._
import cafebabe.AbstractByteCodes._
......
......@@ -36,11 +36,10 @@ object Common {
val getType = tpe
override def equals(other: Any): Boolean = {
if(other == null || !other.isInstanceOf[Identifier])
false
else
other.asInstanceOf[Identifier].globalId == this.globalId
override def equals(other: Any): Boolean = other match {
case null => false
case i: Identifier => i.globalId == this.globalId
case _ => false
}
override def hashCode: Int = globalId
......
......@@ -171,7 +171,7 @@ object Expressions {
val subPatterns: Seq[Pattern]
val binder: Option[Identifier]
private def subBinders = subPatterns.map(_.binders).foldLeft[Set[Identifier]](Set.empty)(_ ++ _)
private def subBinders = subPatterns.flatMap(_.binders).toSet
def binders: Set[Identifier] = subBinders ++ binder.toSet
def withBinder(b : Identifier) = { this match {
......
......@@ -47,7 +47,7 @@ object MethodLifting extends TransformationPhase {
case acd: AbstractClassDef =>
val (r, c) = acd.knownChildren.map(makeCases(_, fdId, breakDown)).unzip
val recs = r.flatten
val complete = c forall (x => x)
val complete = !(c contains false)
if (complete) {
// Children define all cases completely, we don't need to add anything
(recs, true)
......
......@@ -12,14 +12,14 @@ import Constructors._
object TypeOps {
def typeDepth(t: TypeTree): Int = t match {
case NAryType(tps, builder) => 1+tps.foldLeft(0) { case (d, t) => d max typeDepth(t) }
case NAryType(tps, builder) => 1+ (0 +: (tps map typeDepth)).max
}
def typeParamsOf(t: TypeTree): Set[TypeParameter] = t match {
case tp: TypeParameter => Set(tp)
case _ =>
val NAryType(subs, _) = t
subs.map(typeParamsOf).foldLeft(Set[TypeParameter]())(_ ++ _)
subs.flatMap(typeParamsOf).toSet
}
def canBeSubtypeOf(
......
......@@ -64,8 +64,8 @@ class SimpleTerminationChecker(context: LeonContext, program: Program) extends T
// We check all functions that are in a "lower" scc. These must
// terminate for all inputs in any case.
val sccLowerCallees = sccCallees.filterNot(_ == sccIndex)
val lowerDefs = sccLowerCallees.map(sccArray(_)).foldLeft(Set.empty[FunDef])(_ ++ _)
val sccLowerCallees = sccCallees - sccIndex
val lowerDefs = sccLowerCallees.flatMap(sccArray(_))
val lowerOK = lowerDefs.forall(terminates(_).isGuaranteed)
if (!lowerOK)
return NoGuarantee
......
......@@ -69,8 +69,7 @@ trait StructuralSize {
}
}
def caseClassType2MatchCase(_c: ClassType): MatchCase = {
val c = _c.asInstanceOf[CaseClassType] // required by leon framework
def caseClassType2MatchCase(c: CaseClassType): MatchCase = {
val arguments = c.fields.map(vd => FreshIdentifier(vd.id.name, vd.getType))
val argumentPatterns = arguments.map(id => WildcardPattern(Some(id)))
val sizes = arguments.map(id => size(Variable(id)))
......
......@@ -203,7 +203,7 @@ object Graphs {
if (outs(v2)) {
true
} else {
outs.map(rec).foldLeft(false)( _ || _ )
outs.map(rec).contains(true)
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment