Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use enum instead of immutable for CTFE-only literals #16670

Merged
merged 2 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions compiler/src/dmd/astbase.d
Original file line number Diff line number Diff line change
Expand Up @@ -6991,7 +6991,8 @@ struct ASTBase
}
}

private immutable ubyte[EXP.max + 1] exptab =
private:
immutable ubyte[EXP.max + 1] exptab =
() {
ubyte[EXP.max + 1] tab;
with (EXPFLAGS)
Expand All @@ -7003,14 +7004,14 @@ private immutable ubyte[EXP.max + 1] exptab =
return tab;
} ();

private enum EXPFLAGS : ubyte
enum EXPFLAGS : ubyte
{
unary = 1,
binary = 2,
binaryAssign = 4,
}

private static immutable Eunary =
enum Eunary =
[
EXP.import_, EXP.assert_, EXP.throw_, EXP.dotIdentifier, EXP.dotTemplateDeclaration,
EXP.dotVariable, EXP.dotTemplateInstance, EXP.delegate_, EXP.dotType, EXP.call,
Expand All @@ -7019,7 +7020,7 @@ private static immutable Eunary =
EXP.delegateFunctionPointer, EXP.preMinusMinus, EXP.prePlusPlus,
];

private static immutable Ebinary =
enum Ebinary =
[
EXP.dot, EXP.comma, EXP.index, EXP.minusMinus, EXP.plusPlus, EXP.assign,
EXP.add, EXP.min, EXP.concatenate, EXP.mul, EXP.div, EXP.mod, EXP.pow, EXP.leftShift,
Expand All @@ -7030,7 +7031,7 @@ private static immutable Ebinary =
EXP.construct, EXP.blit,
];

private static immutable EbinaryAssign =
enum EbinaryAssign =
[
EXP.addAssign, EXP.minAssign, EXP.mulAssign, EXP.divAssign, EXP.modAssign,
EXP.andAssign, EXP.orAssign, EXP.xorAssign, EXP.powAssign,
Expand Down
36 changes: 18 additions & 18 deletions compiler/src/dmd/backend/oper.d
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ private:
* Different categories of operators.
*/

static immutable Ebinary =
enum Ebinary =
[
OPadd,OPmul,OPand,OPmin,OPcond,OPcomma,OPdiv,OPmod,OPxor,
OPor,OPoror,OPandand,OPshl,OPshr,OPashr,OPstreq,OPstrcpy,OPstrcat,OPstrcmp,
Expand All @@ -835,7 +835,7 @@ static immutable Ebinary =
OPvecsto,OPprefetch
];

static immutable Eunary =
enum Eunary =
[
OPnot,OPcom,OPind,OPaddr,OPneg,OPuadd,
OPabs,OPrndtol,OPrint,
Expand All @@ -858,16 +858,16 @@ static immutable Eunary =
OPvp_fp,OPcvp_fp,OPnp_fp,OPnp_f16p,OPf16p_np,OPoffset,
];

static immutable Ecommut =
enum Ecommut =
[
OPadd,OPand,OPor,OPxor,OPmul,OPeqeq,OPne,OPle,OPlt,OPge,OPgt,
OPunord,OPlg,OPleg,OPule,OPul,OPuge,OPug,OPue,OPngt,OPnge,
OPnlt,OPnle,OPord,OPnlg,OPnleg,OPnule,OPnul,OPnuge,OPnug,OPnue,
];

static immutable Eassoc = [ OPadd,OPand,OPor,OPxor,OPmul ];
enum Eassoc = [ OPadd,OPand,OPor,OPxor,OPmul ];

static immutable Esideff =
enum Esideff =
[
OPasm,OPucall,OPstrcpy,OPmemcpy,OPmemset,OPstrcat,
OPcall,OPeq,OPstreq,OPpostinc,OPpostdec,
Expand All @@ -881,35 +881,35 @@ static immutable Esideff =
OPinp,OPoutp,OPvecsto,OPprefetch,
];

static immutable Eeop0e =
enum Eeop0e =
[
OPadd,OPmin,OPxor,OPor,OPshl,OPshr,OPashr,OPpostinc,OPpostdec,OPaddass,
OPminass,OPshrass,OPashrass,OPshlass,OPxorass,OPorass,
OPror,OProl,
];

static immutable Eeop00 = [ OPmul,OPand,OPmulass,OPandass ];
enum Eeop00 = [ OPmul,OPand,OPmulass,OPandass ];

static immutable Eeop1e = [ OPmul,OPdiv,OPmulass,OPdivass ];
enum Eeop1e = [ OPmul,OPdiv,OPmulass,OPdivass ];

static immutable Elogical =
enum Elogical =
[
OPeqeq,OPne,OPle,OPlt,OPgt,OPge,OPandand,OPoror,OPnot,OPbool,
OPunord,OPlg,OPleg,OPule,OPul,OPuge,OPug,OPue,OPngt,OPnge,
OPnlt,OPnle,OPord,OPnlg,OPnleg,OPnule,OPnul,OPnuge,OPnug,OPnue,
OPbt,OPbtst,
];

static immutable Ewid =
enum Ewid =
[
OPadd,OPmin,OPand,OPor,OPxor,OPcom,OPneg,OPmul,OPaddass,OPnegass,
OPminass,OPandass,OPorass,OPxorass,OPmulass,OPshlass,OPshl,OPshrass,
OPashrass,
];

static immutable Ecall = [ OPcall,OPucall,OPcallns,OPucallns ];
enum Ecall = [ OPcall,OPucall,OPcallns,OPucallns ];

static immutable Ertol =
enum Ertol =
[
OPeq,OPstreq,OPstrcpy,OPmemcpy,OPpostinc,OPpostdec,OPaddass,
OPminass,OPmulass,OPdivass,OPmodass,OPandass,
Expand All @@ -918,14 +918,14 @@ static immutable Ertol =
OPvecsto,OPcmpxchg,
];

static immutable Eassign =
enum Eassign =
[
OPstreq,OPeq,OPaddass,OPminass,OPmulass,OPdivass,OPmodass,
OPshrass,OPashrass,OPshlass,OPandass,OPxorass,OPorass,OPpostinc,OPpostdec,
OPnegass,OPvecsto,OPcmpxchg,
];

static immutable Edef =
enum Edef =
[
OPstreq,OPeq,OPaddass,OPminass,OPmulass,OPdivass,OPmodass,
OPshrass,OPashrass,OPshlass,OPandass,OPxorass,OPorass,
Expand All @@ -936,7 +936,7 @@ static immutable Edef =
OPvecsto,OPcmpxchg,
];

static immutable Eae =
enum Eae =
[
OPvar,OPconst,OPrelconst,OPneg,
OPabs,OPrndtol,OPrint,
Expand All @@ -962,7 +962,7 @@ static immutable Eae =
OPvp_fp,OPcvp_fp,OPnp_fp,OPnp_f16p,OPf16p_np,OPoffset,OPvecfill,
];

static immutable Eboolnop =
enum Eboolnop =
[
OPuadd,OPbool,OPs16_32,OPu16_32,
OPs16_d,
Expand All @@ -977,15 +977,15 @@ static immutable Eboolnop =
];

/** if invalid exception can be generated by operator */
static immutable Eexception =
enum Eexception =
[
OPgt,OPge,OPlt,OPle,
OPlg,OPleg,
OPngt,OPnge,OPnlt,OPnle,OPnlg,OPnleg,
];

/** result of unordered operands */
static immutable Eunord =
enum Eunord =
[
OPne,
OPunord,OPule,OPul,OPuge,OPug,OPue,
Expand Down
Loading