CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
SourceArea.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "SourcePosition.hpp"
11
13
15
16 class Token;
17 struct AST;
18
19 // Source area structure with position and length.
20 class SourceArea {
21 public:
22 // Invalid source area.
23 static const SourceArea ignore;
24
25 SourceArea() = default;
26 SourceArea(const SourceArea&) = default;
27 SourceArea& operator=(const SourceArea&) = default;
28
30
31 // Returns ture if this is a valid source area. False if the position is invalid or the length is 0.
32 [[nodiscard]] bool isValid() const;
33
34 // Updates the source area from the specified other area.
35 void update(const SourceArea& area);
36
37 // Updates the source area length from the specified identifier.
39
40 // Updates the source area from the specified token.
41 void update(const Token& token);
42
43 // Updates the source area from the specified AST node.
44 void update(const AST& ast);
45
46 // Sets the new offset of the marker pointer.
48
49 // Sets the new offset of the marker pointer by a source position.
51
52 // Returns the offset of the marker pointer (e.g. "^~~~") clamped to the range [0, length).
54
55 // Returns the start position of the source area.
56 [[nodiscard]] inline const SourcePosition& getPosition() const { return mPos; }
57
58 // Returns the length of the source area.
59 [[nodiscard]] inline UInt32 getLength() const { return mLength; }
60
61 private:
65 };
66
67} // namespace CeresEngine::ShaderCompiler
Definition SourceArea.hpp:20
SourceArea & operator=(const SourceArea &)=default
UInt32 mLength
Definition SourceArea.hpp:63
UInt32 getLength() const
Definition SourceArea.hpp:59
SourceArea(const SourcePosition &pos, UInt32 length, UInt32 offset=0)
SourceArea(const SourceArea &)=default
SourcePosition mPos
Definition SourceArea.hpp:62
UInt32 mOffset
Definition SourceArea.hpp:64
void offset(const SourcePosition &pos)
void update(const SourceArea &area)
static const SourceArea ignore
Definition SourceArea.hpp:23
void update(const String &lengthFromIdent)
const SourcePosition & getPosition() const
Definition SourceArea.hpp:56
Definition SourcePosition.hpp:30
Definition Token.hpp:21
Definition AST.hpp:33
std::uint32_t UInt32
Definition DataTypes.hpp:23
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25