summaryrefslogtreecommitdiff
path: root/source/compiler-core/slang-token.h
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2024-10-29 14:49:26 +0800
committerGitHub <noreply@github.com>2024-10-29 14:49:26 +0800
commitf65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 (patch)
treeea1d61342cd29368e19135000ec2948813096205 /source/compiler-core/slang-token.h
parenta729c15e9dce9f5116a38afc66329ab2ca4cea54 (diff)
format
* format * Minor test fixes * enable checking cpp format in ci
Diffstat (limited to 'source/compiler-core/slang-token.h')
-rw-r--r--source/compiler-core/slang-token.h49
1 files changed, 21 insertions, 28 deletions
diff --git a/source/compiler-core/slang-token.h b/source/compiler-core/slang-token.h
index 7feda6824..9978ec5cf 100644
--- a/source/compiler-core/slang-token.h
+++ b/source/compiler-core/slang-token.h
@@ -3,11 +3,11 @@
#define SLANG_TOKEN_H_INCLUDED
#include "../core/slang-basic.h"
-
-#include "slang-source-loc.h"
#include "slang-name.h"
+#include "slang-source-loc.h"
-namespace Slang {
+namespace Slang
+{
class Name;
@@ -24,22 +24,21 @@ struct TokenFlag
{
enum Enum : TokenFlags
{
- AtStartOfLine = 1 << 0,
- AfterWhitespace = 1 << 1,
- ScrubbingNeeded = 1 << 2,
- Name = 1 << 3, ///< Determines if 'name' is set or 'chars' in the charsNameUnion
+ AtStartOfLine = 1 << 0,
+ AfterWhitespace = 1 << 1,
+ ScrubbingNeeded = 1 << 2,
+ Name = 1 << 3, ///< Determines if 'name' is set or 'chars' in the charsNameUnion
};
};
class Token
{
public:
+ TokenType type = TokenType::Unknown;
+ TokenFlags flags = 0;
- TokenType type = TokenType::Unknown;
- TokenFlags flags = 0;
-
- SourceLoc loc;
- uint32_t charsCount = 0; ///< Amount of characters. Is set if name or not.
+ SourceLoc loc;
+ uint32_t charsCount = 0; ///< Amount of characters. Is set if name or not.
union CharsNameUnion
{
@@ -53,7 +52,7 @@ public:
Index getContentLength() const { return charsCount; }
UnownedStringSlice getContent() const;
- /// Set content
+ /// Set content
void setContent(const UnownedStringSlice& content);
Name* getName() const;
@@ -62,13 +61,10 @@ public:
SourceLoc getLoc() const { return loc; }
- /// Set the name
+ /// Set the name
SLANG_FORCE_INLINE void setName(Name* inName);
- Token()
- {
- charsNameUnion.chars = nullptr;
- }
+ Token() { charsNameUnion.chars = nullptr; }
Token(
TokenType inType,
@@ -76,18 +72,14 @@ public:
SourceLoc inLoc,
TokenFlags inFlags = 0)
: flags(inFlags)
- {
- SLANG_ASSERT((inFlags & TokenFlag::Name) == 0);
- type = inType;
+ {
+ SLANG_ASSERT((inFlags & TokenFlag::Name) == 0);
+ type = inType;
charsNameUnion.chars = inContent.begin();
charsCount = uint32_t(inContent.getLength());
loc = inLoc;
- }
- Token(
- TokenType inType,
- Name* name,
- SourceLoc inLoc,
- TokenFlags inFlags = 0)
+ }
+ Token(TokenType inType, Name* name, SourceLoc inLoc, TokenFlags inFlags = 0)
{
SLANG_ASSERT(name);
type = inType;
@@ -101,7 +93,8 @@ public:
// ---------------------------------------------------------------------------
SLANG_FORCE_INLINE UnownedStringSlice Token::getContent() const
{
- return (flags & TokenFlag::Name) ? charsNameUnion.name->text.getUnownedSlice() : UnownedStringSlice(charsNameUnion.chars, charsCount);
+ return (flags & TokenFlag::Name) ? charsNameUnion.name->text.getUnownedSlice()
+ : UnownedStringSlice(charsNameUnion.chars, charsCount);
}
// ---------------------------------------------------------------------------