Beispiel #1
0
        private void CheckType(Microsoft.Boogie.Type type, LiteralExpr theConstant, string expectedType, string expectedExpr)
        {
            string result = null;

            using (var stringWriter = new StringWriter())
            {
                var printer = GetPrinter(stringWriter);

                var ts = CreateTypeSynonym(type, "mysn");

                // Check we get the basic type back
                Assert.AreEqual(expectedType, SMTLIBQueryPrinter.GetSMTLIBType(ts));

                // Now check it can be used in a query
                var typeIdent = new TypedIdent(Token.NoToken, "thetype", ts);
                var variable  = new LocalVariable(Token.NoToken, typeIdent);

                // SymbolicVariable constructor requires that a ProgramLocation is already attached
                variable.SetMetadata((int)AnnotationIndex.PROGRAM_LOCATION, new ProgramLocation(variable));

                var symbolic = new SymbolicVariable("symbolic_0", variable);
                var theExpr  = Expr.Eq(symbolic.Expr, theConstant);

                printer.AddDeclarations(theExpr);
                printer.PrintExpr(theExpr);
                result = stringWriter.ToString();
            }

            Assert.AreEqual(expectedExpr, result);
        }
Beispiel #2
0
            private void CreateNewProcess()
            {
                lock (DisposeLock)
                {
                    if (HasBeenDisposed)
                    {
                        return;
                    }

                    SolverProcessTimer.Start(); // Include the process setup time in solver execution time
                    if (TheProcess != null)
                    {
                        // Process.Close() does not kill the process
                        // so we need to kill it first if necessary
                        try
                        {
                            if (!TheProcess.HasExited)
                            {
                                TheProcess.Kill();
                            }
                        }
                        catch (InvalidOperationException)
                        {
                            // The process has not been started
                        }
                        catch (SystemException)
                        {
                            // No process to kill
                        }

                        TheProcess.Close();
                    }

                    ++InternalStatistics.ProcessCreationCount;

                    // HACK: When running in a NUnit test environment Console.Out.Encoding under Mono (4.0.4) is a UTF-8
                    // encoding with emission of the "Byte ordering mark" (BOM) enabled whereas in a normal executable
                    // environment the emission of the BOM is disabled. This causes problems because Z3 can't handle a
                    // BOM, therefore we want the emission of a BOM to always be disabled. It seems that when Mono sets
                    // up a process, it creates a pipe for the redirected input stream and it uses Console.Out.Encoding
                    // to set the encoding on the writable end of the pipe, therefore we want emission of the BOM to
                    // always be disabled on that stream. Modifying Console.OutputEncoding seems to acheieve this.
                    Console.OutputEncoding = TheEncoding;

                    this.TheProcess = Process.Start(StartInfo);

                    if (Printer == null)
                    {
                        Printer = new SMTLIBQueryPrinter(TheProcess.StandardInput, /*useNamedAttributeBindings*/ UseNamedAttributes, /*humanReadable=*/ false, /*printTriggers=*/ EmitTriggers);
                    }
                    else
                    {
                        Printer.ChangeOutput(TheProcess.StandardInput);
                    }


                    // Register for asynchronous callbacks
                    TheProcess.OutputDataReceived += OutputHandler;
                    TheProcess.ErrorDataReceived  += ErrorHandler;
                    TheProcess.BeginOutputReadLine();
                    TheProcess.BeginErrorReadLine();
                    SolverOptionsSet = false;
                    ReceivedResult   = false;
                    SolverProcessTimer.Stop();
                }
            }
Beispiel #3
0
 public SMTLIBQueryLoggingSolverImpl(ISolverImpl underlyingImplementation, TextWriter TW, bool namedAttributeBindings, bool humanReadable)
 {
     this.UnderlyingImpl = underlyingImplementation;
     Printer             = new SMTLIBQueryPrinter(TW, namedAttributeBindings, humanReadable);
 }