alokp@chromium.org | 2c958ee | 2012-05-17 20:35:42 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 7 | #ifndef COMPILER_PREPROCESSOR_SOURCELOCATION_H_ |
| 8 | #define COMPILER_PREPROCESSOR_SOURCELOCATION_H_ |
alokp@chromium.org | 2c958ee | 2012-05-17 20:35:42 +0000 | [diff] [blame] | 9 | |
| 10 | namespace pp |
| 11 | { |
| 12 | |
| 13 | struct SourceLocation |
| 14 | { |
Zhenyao Mo | d526f98 | 2014-05-13 14:51:19 -0700 | [diff] [blame] | 15 | SourceLocation() |
| 16 | : file(0), |
| 17 | line(0) |
| 18 | { |
| 19 | } |
| 20 | SourceLocation(int f, int l) |
| 21 | : file(f), |
| 22 | line(l) |
| 23 | { |
| 24 | } |
alokp@chromium.org | 2c958ee | 2012-05-17 20:35:42 +0000 | [diff] [blame] | 25 | |
Zhenyao Mo | d526f98 | 2014-05-13 14:51:19 -0700 | [diff] [blame] | 26 | bool equals(const SourceLocation &other) const |
alokp@chromium.org | 2c958ee | 2012-05-17 20:35:42 +0000 | [diff] [blame] | 27 | { |
| 28 | return (file == other.file) && (line == other.line); |
| 29 | } |
| 30 | |
| 31 | int file; |
| 32 | int line; |
| 33 | }; |
| 34 | |
Zhenyao Mo | d526f98 | 2014-05-13 14:51:19 -0700 | [diff] [blame] | 35 | inline bool operator==(const SourceLocation &lhs, const SourceLocation &rhs) |
alokp@chromium.org | 2c958ee | 2012-05-17 20:35:42 +0000 | [diff] [blame] | 36 | { |
| 37 | return lhs.equals(rhs); |
| 38 | } |
| 39 | |
Zhenyao Mo | d526f98 | 2014-05-13 14:51:19 -0700 | [diff] [blame] | 40 | inline bool operator!=(const SourceLocation &lhs, const SourceLocation &rhs) |
alokp@chromium.org | 2c958ee | 2012-05-17 20:35:42 +0000 | [diff] [blame] | 41 | { |
| 42 | return !lhs.equals(rhs); |
| 43 | } |
| 44 | |
| 45 | } // namespace pp |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 46 | |
| 47 | #endif // COMPILER_PREPROCESSOR_SOURCELOCATION_H_ |