aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/parsing
diff options
context:
space:
mode:
authorLeonardo Alt <leo@ethereum.org>2018-11-12 19:21:25 +0800
committerLeonardo Alt <leo@ethereum.org>2018-11-13 20:49:29 +0800
commit9a4fd946c349712cab2c9f77f4dc08fb6e2ca68f (patch)
tree004d066cf446d468e67891004ad2bb02af889bf4 /libsolidity/parsing
parent82fadfd1a7c5715595ddbf6643ae494cdb6eca8c (diff)
downloaddexon-solidity-9a4fd946c349712cab2c9f77f4dc08fb6e2ca68f.tar.gz
dexon-solidity-9a4fd946c349712cab2c9f77f4dc08fb6e2ca68f.tar.zst
dexon-solidity-9a4fd946c349712cab2c9f77f4dc08fb6e2ca68f.zip
Add Scanner function that prints source based on SourceLocation
Diffstat (limited to 'libsolidity/parsing')
-rw-r--r--libsolidity/parsing/Scanner.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/libsolidity/parsing/Scanner.h b/libsolidity/parsing/Scanner.h
index 02e0553f..14eeb66e 100644
--- a/libsolidity/parsing/Scanner.h
+++ b/libsolidity/parsing/Scanner.h
@@ -162,6 +162,13 @@ public:
/// Do only use in error cases, they are quite expensive.
std::string lineAtPosition(int _position) const { return m_source.lineAtPosition(_position); }
std::tuple<int, int> translatePositionToLineColumn(int _position) const { return m_source.translatePositionToLineColumn(_position); }
+ std::string sourceAt(SourceLocation const& _location) const
+ {
+ solAssert(!_location.isEmpty(), "");
+ solAssert(m_sourceName && _location.sourceName, "");
+ solAssert(*m_sourceName == *_location.sourceName, "");
+ return m_source.source().substr(_location.start, _location.end - _location.start);
+ }
///@}
private: