@@ -159,22 +159,15 @@ trait BoogieInterface {
159159 * Invoke Boogie.
160160 */
161161 private def run (input : String , options : Seq [String ]) = {
162- // write program to a temporary file
163- val tmp = File .createTempFile(" carbon" , " .bpl" )
164- tmp.deleteOnExit()
165- val stream = new BufferedOutputStream (new FileOutputStream (tmp))
166- stream.write(input.getBytes)
167- stream.close()
168-
169162 reporter report BackendSubProcessReport (" carbon" , boogiePath, BeforeInputSent , _boogieProcessPid)
170163
171- val cmd : Seq [String ] = (Seq (boogiePath) ++ options ++ Seq (tmp.getAbsolutePath))
164+ // When the filename is "stdin.bpl" Boogie reads the program from standard input.
165+ val cmd : Seq [String ] = Seq (boogiePath) ++ options ++ Seq (" stdin.bpl" )
172166 val pb : ProcessBuilder = new ProcessBuilder (cmd.asJava)
173167 val proc : Process = pb.start()
174168 _boogieProcess = Some (proc)
175169 _boogieProcessPid = Some (proc.pid)
176170
177-
178171 // proverShutDownHook approach taken from Silicon's codebase
179172 val proverShutdownHook = new Thread {
180173 override def run (): Unit = {
@@ -183,8 +176,6 @@ trait BoogieInterface {
183176 }
184177 Runtime .getRuntime.addShutdownHook(proverShutdownHook)
185178
186- proc.getOutputStream.close()
187-
188179 // _z3ProcessStream = Some(proc.descendants().toScala(LazyList))
189180 reporter report BackendSubProcessReport (" carbon" , boogiePath, AfterInputSent , _boogieProcessPid)
190181
@@ -198,6 +189,10 @@ trait BoogieInterface {
198189 errorStreamThread.start()
199190 inputStreamThread.start()
200191
192+ // Send the program to Boogie
193+ proc.getOutputStream.write(input.getBytes);
194+ proc.getOutputStream.close()
195+
201196 try {
202197 proc.waitFor()
203198 } finally {
@@ -239,30 +234,4 @@ trait BoogieInterface {
239234 case None =>
240235 }
241236 }
242-
243- /* // TODO: investigate why passing the program directly does not work
244- private def runX(input: String, options: Seq[String]): String = {
245- def convertStreamToString(is: java.io.InputStream) = {
246- val s = new java.util.Scanner(is).useDelimiter("\\A")
247- if (s.hasNext) s.next() else ""
248- }
249- var res: String = ""
250- var reserr: String = ""
251- def out(input: java.io.InputStream) {
252- res += convertStreamToString(input)
253- input.close()
254- }
255- def err(in: java.io.InputStream) {
256- reserr += convertStreamToString(in)
257- in.close()
258- }
259- def in(output: java.io.OutputStream) {
260- output.write(input.getBytes)
261- output.close()
262- }
263- // Note: call exitValue to block until Boogie has finished
264- // Note: we call boogie with an empty input "file" on stdin and parse the output
265- (Seq(boogiePath) ++ options ++ Seq("stdin.bpl")).run(new ProcessIO(in, out, err)).exitValue()
266- reserr + res
267- }*/
268- }
237+ }
0 commit comments