Blender V5.3
source_location.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2026 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "token.hh"
12
13namespace bsl {
14
15using namespace std;
16using Token = blender::gpu::shader::parser::Token;
18
28
30
31 operator string() const
32 {
33 return tok.filename() + ':' + to_string(tok.line_number()) + ':' +
34 to_string(tok.char_number() + 1);
35 }
36
37 friend bool operator<=(const SourceLocation &a, const SourceLocation &b)
38 {
39 return (a.include_id() != b.include_id()) ? (a.include_id() <= b.include_id()) :
40 (a.tok.index_ <= b.tok.index_);
41 }
42
43 friend bool operator<(const SourceLocation &a, const SourceLocation &b)
44 {
45 return (a.include_id() != b.include_id()) ? (a.include_id() < b.include_id()) :
46 (a.tok.index_ < b.tok.index_);
47 }
48
49 private:
50 int include_id() const
51 {
52 return static_cast<const ParserBase *>(tok.buf_)->include_id;
53 }
54};
55
56} // namespace bsl
Definition codegen.cc:18
string to_string(const char *str)
Definition string.cpp:202
friend bool operator<=(const SourceLocation &a, const SourceLocation &b)
friend bool operator<(const SourceLocation &a, const SourceLocation &b)
const TokenBuffer * buf_
Definition lexit.hh:50
int32_t index_
Definition lexit.hh:51