Debian Codegraph @

gcc/d/dmd/aliasthis.d

raw
1 /**
2 * Implements the `alias this` symbol.
3 *
4 * Specification: $(LINK2 https://dlang.org/spec/class.html#alias-this, Alias This)
5 *
6 * Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved
7 * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
8 * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
9 * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/aliasthis.d, _aliasthis.d)
10 * Documentation: https://dlang.org/phobos/dmd_aliasthis.html
11 * Coverage: https://codecov.io/gh/dlang/dmd/src/master/compiler/src/dmd/aliasthis.d
12 */
13
14 module dmd.aliasthis;
15
16 import core.stdc.stdio;
17
18 import dmd.dsymbol;
19 import dmd.identifier;
20 import dmd.location;
21 import dmd.visitor;
22
23 /***********************************************************
24 * alias ident this;
25 */
26 extern (C++) final class AliasThis : Dsymbol
27 {
28 Identifier ident;
29 /// The symbol this `alias this` resolves to
30 Dsymbol sym;
31 /// Whether this `alias this` is deprecated or not
32 bool isDeprecated_;
33
34 extern (D) this(Loc loc, Identifier ident) @safe
35 {
36 super(DSYM.aliasThis, loc, null); // it's anonymous (no identifier)
37 this.ident = ident;
38 }
39
40 override AliasThis syntaxCopy(Dsymbol s)
41 {
42 assert(!s);
43 auto at = new AliasThis(loc, ident);
44 at.comment = comment;
45 return at;
46 }
47
48 override const(char)* kind() const
49 {
50 return "alias this";
51 }
52
53 AliasThis isAliasThis()
54 {
55 return this;
56 }
57
58 override void accept(Visitor v)
59 {
60 v.visit(this);
61 }
62
63 override bool isDeprecated() const
64 {
65 return this.isDeprecated_;
66 }
67 }