aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/inlineasm
diff options
context:
space:
mode:
Diffstat (limited to 'libsolidity/inlineasm')
-rw-r--r--libsolidity/inlineasm/AsmAnalysis.cpp1
-rw-r--r--libsolidity/inlineasm/AsmAnalysis.h23
-rw-r--r--libsolidity/inlineasm/AsmCodeGen.cpp1
-rw-r--r--libsolidity/inlineasm/AsmData.h40
-rw-r--r--libsolidity/inlineasm/AsmParser.cpp1
-rw-r--r--libsolidity/inlineasm/AsmParser.h12
-rw-r--r--libsolidity/inlineasm/AsmScopeFiller.cpp1
-rw-r--r--libsolidity/inlineasm/AsmScopeFiller.h14
8 files changed, 54 insertions, 39 deletions
diff --git a/libsolidity/inlineasm/AsmAnalysis.cpp b/libsolidity/inlineasm/AsmAnalysis.cpp
index 95c8537d..fb96f73c 100644
--- a/libsolidity/inlineasm/AsmAnalysis.cpp
+++ b/libsolidity/inlineasm/AsmAnalysis.cpp
@@ -35,6 +35,7 @@
using namespace std;
using namespace dev;
+using namespace langutil;
using namespace dev::solidity;
using namespace dev::solidity::assembly;
diff --git a/libsolidity/inlineasm/AsmAnalysis.h b/libsolidity/inlineasm/AsmAnalysis.h
index 7ae27ebd..194f736e 100644
--- a/libsolidity/inlineasm/AsmAnalysis.h
+++ b/libsolidity/inlineasm/AsmAnalysis.h
@@ -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;
};
}
diff --git a/libsolidity/inlineasm/AsmCodeGen.cpp b/libsolidity/inlineasm/AsmCodeGen.cpp
index ee69b44f..2800cc7b 100644
--- a/libsolidity/inlineasm/AsmCodeGen.cpp
+++ b/libsolidity/inlineasm/AsmCodeGen.cpp
@@ -46,6 +46,7 @@
using namespace std;
using namespace dev;
+using namespace langutil;
using namespace dev::solidity;
using namespace dev::solidity::assembly;
diff --git a/libsolidity/inlineasm/AsmData.h b/libsolidity/inlineasm/AsmData.h
index e9bf4841..23a9db75 100644
--- a/libsolidity/inlineasm/AsmData.h
+++ b/libsolidity/inlineasm/AsmData.h
@@ -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);
}
diff --git a/libsolidity/inlineasm/AsmParser.cpp b/libsolidity/inlineasm/AsmParser.cpp
index 3103e2b3..b11f70e0 100644
--- a/libsolidity/inlineasm/AsmParser.cpp
+++ b/libsolidity/inlineasm/AsmParser.cpp
@@ -31,6 +31,7 @@
using namespace std;
using namespace dev;
+using namespace langutil;
using namespace dev::solidity;
using namespace dev::solidity::assembly;
diff --git a/libsolidity/inlineasm/AsmParser.h b/libsolidity/inlineasm/AsmParser.h
index b3d74df1..9e13799a 100644
--- a/libsolidity/inlineasm/AsmParser.h
+++ b/libsolidity/inlineasm/AsmParser.h
@@ -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();
diff --git a/libsolidity/inlineasm/AsmScopeFiller.cpp b/libsolidity/inlineasm/AsmScopeFiller.cpp
index c7625fe0..09934bd8 100644
--- a/libsolidity/inlineasm/AsmScopeFiller.cpp
+++ b/libsolidity/inlineasm/AsmScopeFiller.cpp
@@ -36,6 +36,7 @@
using namespace std;
using namespace dev;
+using namespace langutil;
using namespace dev::solidity;
using namespace dev::solidity::assembly;
diff --git a/libsolidity/inlineasm/AsmScopeFiller.h b/libsolidity/inlineasm/AsmScopeFiller.h
index bb023f61..7454fd6c 100644
--- a/libsolidity/inlineasm/AsmScopeFiller.h
+++ b/libsolidity/inlineasm/AsmScopeFiller.h
@@ -27,12 +27,16 @@
#include <functional>
#include <memory>
-namespace dev
+namespace langutil
{
+class ErrorReporter;
struct SourceLocation;
+}
+
+namespace dev
+{
namespace solidity
{
-class ErrorReporter;
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;
};
}