diff options
author | chriseth <chris@ethereum.org> | 2019-01-22 20:49:41 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-22 20:49:41 +0800 |
commit | 10d17f245839f208ec5085309022a32cd2502f55 (patch) | |
tree | b2c9f68980d0d418cd6f511e9f3f3f71369abe25 /liblangutil | |
parent | 1df8f40cd2fd7b47698d847907b8ca7b47eb488d (diff) | |
parent | 0ecafe032a84cb6960545dd7f18733430c1f782d (diff) | |
download | dexon-solidity-10d17f245839f208ec5085309022a32cd2502f55.tar.gz dexon-solidity-10d17f245839f208ec5085309022a32cd2502f55.tar.zst dexon-solidity-10d17f245839f208ec5085309022a32cd2502f55.zip |
Merge pull request #5836 from ethereum/develop
Merge develop into release for 0.5.3.
Diffstat (limited to 'liblangutil')
-rw-r--r-- | liblangutil/SourceLocation.h | 20 | ||||
-rw-r--r-- | liblangutil/SourceReferenceExtractor.cpp | 4 | ||||
-rw-r--r-- | liblangutil/Token.h | 2 |
3 files changed, 24 insertions, 2 deletions
diff --git a/liblangutil/SourceLocation.h b/liblangutil/SourceLocation.h index 840891c2..c461909f 100644 --- a/liblangutil/SourceLocation.h +++ b/liblangutil/SourceLocation.h @@ -49,6 +49,26 @@ struct SourceLocation bool isEmpty() const { return start == -1 && end == -1; } + /// @returns the smallest SourceLocation that contains both @param _a and @param _b. + /// Assumes that @param _a and @param _b refer to the same source (exception: if the source of either one + /// is unset, the source of the other will be used for the result, even if that is unset as well). + /// Invalid start and end positions (with value of -1) are ignored (if start or end are -1 for both @param _a and + /// @param _b, then start resp. end of the result will be -1 as well). + static SourceLocation smallestCovering(SourceLocation _a, SourceLocation const& _b) + { + if (!_a.source) + _a.source = _b.source; + + if (_a.start < 0) + _a.start = _b.start; + else if (_b.start >= 0 && _b.start < _a.start) + _a.start = _b.start; + if (_b.end > _a.end) + _a.end = _b.end; + + return _a; + } + int start = -1; int end = -1; std::shared_ptr<CharStream> source; diff --git a/liblangutil/SourceReferenceExtractor.cpp b/liblangutil/SourceReferenceExtractor.cpp index 4502bb23..1a6dbdb3 100644 --- a/liblangutil/SourceReferenceExtractor.cpp +++ b/liblangutil/SourceReferenceExtractor.cpp @@ -58,7 +58,9 @@ SourceReference SourceReferenceExtractor::extract(SourceLocation const* _locatio int locationLength = isMultiline ? line.length() - start.column : end.column - start.column; if (locationLength > 150) { - line = line.substr(0, start.column + 35) + " ... " + line.substr(end.column - 35); + int const lhs = start.column + 35; + int const rhs = (isMultiline ? line.length() : end.column) - 35; + line = line.substr(0, lhs) + " ... " + line.substr(rhs); end.column = start.column + 75; locationLength = 75; } diff --git a/liblangutil/Token.h b/liblangutil/Token.h index f832fdf7..b3a1acb1 100644 --- a/liblangutil/Token.h +++ b/liblangutil/Token.h @@ -180,6 +180,7 @@ namespace langutil K(CallData, "calldata", 0) \ K(Struct, "struct", 0) \ K(Throw, "throw", 0) \ + K(Type, "type", 0) \ K(Using, "using", 0) \ K(Var, "var", 0) \ K(View, "view", 0) \ @@ -256,7 +257,6 @@ namespace langutil K(Supports, "supports", 0) \ K(Switch, "switch", 0) \ K(Try, "try", 0) \ - K(Type, "type", 0) \ K(Typedef, "typedef", 0) \ K(TypeOf, "typeof", 0) \ K(Unchecked, "unchecked", 0) \ |