Skip to content

Commit 154c67d

Browse files
committed
Review changes
1 parent ee75d52 commit 154c67d

4 files changed

Lines changed: 30 additions & 28 deletions

File tree

src/main/scala/viper/silver/ast/Ast.scala

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -367,48 +367,48 @@ trait Info {
367367

368368
/** A default `Info` that is empty. */
369369
case object NoInfo extends Info {
370-
override def comment = Nil
371-
override def isCached = false
370+
override val comment = Nil
371+
override val isCached = false
372372
}
373373

374374
/** A simple `Info` that contains a list of comments. */
375375
case class SimpleInfo(comment: Seq[String]) extends Info {
376-
override def isCached = false
376+
override val isCached = false
377377
}
378378

379379
/** An `Info` instance for labelling a quantifier as auto-triggered. */
380380
case object AutoTriggered extends Info {
381-
override def comment = Nil
382-
override def isCached = false
381+
override val comment = Nil
382+
override val isCached = false
383383
}
384384

385385
/** An `Info` instance for labelling a pre-verified AST node (e.g., via caching). */
386386
case object Cached extends Info {
387-
override def comment = Nil
388-
override def isCached = true
387+
override val comment = Nil
388+
override val isCached = true
389389
}
390390

391391
/** An `Info` instance for labelling a node as synthesized. A synthesized node is one that
392392
* was not present in the original program that was passed to a Viper backend, such as nodes that
393393
* originate from an AST transformation.
394394
*/
395395
case object Synthesized extends Info {
396-
override def comment = Nil
397-
override def isCached = false
396+
override val comment = Nil
397+
override val isCached = false
398398
}
399399

400400
/** An `Info` instance for labelling an AST node which is expected to fail verification.
401401
* This is used by Silicon to avoid stopping verification.
402402
*/
403403
abstract class FailureExpectedInfo extends Info {
404-
override def comment = Nil
405-
override def isCached = false
404+
override val comment = Nil
405+
override val isCached = false
406406
}
407407

408408
/** An `Info` instance for composing multiple `Info`s together */
409409
case class ConsInfo(head: Info, tail: Info) extends Info {
410-
override def comment = head.comment ++ tail.comment
411-
override def isCached = head.isCached || tail.isCached
410+
override val comment = head.comment ++ tail.comment
411+
override val isCached = head.isCached || tail.isCached
412412
}
413413

414414
/** Build a `ConsInfo` instance out of two `Info`s, unless the latter is `NoInfo` (which can be dropped) */

src/main/scala/viper/silver/plugin/standard/refute/RefutePlugin.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ import viper.silver.verifier.errors.AssertFailed
1818
class RefutePlugin extends SilverPlugin with ParserPluginTemplate {
1919

2020
/** Keyword used to define refute statements. */
21-
private val RefuteKeyword: String = "refute"
21+
private val refuteKeyword: String = "refute"
2222

23-
private var RefuteAsserts: Map[Position, Refute] = Map()
23+
private var refuteAsserts: Map[Position, Refute] = Map()
2424

2525
/** Parser for refute statements. */
2626
def refute[_: P]: P[PRefute] =
27-
FP(keyword(RefuteKeyword) ~/ exp).map{ case (pos, e) => PRefute(e)(pos) }
27+
FP(keyword(refuteKeyword) ~/ exp).map{ case (pos, e) => PRefute(e)(pos) }
2828

2929
/** Add refute to the parser. */
3030
override def beforeParse(input: String, isImported: Boolean): String = {
3131
// Add new keyword
32-
ParserExtension.addNewKeywords(Set[String](RefuteKeyword))
32+
ParserExtension.addNewKeywords(Set[String](refuteKeyword))
3333
// Add new parser to the precondition
3434
ParserExtension.addNewStmtAtEnd(refute(_))
3535
input
@@ -42,36 +42,36 @@ class RefutePlugin extends SilverPlugin with ParserPluginTemplate {
4242
override def beforeVerify(input: Program): Program =
4343
ViperStrategy.Slim({
4444
case r@Refute(exp) => {
45-
this.RefuteAsserts += (r.pos -> r)
45+
this.refuteAsserts += (r.pos -> r)
4646
Seqn(Seq(
47-
If(LocalVar(s"__plugin_refute_nondet${this.RefuteAsserts.size}", Bool)(r.pos),
47+
If(LocalVar(s"__plugin_refute_nondet${this.refuteAsserts.size}", Bool)(r.pos),
4848
Seqn(Seq(
4949
Assert(exp)(r.pos, RefuteInfo),
5050
Inhale(BoolLit(false)(r.pos))(r.pos)
5151
), Seq())(r.pos),
5252
Seqn(Seq(), Seq())(r.pos))(r.pos)
5353
),
54-
Seq(LocalVarDecl(s"__plugin_refute_nondet${this.RefuteAsserts.size}", Bool)(r.pos))
54+
Seq(LocalVarDecl(s"__plugin_refute_nondet${this.refuteAsserts.size}", Bool)(r.pos))
5555
)(r.pos)
5656
}
5757
}).recurseFunc({
5858
case Method(_, _, _, _, _, body) => Seq(body)
5959
}).execute(input)
6060

61-
/** Remove refutation related errors and add RefuteAsserts that didn't report an error. */
61+
/** Remove refutation related errors and add refuteAsserts that didn't report an error. */
6262
override def mapVerificationResult(input: VerificationResult): VerificationResult = {
6363
val errors: Seq[AbstractError] = (input match {
6464
case Success => Seq()
6565
case Failure(errors) => {
6666
errors.filter {
6767
case AssertFailed(a, _, _) if a.info == RefuteInfo => {
68-
this.RefuteAsserts -= a.pos
68+
this.refuteAsserts -= a.pos
6969
false
7070
}
7171
case _ => true
7272
}
7373
}
74-
}) ++ this.RefuteAsserts.map(r => RefuteFailed(r._2, RefutationTrue(r._2.exp)))
74+
}) ++ this.refuteAsserts.map(r => RefuteFailed(r._2, RefutationTrue(r._2.exp)))
7575
if (errors.length == 0) Success
7676
else Failure(errors)
7777
}

src/main/scala/viper/silver/plugin/standard/termination/TerminationPlugin.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class TerminationPlugin(reporter: viper.silver.reporter.Reporter,
2828
/**
2929
* Keyword used to define decreases clauses
3030
*/
31-
private val DecreasesKeyword: String = "decreases"
31+
private val decreasesKeyword: String = "decreases"
3232

3333
/**
3434
* Parser for decreases clauses with following possibilities.
@@ -40,7 +40,7 @@ class TerminationPlugin(reporter: viper.silver.reporter.Reporter,
4040
* decreases *
4141
*/
4242
def decreases[_: P]: P[PDecreasesClause] =
43-
P(keyword(DecreasesKeyword) ~/ (decreasesWildcard | decreasesStar | decreasesTuple) ~ ";".?)
43+
P(keyword(decreasesKeyword) ~/ (decreasesWildcard | decreasesStar | decreasesTuple) ~ ";".?)
4444
def decreasesTuple[_: P]: P[PDecreasesTuple] =
4545
FP(exp.rep(sep = ",") ~/ condition.?).map { case (pos, (a, c)) => PDecreasesTuple(a, c)(pos) }
4646
def decreasesWildcard[_: P]: P[PDecreasesWildcard] = FP("_" ~/ condition.?).map{ case (pos, c) => PDecreasesWildcard(c)(pos) }
@@ -53,7 +53,7 @@ class TerminationPlugin(reporter: viper.silver.reporter.Reporter,
5353
*/
5454
override def beforeParse(input: String, isImported: Boolean): String = {
5555
// Add new keyword
56-
ParserExtension.addNewKeywords(Set[String](DecreasesKeyword))
56+
ParserExtension.addNewKeywords(Set[String](decreasesKeyword))
5757
// Add new parser to the precondition
5858
ParserExtension.addNewPreCondition(decreases(_))
5959
// Add new parser to the postcondition

src/main/scala/viper/silver/verifier/VerificationError.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,10 @@ trait ErrorMessage {
155155
def withNode(offendingNode: errors.ErrorNode = this.offendingNode) : ErrorMessage
156156

157157
// Check if the offendingNode contains any `FailureExpectedInfo` info tags
158-
def isExpected: Boolean = if (!offendingNode.isInstanceOf[Infoed]) false
159-
else offendingNode.asInstanceOf[Infoed].info.getUniqueInfo[FailureExpectedInfo].isDefined
158+
def isExpected: Boolean = offendingNode match {
159+
case i: Infoed => i.info.getUniqueInfo[FailureExpectedInfo].isDefined
160+
case _ => false
161+
}
160162
}
161163

162164
trait VerificationError extends AbstractError with ErrorMessage {

0 commit comments

Comments
 (0)