OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "tools/gn/location.h" | 5 #include "tools/gn/location.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "tools/gn/input_file.h" | 9 #include "tools/gn/input_file.h" |
10 | 10 |
11 Location::Location() | 11 Location::Location() |
12 : file_(NULL), | 12 : file_(NULL), |
13 line_number_(-1), | 13 line_number_(-1), |
14 char_offset_(-1) { | 14 char_offset_(-1) { |
15 } | 15 } |
16 | 16 |
17 Location::Location(const InputFile* file, int line_number, int char_offset) | 17 Location::Location(const InputFile* file, |
| 18 int line_number, |
| 19 int char_offset, |
| 20 int byte) |
18 : file_(file), | 21 : file_(file), |
19 line_number_(line_number), | 22 line_number_(line_number), |
20 char_offset_(char_offset) { | 23 char_offset_(char_offset), |
21 } | 24 byte_(byte) {} |
22 | 25 |
23 bool Location::operator==(const Location& other) const { | 26 bool Location::operator==(const Location& other) const { |
24 return other.file_ == file_ && | 27 return other.file_ == file_ && |
25 other.line_number_ == line_number_ && | 28 other.line_number_ == line_number_ && |
26 other.char_offset_ == char_offset_; | 29 other.char_offset_ == char_offset_; |
27 } | 30 } |
28 | 31 |
29 bool Location::operator!=(const Location& other) const { | 32 bool Location::operator!=(const Location& other) const { |
30 return !operator==(other); | 33 return !operator==(other); |
31 } | 34 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 end_(end) { | 67 end_(end) { |
65 DCHECK(begin_.file() == end_.file()); | 68 DCHECK(begin_.file() == end_.file()); |
66 } | 69 } |
67 | 70 |
68 LocationRange LocationRange::Union(const LocationRange& other) const { | 71 LocationRange LocationRange::Union(const LocationRange& other) const { |
69 DCHECK(begin_.file() == other.begin_.file()); | 72 DCHECK(begin_.file() == other.begin_.file()); |
70 return LocationRange( | 73 return LocationRange( |
71 begin_ < other.begin_ ? begin_ : other.begin_, | 74 begin_ < other.begin_ ? begin_ : other.begin_, |
72 end_ < other.end_ ? other.end_ : end_); | 75 end_ < other.end_ ? other.end_ : end_); |
73 } | 76 } |
OLD | NEW |