adde the positions for the end of SourceLocation

This commit is contained in:
Liana Husikyan 2015-05-07 17:22:24 +02:00
parent 83c504ec89
commit 4fdfbaa367
2 changed files with 12 additions and 7 deletions

View File

@ -257,13 +257,16 @@ bytes CompilerStack::staticCompile(std::string const& _sourceCode, bool _optimiz
return stack.compile(_sourceCode, _optimize);
}
pair<int, int> CompilerStack::positionFromSourceLocation(SourceLocation const& _sourceLocation) const
tuple<int, int, int, int> CompilerStack::positionFromSourceLocation(SourceLocation const& _sourceLocation) const
{
int initLine;
int initColumn;
tie(initLine, initColumn) = getScanner(*_sourceLocation.sourceName).translatePositionToLineColumn(_sourceLocation.start);
int startLine;
int startColumn;
int endLine;
int endColumn;
tie(startLine, startColumn) = getScanner(*_sourceLocation.sourceName).translatePositionToLineColumn(_sourceLocation.start);
tie(endLine, endColumn) = getScanner(*_sourceLocation.sourceName).translatePositionToLineColumn(_sourceLocation.end);
return make_pair(++initLine, ++initColumn);
return make_tuple(++startLine, ++startColumn, ++endLine, ++endColumn);
}
void CompilerStack::reset(bool _keepSources)

View File

@ -132,8 +132,10 @@ public:
/// scanning the source code - this is useful for printing exception information.
static bytes staticCompile(std::string const& _sourceCode, bool _optimize = false);
/// helper function for printing logs. Do only use in error cases, it's quite expensive.
std::pair<int, int> positionFromSourceLocation(SourceLocation const& _sourceLocation) const;
/// 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;
private:
/**