diff options
| author | Jim Lawson | 2016-12-02 12:51:03 -0800 |
|---|---|---|
| committer | GitHub | 2016-12-02 12:51:03 -0800 |
| commit | d3ec37edd39799e8cf039e5caed915c00dff7eeb (patch) | |
| tree | 03329ddc11ca15b9d6c7f832354a9cba20c87843 /chiselFrontend/src/main/scala/chisel3/internal/SourceInfo.scala | |
| parent | 1b53d893816d349f5ea18fa0ed13325b9f1b6917 (diff) | |
| parent | eba224e524b249207b47a3b378458c61c9b66e2c (diff) | |
Merge branch 'master' into exceptionfix
Diffstat (limited to 'chiselFrontend/src/main/scala/chisel3/internal/SourceInfo.scala')
| -rw-r--r-- | chiselFrontend/src/main/scala/chisel3/internal/SourceInfo.scala | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/internal/SourceInfo.scala b/chiselFrontend/src/main/scala/chisel3/internal/SourceInfo.scala index 5e3bf33e..f1130db4 100644 --- a/chiselFrontend/src/main/scala/chisel3/internal/SourceInfo.scala +++ b/chiselFrontend/src/main/scala/chisel3/internal/SourceInfo.scala @@ -19,9 +19,17 @@ import scala.reflect.macros.blackbox.Context /** Abstract base class for generalized source information. */ -sealed trait SourceInfo +sealed trait SourceInfo { + /** A prettier toString + * + * Make a useful message if SourceInfo is available, nothing otherwise + */ + def makeMessage(f: String => String): String +} -sealed trait NoSourceInfo extends SourceInfo +sealed trait NoSourceInfo extends SourceInfo { + def makeMessage(f: String => String): String = "" +} /** For when source info can't be generated because of a technical limitation, like for Reg because * Scala macros don't support named or default arguments. @@ -34,7 +42,9 @@ case object DeprecatedSourceInfo extends NoSourceInfo /** For FIRRTL lines from a Scala source line. */ -case class SourceLine(filename: String, line: Int, col: Int) extends SourceInfo +case class SourceLine(filename: String, line: Int, col: Int) extends SourceInfo { + def makeMessage(f: String => String): String = f(s"@[$filename $line:$col]") +} /** Provides a macro that returns the source information at the invocation point. */ |
