d: Merge dmd, druntime d8e3976a58, phobos 7a6e95688
[official-gcc.git] / gcc / d / dmd / identifier.h
blobafd3664bfa89483a0b1766684183991565c3b2a0
2 /* Compiler implementation of the D programming language
3 * Copyright (C) 1999-2024 by The D Language Foundation, All Rights Reserved
4 * written by Walter Bright
5 * https://www.digitalmars.com
6 * Distributed under the Boost Software License, Version 1.0.
7 * https://www.boost.org/LICENSE_1_0.txt
8 * https://github.com/dlang/dmd/blob/master/src/dmd/identifier.h
9 */
11 #pragma once
13 #include "root/dcompat.h"
14 #include "root/object.h"
16 class Identifier final : public RootObject
18 private:
19 int value;
20 d_bool isAnonymous_;
21 DString string;
23 public:
24 static Identifier* create(const char *string);
25 const char *toChars() const override;
26 int getValue() const;
27 bool isAnonymous() const;
28 const char *toHChars2() const;
29 DYNCAST dyncast() const override;
31 static Identifier *generateId(const char *prefix, size_t length, size_t suffix);
32 static Identifier *idPool(const char *s, unsigned len);
34 static inline Identifier *idPool(const char *s)
36 return idPool(s, static_cast<unsigned>(strlen(s)));
39 static bool isValidIdentifier(const char *p);