@@ -35,64 +35,65 @@ trait Driver extends kiama.util.Compiler[EffektConfig, EffektError] { outer =>
35
35
*
36
36
* In LSP mode: invoked for each file opened in an editor
37
37
*/
38
- override def compileSource (source : Source , config : EffektConfig ): Unit = try {
39
- val src = if (source.name.endsWith(" .md" )) { MarkdownSource (source) } else { source }
40
-
41
- // remember that we have seen this source, this is used by LSP (kiama.util.Server)
42
- sources(source.name) = src
43
-
44
- implicit val C = context
45
- C .setup(config)
46
-
47
- def saveOutput (path : String , doc : String ): Unit =
48
- if (C .config.requiresCompilation()) {
49
- val out = C .config.outputPath()
50
- out.mkdirs
51
- IO .createFile((out / path).unixPath, doc)
52
- }
53
-
54
- C .backend match {
38
+ override def compileSource (source : Source , config : EffektConfig ): Unit = {
39
+ val src = if (source.name.endsWith(" .md" )) { MarkdownSource (source) } else { source }
40
+ try {
41
+ // remember that we have seen this source, this is used by LSP (kiama.util.Server)
42
+ sources(source.name) = src
43
+
44
+ implicit val C = context
45
+ C .setup(config)
46
+
47
+ def saveOutput (path : String , doc : String ): Unit =
48
+ if (C .config.requiresCompilation()) {
49
+ val out = C .config.outputPath()
50
+ out.mkdirs
51
+ IO .createFile((out / path).unixPath, doc)
52
+ }
55
53
56
- case Backend (name, compiler, runner) =>
57
- // measure the total compilation time here
58
- def compile () = C .timed(" total" , source.name) {
59
- compiler.compile(src) map {
60
- case (outputFiles, exec) =>
61
- outputFiles.foreach {
62
- case (filename, doc) =>
63
- saveOutput(filename, doc)
54
+ C .backend match {
55
+
56
+ case Backend (name, compiler, runner) =>
57
+ // measure the total compilation time here
58
+ def compile () = C .timed(" total" , source.name) {
59
+ compiler.compile(src) map {
60
+ case (outputFiles, exec) =>
61
+ outputFiles.foreach {
62
+ case (filename, doc) =>
63
+ saveOutput(filename, doc)
64
+ }
65
+ exec
64
66
}
65
- exec
66
- }
67
+ }
68
+
69
+ // we are in one of four exclusive modes: Documenter, LSPServer, Compile, Run
70
+ if (config.documenter()) { documenter(source, config)(context) }
71
+ else if (config.server()) { compiler.runFrontend(src) }
72
+ else if (config.interpret()) { compile() foreach runner.eval }
73
+ else if (config.build()) { compile() foreach runner.build }
74
+ else if (config.compile()) { compile() }
67
75
}
68
-
69
- // we are in one of four exclusive modes: Documenter, LSPServer, Compile, Run
70
- if (config.documenter()) { documenter(source, config)(context) }
71
- else if (config.server()) { compiler.runFrontend(src) }
72
- else if (config.interpret()) { compile() foreach runner.eval }
73
- else if (config.build()) { compile() foreach runner.build }
74
- else if (config.compile()) { compile() }
75
- }
76
- } catch {
77
- case FatalPhaseError (msg) => context.report(msg)
78
- case e @ CompilerPanic (msg) =>
79
- context.report(msg)
80
- e.getStackTrace.foreach { line =>
81
- context.info(" at " + line)
82
- }
83
- // when in server-mode, do not crash but report the error to avoid
84
- // restarting the server.
85
- case e if config.server() =>
86
- context.info(" Effekt Compiler Crash: " + e.getMessage)
87
- e.getStackTrace.foreach { line =>
88
- context.info(" at " + line)
76
+ } catch {
77
+ case FatalPhaseError (msg) => context.report(msg)
78
+ case e @ CompilerPanic (msg) =>
79
+ context.report(msg)
80
+ e.getStackTrace.foreach { line =>
81
+ context.info(" at " + line)
82
+ }
83
+ // when in server-mode, do not crash but report the error to avoid
84
+ // restarting the server.
85
+ case e if config.server() =>
86
+ context.info(" Effekt Compiler Crash: " + e.getMessage)
87
+ e.getStackTrace.foreach { line =>
88
+ context.info(" at " + line)
89
+ }
90
+ } finally {
91
+ outputTimes(src, config)(context)
92
+ showIR(src, config)(context)
93
+ writeIRs(src, config)(context)
94
+ // This reports error messages
95
+ afterCompilation(src, config)(context)
89
96
}
90
- } finally {
91
- outputTimes(source, config)(context)
92
- showIR(source, config)(context)
93
- writeIRs(source, config)(context)
94
- // This reports error messages
95
- afterCompilation(source, config)(context)
96
97
}
97
98
98
99
/**
0 commit comments