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), |
| 24 byte_(byte) { |
21 } | 25 } |
22 | 26 |
23 bool Location::operator==(const Location& other) const { | 27 bool Location::operator==(const Location& other) const { |
24 return other.file_ == file_ && | 28 return other.file_ == file_ && |
25 other.line_number_ == line_number_ && | 29 other.line_number_ == line_number_ && |
26 other.char_offset_ == char_offset_; | 30 other.char_offset_ == char_offset_; |
27 } | 31 } |
28 | 32 |
29 bool Location::operator!=(const Location& other) const { | 33 bool Location::operator!=(const Location& other) const { |
30 return !operator==(other); | 34 return !operator==(other); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 end_(end) { | 68 end_(end) { |
65 DCHECK(begin_.file() == end_.file()); | 69 DCHECK(begin_.file() == end_.file()); |
66 } | 70 } |
67 | 71 |
68 LocationRange LocationRange::Union(const LocationRange& other) const { | 72 LocationRange LocationRange::Union(const LocationRange& other) const { |
69 DCHECK(begin_.file() == other.begin_.file()); | 73 DCHECK(begin_.file() == other.begin_.file()); |
70 return LocationRange( | 74 return LocationRange( |
71 begin_ < other.begin_ ? begin_ : other.begin_, | 75 begin_ < other.begin_ ? begin_ : other.begin_, |
72 end_ < other.end_ ? other.end_ : end_); | 76 end_ < other.end_ ? other.end_ : end_); |
73 } | 77 } |
OLD | NEW |