equal
deleted
inserted
replaced
110 if (class_loader == null) super.parentClassLoader |
110 if (class_loader == null) super.parentClassLoader |
111 else class_loader |
111 else class_loader |
112 } |
112 } |
113 } |
113 } |
114 |
114 |
115 def toplevel(interpret: Boolean, source: String): List[String] = { |
115 def toplevel(source: String): List[String] = { |
116 val out = new StringWriter |
116 val out = new StringWriter |
117 val interp = interpreter(new PrintWriter(out)) |
117 val interp = interpreter(new PrintWriter(out)) |
118 val marker = '\u000b' |
118 val marker = '\u000b' |
119 val ok = |
119 val ok = interp.withLabel(marker.toString) { (new interp.ReadEvalPrint).compile(source) } |
120 interp.withLabel(marker.toString) { |
|
121 if (interpret) interp.interpret(source) == Results.Success |
|
122 else (new interp.ReadEvalPrint).compile(source) |
|
123 } |
|
124 out.close() |
120 out.close() |
125 |
121 |
126 val Error = """(?s)^\S* error: (.*)$""".r |
122 val Error = """(?s)^\S* error: (.*)$""".r |
127 val errors = |
123 val errors = |
128 space_explode(marker, Library.strip_ansi_color(out.toString)). |
124 space_explode(marker, Library.strip_ansi_color(out.toString)). |
133 } |
129 } |
134 } |
130 } |
135 |
131 |
136 object Toplevel extends Fun_String("scala_toplevel") { |
132 object Toplevel extends Fun_String("scala_toplevel") { |
137 val here = Scala_Project.here |
133 val here = Scala_Project.here |
138 def apply(arg: String): String = { |
134 def apply(source: String): String = { |
139 val (interpret, source) = |
|
140 YXML.parse_body(arg) match { |
|
141 case Nil => (false, "") |
|
142 case List(XML.Text(source)) => (false, source) |
|
143 case body => import XML.Decode._; pair(bool, string)(body) |
|
144 } |
|
145 val errors = |
135 val errors = |
146 try { Compiler.context().toplevel(interpret, source) } |
136 try { Compiler.context().toplevel(source) } |
147 catch { case ERROR(msg) => List(msg) } |
137 catch { case ERROR(msg) => List(msg) } |
148 locally { import XML.Encode._; YXML.string_of_body(list(string)(errors)) } |
138 locally { import XML.Encode._; YXML.string_of_body(list(string)(errors)) } |
149 } |
139 } |
150 } |
140 } |
151 |
141 |