From 4fdfbaa3674a1597d1f192075700ac5951772193 Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Thu, 7 May 2015 17:22:24 +0200 Subject: [PATCH] adde the positions for the end of SourceLocation --- CompilerStack.cpp | 13 ++++++++----- CompilerStack.h | 6 ++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CompilerStack.cpp b/CompilerStack.cpp index a1c9b4a5c..b3fedc45d 100644 --- a/CompilerStack.cpp +++ b/CompilerStack.cpp @@ -257,13 +257,16 @@ bytes CompilerStack::staticCompile(std::string const& _sourceCode, bool _optimiz return stack.compile(_sourceCode, _optimize); } -pair CompilerStack::positionFromSourceLocation(SourceLocation const& _sourceLocation) const +tuple 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) diff --git a/CompilerStack.h b/CompilerStack.h index 3eff75773..2ad791f22 100644 --- a/CompilerStack.h +++ b/CompilerStack.h @@ -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 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 positionFromSourceLocation(SourceLocation const& _sourceLocation) const; private: /**