diff options
author | chriseth <chris@ethereum.org> | 2017-07-11 03:21:11 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2017-08-23 20:24:05 +0800 |
commit | 39fc798999b28386405399102d6cc7d199965d80 (patch) | |
tree | 9c087ef0fab8014e5ca7f81160c273d8dc16a2a7 /libsolidity/formal/SMTLib2Interface.h | |
parent | df848859da0ce52a7bb1de6fcd836e0b7ebc2779 (diff) | |
download | dexon-solidity-39fc798999b28386405399102d6cc7d199965d80.tar.gz dexon-solidity-39fc798999b28386405399102d6cc7d199965d80.tar.zst dexon-solidity-39fc798999b28386405399102d6cc7d199965d80.zip |
Use file to communicate with z3.
Diffstat (limited to 'libsolidity/formal/SMTLib2Interface.h')
-rw-r--r-- | libsolidity/formal/SMTLib2Interface.h | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/libsolidity/formal/SMTLib2Interface.h b/libsolidity/formal/SMTLib2Interface.h index f984cfb5..b7bab043 100644 --- a/libsolidity/formal/SMTLib2Interface.h +++ b/libsolidity/formal/SMTLib2Interface.h @@ -17,11 +17,14 @@ #pragma once +#include <libsolidity/interface/Exceptions.h> + +#include <libdevcore/Common.h> + #include <map> #include <string> #include <vector> - -#include <libdevcore/Common.h> +#include <cstdio> namespace dev { @@ -49,7 +52,8 @@ class Expression public: Expression(size_t _number): m_name(std::to_string(_number)) {} - Expression(u256 const& _number): m_name(std::to_string(_number)) {} + Expression(u256 const& _number): m_name(_number.str()) {} + Expression(bigint const& _number): m_name(_number.str()) {} Expression(Expression const& _other) = default; Expression(Expression&& _other) = default; @@ -104,9 +108,16 @@ public: { return Expression("*", std::move(_a), std::move(_b)); } + Expression operator()(Expression _a) const + { + solAssert(m_arguments.empty(), "Attempted function application to non-function."); + return Expression(m_name, _a); + } std::string toSExpr() const { + if (m_arguments.empty()) + return m_name; std::string sexpr = "(" + m_name; for (auto const& arg: m_arguments) sexpr += " " + arg.toSExpr(); @@ -126,9 +137,11 @@ private: std::vector<Expression> const m_arguments; }; -class SMTLib2Interface +class SMTLib2Interface: public boost::noncopyable { public: + SMTLib2Interface(); + ~SMTLib2Interface(); void reset(); @@ -140,8 +153,18 @@ public: Expression newBool(std::string _name); void addAssertion(Expression _expr); - CheckResult check(); - std::string eval(Expression _expr); + std::pair<CheckResult, std::vector<std::string>> check(std::vector<Expression> const& _expressionsToEvaluate); +// std::string eval(Expression _expr); + +private: + void write(std::string _data); + std::string communicate(std::string const& _input); + + std::vector<std::string> parseValues(std::string::const_iterator _start, std::string::const_iterator _end); + + std::vector<std::string> m_accumulatedOutput; +// FILE* m_solverWrite = nullptr; +// FILE* m_solverRead = nullptr; }; |