Introduce namespace langutil in liblangutil directory.

Also:
- Use {}-style list initialisation for SourceLocation construction
- Introduce new system includes
- Changes the API of the Scanner to take source as value (with move) as opposed to as a reference
This commit is contained in:
Christian Parpart 2018-11-14 17:11:55 +01:00 committed by Alex Beregszaszi
parent 80371e2d25
commit d67322a186
118 changed files with 479 additions and 290 deletions

View File

@ -35,6 +35,7 @@
using namespace std;
using namespace dev;
using namespace dev::eth;
using namespace langutil;
void Assembly::append(Assembly const& _a)
{

View File

@ -93,7 +93,7 @@ public:
void setDeposit(int _deposit) { m_deposit = _deposit; assertThrow(m_deposit >= 0, InvalidDeposit, ""); }
/// Changes the source location used for each appended item.
void setSourceLocation(SourceLocation const& _location) { m_currentSourceLocation = _location; }
void setSourceLocation(langutil::SourceLocation const& _location) { m_currentSourceLocation = _location; }
/// Assembles the assembly into bytecode. The assembly should not be modified after this call, since the assembled version is cached.
LinkerObject const& assemble() const;
@ -178,7 +178,7 @@ protected:
int m_deposit = 0;
SourceLocation m_currentSourceLocation;
langutil::SourceLocation m_currentSourceLocation;
};
inline std::ostream& operator<<(std::ostream& _out, Assembly const& _a)

View File

@ -57,14 +57,14 @@ class AssemblyItem
public:
enum class JumpType { Ordinary, IntoFunction, OutOfFunction };
AssemblyItem(u256 _push, SourceLocation const& _location = SourceLocation()):
AssemblyItem(u256 _push, langutil::SourceLocation const& _location = langutil::SourceLocation()):
AssemblyItem(Push, _push, _location) { }
AssemblyItem(solidity::Instruction _i, SourceLocation const& _location = SourceLocation()):
AssemblyItem(solidity::Instruction _i, langutil::SourceLocation const& _location = langutil::SourceLocation()):
m_type(Operation),
m_instruction(_i),
m_location(_location)
{}
AssemblyItem(AssemblyItemType _type, u256 _data = 0, SourceLocation const& _location = SourceLocation()):
AssemblyItem(AssemblyItemType _type, u256 _data = 0, langutil::SourceLocation const& _location = langutil::SourceLocation()):
m_type(_type),
m_location(_location)
{
@ -124,8 +124,8 @@ public:
/// @returns true if the assembly item can be used in a functional context.
bool canBeFunctional() const;
void setLocation(SourceLocation const& _location) { m_location = _location; }
SourceLocation const& location() const { return m_location; }
void setLocation(langutil::SourceLocation const& _location) { m_location = _location; }
langutil::SourceLocation const& location() const { return m_location; }
void setJumpType(JumpType _jumpType) { m_jumpType = _jumpType; }
JumpType getJumpType() const { return m_jumpType; }
@ -140,7 +140,7 @@ private:
AssemblyItemType m_type;
Instruction m_instruction; ///< Only valid if m_type == Operation
std::shared_ptr<u256> m_data; ///< Only valid if m_type != Operation
SourceLocation m_location;
langutil::SourceLocation m_location;
JumpType m_jumpType = JumpType::Ordinary;
/// Pushed value for operations with data to be determined during assembly stage,
/// e.g. PushSubSize, PushTag, PushSub, etc.

View File

@ -30,6 +30,7 @@
using namespace std;
using namespace dev;
using namespace dev::eth;
using namespace langutil;
vector<AssemblyItem> CommonSubexpressionEliminator::getOptimizedItems()
{

View File

@ -34,6 +34,11 @@
#include <libevmasm/SemanticInformation.h>
#include <libevmasm/KnownState.h>
namespace langutil
{
struct SourceLocation;
}
namespace dev
{
namespace eth
@ -137,10 +142,10 @@ private:
bool removeStackTopIfPossible();
/// Appends a dup instruction to m_generatedItems to retrieve the element at the given stack position.
void appendDup(int _fromPosition, SourceLocation const& _location);
void appendDup(int _fromPosition, langutil::SourceLocation const& _location);
/// Appends a swap instruction to m_generatedItems to retrieve the element at the given stack position.
/// @note this might also remove the last item if it exactly the same swap instruction.
void appendOrRemoveSwap(int _fromPosition, SourceLocation const& _location);
void appendOrRemoveSwap(int _fromPosition, langutil::SourceLocation const& _location);
/// Appends the given assembly item.
void appendItem(AssemblyItem const& _item);

View File

@ -275,7 +275,7 @@ void ControlFlowGraph::gatherKnowledge()
//@todo in the case of JUMPI, add knowledge about the condition to the state
// (for both values of the condition)
set<u256> tags = state->tagsInExpression(
state->stackElement(state->stackHeight(), SourceLocation())
state->stackElement(state->stackHeight(), langutil::SourceLocation{})
);
state->feedItem(m_items.at(pc++));

View File

@ -34,7 +34,7 @@
using namespace std;
using namespace dev;
using namespace dev::eth;
using namespace langutil;
bool ExpressionClasses::Expression::operator<(ExpressionClasses::Expression const& _other) const
{

View File

@ -31,6 +31,11 @@
#include <memory>
#include <set>
namespace langutil
{
struct SourceLocation;
}
namespace dev
{
namespace eth
@ -82,7 +87,7 @@ public:
void forceEqual(Id _id, AssemblyItem const& _item, Ids const& _arguments, bool _copyItem = true);
/// @returns the id of a new class which is different to all other classes.
Id newClass(SourceLocation const& _location);
Id newClass(langutil::SourceLocation const& _location);
/// @returns true if the values of the given classes are known to be different (on every input).
/// @note that this function might still return false for some different inputs.

View File

@ -29,6 +29,7 @@
using namespace std;
using namespace dev;
using namespace dev::eth;
using namespace langutil;
ostream& KnownState::stream(ostream& _out) const
{

View File

@ -46,6 +46,11 @@
#include <libevmasm/ExpressionClasses.h>
#include <libevmasm/SemanticInformation.h>
namespace langutil
{
struct SourceLocation;
}
namespace dev
{
namespace eth
@ -121,9 +126,9 @@ public:
/// Retrieves the current equivalence class fo the given stack element (or generates a new
/// one if it does not exist yet).
Id stackElement(int _stackHeight, SourceLocation const& _location);
Id stackElement(int _stackHeight, langutil::SourceLocation const& _location);
/// @returns the stackElement relative to the current stack height.
Id relativeStackElement(int _stackOffset, SourceLocation const& _location = SourceLocation());
Id relativeStackElement(int _stackOffset, langutil::SourceLocation const& _location = {});
/// @returns its set of tags if the given expression class is a known tag union; returns a set
/// containing the tag if it is a PushTag expression and the empty set otherwise.
@ -142,22 +147,22 @@ private:
/// Assigns a new equivalence class to the next sequence number of the given stack element.
void setStackElement(int _stackHeight, Id _class);
/// Swaps the given stack elements in their next sequence number.
void swapStackElements(int _stackHeightA, int _stackHeightB, SourceLocation const& _location);
void swapStackElements(int _stackHeightA, int _stackHeightB, langutil::SourceLocation const& _location);
/// Increments the sequence number, deletes all storage information that might be overwritten
/// and stores the new value at the given slot.
/// @returns the store operation, which might be invalid if storage was not modified
StoreOperation storeInStorage(Id _slot, Id _value, SourceLocation const& _location);
StoreOperation storeInStorage(Id _slot, Id _value, langutil::SourceLocation const& _location);
/// Retrieves the current value at the given slot in storage or creates a new special sload class.
Id loadFromStorage(Id _slot, SourceLocation const& _location);
Id loadFromStorage(Id _slot, langutil::SourceLocation const& _location);
/// Increments the sequence number, deletes all memory information that might be overwritten
/// and stores the new value at the given slot.
/// @returns the store operation, which might be invalid if memory was not modified
StoreOperation storeInMemory(Id _slot, Id _value, SourceLocation const& _location);
StoreOperation storeInMemory(Id _slot, Id _value, langutil::SourceLocation const& _location);
/// Retrieves the current value at the given slot in memory or creates a new special mload class.
Id loadFromMemory(Id _slot, SourceLocation const& _location);
Id loadFromMemory(Id _slot, langutil::SourceLocation const& _location);
/// Finds or creates a new expression that applies the Keccak-256 hash function to the contents in memory.
Id applyKeccak256(Id _start, Id _length, SourceLocation const& _location);
Id applyKeccak256(Id _start, Id _length, langutil::SourceLocation const& _location);
/// @returns a new or already used Id representing the given set of tags.
Id tagUnion(std::set<u256> _tags);

View File

@ -38,7 +38,7 @@
using namespace std;
using namespace dev;
using namespace dev::eth;
using namespace langutil;
SimplificationRule<Pattern> const* Rules::findFirstMatch(
Expression const& _expr,

View File

@ -31,6 +31,11 @@
#include <functional>
#include <vector>
namespace langutil
{
struct SourceLocation;
}
namespace dev
{
namespace eth
@ -97,7 +102,7 @@ public:
unsigned matchGroup() const { return m_matchGroup; }
bool matches(Expression const& _expr, ExpressionClasses const& _classes) const;
AssemblyItem toAssemblyItem(SourceLocation const& _location) const;
AssemblyItem toAssemblyItem(langutil::SourceLocation const& _location) const;
std::vector<Pattern> arguments() const { return m_arguments; }
/// @returns the id of the matched expression if this pattern is part of a match group.
@ -135,7 +140,7 @@ struct ExpressionTemplate
{
using Expression = ExpressionClasses::Expression;
using Id = ExpressionClasses::Id;
explicit ExpressionTemplate(Pattern const& _pattern, SourceLocation const& _location);
explicit ExpressionTemplate(Pattern const& _pattern, langutil::SourceLocation const& _location);
std::string toString() const;
bool hasId = false;
/// Id of the matched expression, if available.

View File

@ -52,15 +52,9 @@
#include <liblangutil/CharStream.h>
#include <liblangutil/Exceptions.h>
#include <algorithm>
#include <tuple>
using namespace std;
namespace dev
{
namespace solidity
{
using namespace langutil;
char CharStream::advanceAndGet(size_t _chars)
{
@ -111,5 +105,4 @@ tuple<int, int> CharStream::translatePositionToLineColumn(int _position) const
return tuple<int, int>(lineNumber, searchPosition - lineStart);
}
}
}

View File

@ -56,9 +56,7 @@
#include <string>
#include <tuple>
namespace dev
{
namespace solidity
namespace langutil
{
/**
@ -97,4 +95,3 @@ private:
};
}
}

View File

@ -21,12 +21,12 @@
*/
#include <liblangutil/ErrorReporter.h>
#include <libsolidity/ast/AST.h>
#include <liblangutil/SourceLocation.h>
#include <memory>
using namespace std;
using namespace dev;
using namespace dev::solidity;
using namespace langutil;
ErrorReporter& ErrorReporter::operator=(ErrorReporter const& _errorReporter)
{

View File

@ -25,12 +25,8 @@
#include <liblangutil/Exceptions.h>
#include <liblangutil/SourceLocation.h>
namespace dev
namespace langutil
{
namespace solidity
{
class ASTNode;
class ErrorReporter
{
@ -120,7 +116,5 @@ private:
const unsigned c_maxErrorsAllowed = 256;
};
}
}

View File

@ -24,7 +24,7 @@
using namespace std;
using namespace dev;
using namespace dev::solidity;
using namespace langutil;
Error::Error(Type _type, SourceLocation const& _location, string const& _description):
m_type(_type)

View File

@ -24,33 +24,33 @@
#include <string>
#include <utility>
#include <vector>
#include <memory>
#include <libdevcore/Exceptions.h>
#include <libdevcore/Assertions.h>
#include <liblangutil/SourceLocation.h>
namespace dev
{
namespace solidity
namespace langutil
{
class Error;
using ErrorList = std::vector<std::shared_ptr<Error const>>;
struct CompilerError: virtual Exception {};
struct InternalCompilerError: virtual Exception {};
struct FatalError: virtual Exception {};
struct UnimplementedFeatureError: virtual Exception{};
struct CompilerError: virtual dev::Exception {};
struct InternalCompilerError: virtual dev::Exception {};
struct FatalError: virtual dev::Exception {};
struct UnimplementedFeatureError: virtual dev::Exception {};
/// Assertion that throws an InternalCompilerError containing the given description if it is not met.
#define solAssert(CONDITION, DESCRIPTION) \
assertThrow(CONDITION, ::dev::solidity::InternalCompilerError, DESCRIPTION)
assertThrow(CONDITION, ::langutil::InternalCompilerError, DESCRIPTION)
#define solUnimplementedAssert(CONDITION, DESCRIPTION) \
assertThrow(CONDITION, ::dev::solidity::UnimplementedFeatureError, DESCRIPTION)
assertThrow(CONDITION, ::langutil::UnimplementedFeatureError, DESCRIPTION)
#define solUnimplemented(DESCRIPTION) \
solUnimplementedAssert(false, DESCRIPTION)
class Error: virtual public Exception
class Error: virtual public dev::Exception
{
public:
enum class Type
@ -98,7 +98,6 @@ private:
std::string m_typeName;
};
using errorSourceLocationInfo = std::pair<std::string, SourceLocation>;
class SecondarySourceLocation
@ -109,6 +108,7 @@ public:
infos.push_back(std::make_pair(_errMsg, _sourceLocation));
return *this;
}
/// Limits the number of secondary source locations to 32 and appends a notice to the
/// error message.
void limitSize(std::string& _message)
@ -124,9 +124,8 @@ public:
std::vector<errorSourceLocationInfo> infos;
};
using errinfo_sourceLocation = boost::error_info<struct tag_sourceLocation, SourceLocation>;
using errinfo_secondarySourceLocation = boost::error_info<struct tag_secondarySourceLocation, SecondarySourceLocation>;
}
}

View File

@ -25,8 +25,7 @@
#include <liblangutil/ErrorReporter.h>
using namespace std;
using namespace dev;
using namespace dev::solidity;
using namespace langutil;
std::shared_ptr<string const> const& ParserBase::sourceName() const
{

View File

@ -22,12 +22,11 @@
#pragma once
#include <memory>
#include <liblangutil/Token.h>
#include <memory>
#include <string>
namespace dev
{
namespace solidity
namespace langutil
{
class ErrorReporter;
@ -90,4 +89,3 @@ protected:
};
}
}

View File

@ -50,16 +50,14 @@
* Solidity scanner.
*/
#include <algorithm>
#include <tuple>
#include <liblangutil/Exceptions.h>
#include <liblangutil/Scanner.h>
#include <algorithm>
#include <tuple>
using namespace std;
namespace dev
{
namespace solidity
namespace langutil
{
namespace
@ -143,10 +141,10 @@ private:
}; // end of LiteralScope class
void Scanner::reset(CharStream const& _source, string const& _sourceName)
void Scanner::reset(CharStream _source, string _sourceName)
{
m_source = _source;
m_sourceName = make_shared<string const>(_sourceName);
m_source = std::move(_source);
m_sourceName = make_shared<string const>(std::move(_sourceName));
reset();
}
@ -866,5 +864,5 @@ tuple<Token, unsigned, unsigned> Scanner::scanIdentifierOrKeyword()
return TokenTraits::fromIdentifierOrKeyword(m_nextToken.literal);
}
}
}

View File

@ -52,15 +52,13 @@
#pragma once
#include <libdevcore/Common.h>
#include <libdevcore/CommonData.h>
#include <liblangutil/Token.h>
#include <liblangutil/CharStream.h>
#include <liblangutil/SourceLocation.h>
#include <liblangutil/Token.h>
#include <libdevcore/Common.h>
#include <libdevcore/CommonData.h>
namespace dev
{
namespace solidity
namespace langutil
{
class AstRawString;
@ -71,13 +69,12 @@ class Scanner
{
friend class LiteralScope;
public:
explicit Scanner(CharStream const& _source = CharStream(), std::string const& _sourceName = "") { reset(_source, _sourceName); }
explicit Scanner(CharStream _source = CharStream(), std::string _sourceName = "") { reset(std::move(_source), std::move(_sourceName)); }
std::string source() const { return m_source.source(); }
/// Resets the scanner as if newly constructed with _source and _sourceName as input.
void reset(CharStream const& _source, std::string const& _sourceName);
void reset(CharStream _source, std::string _sourceName);
/// Resets scanner to the start of input.
void reset();
@ -216,4 +213,3 @@ private:
};
}
}

View File

@ -22,13 +22,13 @@
#pragma once
#include <libdevcore/Common.h> // defines noexcept macro for MSVC
#include <memory>
#include <string>
#include <ostream>
#include <tuple>
#include <libdevcore/Common.h> // defines noexcept macro for MSVC
namespace dev
namespace langutil
{
/**

View File

@ -40,15 +40,13 @@
// You should have received a copy of the GNU General Public License
// along with solidity. If not, see <http://www.gnu.org/licenses/>.
#include <map>
#include <liblangutil/Token.h>
#include <boost/range/iterator_range.hpp>
#include <map>
using namespace std;
namespace dev
{
namespace solidity
namespace langutil
{
void ElementaryTypeNameToken::assertDetails(Token _baseType, unsigned const& _first, unsigned const& _second)
@ -204,4 +202,3 @@ tuple<Token, unsigned int, unsigned int> fromIdentifierOrKeyword(string const& _
}
}
}

View File

@ -45,11 +45,12 @@
#include <libdevcore/Common.h>
#include <liblangutil/Exceptions.h>
#include <liblangutil/UndefMacros.h>
#include <iosfwd>
namespace dev
{
namespace solidity
#include <iosfwd>
#include <string>
#include <tuple>
namespace langutil
{
// TOKEN_LIST takes a list of 3 macros M, all of which satisfy the
@ -375,4 +376,3 @@ private:
};
}
}

View File

@ -24,12 +24,16 @@
#include <libsolidity/ast/ASTVisitor.h>
namespace langutil
{
class ErrorReporter;
}
namespace dev
{
namespace solidity
{
class ErrorReporter;
class TypeChecker;
/**
@ -39,7 +43,7 @@ class ConstantEvaluator: private ASTConstVisitor
{
public:
ConstantEvaluator(
ErrorReporter& _errorReporter,
langutil::ErrorReporter& _errorReporter,
size_t _newDepth = 0,
std::shared_ptr<std::map<ASTNode const*, TypePointer>> _types = std::make_shared<std::map<ASTNode const*, TypePointer>>()
):
@ -61,7 +65,7 @@ private:
void setType(ASTNode const& _node, TypePointer const& _type);
TypePointer type(ASTNode const& _node);
ErrorReporter& m_errorReporter;
langutil::ErrorReporter& m_errorReporter;
/// Current recursion depth.
size_t m_depth = 0;
std::shared_ptr<std::map<ASTNode const*, TypePointer>> m_types;

View File

@ -16,8 +16,10 @@
*/
#include <libsolidity/analysis/ControlFlowAnalyzer.h>
#include <liblangutil/SourceLocation.h>
using namespace std;
using namespace langutil;
using namespace dev::solidity;
bool ControlFlowAnalyzer::analyze(ASTNode const& _astRoot)

View File

@ -29,7 +29,7 @@ namespace solidity
class ControlFlowAnalyzer: private ASTConstVisitor
{
public:
explicit ControlFlowAnalyzer(CFG const& _cfg, ErrorReporter& _errorReporter):
explicit ControlFlowAnalyzer(CFG const& _cfg, langutil::ErrorReporter& _errorReporter):
m_cfg(_cfg), m_errorReporter(_errorReporter) {}
bool analyze(ASTNode const& _astRoot);
@ -45,7 +45,7 @@ private:
) const;
CFG const& m_cfg;
ErrorReporter& m_errorReporter;
langutil::ErrorReporter& m_errorReporter;
};
}

View File

@ -23,6 +23,7 @@
#include <algorithm>
using namespace std;
using namespace langutil;
using namespace dev::solidity;
bool CFG::constructFlow(ASTNode const& _astRoot)
@ -133,4 +134,4 @@ void CFG::applyModifierFlowToFunctionFlow(
_functionFlow->entry = copySrcToCopyDst[_modifierFlow.entry];
_functionFlow->exit = copySrcToCopyDst[_modifierFlow.exit];
}
}

View File

@ -101,7 +101,7 @@ struct ModifierFlow: FunctionFlow
class CFG: private ASTConstVisitor
{
public:
explicit CFG(ErrorReporter& _errorReporter): m_errorReporter(_errorReporter) {}
explicit CFG(langutil::ErrorReporter& _errorReporter): m_errorReporter(_errorReporter) {}
bool constructFlow(ASTNode const& _astRoot);
@ -133,7 +133,7 @@ private:
FunctionFlow* _functionFlow
);
ErrorReporter& m_errorReporter;
langutil::ErrorReporter& m_errorReporter;
/// Node container.
/// All nodes allocated during the construction of the control flow graph

View File

@ -28,6 +28,7 @@
using namespace std;
using namespace dev;
using namespace langutil;
using namespace dev::solidity;
bool DocStringAnalyser::analyseDocStrings(SourceUnit const& _sourceUnit)

View File

@ -25,13 +25,16 @@
#include <libsolidity/ast/ASTVisitor.h>
namespace langutil
{
class ErrorReporter;
}
namespace dev
{
namespace solidity
{
class ErrorReporter;
/**
* Parses and analyses the doc strings.
* Stores the parsing results in the AST annotations and reports errors.
@ -39,7 +42,7 @@ class ErrorReporter;
class DocStringAnalyser: private ASTConstVisitor
{
public:
DocStringAnalyser(ErrorReporter& _errorReporter): m_errorReporter(_errorReporter) {}
DocStringAnalyser(langutil::ErrorReporter& _errorReporter): m_errorReporter(_errorReporter) {}
bool analyseDocStrings(SourceUnit const& _sourceUnit);
private:
@ -75,7 +78,7 @@ private:
void appendError(std::string const& _description);
bool m_errorOccured = false;
ErrorReporter& m_errorReporter;
langutil::ErrorReporter& m_errorReporter;
};
}

View File

@ -30,6 +30,7 @@
#include <boost/algorithm/string.hpp>
using namespace std;
using namespace langutil;
namespace dev
{
@ -59,7 +60,7 @@ bool NameAndTypeResolver::registerDeclarations(SourceUnit& _sourceUnit, ASTNode
{
DeclarationRegistrationHelper registrar(m_scopes, _sourceUnit, m_errorReporter, _currentScope);
}
catch (FatalError const&)
catch (langutil::FatalError const&)
{
if (m_errorReporter.errors().empty())
throw; // Something is weird here, rather throw again.
@ -129,7 +130,7 @@ bool NameAndTypeResolver::resolveNamesAndTypes(ASTNode& _node, bool _resolveInsi
{
return resolveNamesAndTypesInternal(_node, _resolveInsideCode);
}
catch (FatalError const&)
catch (langutil::FatalError const&)
{
if (m_errorReporter.errors().empty())
throw; // Something is weird here, rather throw again.
@ -144,7 +145,7 @@ bool NameAndTypeResolver::updateDeclaration(Declaration const& _declaration)
m_scopes[nullptr]->registerDeclaration(_declaration, nullptr, false, true);
solAssert(_declaration.scope() == nullptr, "Updated declaration outside global scope.");
}
catch (FatalError const&)
catch (langutil::FatalError const&)
{
if (m_errorReporter.errors().empty())
throw; // Something is weird here, rather throw again.

View File

@ -30,13 +30,16 @@
#include <libsolidity/ast/ASTVisitor.h>
#include <libsolidity/ast/ASTAnnotations.h>
namespace langutil
{
class ErrorReporter;
}
namespace dev
{
namespace solidity
{
class ErrorReporter;
/**
* Resolves name references, typenames and sets the (explicitly given) types for all variable
* declarations.
@ -50,7 +53,7 @@ public:
NameAndTypeResolver(
std::vector<Declaration const*> const& _globals,
std::map<ASTNode const*, std::shared_ptr<DeclarationContainer>>& _scopes,
ErrorReporter& _errorReporter
langutil::ErrorReporter& _errorReporter
);
/// Registers all declarations found in the AST node, usually a source unit.
/// @returns false in case of error.
@ -125,7 +128,7 @@ private:
std::map<ASTNode const*, std::shared_ptr<DeclarationContainer>>& m_scopes;
DeclarationContainer* m_currentScope = nullptr;
ErrorReporter& m_errorReporter;
langutil::ErrorReporter& m_errorReporter;
};
/**
@ -142,7 +145,7 @@ public:
DeclarationRegistrationHelper(
std::map<ASTNode const*, std::shared_ptr<DeclarationContainer>>& _scopes,
ASTNode& _astRoot,
ErrorReporter& _errorReporter,
langutil::ErrorReporter& _errorReporter,
ASTNode const* _currentScope = nullptr
);
@ -150,10 +153,10 @@ public:
DeclarationContainer& _container,
Declaration const& _declaration,
std::string const* _name,
SourceLocation const* _errorLocation,
langutil::SourceLocation const* _errorLocation,
bool _warnOnShadow,
bool _inactive,
ErrorReporter& _errorReporter
langutil::ErrorReporter& _errorReporter
);
private:
@ -194,7 +197,7 @@ private:
std::map<ASTNode const*, std::shared_ptr<DeclarationContainer>>& m_scopes;
ASTNode const* m_currentScope = nullptr;
VariableScope* m_currentFunction = nullptr;
ErrorReporter& m_errorReporter;
langutil::ErrorReporter& m_errorReporter;
};
}

View File

@ -29,6 +29,7 @@
using namespace std;
using namespace dev;
using namespace langutil;
using namespace dev::solidity;

View File

@ -23,13 +23,17 @@
#include <libsolidity/ast/ASTForward.h>
#include <libsolidity/ast/ASTVisitor.h>
namespace langutil
{
class ErrorReporter;
struct SourceLocation;
}
namespace dev
{
namespace solidity
{
class ErrorReporter;
/**
* This module performs analyses on the AST that are done after type checking and assignments of types:
* - whether there are circular references in constant state variables
@ -39,13 +43,13 @@ class PostTypeChecker: private ASTConstVisitor
{
public:
/// @param _errorReporter provides the error logging functionality.
PostTypeChecker(ErrorReporter& _errorReporter): m_errorReporter(_errorReporter) {}
PostTypeChecker(langutil::ErrorReporter& _errorReporter): m_errorReporter(_errorReporter) {}
bool check(ASTNode const& _astRoot);
private:
/// Adds a new error to the list of errors.
void typeError(SourceLocation const& _location, std::string const& _description);
void typeError(langutil::SourceLocation const& _location, std::string const& _description);
bool visit(ContractDefinition const& _contract) override;
void endVisit(ContractDefinition const& _contract) override;
@ -57,7 +61,7 @@ private:
VariableDeclaration const* findCycle(VariableDeclaration const& _startingFrom);
ErrorReporter& m_errorReporter;
langutil::ErrorReporter& m_errorReporter;
VariableDeclaration const* m_currentConstVariable = nullptr;
std::vector<VariableDeclaration const*> m_constVariables; ///< Required for determinism.

View File

@ -36,9 +36,12 @@
#include <boost/range/adaptor/transformed.hpp>
using namespace std;
using namespace dev;
using namespace dev::solidity;
using namespace langutil;
namespace dev
{
namespace solidity
{
bool ReferencesResolver::resolve(ASTNode const& _root)
{
@ -454,3 +457,6 @@ void ReferencesResolver::fatalDeclarationError(SourceLocation const& _location,
m_errorOccurred = true;
m_errorReporter.fatalDeclarationError(_location, _description);
}
}
}

View File

@ -28,12 +28,17 @@
#include <libsolidity/ast/ASTVisitor.h>
#include <libsolidity/ast/ASTAnnotations.h>
namespace langutil
{
class ErrorReporter;
struct SourceLocation;
}
namespace dev
{
namespace solidity
{
class ErrorReporter;
class NameAndTypeResolver;
/**
@ -44,7 +49,7 @@ class ReferencesResolver: private ASTConstVisitor
{
public:
ReferencesResolver(
ErrorReporter& _errorReporter,
langutil::ErrorReporter& _errorReporter,
NameAndTypeResolver& _resolver,
bool _resolveInsideCode = false
):
@ -77,18 +82,18 @@ private:
void endVisit(VariableDeclaration const& _variable) override;
/// Adds a new error to the list of errors.
void typeError(SourceLocation const& _location, std::string const& _description);
void typeError(langutil::SourceLocation const& _location, std::string const& _description);
/// Adds a new error to the list of errors and throws to abort reference resolving.
void fatalTypeError(SourceLocation const& _location, std::string const& _description);
void fatalTypeError(langutil::SourceLocation const& _location, std::string const& _description);
/// Adds a new error to the list of errors.
void declarationError(SourceLocation const& _location, std::string const& _description);
void declarationError(langutil::SourceLocation const& _location, std::string const& _description);
/// Adds a new error to the list of errors and throws to abort reference resolving.
void fatalDeclarationError(SourceLocation const& _location, std::string const& _description);
void fatalDeclarationError(langutil::SourceLocation const& _location, std::string const& _description);
ErrorReporter& m_errorReporter;
langutil::ErrorReporter& m_errorReporter;
NameAndTypeResolver& m_resolver;
/// Stack of return parameters.
std::vector<ParameterList const*> m_returnParameters;

View File

@ -22,8 +22,9 @@
#pragma once
#include <libsolidity/parsing/Token.h>
#include <string>
#include <vector>
#include <liblangutil/Token.h>
namespace dev
{

View File

@ -28,6 +28,7 @@
using namespace std;
using namespace dev;
using namespace langutil;
using namespace dev::solidity;
bool StaticAnalyzer::analyze(SourceUnit const& _sourceUnit)

View File

@ -28,6 +28,11 @@
#include <libsolidity/ast/ASTForward.h>
#include <libsolidity/ast/ASTVisitor.h>
namespace langutil
{
class ErrorReporter;
}
namespace dev
{
namespace solidity
@ -44,7 +49,7 @@ class StaticAnalyzer: private ASTConstVisitor
{
public:
/// @param _errorReporter provides the error logging functionality.
explicit StaticAnalyzer(ErrorReporter& _errorReporter): m_errorReporter(_errorReporter) {}
explicit StaticAnalyzer(langutil::ErrorReporter& _errorReporter): m_errorReporter(_errorReporter) {}
/// Performs static analysis on the given source unit and all of its sub-nodes.
/// @returns true iff all checks passed. Note even if all checks passed, errors() can still contain warnings
@ -70,7 +75,7 @@ private:
/// @returns the size of this type in storage, including all sub-types.
static bigint structureSizeEstimate(Type const& _type, std::set<StructDefinition const*>& _structsSeen);
ErrorReporter& m_errorReporter;
langutil::ErrorReporter& m_errorReporter;
/// Flag that indicates whether the current contract definition is a library.
bool m_library = false;

View File

@ -29,6 +29,7 @@
using namespace std;
using namespace dev;
using namespace langutil;
using namespace dev::solidity;

View File

@ -23,6 +23,11 @@
#include <libsolidity/ast/ASTForward.h>
#include <libsolidity/ast/ASTVisitor.h>
namespace langutil
{
class ErrorReporter;
}
namespace dev
{
namespace solidity
@ -39,7 +44,7 @@ class SyntaxChecker: private ASTConstVisitor
{
public:
/// @param _errorReporter provides the error logging functionality.
SyntaxChecker(ErrorReporter& _errorReporter): m_errorReporter(_errorReporter) {}
SyntaxChecker(langutil::ErrorReporter& _errorReporter): m_errorReporter(_errorReporter) {}
bool checkSyntax(ASTNode const& _astRoot);
@ -81,7 +86,7 @@ private:
bool visit(StructDefinition const& _struct) override;
bool visit(Literal const& _literal) override;
ErrorReporter& m_errorReporter;
langutil::ErrorReporter& m_errorReporter;
/// Flag that indicates whether a function modifier actually contains '_'.
bool m_placeholderFound = false;

View File

@ -35,6 +35,7 @@
using namespace std;
using namespace dev;
using namespace langutil;
using namespace dev::solidity;
namespace

View File

@ -29,13 +29,16 @@
#include <libsolidity/ast/ASTForward.h>
#include <libsolidity/ast/ASTVisitor.h>
namespace langutil
{
class ErrorReporter;
}
namespace dev
{
namespace solidity
{
class ErrorReporter;
/**
* The module that performs type analysis on the AST, checks the applicability of operations on
* those types and stores errors for invalid operations.
@ -45,7 +48,7 @@ class TypeChecker: private ASTConstVisitor
{
public:
/// @param _errorReporter provides the error logging functionality.
TypeChecker(EVMVersion _evmVersion, ErrorReporter& _errorReporter):
TypeChecker(EVMVersion _evmVersion, langutil::ErrorReporter& _errorReporter):
m_evmVersion(_evmVersion),
m_errorReporter(_errorReporter)
{}
@ -183,7 +186,7 @@ private:
/// Flag indicating whether we are currently inside a StructDefinition.
bool m_insideStruct = false;
ErrorReporter& m_errorReporter;
langutil::ErrorReporter& m_errorReporter;
};
}

View File

@ -22,10 +22,13 @@
#include <libsolidity/inlineasm/AsmData.h>
#include <libsolidity/ast/ExperimentalFeatures.h>
#include <liblangutil/ErrorReporter.h>
#include <functional>
using namespace std;
using namespace dev;
using namespace langutil;
using namespace dev::solidity;
namespace

View File

@ -21,11 +21,15 @@
#include <libsolidity/ast/ASTForward.h>
#include <libsolidity/ast/ASTVisitor.h>
#include <liblangutil/ErrorReporter.h>
#include <map>
#include <memory>
namespace langutil
{
class ErrorReporter;
struct SourceLocation;
}
namespace dev
{
namespace solidity
@ -34,7 +38,7 @@ namespace solidity
class ViewPureChecker: private ASTConstVisitor
{
public:
ViewPureChecker(std::vector<std::shared_ptr<ASTNode>> const& _ast, ErrorReporter& _errorReporter):
ViewPureChecker(std::vector<std::shared_ptr<ASTNode>> const& _ast, langutil::ErrorReporter& _errorReporter):
m_ast(_ast), m_errorReporter(_errorReporter) {}
bool check();
@ -43,7 +47,7 @@ private:
struct MutabilityAndLocation
{
StateMutability mutability;
SourceLocation location;
langutil::SourceLocation location;
};
bool visit(FunctionDefinition const& _funDef) override;
@ -62,15 +66,15 @@ private:
/// Creates appropriate warnings and errors and sets @a m_currentBestMutability.
void reportMutability(
StateMutability _mutability,
SourceLocation const& _location,
boost::optional<SourceLocation> const& _nestedLocation = {}
langutil::SourceLocation const& _location,
boost::optional<langutil::SourceLocation> const& _nestedLocation = {}
);
std::vector<std::shared_ptr<ASTNode>> const& m_ast;
ErrorReporter& m_errorReporter;
langutil::ErrorReporter& m_errorReporter;
bool m_errors = false;
MutabilityAndLocation m_bestMutabilityAndLocation = MutabilityAndLocation{StateMutability::Payable, SourceLocation()};
MutabilityAndLocation m_bestMutabilityAndLocation = MutabilityAndLocation{StateMutability::Payable, langutil::SourceLocation()};
FunctionDefinition const* m_currentFunction = nullptr;
std::map<ModifierDefinition const*, MutabilityAndLocation> m_inferredMutability;
};

View File

@ -23,8 +23,8 @@
#pragma once
#include <libsolidity/parsing/Token.h>
#include <libsolidity/ast/ASTForward.h>
#include <liblangutil/Token.h>
#include <libsolidity/ast/Types.h>
#include <libsolidity/ast/ASTAnnotations.h>
#include <libsolidity/ast/ASTEnums.h>
@ -58,6 +58,8 @@ class ASTConstVisitor;
class ASTNode: private boost::noncopyable
{
public:
using SourceLocation = langutil::SourceLocation;
explicit ASTNode(SourceLocation const& _location);
virtual ~ASTNode();

View File

@ -27,6 +27,7 @@
#include <libsolidity/inlineasm/AsmPrinter.h>
using namespace std;
using namespace langutil;
namespace dev
{

View File

@ -29,6 +29,11 @@
#include <libsolidity/ast/ASTAnnotations.h>
#include <json/json.h>
namespace langutil
{
struct SourceLocation;
}
namespace dev
{
namespace solidity
@ -120,7 +125,7 @@ private:
std::string const& _nodeName,
std::vector<std::pair<std::string, Json::Value>>&& _attributes
);
std::string sourceLocationToString(SourceLocation const& _location) const;
std::string sourceLocationToString(langutil::SourceLocation const& _location) const;
static std::string namePathToString(std::vector<ASTString> const& _namePath);
static Json::Value idOrNull(ASTNode const* _pt)
{

View File

@ -28,6 +28,7 @@
#include <boost/algorithm/string/join.hpp>
using namespace std;
using namespace langutil;
namespace dev
{

View File

@ -45,6 +45,7 @@
using namespace std;
using namespace dev;
using namespace langutil;
using namespace dev::solidity;
namespace

View File

@ -25,7 +25,7 @@
#include <liblangutil/Exceptions.h>
#include <libsolidity/ast/ASTForward.h>
#include <libsolidity/ast/ASTEnums.h>
#include <liblangutil/Token.h>
#include <libsolidity/parsing/Token.h>
#include <libdevcore/Common.h>
#include <libdevcore/CommonIO.h>

View File

@ -30,6 +30,7 @@
using namespace std;
using namespace dev;
using namespace langutil;
using namespace solidity;
void ArrayUtils::copyArrayToStorage(ArrayType const& _targetType, ArrayType const& _sourceType) const

View File

@ -26,6 +26,7 @@
#include <libsolidity/codegen/Compiler.h>
#include <libsolidity/interface/Version.h>
#include <liblangutil/ErrorReporter.h>
#include <liblangutil/Scanner.h>
#include <libsolidity/interface/SourceReferenceFormatter.h>
#include <liblangutil/Scanner.h>
#include <libsolidity/inlineasm/AsmParser.h>
@ -47,6 +48,7 @@
using namespace std;
using namespace langutil;
namespace dev
{
@ -359,7 +361,7 @@ void CompilerContext::appendInlineAssembly(
ErrorList errors;
ErrorReporter errorReporter(errors);
auto scanner = make_shared<Scanner>(CharStream(_assembly), "--CODEGEN--");
auto scanner = make_shared<langutil::Scanner>(langutil::CharStream(_assembly), "--CODEGEN--");
auto parserResult = assembly::Parser(errorReporter, assembly::AsmFlavour::Strict).parse(scanner, false);
#ifdef SOL_OUTPUT_ASM
cout << assembly::AsmPrinter()(*parserResult) << endl;

View File

@ -32,6 +32,7 @@
#include <libdevcore/Whiskers.h>
using namespace std;
using namespace langutil;
namespace dev
{

View File

@ -37,6 +37,7 @@
using namespace std;
using namespace dev;
using namespace langutil;
using namespace dev::solidity;
namespace

View File

@ -36,6 +36,7 @@
#include <libdevcore/Whiskers.h>
using namespace std;
using namespace langutil;
namespace dev
{

View File

@ -28,6 +28,7 @@
using namespace std;
using namespace dev;
using namespace langutil;
using namespace solidity;

View File

@ -55,17 +55,17 @@ public:
/// Copies the value of the current lvalue to the top of the stack and, if @a _remove is true,
/// also removes the reference from the stack.
/// @a _location source location of the current expression, used for error reporting.
virtual void retrieveValue(SourceLocation const& _location, bool _remove = false) const = 0;
virtual void retrieveValue(langutil::SourceLocation const& _location, bool _remove = false) const = 0;
/// Moves a value from the stack to the lvalue. Removes the value if @a _move is true.
/// @a _location is the source location of the expression that caused this operation.
/// Stack pre: value [lvalue_ref]
/// Stack post: if !_move: value_of(lvalue_ref)
virtual void storeValue(Type const& _sourceType,
SourceLocation const& _location = SourceLocation(), bool _move = false) const = 0;
langutil::SourceLocation const& _location = {}, bool _move = false) const = 0;
/// Stores zero in the lvalue. Removes the reference from the stack if @a _removeReference is true.
/// @a _location is the source location of the requested operation
virtual void setToZero(
SourceLocation const& _location = SourceLocation(),
langutil::SourceLocation const& _location = {},
bool _removeReference = true
) const = 0;
@ -83,14 +83,14 @@ public:
StackVariable(CompilerContext& _compilerContext, VariableDeclaration const& _declaration);
unsigned sizeOnStack() const override { return 0; }
void retrieveValue(SourceLocation const& _location, bool _remove = false) const override;
void retrieveValue(langutil::SourceLocation const& _location, bool _remove = false) const override;
virtual void storeValue(
Type const& _sourceType,
SourceLocation const& _location = SourceLocation(),
langutil::SourceLocation const& _location = {},
bool _move = false
) const override;
virtual void setToZero(
SourceLocation const& _location = SourceLocation(),
langutil::SourceLocation const& _location = {},
bool _removeReference = true
) const override;
@ -109,14 +109,14 @@ class MemoryItem: public LValue
public:
MemoryItem(CompilerContext& _compilerContext, Type const& _type, bool _padded = true);
unsigned sizeOnStack() const override { return 1; }
void retrieveValue(SourceLocation const& _location, bool _remove = false) const override;
void retrieveValue(langutil::SourceLocation const& _location, bool _remove = false) const override;
virtual void storeValue(
Type const& _sourceType,
SourceLocation const& _location = SourceLocation(),
langutil::SourceLocation const& _location = {},
bool _move = false
) const override;
virtual void setToZero(
SourceLocation const& _location = SourceLocation(),
langutil::SourceLocation const& _location = {},
bool _removeReference = true
) const override;
private:
@ -137,14 +137,14 @@ public:
/// Constructs the LValue and assumes that the storage reference is already on the stack.
StorageItem(CompilerContext& _compilerContext, Type const& _type);
unsigned sizeOnStack() const override { return 2; }
void retrieveValue(SourceLocation const& _location, bool _remove = false) const override;
void retrieveValue(langutil::SourceLocation const& _location, bool _remove = false) const override;
virtual void storeValue(
Type const& _sourceType,
SourceLocation const& _location = SourceLocation(),
langutil::SourceLocation const& _location = {},
bool _move = false
) const override;
virtual void setToZero(
SourceLocation const& _location = SourceLocation(),
langutil::SourceLocation const& _location = {},
bool _removeReference = true
) const override;
};
@ -159,14 +159,14 @@ public:
/// Constructs the LValue and assumes that the storage reference is already on the stack.
StorageByteArrayElement(CompilerContext& _compilerContext);
unsigned sizeOnStack() const override { return 2; }
void retrieveValue(SourceLocation const& _location, bool _remove = false) const override;
void retrieveValue(langutil::SourceLocation const& _location, bool _remove = false) const override;
virtual void storeValue(
Type const& _sourceType,
SourceLocation const& _location = SourceLocation(),
langutil::SourceLocation const& _location = {},
bool _move = false
) const override;
virtual void setToZero(
SourceLocation const& _location = SourceLocation(),
langutil::SourceLocation const& _location = {},
bool _removeReference = true
) const override;
};
@ -181,14 +181,14 @@ class StorageArrayLength: public LValue
public:
/// Constructs the LValue, assumes that the reference to the array head is already on the stack.
StorageArrayLength(CompilerContext& _compilerContext, ArrayType const& _arrayType);
void retrieveValue(SourceLocation const& _location, bool _remove = false) const override;
void retrieveValue(langutil::SourceLocation const& _location, bool _remove = false) const override;
virtual void storeValue(
Type const& _sourceType,
SourceLocation const& _location = SourceLocation(),
langutil::SourceLocation const& _location = {},
bool _move = false
) const override;
virtual void setToZero(
SourceLocation const& _location = SourceLocation(),
langutil::SourceLocation const& _location = {},
bool _removeReference = true
) const override;
@ -206,14 +206,14 @@ public:
/// Empty unique_ptrs are possible if e.g. some values should be ignored during assignment.
TupleObject(CompilerContext& _compilerContext, std::vector<std::unique_ptr<LValue>>&& _lvalues);
unsigned sizeOnStack() const override;
void retrieveValue(SourceLocation const& _location, bool _remove = false) const override;
void retrieveValue(langutil::SourceLocation const& _location, bool _remove = false) const override;
virtual void storeValue(
Type const& _sourceType,
SourceLocation const& _location = SourceLocation(),
langutil::SourceLocation const& _location = {},
bool _move = false
) const override;
virtual void setToZero(
SourceLocation const& _location = SourceLocation(),
langutil::SourceLocation const& _location = {},
bool _removeReference = true
) const override;

View File

@ -29,6 +29,7 @@
using namespace std;
using namespace dev;
using namespace langutil;
using namespace dev::solidity;
SMTChecker::SMTChecker(ErrorReporter& _errorReporter, ReadCallback::Callback const& _readFileCallback):

View File

@ -31,20 +31,25 @@
#include <string>
#include <vector>
namespace langutil
{
class ErrorReporter;
struct SourceLocation;
}
namespace dev
{
namespace solidity
{
class VariableUsage;
class ErrorReporter;
class SMTChecker: private ASTConstVisitor
{
public:
SMTChecker(ErrorReporter& _errorReporter, ReadCallback::Callback const& _readCallback);
SMTChecker(langutil::ErrorReporter& _errorReporter, ReadCallback::Callback const& _readCallback);
void analyze(SourceUnit const& _sources, std::shared_ptr<Scanner> const& _scanner);
void analyze(SourceUnit const& _sources, std::shared_ptr<langutil::Scanner> const& _scanner);
private:
// TODO: Check that we do not have concurrent reads and writes to a variable,
@ -89,8 +94,8 @@ private:
/// of rounding for signed division.
smt::Expression division(smt::Expression _left, smt::Expression _right, IntegerType const& _type);
void assignment(VariableDeclaration const& _variable, Expression const& _value, SourceLocation const& _location);
void assignment(VariableDeclaration const& _variable, smt::Expression const& _value, SourceLocation const& _location);
void assignment(VariableDeclaration const& _variable, Expression const& _value, langutil::SourceLocation const& _location);
void assignment(VariableDeclaration const& _variable, smt::Expression const& _value, langutil::SourceLocation const& _location);
/// Maps a variable to an SSA index.
using VariableIndices = std::unordered_map<VariableDeclaration const*, int>;
@ -104,7 +109,7 @@ private:
/// Check that a condition can be satisfied.
void checkCondition(
smt::Expression _condition,
SourceLocation const& _location,
langutil::SourceLocation const& _location,
std::string const& _description,
std::string const& _additionalValueName = "",
smt::Expression* _additionalValue = nullptr
@ -117,7 +122,7 @@ private:
std::string const& _description
);
/// Checks that the value is in the range given by the type.
void checkUnderOverflow(smt::Expression _value, IntegerType const& _Type, SourceLocation const& _location);
void checkUnderOverflow(smt::Expression _value, IntegerType const& _Type, langutil::SourceLocation const& _location);
std::pair<smt::CheckResult, std::vector<std::string>>
@ -200,8 +205,8 @@ private:
/// Used to retrieve models.
std::vector<Expression const*> m_uninterpretedTerms;
std::vector<smt::Expression> m_pathConditions;
ErrorReporter& m_errorReporter;
std::shared_ptr<Scanner> m_scanner;
langutil::ErrorReporter& m_errorReporter;
std::shared_ptr<langutil::Scanner> m_scanner;
/// Stores the current path of function calls.
std::vector<FunctionDefinition const*> m_functionPath;

View File

@ -35,6 +35,7 @@
using namespace std;
using namespace dev;
using namespace langutil;
using namespace dev::solidity;
using namespace dev::solidity::assembly;

View File

@ -35,11 +35,16 @@
#include <functional>
#include <memory>
namespace langutil
{
class ErrorReporter;
struct SourceLocation;
}
namespace dev
{
namespace solidity
{
class ErrorReporter;
namespace assembly
{
@ -55,9 +60,9 @@ class AsmAnalyzer: public boost::static_visitor<bool>
public:
explicit AsmAnalyzer(
AsmAnalysisInfo& _analysisInfo,
ErrorReporter& _errorReporter,
langutil::ErrorReporter& _errorReporter,
EVMVersion _evmVersion,
boost::optional<Error::Type> _errorTypeForLoose,
boost::optional<langutil::Error::Type> _errorTypeForLoose,
AsmFlavour _flavour = AsmFlavour::Loose,
yul::ExternalIdentifierAccess::Resolver const& _resolver = yul::ExternalIdentifierAccess::Resolver()
):
@ -90,20 +95,20 @@ public:
private:
/// Visits the statement and expects it to deposit one item onto the stack.
bool expectExpression(Expression const& _expr);
bool expectDeposit(int _deposit, int _oldHeight, SourceLocation const& _location);
bool expectDeposit(int _deposit, int _oldHeight, langutil::SourceLocation const& _location);
/// Verifies that a variable to be assigned to exists and has the same size
/// as the value, @a _valueSize, unless that is equal to -1.
bool checkAssignment(assembly::Identifier const& _assignment, size_t _valueSize = size_t(-1));
Scope& scope(assembly::Block const* _block);
void expectValidType(std::string const& type, SourceLocation const& _location);
void warnOnInstructions(solidity::Instruction _instr, SourceLocation const& _location);
void expectValidType(std::string const& type, langutil::SourceLocation const& _location);
void warnOnInstructions(solidity::Instruction _instr, langutil::SourceLocation const& _location);
/// Depending on @a m_flavour and @a m_errorTypeForLoose, throws an internal compiler
/// exception (if the flavour is not Loose), reports an error/warning
/// (if m_errorTypeForLoose is set) or does nothing.
void checkLooseFeature(SourceLocation const& _location, std::string const& _description);
void checkLooseFeature(langutil::SourceLocation const& _location, std::string const& _description);
int m_stackHeight = 0;
yul::ExternalIdentifierAccess::Resolver m_resolver;
@ -112,10 +117,10 @@ private:
/// "part of the scope but not yet declared")
std::set<Scope::Variable const*> m_activeVariables;
AsmAnalysisInfo& m_info;
ErrorReporter& m_errorReporter;
langutil::ErrorReporter& m_errorReporter;
EVMVersion m_evmVersion;
AsmFlavour m_flavour = AsmFlavour::Loose;
boost::optional<Error::Type> m_errorTypeForLoose;
boost::optional<langutil::Error::Type> m_errorTypeForLoose;
};
}

View File

@ -46,6 +46,7 @@
using namespace std;
using namespace dev;
using namespace langutil;
using namespace dev::solidity;
using namespace dev::solidity::assembly;

View File

@ -45,56 +45,56 @@ namespace assembly
using YulString = dev::yul::YulString;
using Type = YulString;
struct TypedName { SourceLocation location; YulString name; Type type; };
struct TypedName { langutil::SourceLocation location; YulString name; Type type; };
using TypedNameList = std::vector<TypedName>;
/// Direct EVM instruction (except PUSHi and JUMPDEST)
struct Instruction { SourceLocation location; solidity::Instruction instruction; };
struct Instruction { langutil::SourceLocation location; solidity::Instruction instruction; };
/// Literal number or string (up to 32 bytes)
enum class LiteralKind { Number, Boolean, String };
struct Literal { SourceLocation location; LiteralKind kind; YulString value; Type type; };
struct Literal { langutil::SourceLocation location; LiteralKind kind; YulString value; Type type; };
/// External / internal identifier or label reference
struct Identifier { SourceLocation location; YulString name; };
struct Identifier { langutil::SourceLocation location; YulString name; };
/// Jump label ("name:")
struct Label { SourceLocation location; YulString name; };
struct Label { langutil::SourceLocation location; YulString name; };
/// Assignment from stack (":= x", moves stack top into x, potentially multiple slots)
struct StackAssignment { SourceLocation location; Identifier variableName; };
struct StackAssignment { langutil::SourceLocation location; Identifier variableName; };
/// Assignment ("x := mload(20:u256)", expects push-1-expression on the right hand
/// side and requires x to occupy exactly one stack slot.
///
/// Multiple assignment ("x, y := f()"), where the left hand side variables each occupy
/// a single stack slot and expects a single expression on the right hand returning
/// the same amount of items as the number of variables.
struct Assignment { SourceLocation location; std::vector<Identifier> variableNames; std::shared_ptr<Expression> value; };
struct Assignment { langutil::SourceLocation location; std::vector<Identifier> variableNames; std::shared_ptr<Expression> value; };
/// Functional instruction, e.g. "mul(mload(20:u256), add(2:u256, x))"
struct FunctionalInstruction { SourceLocation location; solidity::Instruction instruction; std::vector<Expression> arguments; };
struct FunctionCall { SourceLocation location; Identifier functionName; std::vector<Expression> arguments; };
struct FunctionalInstruction { langutil::SourceLocation location; solidity::Instruction instruction; std::vector<Expression> arguments; };
struct FunctionCall { langutil::SourceLocation location; Identifier functionName; std::vector<Expression> arguments; };
/// Statement that contains only a single expression
struct ExpressionStatement { SourceLocation location; Expression expression; };
struct ExpressionStatement { langutil::SourceLocation location; Expression expression; };
/// Block-scope variable declaration ("let x:u256 := mload(20:u256)"), non-hoisted
struct VariableDeclaration { SourceLocation location; TypedNameList variables; std::shared_ptr<Expression> value; };
struct VariableDeclaration { langutil::SourceLocation location; TypedNameList variables; std::shared_ptr<Expression> value; };
/// Block that creates a scope (frees declared stack variables)
struct Block { SourceLocation location; std::vector<Statement> statements; };
struct Block { langutil::SourceLocation location; std::vector<Statement> statements; };
/// Function definition ("function f(a, b) -> (d, e) { ... }")
struct FunctionDefinition { SourceLocation location; YulString name; TypedNameList parameters; TypedNameList returnVariables; Block body; };
struct FunctionDefinition { langutil::SourceLocation location; YulString name; TypedNameList parameters; TypedNameList returnVariables; Block body; };
/// Conditional execution without "else" part.
struct If { SourceLocation location; std::shared_ptr<Expression> condition; Block body; };
struct If { langutil::SourceLocation location; std::shared_ptr<Expression> condition; Block body; };
/// Switch case or default case
struct Case { SourceLocation location; std::shared_ptr<Literal> value; Block body; };
struct Case { langutil::SourceLocation location; std::shared_ptr<Literal> value; Block body; };
/// Switch statement
struct Switch { SourceLocation location; std::shared_ptr<Expression> expression; std::vector<Case> cases; };
struct ForLoop { SourceLocation location; Block pre; std::shared_ptr<Expression> condition; Block post; Block body; };
struct Switch { langutil::SourceLocation location; std::shared_ptr<Expression> expression; std::vector<Case> cases; };
struct ForLoop { langutil::SourceLocation location; Block pre; std::shared_ptr<Expression> condition; Block post; Block body; };
struct LocationExtractor: boost::static_visitor<SourceLocation>
struct LocationExtractor: boost::static_visitor<langutil::SourceLocation>
{
template <class T> SourceLocation operator()(T const& _node) const
template <class T> langutil::SourceLocation operator()(T const& _node) const
{
return _node.location;
}
};
/// Extracts the source location from an inline assembly node.
template <class T> inline SourceLocation locationOf(T const& _node)
template <class T> inline langutil::SourceLocation locationOf(T const& _node)
{
return boost::apply_visitor(LocationExtractor(), _node);
}

View File

@ -31,6 +31,7 @@
using namespace std;
using namespace dev;
using namespace langutil;
using namespace dev::solidity;
using namespace dev::solidity::assembly;

View File

@ -25,6 +25,8 @@
#include <memory>
#include <vector>
#include <libsolidity/inlineasm/AsmData.h>
#include <liblangutil/SourceLocation.h>
#include <liblangutil/Scanner.h>
#include <liblangutil/ParserBase.h>
namespace dev
@ -34,22 +36,22 @@ namespace solidity
namespace assembly
{
class Parser: public ParserBase
class Parser: public langutil::ParserBase
{
public:
explicit Parser(ErrorReporter& _errorReporter, AsmFlavour _flavour = AsmFlavour::Loose):
explicit Parser(langutil::ErrorReporter& _errorReporter, AsmFlavour _flavour = AsmFlavour::Loose):
ParserBase(_errorReporter), m_flavour(_flavour) {}
/// Parses an inline assembly block starting with `{` and ending with `}`.
/// @param _reuseScanner if true, do check for end of input after the `}`.
/// @returns an empty shared pointer on error.
std::shared_ptr<Block> parse(std::shared_ptr<Scanner> const& _scanner, bool _reuseScanner);
std::shared_ptr<Block> parse(std::shared_ptr<langutil::Scanner> const& _scanner, bool _reuseScanner);
protected:
using ElementaryOperation = boost::variant<assembly::Instruction, assembly::Literal, assembly::Identifier>;
/// Creates an inline assembly node with the given source location.
template <class T> T createWithLocation(SourceLocation const& _loc = SourceLocation()) const
template <class T> T createWithLocation(langutil::SourceLocation const& _loc = {}) const
{
T r;
r.location = _loc;
@ -62,7 +64,7 @@ protected:
r.location.sourceName = sourceName();
return r;
}
SourceLocation location() const { return SourceLocation(position(), endPosition(), sourceName()); }
langutil::SourceLocation location() const { return {position(), endPosition(), sourceName()}; }
Block parseBlock();
Statement parseStatement();

View File

@ -36,6 +36,7 @@
using namespace std;
using namespace dev;
using namespace langutil;
using namespace dev::solidity;
using namespace dev::solidity::assembly;

View File

@ -27,12 +27,16 @@
#include <functional>
#include <memory>
namespace dev
{
struct SourceLocation;
namespace solidity
namespace langutil
{
class ErrorReporter;
struct SourceLocation;
}
namespace dev
{
namespace solidity
{
namespace assembly
{
@ -47,7 +51,7 @@ struct AsmAnalysisInfo;
class ScopeFiller: public boost::static_visitor<bool>
{
public:
ScopeFiller(AsmAnalysisInfo& _info, ErrorReporter& _errorReporter);
ScopeFiller(AsmAnalysisInfo& _info, langutil::ErrorReporter& _errorReporter);
bool operator()(assembly::Instruction const&) { return true; }
bool operator()(assembly::Literal const&) { return true; }
@ -68,7 +72,7 @@ public:
private:
bool registerVariable(
TypedName const& _name,
SourceLocation const& _location,
langutil::SourceLocation const& _location,
Scope& _scope
);
@ -76,7 +80,7 @@ private:
Scope* m_currentScope = nullptr;
AsmAnalysisInfo& m_info;
ErrorReporter& m_errorReporter;
langutil::ErrorReporter& m_errorReporter;
};
}

View File

@ -36,6 +36,7 @@
using namespace std;
using namespace dev;
using namespace langutil;
using namespace dev::solidity;
namespace

View File

@ -29,11 +29,15 @@
#include <string>
#include <memory>
namespace langutil
{
class Scanner;
}
namespace dev
{
namespace solidity
{
class Scanner;
namespace assembly
{
struct AsmAnalysisInfo;
@ -61,7 +65,7 @@ public:
{}
/// @returns the scanner used during parsing
Scanner const& scanner() const;
langutil::Scanner const& scanner() const;
/// Runs parsing and analysis steps, returns false if input cannot be assembled.
/// Multiple calls overwrite the previous state.
@ -69,13 +73,13 @@ public:
/// Runs analysis step on the supplied block, returns false if input cannot be assembled.
/// Multiple calls overwrite the previous state.
bool analyze(assembly::Block const& _block, Scanner const* _scanner = nullptr);
bool analyze(assembly::Block const& _block, langutil::Scanner const* _scanner = nullptr);
/// Run the assembly step (should only be called after parseAndAnalyze).
MachineAssemblyObject assemble(Machine _machine) const;
/// @returns the errors generated during parsing, analysis (and potentially assembly).
ErrorList const& errors() const { return m_errors; }
langutil::ErrorList const& errors() const { return m_errors; }
/// Pretty-print the input after having parsed it.
std::string print() const;
@ -86,13 +90,13 @@ private:
Language m_language = Language::Assembly;
EVMVersion m_evmVersion;
std::shared_ptr<Scanner> m_scanner;
std::shared_ptr<langutil::Scanner> m_scanner;
bool m_analysisSuccessful = false;
std::shared_ptr<assembly::Block> m_parserResult;
std::shared_ptr<assembly::AsmAnalysisInfo> m_analysisInfo;
ErrorList m_errors;
ErrorReporter m_errorReporter;
langutil::ErrorList m_errors;
langutil::ErrorReporter m_errorReporter;
};
}

View File

@ -58,6 +58,7 @@
using namespace std;
using namespace dev;
using namespace langutil;
using namespace dev::solidity;
boost::optional<CompilerStack::Remapping> CompilerStack::parseRemapping(string const& _remapping)

View File

@ -23,11 +23,12 @@
#pragma once
#include <liblangutil/ErrorReporter.h>
#include <libsolidity/interface/ReadFile.h>
#include <liblangutil/EVMVersion.h>
#include <liblangutil/ErrorReporter.h>
#include <liblangutil/EVMVersion.h>
#include <liblangutil/SourceLocation.h>
#include <libevmasm/LinkerObject.h>
#include <libdevcore/Common.h>
@ -43,6 +44,11 @@
#include <vector>
#include <functional>
namespace langutil
{
class Scanner;
}
namespace dev
{
@ -57,7 +63,6 @@ namespace solidity
{
// forward declarations
class Scanner;
class ASTNode;
class ContractDefinition;
class FunctionDefinition;
@ -65,7 +70,6 @@ class SourceUnit;
class Compiler;
class GlobalContext;
class Natspec;
class Error;
class DeclarationContainer;
/**
@ -100,7 +104,7 @@ public:
m_errorReporter(m_errorList) {}
/// @returns the list of errors that occurred during parsing and type checking.
ErrorList const& errors() const { return m_errorReporter.errors(); }
langutil::ErrorList const& errors() const { return m_errorReporter.errors(); }
/// @returns the current state.
State state() const { return m_stackState; }
@ -174,7 +178,7 @@ public:
std::map<std::string, unsigned> sourceIndices() const;
/// @returns the previously used scanner, useful for counting lines during error reporting.
Scanner const& scanner(std::string const& _sourceName) const;
langutil::Scanner const& scanner(std::string const& _sourceName) const;
/// @returns the parsed source unit with the supplied name.
SourceUnit const& ast(std::string const& _sourceName) const;
@ -182,7 +186,7 @@ public:
/// Helper function for logs printing. Do only use in error cases, it's quite expensive.
/// line and columns are numbered starting from 1 with following order:
/// start line, start column, end line, end column
std::tuple<int, int, int, int> positionFromSourceLocation(SourceLocation const& _sourceLocation) const;
std::tuple<int, int, int, int> positionFromSourceLocation(langutil::SourceLocation const& _sourceLocation) const;
/// @returns a list of the contract names in the sources.
std::vector<std::string> contractNames() const;
@ -248,7 +252,7 @@ private:
/// The state per source unit. Filled gradually during parsing.
struct Source
{
std::shared_ptr<Scanner> scanner;
std::shared_ptr<langutil::Scanner> scanner;
std::shared_ptr<SourceUnit> ast;
bool isLibrary = false;
void reset() { scanner.reset(); ast.reset(); }
@ -345,8 +349,8 @@ private:
/// This is updated during compilation.
std::map<ASTNode const*, std::shared_ptr<DeclarationContainer>> m_scopes;
std::map<std::string const, Contract> m_contracts;
ErrorList m_errorList;
ErrorReporter m_errorReporter;
langutil::ErrorList m_errorList;
langutil::ErrorReporter m_errorReporter;
bool m_metadataLiteralSources = false;
State m_stackState = Empty;
};

View File

@ -35,6 +35,7 @@
using namespace std;
using namespace dev;
using namespace dev::eth;
using namespace langutil;
using namespace dev::solidity;
GasEstimator::ASTGasConsumptionSelfAccumulated GasEstimator::structuralEstimation(

View File

@ -25,6 +25,7 @@
#include <liblangutil/Exceptions.h>
using namespace std;
using namespace langutil;
namespace dev
{

View File

@ -25,7 +25,12 @@
#include <ostream>
#include <sstream>
#include <functional>
#include <liblangutil/SourceLocation.h>
namespace langutil
{
struct SourceLocation;
class Scanner;
}
namespace dev
{
@ -35,13 +40,12 @@ struct Exception; // forward
namespace solidity
{
class Scanner; // forward
class CompilerStack; // forward
class SourceReferenceFormatter
{
public:
using ScannerFromSourceNameFun = std::function<Scanner const&(std::string const&)>;
using ScannerFromSourceNameFun = std::function<langutil::Scanner const&(std::string const&)>;
explicit SourceReferenceFormatter(
std::ostream& _stream,
@ -52,7 +56,7 @@ public:
{}
/// Prints source location if it is given.
void printSourceLocation(SourceLocation const* _location);
void printSourceLocation(langutil::SourceLocation const* _location);
void printExceptionInformation(Exception const& _exception, std::string const& _name);
static std::string formatExceptionInformation(
@ -69,7 +73,7 @@ public:
}
private:
/// Prints source name if location is given.
void printSourceName(SourceLocation const* _location);
void printSourceName(langutil::SourceLocation const* _location);
std::ostream& m_stream;
ScannerFromSourceNameFun m_scannerFromSourceName;

View File

@ -31,6 +31,7 @@
using namespace std;
using namespace dev;
using namespace langutil;
using namespace dev::solidity;
namespace {
@ -411,7 +412,7 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input)
Json::Value outputSelection = settings.get("outputSelection", Json::Value());
m_compilerStack.setRequestedContractNames(requestedContractNames(outputSelection));
auto scannerFromSourceName = [&](string const& _sourceName) -> solidity::Scanner const& { return m_compilerStack.scanner(_sourceName); };
auto scannerFromSourceName = [&](string const& _sourceName) -> Scanner const& { return m_compilerStack.scanner(_sourceName); };
try
{

View File

@ -8,6 +8,7 @@
using namespace std;
using namespace dev;
using namespace langutil;
using namespace dev::solidity;

View File

@ -25,19 +25,22 @@
#include <string>
#include <libsolidity/ast/ASTAnnotations.h>
namespace langutil
{
class ErrorReporter;
}
namespace dev
{
namespace solidity
{
class ErrorReporter;
class DocStringParser
{
public:
/// Parse the given @a _docString and stores the parsed components internally.
/// @returns false on error and appends the error to @a _errors.
bool parse(std::string const& _docString, ErrorReporter& _errorReporter);
bool parse(std::string const& _docString, langutil::ErrorReporter& _errorReporter);
std::multimap<std::string, DocTag> const& tags() const { return m_docTags; }
@ -63,7 +66,7 @@ private:
/// Mapping tag name -> content.
std::multimap<std::string, DocTag> m_docTags;
DocTag* m_lastTag = nullptr;
ErrorReporter* m_errorReporter = nullptr;
langutil::ErrorReporter* m_errorReporter = nullptr;
bool m_errorsOccurred = false;
};

View File

@ -29,6 +29,7 @@
#include <liblangutil/ErrorReporter.h>
using namespace std;
using namespace langutil;
namespace dev
{

View File

@ -25,19 +25,22 @@
#include <libsolidity/ast/AST.h>
#include <liblangutil/ParserBase.h>
namespace langutil
{
class Scanner;
}
namespace dev
{
namespace solidity
{
class Scanner;
class Parser: public ParserBase
class Parser: public langutil::ParserBase
{
public:
explicit Parser(ErrorReporter& _errorReporter): ParserBase(_errorReporter) {}
explicit Parser(langutil::ErrorReporter& _errorReporter): ParserBase(_errorReporter) {}
ASTPointer<SourceUnit> parse(std::shared_ptr<Scanner> const& _scanner);
ASTPointer<SourceUnit> parse(std::shared_ptr<langutil::Scanner> const& _scanner);
private:
class ASTNodeFactory;
@ -146,7 +149,7 @@ private:
struct IndexAccessedPath
{
std::vector<ASTPointer<PrimaryExpression>> path;
std::vector<std::pair<ASTPointer<Expression>, SourceLocation>> indices;
std::vector<std::pair<ASTPointer<Expression>, langutil::SourceLocation>> indices;
bool empty() const;
};

View File

@ -0,0 +1,36 @@
/*
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/>.
*/
/**
* Solidity and Yul both share the same Token (and Scanner) API.
*
* This may (or may not) change in the future. But for the time being, we've put both
* at a shared place, and *just* import them.
*/
#pragma once
#include <liblangutil/Token.h>
namespace dev
{
namespace solidity
{
namespace TokenTraits = ::langutil::TokenTraits;
using ::langutil::Token;
using ::langutil::ElementaryTypeNameToken;
}
}

View File

@ -26,9 +26,13 @@
#include <functional>
namespace dev
namespace langutil
{
struct SourceLocation;
}
namespace dev
{
namespace solidity
{
enum class Instruction: uint8_t;
@ -52,7 +56,7 @@ public:
virtual ~AbstractAssembly() {}
/// Set a new source location valid starting from the next instruction.
virtual void setSourceLocation(SourceLocation const& _location) = 0;
virtual void setSourceLocation(langutil::SourceLocation const& _location) = 0;
/// Retrieve the current height of the stack. This does not have to be zero
/// at the beginning.
virtual int stackHeight() const = 0;

View File

@ -26,6 +26,7 @@
using namespace std;
using namespace dev;
using namespace langutil;
using namespace dev::yul;
namespace

View File

@ -26,6 +26,11 @@
#include <map>
namespace langutil
{
struct SourceLocation;
}
namespace dev
{
namespace yul
@ -38,7 +43,7 @@ public:
virtual ~EVMAssembly() {}
/// Set a new source location valid starting from the next instruction.
void setSourceLocation(SourceLocation const& _location) override;
void setSourceLocation(langutil::SourceLocation const& _location) override;
/// Retrieve the current height of the stack. This does not have to be zero
/// at the beginning.
int stackHeight() const override { return m_stackHeight; }

View File

@ -31,6 +31,7 @@
using namespace std;
using namespace dev;
using namespace langutil;
using namespace dev::yul;
using namespace dev::solidity;

View File

@ -31,6 +31,7 @@
using namespace std;
using namespace dev;
using namespace langutil;
using namespace dev::yul;
using namespace dev::solidity;

View File

@ -31,6 +31,7 @@
using namespace std;
using namespace dev;
using namespace langutil;
using namespace dev::yul;

View File

@ -107,7 +107,7 @@ public:
/// Turns this pattern into an actual expression. Should only be called
/// for patterns resulting from an action, i.e. with match groups assigned.
Expression toExpression(SourceLocation const& _location) const;
Expression toExpression(langutil::SourceLocation const& _location) const;
private:
Expression const& matchGroupValue() const;

View File

@ -62,6 +62,7 @@
#include <fstream>
using namespace std;
using namespace langutil;
namespace po = boost::program_options;
namespace dev
@ -827,7 +828,7 @@ bool CommandLineInterface::processInput()
m_compiler.reset(new CompilerStack(fileReader));
auto scannerFromSourceName = [&](string const& _sourceName) -> solidity::Scanner const& { return m_compiler->scanner(_sourceName); };
auto scannerFromSourceName = [&](string const& _sourceName) -> Scanner const& { return m_compiler->scanner(_sourceName); };
SourceReferenceFormatter formatter(cerr, scannerFromSourceName);
try

View File

@ -30,6 +30,7 @@
#include <memory>
using namespace std;
using namespace langutil;
using namespace dev::eth;
namespace dev

View File

@ -36,6 +36,7 @@
#include <memory>
using namespace std;
using namespace langutil;
using namespace dev::eth;
namespace dev

View File

@ -24,9 +24,7 @@
#include <test/Options.h>
namespace dev
{
namespace solidity
namespace langutil
{
namespace test
{
@ -45,6 +43,5 @@ BOOST_AUTO_TEST_CASE(test_fail)
BOOST_AUTO_TEST_SUITE_END()
}
}
} // end namespaces

View File

@ -35,6 +35,7 @@
using namespace std;
using namespace dev;
using namespace langutil;
using namespace dev::solidity;
using namespace dev::solidity::test;
@ -127,7 +128,7 @@ string AnalysisFramework::formatError(Error const& _error) const
return SourceReferenceFormatter::formatExceptionInformation(
_error,
(_error.type() == Error::Type::Warning) ? "Warning" : "Error",
[&](std::string const& _sourceName) -> solidity::Scanner const& { return m_compiler.scanner(_sourceName); }
[&](std::string const& _sourceName) -> Scanner const& { return m_compiler.scanner(_sourceName); }
);
}

View File

@ -45,7 +45,7 @@ class AnalysisFramework
{
protected:
virtual std::pair<SourceUnit const*, ErrorList>
virtual std::pair<SourceUnit const*, langutil::ErrorList>
parseAnalyseAndReturnError(
std::string const& _source,
bool _reportWarnings = false,
@ -56,10 +56,10 @@ protected:
SourceUnit const* parseAndAnalyse(std::string const& _source);
bool success(std::string const& _source);
ErrorList expectError(std::string const& _source, bool _warning = false, bool _allowMultiple = false);
langutil::ErrorList expectError(std::string const& _source, bool _warning = false, bool _allowMultiple = false);
std::string formatErrors() const;
std::string formatError(Error const& _error) const;
std::string formatError(langutil::Error const& _error) const;
static ContractDefinition const* retrieveContractByName(SourceUnit const& _source, std::string const& _name);
static FunctionTypePointer retrieveFunctionBySignature(
@ -68,7 +68,7 @@ protected:
);
// filter out the warnings in m_warningsToFilter or all warnings if _includeWarnings is false
ErrorList filterErrors(ErrorList const& _errorList, bool _includeWarnings) const;
langutil::ErrorList filterErrors(langutil::ErrorList const& _errorList, bool _includeWarnings) const;
std::vector<std::string> m_warningsToFilter = {"This is a pre-release compiler version"};
dev::solidity::CompilerStack m_compiler;

View File

@ -39,6 +39,7 @@
#include <iostream>
using namespace std;
using namespace langutil;
using namespace dev::eth;
namespace dev

View File

@ -27,6 +27,7 @@
using namespace std;
using namespace dev;
using namespace langutil;
using namespace dev::solidity;
namespace

View File

@ -30,10 +30,10 @@ namespace dev
{
namespace solidity
{
bool searchErrorMessage(Error const& _err, std::string const& _substr);
bool searchErrorMessage(langutil::Error const& _err, std::string const& _substr);
/// Checks that all provided errors are of the given type and have a given substring in their
/// description.
/// If the expectations are not met, returns a nonempty description, otherwise an empty string.
std::string searchErrors(ErrorList const& _errors, std::vector<std::pair<Error::Type, std::string>> const& _expectations);
std::string searchErrors(langutil::ErrorList const& _errors, std::vector<std::pair<langutil::Error::Type, std::string>> const& _expectations);
}
}

View File

@ -29,6 +29,7 @@
#include <libsolidity/interface/SourceReferenceFormatter.h>
using namespace std;
using namespace langutil;
using namespace dev::eth;
using namespace dev::solidity;
using namespace dev::test;

Some files were not shown because too many files have changed in this diff Show More