diff options
author | Leonardo Alt <leo@ethereum.org> | 2018-11-12 19:21:25 +0800 |
---|---|---|
committer | Leonardo Alt <leo@ethereum.org> | 2018-11-13 20:49:29 +0800 |
commit | 9a4fd946c349712cab2c9f77f4dc08fb6e2ca68f (patch) | |
tree | 004d066cf446d468e67891004ad2bb02af889bf4 /libsolidity/parsing | |
parent | 82fadfd1a7c5715595ddbf6643ae494cdb6eca8c (diff) | |
download | dexon-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.h | 7 |
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: |