| 1 |
/** |
| 2 |
* Defines a `Dsymbol` for `version = identifier` and `debug = identifier` statements. |
| 3 |
* |
| 4 |
* Specification: $(LINK2 https://dlang.org/spec/version.html#version-specification, Version Specification), |
| 5 |
* $(LINK2 https://dlang.org/spec/version.html#debug_specification, Debug Specification). |
| 6 |
* |
| 7 |
* Copyright: Copyright (C) 1999-2025 by The D Language Foundation, All Rights Reserved |
| 8 |
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) |
| 9 |
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) |
| 10 |
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dversion.d, _dversion.d) |
| 11 |
* Documentation: https://dlang.org/phobos/dmd_dversion.html |
| 12 |
* Coverage: https://codecov.io/gh/dlang/dmd/src/master/compiler/src/dmd/dversion.d |
| 13 |
*/ |
| 14 |
|
| 15 |
module dmd.dversion; |
| 16 |
|
| 17 |
import dmd.arraytypes; |
| 18 |
import dmd.cond; |
| 19 |
import dmd.dmodule; |
| 20 |
import dmd.dscope; |
| 21 |
import dmd.dsymbol; |
| 22 |
import dmd.dsymbolsem; |
| 23 |
import dmd.globals; |
| 24 |
import dmd.identifier; |
| 25 |
import dmd.location; |
| 26 |
import dmd.common.outbuffer; |
| 27 |
import dmd.visitor; |
| 28 |
|
| 29 |
/*********************************************************** |
| 30 |
* DebugSymbol's happen for statements like: |
| 31 |
* debug = identifier; |
| 32 |
*/ |
| 33 |
extern (C++) final class DebugSymbol : Dsymbol |
| 34 |
{ |
| 35 |
extern (D) this(Loc loc, Identifier ident) @safe |
| 36 |
{ |
| 37 |
super(DSYM.debugSymbol, loc, ident); |
| 38 |
} |
| 39 |
|
| 40 |
extern (D) this(Loc loc) @safe |
| 41 |
{ |
| 42 |
super(DSYM.aliasDeclaration, loc, null); |
| 43 |
} |
| 44 |
|
| 45 |
override DebugSymbol syntaxCopy(Dsymbol s) |
| 46 |
{ |
| 47 |
assert(!s); |
| 48 |
auto ds = new DebugSymbol(loc, ident); |
| 49 |
ds.comment = comment; |
| 50 |
return ds; |
| 51 |
} |
| 52 |
|
| 53 |
override const(char)* kind() const nothrow |
| 54 |
{ |
| 55 |
return "debug"; |
| 56 |
} |
| 57 |
|
| 58 |
override void accept(Visitor v) |
| 59 |
{ |
| 60 |
v.visit(this); |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
/*********************************************************** |
| 65 |
* VersionSymbol's happen for statements like: |
| 66 |
* version = identifier; |
| 67 |
*/ |
| 68 |
extern (C++) final class VersionSymbol : Dsymbol |
| 69 |
{ |
| 70 |
|
| 71 |
extern (D) this(Loc loc, Identifier ident) @safe |
| 72 |
{ |
| 73 |
super(DSYM.versionSymbol, loc, ident); |
| 74 |
} |
| 75 |
|
| 76 |
extern (D) this(Loc loc) @safe |
| 77 |
{ |
| 78 |
super(DSYM.versionSymbol, loc, null); |
| 79 |
} |
| 80 |
|
| 81 |
override VersionSymbol syntaxCopy(Dsymbol s) |
| 82 |
{ |
| 83 |
assert(!s); |
| 84 |
auto ds = new VersionSymbol(loc, ident); |
| 85 |
ds.comment = comment; |
| 86 |
return ds; |
| 87 |
} |
| 88 |
|
| 89 |
override const(char)* kind() const nothrow |
| 90 |
{ |
| 91 |
return "version"; |
| 92 |
} |
| 93 |
|
| 94 |
override void accept(Visitor v) |
| 95 |
{ |
| 96 |
v.visit(this); |
| 97 |
} |
| 98 |
} |