@@ -304,9 +304,13 @@ extern (C++) abstract class Expression : ASTNode
304
304
305
305
static struct BitFields
306
306
{
307
- bool parens; // if this is a parenthesized expression
308
- bool rvalue; // true if this is considered to be an rvalue, even if it is an lvalue
309
- bool gcPassDone; // `checkGC` has been run on this expression
307
+ OwnedBy ownedByCtfe = OwnedBy.code;
308
+ bool parens; // if this is a parenthesized expression
309
+ bool rvalue; // true if this is considered to be an rvalue, even if it is an lvalue
310
+ bool gcPassDone; // `checkGC` has been run on this expression
311
+ bool flag1; // reserved space for flags of derived classes
312
+ bool flag2; // ditto
313
+ bool flag3; // ditto
310
314
}
311
315
import dmd.common.bitfields;
312
316
mixin (generateBitFields! (BitFields, ubyte ));
@@ -1246,7 +1250,7 @@ extern (C++) final class DollarExp : IdentifierExp
1246
1250
extern (C++ ) final class DsymbolExp : Expression
1247
1251
{
1248
1252
Dsymbol s;
1249
- bool hasOverloads;
1253
+ alias hasOverloads = flag1 ;
1250
1254
1251
1255
extern (D ) this (Loc loc, Dsymbol s, bool hasOverloads = true ) @safe
1252
1256
{
@@ -1382,8 +1386,6 @@ extern (C++) final class NullExp : Expression
1382
1386
*/
1383
1387
extern (C++ ) final class StringExp : Expression
1384
1388
{
1385
- char postfix = NoPostfix; // 'c', 'w', 'd'
1386
- OwnedBy ownedByCtfe = OwnedBy.code;
1387
1389
private union
1388
1390
{
1389
1391
char * string ; // if sz == 1
@@ -1393,6 +1395,7 @@ extern (C++) final class StringExp : Expression
1393
1395
} // (const if ownedByCtfe == OwnedBy.code)
1394
1396
size_t len; // number of code units
1395
1397
ubyte sz = 1 ; // 1: char, 2: wchar, 4: dchar
1398
+ char postfix = NoPostfix; // 'c', 'w', 'd'
1396
1399
1397
1400
/**
1398
1401
* Whether the string literal's type is fixed
@@ -1402,12 +1405,12 @@ extern (C++) final class StringExp : Expression
1402
1405
* wstring y = cast(string) "abc"; // Error: type was committed after cast
1403
1406
* ---
1404
1407
*/
1405
- bool committed;
1408
+ alias committed = flag1 ;
1406
1409
1407
1410
// / If the string is parsed from a hex string literal
1408
- bool hexString = false ;
1411
+ alias hexString = flag2 ;
1409
1412
// / If the string is from a collected C macro
1410
- bool cMacro = false ;
1413
+ alias cMacro = flag3 ;
1411
1414
1412
1415
enum char NoPostfix = 0 ;
1413
1416
@@ -1760,10 +1763,9 @@ extern (C++) final class StringExp : Expression
1760
1763
1761
1764
extern (C++ ) final class InterpExp : Expression
1762
1765
{
1763
- char postfix = NoPostfix; // 'c', 'w', 'd'
1764
- OwnedBy ownedByCtfe = OwnedBy.code;
1765
1766
InterpolatedSet* interpolatedSet;
1766
1767
1768
+ char postfix = NoPostfix; // 'c', 'w', 'd'
1767
1769
enum char NoPostfix = 0 ;
1768
1770
1769
1771
extern (D ) this (Loc loc, InterpolatedSet* set, char postfix = NoPostfix) scope @safe
@@ -1895,8 +1897,8 @@ extern (C++) final class TupleExp : Expression
1895
1897
*/
1896
1898
extern (C++ ) final class ArrayLiteralExp : Expression
1897
1899
{
1898
- OwnedBy ownedByCtfe = OwnedBy.code;
1899
- bool onstack = false ;
1900
+ bool onstack () { return flag1; }
1901
+ void onstack ( bool v) { flag1 = v; }
1900
1902
1901
1903
/* * If !is null, elements[] can be sparse and basis is used for the
1902
1904
* "default" element value. In other words, non-null elements[i] overrides
@@ -2056,8 +2058,6 @@ extern (C++) final class ArrayLiteralExp : Expression
2056
2058
*/
2057
2059
extern (C++ ) final class AssocArrayLiteralExp : Expression
2058
2060
{
2059
- OwnedBy ownedByCtfe = OwnedBy.code;
2060
-
2061
2061
Expressions* keys ;
2062
2062
Expressions* values ;
2063
2063
// / Lower to core.internal.newaa for static initializaton
@@ -2122,14 +2122,11 @@ extern (C++) final class AssocArrayLiteralExp : Expression
2122
2122
*/
2123
2123
extern (C++ ) final class StructLiteralExp : Expression
2124
2124
{
2125
- struct BitFields
2126
- {
2127
- bool useStaticInit; // / if this is true, use the StructDeclaration's init symbol
2128
- bool isOriginal = false ; // / used when moving instances to indicate `this is this.origin`
2129
- OwnedBy ownedByCtfe = OwnedBy.code;
2130
- }
2131
- import dmd.common.bitfields;
2132
- mixin (generateBitFields! (BitFields, ubyte ));
2125
+
2126
+ alias useStaticInit = flag1; // / if this is true, use the StructDeclaration's init symbol
2127
+ bool useStaticInit () { return flag1; }
2128
+ void useStaticInit (bool v) { flag1 = v; }
2129
+ alias isOriginal = flag2; // / used when moving instances to indicate `this is this.origin`
2133
2130
StageFlags stageflags;
2134
2131
2135
2132
StructDeclaration sd; // / which aggregate this is for
@@ -2455,8 +2452,13 @@ extern (C++) final class NewExp : Expression
2455
2452
2456
2453
Expression argprefix; // expression to be evaluated just before arguments[]
2457
2454
CtorDeclaration member; // constructor function
2458
- bool onstack; // allocate on stack
2459
- bool thrownew; // this NewExp is the expression of a ThrowStatement
2455
+
2456
+ // allocate on stack
2457
+ bool onstack () { return flag1; }
2458
+ void onstack (bool v) { flag1 = v; }
2459
+ // this NewExp is the expression of a ThrowStatement
2460
+ bool thrownew () { return flag2; }
2461
+ void thrownew (bool v) { flag2 = v; }
2460
2462
2461
2463
Expression lowering; // lowered druntime hook: `_d_new{class,itemT}`
2462
2464
@@ -2534,7 +2536,7 @@ extern (C++) class SymbolExp : Expression
2534
2536
{
2535
2537
Declaration var;
2536
2538
Dsymbol originalScope; // original scope before inlining
2537
- bool hasOverloads;
2539
+ alias hasOverloads = flag1 ;
2538
2540
2539
2541
extern (D ) this (Loc loc, EXP op, Declaration var, bool hasOverloads) @safe
2540
2542
{
@@ -2591,7 +2593,7 @@ extern (C++) final class SymOffExp : SymbolExp
2591
2593
*/
2592
2594
extern (C++ ) final class VarExp : SymbolExp
2593
2595
{
2594
- bool delegateWasExtracted;
2596
+ alias delegateWasExtracted = flag1 ;
2595
2597
extern (D ) this (Loc loc, Declaration var, bool hasOverloads = true ) @safe
2596
2598
{
2597
2599
if (var.isVarDeclaration())
@@ -3104,10 +3106,9 @@ extern (C++) final class ThrowExp : UnaExp
3104
3106
extern (C++ ) final class DotIdExp : UnaExp
3105
3107
{
3106
3108
Identifier ident;
3107
- bool noderef; // true if the result of the expression will never be dereferenced
3108
- bool wantsym; // do not replace Symbol with its initializer during semantic()
3109
- bool arrow; // ImportC: if -> instead of .
3110
-
3109
+ alias noderef = flag1; // true if the result of the expression will never be dereferenced
3110
+ alias wantsym = flag2; // do not replace Symbol with its initializer during semantic()
3111
+ alias arrow = flag3; // ImportC: if -> instead of .
3111
3112
extern (D ) this (Loc loc, Expression e, Identifier ident) @safe
3112
3113
{
3113
3114
super (loc, EXP .dotIdentifier, e);
@@ -3155,7 +3156,7 @@ extern (C++) final class DotTemplateExp : UnaExp
3155
3156
extern (C++ ) final class DotVarExp : UnaExp
3156
3157
{
3157
3158
Declaration var;
3158
- bool hasOverloads;
3159
+ alias hasOverloads = flag1 ;
3159
3160
3160
3161
extern (D ) this (Loc loc, Expression e, Declaration var, bool hasOverloads = true ) @safe
3161
3162
{
@@ -3233,7 +3234,7 @@ extern (C++) final class DotTemplateInstanceExp : UnaExp
3233
3234
extern (C++ ) final class DelegateExp : UnaExp
3234
3235
{
3235
3236
FuncDeclaration func;
3236
- bool hasOverloads;
3237
+ alias hasOverloads = flag1 ;
3237
3238
VarDeclaration vthis2; // container for multi-context
3238
3239
3239
3240
extern (D ) this (Loc loc, Expression e, FuncDeclaration f, bool hasOverloads = true , VarDeclaration vthis2 = null ) @safe
@@ -3308,11 +3309,18 @@ extern (C++) final class CallExp : UnaExp
3308
3309
Expressions* arguments; // function arguments
3309
3310
ArgumentLabels * names; // named argument labels
3310
3311
FuncDeclaration f; // symbol to call
3311
- bool directcall; // true if a virtual call is devirtualized
3312
- bool inDebugStatement; // / true if this was in a debug statement
3313
- bool ignoreAttributes; // / don't enforce attributes (e.g. call @gc function in @nogc code)
3314
- bool isUfcsRewrite; // / the first argument was pushed in here by a UFCS rewrite
3315
3312
VarDeclaration vthis2; // container for multi-context
3313
+ bool directcall () { return flag1; }
3314
+ void directcall (bool v) {flag1 = v; }
3315
+ alias directcall = flag1; // / true if a virtual call is devirtualized
3316
+ alias inDebugStatement = flag2; // / true if this was in a debug statement
3317
+ alias ignoreAttributes = flag3; // / don't enforce attributes (e.g. call @gc function in @nogc code)
3318
+
3319
+ // / the first argument was pushed in here by a UFCS rewrite
3320
+ // we reuse the `ownedBy` bits of the bitfield
3321
+ bool isUfcsRewrite () { return ownedByCtfe != OwnedBy.code; }
3322
+ void isUfcsRewrite (bool v) { ownedByCtfe = v ? OwnedBy.ctfe : OwnedBy.code; }
3323
+
3316
3324
3317
3325
// / Puts the `arguments` and `names` into an `ArgumentList` for easily passing them around.
3318
3326
// / The fields are still separate for backwards compatibility
@@ -3593,7 +3601,7 @@ extern (C++) final class NotExp : UnaExp
3593
3601
*/
3594
3602
extern (C++ ) final class DeleteExp : UnaExp
3595
3603
{
3596
- bool isRAII; // true if called automatically as a result of scoped destruction
3604
+ alias isRAII = flag1 ; // true if called automatically as a result of scoped destruction
3597
3605
3598
3606
extern (D ) this (Loc loc, Expression e, bool isRAII) @safe
3599
3607
{
@@ -3617,9 +3625,9 @@ extern (C++) final class DeleteExp : UnaExp
3617
3625
extern (C++ ) final class CastExp : UnaExp
3618
3626
{
3619
3627
Type to; // type to cast to
3620
- ubyte mod = cast (ubyte )~ 0 ; // MODxxxxx
3621
- bool trusted; // assume cast is safe
3622
3628
Expression lowering;
3629
+ ubyte mod = cast (ubyte )~ 0 ; // MODxxxxx
3630
+ alias trusted = flag1; // assume cast is safe
3623
3631
3624
3632
extern (D ) this (Loc loc, Expression e, Type t) @safe
3625
3633
{
@@ -3662,7 +3670,6 @@ extern (C++) final class VectorExp : UnaExp
3662
3670
{
3663
3671
TypeVector to; // the target vector type before semantic()
3664
3672
uint dim = ~ 0 ; // number of elements in the vector
3665
- OwnedBy ownedByCtfe = OwnedBy.code;
3666
3673
3667
3674
extern (D ) this (Loc loc, Expression e, Type t) @trusted
3668
3675
{
@@ -3722,14 +3729,14 @@ extern (C++) final class SliceExp : UnaExp
3722
3729
3723
3730
VarDeclaration lengthVar;
3724
3731
3725
- private extern ( D ) static struct BitFields
3726
- {
3727
- bool upperIsInBounds; // true if upr <= e1.length
3728
- bool lowerIsLessThanUpper; // true if lwr <= upr
3729
- bool arrayop; // an array operation, rather than a slice
3730
- }
3731
- import dmd.common.bitfields : generateBitFields;
3732
- mixin (generateBitFields ! (BitFields, ubyte ));
3732
+ // true if upr <= e1.length
3733
+ bool upperIsInBounds () { return flag1; }
3734
+ void upperIsInBounds ( bool v) { flag1 = v; }
3735
+ // true if lwr <= upr
3736
+ bool lowerIsLessThanUpper () { return flag2; }
3737
+ void lowerIsLessThanUpper ( bool v) { flag2 = v; }
3738
+
3739
+ alias arrayop = flag3; // an array operation, rather than a slice
3733
3740
3734
3741
/* ***********************************************************/
3735
3742
extern (D ) this (Loc loc, Expression e1, IntervalExp ie) @safe
@@ -3857,13 +3864,14 @@ extern (C++) final class CommaExp : BinExp
3857
3864
{
3858
3865
// / This is needed because AssignExp rewrites CommaExp, hence it needs
3859
3866
// / to trigger the deprecation.
3860
- const bool isGenerated;
3867
+ bool isGenerated () { return flag1; }
3868
+ void isGenerated (bool v) { flag1 = v; }
3861
3869
3862
3870
// / Temporary variable to enable / disable deprecation of comma expression
3863
3871
// / depending on the context.
3864
3872
// / Since most constructor calls are rewritting, the only place where
3865
3873
// / false will be passed will be from the parser.
3866
- bool allowCommaExp;
3874
+ alias allowCommaExp = flag2 ;
3867
3875
3868
3876
// / The original expression before any rewriting occurs.
3869
3877
// / This is used in error messages.
@@ -3996,8 +4004,12 @@ extern (C++) final class DelegateFuncptrExp : UnaExp
3996
4004
extern (C++ ) final class IndexExp : BinExp
3997
4005
{
3998
4006
VarDeclaration lengthVar;
3999
- bool modifiable = false ; // assume it is an rvalue
4000
- bool indexIsInBounds; // true if 0 <= e2 && e2 <= e1.length - 1
4007
+ // assume it is an rvalue
4008
+ bool modifiable () { return flag1; }
4009
+ void modifiable (bool v) { flag1 = v; }
4010
+ // true if 0 <= e2 && e2 <= e1.length - 1
4011
+ bool indexIsInBounds () { return flag1; }
4012
+ void indexIsInBounds (bool v) { flag1 = v; }
4001
4013
4002
4014
extern (D ) this (Loc loc, Expression e1, Expression e2) @safe
4003
4015
{
0 commit comments