diff options
Diffstat (limited to 'src/dotty/tools/dotc/Run.scala')
-rw-r--r-- | src/dotty/tools/dotc/Run.scala | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/Run.scala b/src/dotty/tools/dotc/Run.scala index 928bf753a..cc9b8db3a 100644 --- a/src/dotty/tools/dotc/Run.scala +++ b/src/dotty/tools/dotc/Run.scala @@ -6,6 +6,7 @@ import Contexts._, Periods._, Symbols._ import io.PlainFile import util.{SourceFile, NoSource, Stats, SimpleMap} import reporting.Reporter +import java.io.FileWriter class Run(comp: Compiler)(implicit ctx: Context) { @@ -29,6 +30,15 @@ class Run(comp: Compiler)(implicit ctx: Context) { } } + def compile(sourceCode: String): Unit = { + val tmpFile = java.io.File.createTempFile("dotty-source-tmp", ".scala") + tmpFile.createNewFile() + val writer = new FileWriter(tmpFile) + writer.write(sourceCode) + writer.close() + compile(List(tmpFile.getAbsolutePath)) + } + /** Print summary; return # of errors encountered */ def printSummary(): Reporter = { ctx.runInfo.printMaxConstraint() |