2018-10-15 15:32:17 +00:00
|
|
|
/*
|
|
|
|
This file is part of solidity.
|
|
|
|
|
|
|
|
solidity is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
solidity is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-07-03 14:05:56 +00:00
|
|
|
#include <libsolidity/formal/EncodingContext.h>
|
2018-10-22 08:29:03 +00:00
|
|
|
#include <libsolidity/formal/SymbolicVariables.h>
|
2018-10-15 15:32:17 +00:00
|
|
|
#include <libsolidity/ast/AST.h>
|
|
|
|
#include <libsolidity/ast/Types.h>
|
|
|
|
|
|
|
|
namespace dev
|
|
|
|
{
|
|
|
|
namespace solidity
|
|
|
|
{
|
2019-05-09 10:16:52 +00:00
|
|
|
namespace smt
|
|
|
|
{
|
2018-10-15 15:32:17 +00:00
|
|
|
|
2018-10-25 14:00:09 +00:00
|
|
|
/// Returns the SMT sort that models the Solidity type _type.
|
2019-05-09 10:16:52 +00:00
|
|
|
SortPointer smtSort(solidity::Type const& _type);
|
|
|
|
std::vector<SortPointer> smtSort(std::vector<solidity::TypePointer> const& _types);
|
2018-11-21 14:13:50 +00:00
|
|
|
/// Returns the SMT kind that models the Solidity type type category _category.
|
2019-05-09 10:16:52 +00:00
|
|
|
Kind smtKind(solidity::Type::Category _category);
|
2018-10-25 14:00:09 +00:00
|
|
|
|
2018-12-10 16:23:36 +00:00
|
|
|
/// Returns true if type is fully supported (declaration and operations).
|
2019-05-09 10:16:52 +00:00
|
|
|
bool isSupportedType(solidity::Type::Category _category);
|
|
|
|
bool isSupportedType(solidity::Type const& _type);
|
2018-12-10 16:23:36 +00:00
|
|
|
/// Returns true if type is partially supported (declaration).
|
2019-05-09 10:16:52 +00:00
|
|
|
bool isSupportedTypeDeclaration(solidity::Type::Category _category);
|
|
|
|
bool isSupportedTypeDeclaration(solidity::Type const& _type);
|
2018-10-15 15:32:17 +00:00
|
|
|
|
2019-05-09 10:16:52 +00:00
|
|
|
bool isInteger(solidity::Type::Category _category);
|
|
|
|
bool isRational(solidity::Type::Category _category);
|
|
|
|
bool isFixedBytes(solidity::Type::Category _category);
|
|
|
|
bool isAddress(solidity::Type::Category _category);
|
|
|
|
bool isContract(solidity::Type::Category _category);
|
|
|
|
bool isEnum(solidity::Type::Category _category);
|
|
|
|
bool isNumber(solidity::Type::Category _category);
|
|
|
|
bool isBool(solidity::Type::Category _category);
|
|
|
|
bool isFunction(solidity::Type::Category _category);
|
|
|
|
bool isMapping(solidity::Type::Category _category);
|
|
|
|
bool isArray(solidity::Type::Category _category);
|
|
|
|
bool isTuple(solidity::Type::Category _category);
|
2019-08-07 08:48:09 +00:00
|
|
|
bool isStringLiteral(solidity::Type::Category _category);
|
2018-10-15 15:32:17 +00:00
|
|
|
|
2018-10-17 16:00:42 +00:00
|
|
|
/// Returns a new symbolic variable, according to _type.
|
|
|
|
/// Also returns whether the type is abstract or not,
|
|
|
|
/// which is true for unsupported types.
|
2019-07-03 14:05:56 +00:00
|
|
|
std::pair<bool, std::shared_ptr<SymbolicVariable>> newSymbolicVariable(solidity::Type const& _type, std::string const& _uniqueName, EncodingContext& _context);
|
2018-10-17 13:56:44 +00:00
|
|
|
|
2019-05-09 10:16:52 +00:00
|
|
|
Expression minValue(solidity::IntegerType const& _type);
|
|
|
|
Expression maxValue(solidity::IntegerType const& _type);
|
2018-11-22 13:48:31 +00:00
|
|
|
|
2019-07-03 14:05:56 +00:00
|
|
|
void setSymbolicZeroValue(SymbolicVariable const& _variable, EncodingContext& _context);
|
|
|
|
void setSymbolicZeroValue(Expression _expr, solidity::TypePointer const& _type, EncodingContext& _context);
|
|
|
|
void setSymbolicUnknownValue(SymbolicVariable const& _variable, EncodingContext& _context);
|
|
|
|
void setSymbolicUnknownValue(Expression _expr, solidity::TypePointer const& _type, EncodingContext& _context);
|
2018-11-22 13:48:31 +00:00
|
|
|
|
|
|
|
}
|
2018-10-15 15:32:17 +00:00
|
|
|
}
|
|
|
|
}
|