-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make systemerrors use context by default, and turn non-fatal exceptio…
…ns into systemerrors
- Loading branch information
1 parent
cdb4b33
commit b2455e3
Showing
24 changed files
with
166 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
package vct.col.ast.statement.terminal | ||
|
||
import vct.col.ast.Label | ||
import vct.col.print.{Ctx, Doc, Show, Text} | ||
import vct.col.print.{Ctx, Doc, NodeDoc, Show, Text} | ||
|
||
trait LabelImpl[G] { this: Label[G] => | ||
override def blockElementsForLayout(implicit ctx: Ctx): Seq[Show] = ctx.syntax match { | ||
case Ctx.PVL => Seq(layoutLabel) ++ stat.blockElementsForLayout | ||
case Ctx.Silver => Seq(layoutLabel) ++ stat.blockElementsForLayout | ||
case Ctx.Java => Seq(this) | ||
case Ctx.C | Ctx.Cuda | Ctx.OpenCL | Ctx.CPP => Seq(layoutLabel) ++ stat.blockElementsForLayout | ||
override def foldBlock(f: (Doc, Doc) => Doc)(implicit ctx: Ctx): Doc = ctx.syntax match { | ||
case Ctx.PVL => f(layoutLabel, stat.foldBlock(f)) | ||
case Ctx.Silver => f(layoutLabel, stat.foldBlock(f)) | ||
case Ctx.Java => layoutLabel <+> stat.show | ||
case Ctx.C | Ctx.Cuda | Ctx.OpenCL | Ctx.CPP => f(layoutLabel, stat.foldBlock(f)) | ||
} | ||
|
||
def layoutLabel(implicit ctx: Ctx): Doc = ctx.syntax match { | ||
def layoutLabel(implicit ctx: Ctx): Doc = NodeDoc(this, ctx.syntax match { | ||
case Ctx.PVL => Text("label") <+> ctx.name(decl) <> ";" | ||
case Ctx.Silver => Text("label") <+> ctx.name(decl) | ||
case Ctx.Java => Text(ctx.name(decl)) <> ":" | ||
case Ctx.C | Ctx.Cuda | Ctx.OpenCL | Ctx.CPP => Text(ctx.name(decl)) <> ":" | ||
} | ||
}) | ||
|
||
override def layout(implicit ctx: Ctx): Doc = | ||
Doc.stack(blockElementsForLayout) | ||
override def layout(implicit ctx: Ctx): Doc = foldBlock(_ <+/> _) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
package vct.col.util | ||
|
||
import vct.col.ast.Declaration | ||
import vct.col.print.Doc | ||
import vct.result.VerificationError | ||
|
||
case class ConstructingSuccessorOfContext(decl: Declaration[_]) extends VerificationError.Context | ||
case class ConstructingSuccessorOfContext(decl: Declaration[_]) extends VerificationError.Context { | ||
override def tryMessageContext(message: String, err: VerificationError): Option[String] = | ||
err.context[CurrentRewriteProgramContext].map { ctx => | ||
Doc.messagesInContext(Seq( | ||
(ctx.program, decl, message) | ||
)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
package vct.col.util | ||
|
||
import vct.col.ast.Node | ||
import vct.col.print.Doc | ||
import vct.result.VerificationError | ||
|
||
case class CurrentCheckNodeContext(node: Node[_]) extends VerificationError.Context | ||
case class CurrentCheckNodeContext(node: Node[_]) extends VerificationError.Context { | ||
override def tryMessageContext(message: String, err: VerificationError): Option[String] = | ||
err.context[CurrentCheckProgramContext].map { ctx => | ||
Doc.messagesInContext(Seq( | ||
(ctx.program, node, message) | ||
)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package vct.col.util | ||
|
||
import vct.col.ast.Program | ||
import vct.col.print.Doc | ||
import vct.result.VerificationError | ||
|
||
case class CurrentCheckProgramContext(program: Program[_]) extends VerificationError.Context { | ||
override def tryMessageContext(message: String, err: VerificationError): Option[String] = | ||
Some(Doc.messagesInContext(Seq( | ||
(program, program, message) | ||
))) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package vct.col.util | ||
|
||
import vct.col.ast.Node | ||
import vct.col.print.Doc | ||
import vct.result.VerificationError | ||
|
||
case class CurrentRewriteNodeContext(node: Node[_]) extends VerificationError.Context { | ||
override def tryMessageContext(message: String, err: VerificationError): Option[String] = | ||
err.context[CurrentRewriteProgramContext].map { ctx => | ||
Doc.messagesInContext(Seq( | ||
(ctx.program, node, message) | ||
)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package vct.col.util | ||
|
||
import vct.col.ast.Program | ||
import vct.col.print.Doc | ||
import vct.result.VerificationError | ||
|
||
case class CurrentRewriteProgramContext(program: Program[_]) extends VerificationError.Context { | ||
override def tryMessageContext(message: String, err: VerificationError): Option[String] = | ||
Some(Doc.messagesInContext(Seq( | ||
(program, program, message) | ||
))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package hre.io | ||
|
||
import java.io.{ByteArrayOutputStream, PrintStream} | ||
import java.nio.charset.StandardCharsets | ||
|
||
object CollectString { | ||
def apply(f: PrintStream => Unit): String = { | ||
val bytes = new ByteArrayOutputStream | ||
val print = new PrintStream(bytes) | ||
f(print) | ||
new String(bytes.toByteArray, StandardCharsets.UTF_8) | ||
} | ||
} |
Oops, something went wrong.