From 8b46e457bc26d9c413bb8333f236d9ef3e1bc07f Mon Sep 17 00:00:00 2001 From: Nicholas Wilson Date: Fri, 25 Jul 2025 18:30:04 +0800 Subject: [PATCH] [expression.d] compress flags --- compiler/src/dmd/expression.d | 121 ++++++++++++----------- compiler/src/dmd/expression.h | 39 +------- compiler/src/dmd/expressionsem.d | 2 +- compiler/src/dmd/frontend.h | 161 +++++++++++-------------------- 4 files changed, 127 insertions(+), 196 deletions(-) diff --git a/compiler/src/dmd/expression.d b/compiler/src/dmd/expression.d index 6d4775d3ce6f..3188fbbf2917 100644 --- a/compiler/src/dmd/expression.d +++ b/compiler/src/dmd/expression.d @@ -304,9 +304,13 @@ extern (C++) abstract class Expression : ASTNode static struct BitFields { - bool parens; // if this is a parenthesized expression - bool rvalue; // true if this is considered to be an rvalue, even if it is an lvalue - bool gcPassDone; // `checkGC` has been run on this expression + OwnedBy ownedByCtfe = OwnedBy.code; + bool parens; // if this is a parenthesized expression + bool rvalue; // true if this is considered to be an rvalue, even if it is an lvalue + bool gcPassDone; // `checkGC` has been run on this expression + bool flag1; // reserved space for flags of derived classes + bool flag2; // ditto + bool flag3; // ditto } import dmd.common.bitfields; mixin(generateBitFields!(BitFields, ubyte)); @@ -1246,7 +1250,7 @@ extern (C++) final class DollarExp : IdentifierExp extern (C++) final class DsymbolExp : Expression { Dsymbol s; - bool hasOverloads; + alias hasOverloads = flag1; extern (D) this(Loc loc, Dsymbol s, bool hasOverloads = true) @safe { @@ -1382,8 +1386,6 @@ extern (C++) final class NullExp : Expression */ extern (C++) final class StringExp : Expression { - char postfix = NoPostfix; // 'c', 'w', 'd' - OwnedBy ownedByCtfe = OwnedBy.code; private union { char* string; // if sz == 1 @@ -1393,6 +1395,7 @@ extern (C++) final class StringExp : Expression } // (const if ownedByCtfe == OwnedBy.code) size_t len; // number of code units ubyte sz = 1; // 1: char, 2: wchar, 4: dchar + char postfix = NoPostfix; // 'c', 'w', 'd' /** * Whether the string literal's type is fixed @@ -1402,12 +1405,12 @@ extern (C++) final class StringExp : Expression * wstring y = cast(string) "abc"; // Error: type was committed after cast * --- */ - bool committed; + alias committed = flag1; /// If the string is parsed from a hex string literal - bool hexString = false; + alias hexString = flag2; /// If the string is from a collected C macro - bool cMacro = false; + alias cMacro = flag3; enum char NoPostfix = 0; @@ -1760,10 +1763,9 @@ extern (C++) final class StringExp : Expression extern (C++) final class InterpExp : Expression { - char postfix = NoPostfix; // 'c', 'w', 'd' - OwnedBy ownedByCtfe = OwnedBy.code; InterpolatedSet* interpolatedSet; + char postfix = NoPostfix; // 'c', 'w', 'd' enum char NoPostfix = 0; extern (D) this(Loc loc, InterpolatedSet* set, char postfix = NoPostfix) scope @safe @@ -1895,8 +1897,8 @@ extern (C++) final class TupleExp : Expression */ extern (C++) final class ArrayLiteralExp : Expression { - OwnedBy ownedByCtfe = OwnedBy.code; - bool onstack = false; + bool onstack() { return flag1; } + void onstack(bool v) { flag1 = v; } /** If !is null, elements[] can be sparse and basis is used for the * "default" element value. In other words, non-null elements[i] overrides @@ -2056,8 +2058,6 @@ extern (C++) final class ArrayLiteralExp : Expression */ extern (C++) final class AssocArrayLiteralExp : Expression { - OwnedBy ownedByCtfe = OwnedBy.code; - Expressions* keys; Expressions* values; /// Lower to core.internal.newaa for static initializaton @@ -2122,14 +2122,11 @@ extern (C++) final class AssocArrayLiteralExp : Expression */ extern (C++) final class StructLiteralExp : Expression { - struct BitFields - { - bool useStaticInit; /// if this is true, use the StructDeclaration's init symbol - bool isOriginal = false; /// used when moving instances to indicate `this is this.origin` - OwnedBy ownedByCtfe = OwnedBy.code; - } - import dmd.common.bitfields; - mixin(generateBitFields!(BitFields, ubyte)); + + /// if this is true, use the StructDeclaration's init symbol + bool useStaticInit() { return flag1; } + void useStaticInit(bool v) { flag1 = v; } + alias isOriginal = flag2; /// used when moving instances to indicate `this is this.origin` StageFlags stageflags; StructDeclaration sd; /// which aggregate this is for @@ -2455,8 +2452,13 @@ extern (C++) final class NewExp : Expression Expression argprefix; // expression to be evaluated just before arguments[] CtorDeclaration member; // constructor function - bool onstack; // allocate on stack - bool thrownew; // this NewExp is the expression of a ThrowStatement + + // allocate on stack + bool onstack() { return flag1; } + void onstack(bool v) { flag1 = v; } + // this NewExp is the expression of a ThrowStatement + bool thrownew() { return flag2; } + void thrownew(bool v) { flag2 = v; } Expression lowering; // lowered druntime hook: `_d_new{class,itemT}` @@ -2534,7 +2536,7 @@ extern (C++) class SymbolExp : Expression { Declaration var; Dsymbol originalScope; // original scope before inlining - bool hasOverloads; + alias hasOverloads = flag1; extern (D) this(Loc loc, EXP op, Declaration var, bool hasOverloads) @safe { @@ -2591,7 +2593,7 @@ extern (C++) final class SymOffExp : SymbolExp */ extern (C++) final class VarExp : SymbolExp { - bool delegateWasExtracted; + alias delegateWasExtracted = flag1; extern (D) this(Loc loc, Declaration var, bool hasOverloads = true) @safe { if (var.isVarDeclaration()) @@ -3104,10 +3106,9 @@ extern (C++) final class ThrowExp : UnaExp extern (C++) final class DotIdExp : UnaExp { Identifier ident; - bool noderef; // true if the result of the expression will never be dereferenced - bool wantsym; // do not replace Symbol with its initializer during semantic() - bool arrow; // ImportC: if -> instead of . - + alias noderef = flag1; // true if the result of the expression will never be dereferenced + alias wantsym = flag2; // do not replace Symbol with its initializer during semantic() + alias arrow = flag3; // ImportC: if -> instead of . extern (D) this(Loc loc, Expression e, Identifier ident) @safe { super(loc, EXP.dotIdentifier, e); @@ -3155,7 +3156,7 @@ extern (C++) final class DotTemplateExp : UnaExp extern (C++) final class DotVarExp : UnaExp { Declaration var; - bool hasOverloads; + alias hasOverloads = flag1; extern (D) this(Loc loc, Expression e, Declaration var, bool hasOverloads = true) @safe { @@ -3233,7 +3234,7 @@ extern (C++) final class DotTemplateInstanceExp : UnaExp extern (C++) final class DelegateExp : UnaExp { FuncDeclaration func; - bool hasOverloads; + alias hasOverloads = flag1; VarDeclaration vthis2; // container for multi-context 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 Expressions* arguments; // function arguments ArgumentLabels *names; // named argument labels FuncDeclaration f; // symbol to call - bool directcall; // true if a virtual call is devirtualized - bool inDebugStatement; /// true if this was in a debug statement - bool ignoreAttributes; /// don't enforce attributes (e.g. call @gc function in @nogc code) - bool isUfcsRewrite; /// the first argument was pushed in here by a UFCS rewrite VarDeclaration vthis2; // container for multi-context + /// true if a virtual call is devirtualized + bool directcall() { return flag1; } + void directcall(bool v) {flag1 = v; } + alias inDebugStatement = flag2; /// true if this was in a debug statement + alias ignoreAttributes = flag3; /// don't enforce attributes (e.g. call @gc function in @nogc code) + + /// the first argument was pushed in here by a UFCS rewrite + // we reuse the `ownedBy` bits of the bitfield + bool isUfcsRewrite() { return ownedByCtfe != OwnedBy.code; } + void isUfcsRewrite(bool v) { ownedByCtfe = v ? OwnedBy.ctfe : OwnedBy.code; } + /// Puts the `arguments` and `names` into an `ArgumentList` for easily passing them around. /// The fields are still separate for backwards compatibility @@ -3593,7 +3601,7 @@ extern (C++) final class NotExp : UnaExp */ extern (C++) final class DeleteExp : UnaExp { - bool isRAII; // true if called automatically as a result of scoped destruction + alias isRAII = flag1; // true if called automatically as a result of scoped destruction extern (D) this(Loc loc, Expression e, bool isRAII) @safe { @@ -3617,9 +3625,9 @@ extern (C++) final class DeleteExp : UnaExp extern (C++) final class CastExp : UnaExp { Type to; // type to cast to - ubyte mod = cast(ubyte)~0; // MODxxxxx - bool trusted; // assume cast is safe Expression lowering; + ubyte mod = cast(ubyte)~0; // MODxxxxx + alias trusted = flag1; // assume cast is safe extern (D) this(Loc loc, Expression e, Type t) @safe { @@ -3662,7 +3670,6 @@ extern (C++) final class VectorExp : UnaExp { TypeVector to; // the target vector type before semantic() uint dim = ~0; // number of elements in the vector - OwnedBy ownedByCtfe = OwnedBy.code; extern (D) this(Loc loc, Expression e, Type t) @trusted { @@ -3722,14 +3729,14 @@ extern (C++) final class SliceExp : UnaExp VarDeclaration lengthVar; - private extern(D) static struct BitFields - { - bool upperIsInBounds; // true if upr <= e1.length - bool lowerIsLessThanUpper; // true if lwr <= upr - bool arrayop; // an array operation, rather than a slice - } - import dmd.common.bitfields : generateBitFields; - mixin(generateBitFields!(BitFields, ubyte)); + // true if upr <= e1.length + bool upperIsInBounds() { return flag1; } + void upperIsInBounds(bool v) { flag1 = v; } + // true if lwr <= upr + bool lowerIsLessThanUpper() { return flag2; } + void lowerIsLessThanUpper(bool v) { flag2 = v; } + + alias arrayop = flag3; // an array operation, rather than a slice /************************************************************/ extern (D) this(Loc loc, Expression e1, IntervalExp ie) @safe @@ -3857,13 +3864,14 @@ extern (C++) final class CommaExp : BinExp { /// This is needed because AssignExp rewrites CommaExp, hence it needs /// to trigger the deprecation. - const bool isGenerated; + bool isGenerated() @safe { return flag1; } + void isGenerated(bool v) @safe { flag1 = v; } /// Temporary variable to enable / disable deprecation of comma expression /// depending on the context. /// Since most constructor calls are rewritting, the only place where /// false will be passed will be from the parser. - bool allowCommaExp; + alias allowCommaExp = flag2; /// The original expression before any rewriting occurs. /// This is used in error messages. @@ -3872,7 +3880,8 @@ extern (C++) final class CommaExp : BinExp extern (D) this(Loc loc, Expression e1, Expression e2, bool generated = true) @safe { super(loc, EXP.comma, e1, e2); - allowCommaExp = isGenerated = generated; + allowCommaExp = generated; + isGenerated = generated; } extern (D) this(Loc loc, Expression e1, Expression e2, Expression oe) @safe @@ -3996,8 +4005,12 @@ extern (C++) final class DelegateFuncptrExp : UnaExp extern (C++) final class IndexExp : BinExp { VarDeclaration lengthVar; - bool modifiable = false; // assume it is an rvalue - bool indexIsInBounds; // true if 0 <= e2 && e2 <= e1.length - 1 + // assume it is an rvalue + bool modifiable() { return flag1; } + void modifiable(bool v) { flag1 = v; } + // true if 0 <= e2 && e2 <= e1.length - 1 + bool indexIsInBounds() @safe { return flag2; } + void indexIsInBounds(bool v) @safe { flag2 = v; } extern (D) this(Loc loc, Expression e1, Expression e2) @safe { diff --git a/compiler/src/dmd/expression.h b/compiler/src/dmd/expression.h index 8fffbe484a9e..f69e265f6ad4 100644 --- a/compiler/src/dmd/expression.h +++ b/compiler/src/dmd/expression.h @@ -309,7 +309,6 @@ class DsymbolExp final : public Expression { public: Dsymbol *s; - d_bool hasOverloads; DsymbolExp *syntaxCopy() override; bool isLvalue() override; @@ -346,14 +345,10 @@ class NullExp final : public Expression class StringExp final : public Expression { public: - utf8_t postfix; // 'c', 'w', 'd' - OwnedBy ownedByCtfe; void *string; // char, wchar, dchar, or long data size_t len; // number of chars, wchars, or dchars unsigned char sz; // 1: char, 2: wchar, 4: dchar - d_bool committed; // if type is committed - d_bool hexString; // if string is parsed from a hex string literal - d_bool cMacro; // If the string is from a collected C macro + utf8_t postfix; // 'c', 'w', 'd' static StringExp *create(Loc loc, const char *s); static StringExp *create(Loc loc, const void *s, d_size_t len); @@ -371,9 +366,8 @@ class StringExp final : public Expression class InterpExp final : public Expression { public: - utf8_t postfix; // 'c', 'w', 'd' - OwnedBy ownedByCtfe; void* interpolatedSet; + utf8_t postfix; // 'c', 'w', 'd' void accept(Visitor* v) override { v->visit(this); } }; @@ -403,8 +397,6 @@ class TupleExp final : public Expression class ArrayLiteralExp final : public Expression { public: - OwnedBy ownedByCtfe; - d_bool onstack; Expression *basis; Expressions *elements; Expression *lowering; @@ -422,7 +414,6 @@ class ArrayLiteralExp final : public Expression class AssocArrayLiteralExp final : public Expression { public: - OwnedBy ownedByCtfe; Expressions *keys; Expressions *values; Expression* lowering; @@ -437,8 +428,6 @@ class AssocArrayLiteralExp final : public Expression class StructLiteralExp final : public Expression { public: - uint8_t bitFields; - // if this is true, use the StructDeclaration's init symbol bool useStaticInit() const; bool useStaticInit(bool v); @@ -525,8 +514,6 @@ class NewExp final : public Expression Expression *argprefix; // expression to be evaluated just before arguments[] CtorDeclaration *member; // constructor function - d_bool onstack; // allocate on stack - d_bool thrownew; // this NewExp is the expression of a ThrowStatement Expression *lowering; // lowered druntime hook: `_d_newclass` @@ -555,7 +542,6 @@ class SymbolExp : public Expression public: Declaration *var; Dsymbol *originalScope; - d_bool hasOverloads; void accept(Visitor *v) override { v->visit(this); } }; @@ -577,7 +563,6 @@ class SymOffExp final : public SymbolExp class VarExp final : public SymbolExp { public: - d_bool delegateWasExtracted; static VarExp *create(Loc loc, Declaration *var, bool hasOverloads = true); bool equals(const RootObject * const o) const override; bool isLvalue() override; @@ -737,9 +722,6 @@ class DotIdExp final : public UnaExp { public: Identifier *ident; - d_bool noderef; // true if the result of the expression will never be dereferenced - d_bool wantsym; // do not replace Symbol with its initializer during semantic() - d_bool arrow; // ImportC: if -> instead of . static DotIdExp *create(Loc loc, Expression *e, Identifier *ident); void accept(Visitor *v) override { v->visit(this); } @@ -758,7 +740,6 @@ class DotVarExp final : public UnaExp { public: Declaration *var; - d_bool hasOverloads; bool isLvalue() override; void accept(Visitor *v) override { v->visit(this); } @@ -778,7 +759,6 @@ class DelegateExp final : public UnaExp { public: FuncDeclaration *func; - d_bool hasOverloads; VarDeclaration *vthis2; // container for multi-context @@ -829,10 +809,6 @@ class CallExp final : public UnaExp Expressions *arguments; // function arguments ArgumentLabels* names; // function argument Labels (name + location of name) FuncDeclaration *f; // symbol to call - d_bool directcall; // true if a virtual call is devirtualized - d_bool inDebugStatement; // true if this was in a debug statement - d_bool ignoreAttributes; // don't enforce attributes (e.g. call @gc function in @nogc code) - d_bool isUfcsRewrite; // the first argument was pushed in here by a UFCS rewrite VarDeclaration *vthis2; // container for multi-context static CallExp *create(Loc loc, Expression *e, Expressions *exps); @@ -887,7 +863,6 @@ class NotExp final : public UnaExp class DeleteExp final : public UnaExp { public: - d_bool isRAII; void accept(Visitor *v) override { v->visit(this); } }; @@ -896,9 +871,8 @@ class CastExp final : public UnaExp public: // Possible to cast to one type while painting to another type Type *to; // type to cast to - unsigned char mod; // MODxxxxx - d_bool trusted; // assume cast is safe Expression* lowering; + unsigned char mod; // MODxxxxx CastExp *syntaxCopy() override; bool isLvalue() override; @@ -911,7 +885,6 @@ class VectorExp final : public UnaExp public: TypeVector *to; // the target vector type before semantic() unsigned dim; // number of elements in the vector - OwnedBy ownedByCtfe; static VectorExp *create(Loc loc, Expression *e, Type *t); VectorExp *syntaxCopy() override; @@ -938,8 +911,6 @@ class SliceExp final : public UnaExp bool lowerIsLessThanUpper(bool v); bool arrayop() const; // an array operation, rather than a slice bool arrayop(bool v); -private: - uint8_t bitFields; public: SliceExp *syntaxCopy() override; @@ -1006,8 +977,6 @@ class DotExp final : public BinExp class CommaExp final : public BinExp { public: - d_bool isGenerated; - d_bool allowCommaExp; Expression* originalExp; bool isLvalue() override; Optional toBool() override; @@ -1018,8 +987,6 @@ class IndexExp final : public BinExp { public: VarDeclaration *lengthVar; - d_bool modifiable; - d_bool indexIsInBounds; // true if 0 <= e2 && e2 <= e1.length - 1 IndexExp *syntaxCopy() override; bool isLvalue() override; diff --git a/compiler/src/dmd/expressionsem.d b/compiler/src/dmd/expressionsem.d index 042d6b6c0845..09ef49b661c1 100644 --- a/compiler/src/dmd/expressionsem.d +++ b/compiler/src/dmd/expressionsem.d @@ -10270,7 +10270,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor { auto bounds = IntRange(SignExtendedNumber(0), SignExtendedNumber(length - 1)); // OR it in, because it might already be set for C array indexing - exp.indexIsInBounds |= bounds.contains(getIntRange(exp.e2)); + exp.indexIsInBounds = exp.indexIsInBounds || bounds.contains(getIntRange(exp.e2)); } else if (sc.inCfile && t1b.ty == Tsarray) { diff --git a/compiler/src/dmd/frontend.h b/compiler/src/dmd/frontend.h index 46dfe43bf9c7..f1332d1ab503 100644 --- a/compiler/src/dmd/frontend.h +++ b/compiler/src/dmd/frontend.h @@ -2352,6 +2352,13 @@ enum class EXP : uint8_t rvalue = 128u, }; +enum class OwnedBy : uint8_t +{ + code = 0u, + ctfe = 1u, + cache = 2u, +}; + typedef uint64_t dinteger_t; typedef uint64_t uinteger_t; @@ -2390,28 +2397,48 @@ class Expression : public ASTNode const EXP op; struct BitFields final { + OwnedBy ownedByCtfe; bool parens; bool rvalue; bool gcPassDone; + bool flag1; + bool flag2; + bool flag3; BitFields() : + ownedByCtfe((OwnedBy)0u), parens(), rvalue(), - gcPassDone() + gcPassDone(), + flag1(), + flag2(), + flag3() { } - BitFields(bool parens, bool rvalue = false, bool gcPassDone = false) : + BitFields(OwnedBy ownedByCtfe, bool parens = false, bool rvalue = false, bool gcPassDone = false, bool flag1 = false, bool flag2 = false, bool flag3 = false) : + ownedByCtfe(ownedByCtfe), parens(parens), rvalue(rvalue), - gcPassDone(gcPassDone) + gcPassDone(gcPassDone), + flag1(flag1), + flag2(flag2), + flag3(flag3) {} }; + OwnedBy ownedByCtfe() const; + OwnedBy ownedByCtfe(OwnedBy v); bool parens() const; bool parens(bool v); bool rvalue() const; bool rvalue(bool v); bool gcPassDone() const; bool gcPassDone(bool v); + bool flag1() const; + bool flag1(bool v); + bool flag2() const; + bool flag2(bool v); + bool flag3() const; + bool flag3(bool v); private: uint8_t bitFields; public: @@ -2641,18 +2668,11 @@ class ArrayLengthExp final : public UnaExp void accept(Visitor* v) override; }; -enum class OwnedBy : uint8_t -{ - code = 0u, - ctfe = 1u, - cache = 2u, -}; - class ArrayLiteralExp final : public Expression { public: - OwnedBy ownedByCtfe; - bool onstack; + bool onstack(); + void onstack(bool v); Expression* basis; Array* elements; Expression* lowering; @@ -2692,7 +2712,6 @@ class AssignExp : public BinExp class AssocArrayLiteralExp final : public Expression { public: - OwnedBy ownedByCtfe; Array* keys; Array* values; Expression* lowering; @@ -2718,11 +2737,11 @@ class CallExp final : public UnaExp Array* arguments; Array* names; FuncDeclaration* f; - bool directcall; - bool inDebugStatement; - bool ignoreAttributes; - bool isUfcsRewrite; VarDeclaration* vthis2; + bool directcall(); + void directcall(bool v); + bool isUfcsRewrite(); + void isUfcsRewrite(bool v); static CallExp* create(Loc loc, Expression* e, Array* exps); static CallExp* create(Loc loc, Expression* e); static CallExp* create(Loc loc, Expression* e, Expression* earg1); @@ -2736,9 +2755,8 @@ class CastExp final : public UnaExp { public: Type* to; - uint8_t mod; - bool trusted; Expression* lowering; + uint8_t mod; CastExp* syntaxCopy() override; bool isLvalue() override; void accept(Visitor* v) override; @@ -2795,8 +2813,6 @@ class ComExp final : public UnaExp class CommaExp final : public BinExp { public: - const bool isGenerated; - bool allowCommaExp; Expression* originalExp; bool isLvalue() override; Optional toBool() override; @@ -2861,7 +2877,6 @@ class DelegateExp final : public UnaExp { public: FuncDeclaration* func; - bool hasOverloads; VarDeclaration* vthis2; void accept(Visitor* v) override; }; @@ -2883,7 +2898,6 @@ class DelegatePtrExp final : public UnaExp class DeleteExp final : public UnaExp { public: - bool isRAII; void accept(Visitor* v) override; }; @@ -2924,9 +2938,6 @@ class DotIdExp final : public UnaExp { public: Identifier* ident; - bool noderef; - bool wantsym; - bool arrow; static DotIdExp* create(Loc loc, Expression* e, Identifier* ident); void accept(Visitor* v) override; }; @@ -2959,7 +2970,6 @@ class DotVarExp final : public UnaExp { public: Declaration* var; - bool hasOverloads; bool isLvalue() override; void accept(Visitor* v) override; }; @@ -2968,7 +2978,6 @@ class DsymbolExp final : public Expression { public: Dsymbol* s; - bool hasOverloads; bool isLvalue() override; void accept(Visitor* v) override; }; @@ -3280,8 +3289,10 @@ class IndexExp final : public BinExp { public: VarDeclaration* lengthVar; - bool modifiable; - bool indexIsInBounds; + bool modifiable(); + void modifiable(bool v); + bool indexIsInBounds(); + void indexIsInBounds(bool v); IndexExp* syntaxCopy() override; bool isLvalue() override; void accept(Visitor* v) override; @@ -3307,9 +3318,8 @@ class IntegerExp final : public Expression class InterpExp final : public Expression { public: - char postfix; - OwnedBy ownedByCtfe; InterpolatedSet* interpolatedSet; + char postfix; enum : char { NoPostfix = 0u }; void accept(Visitor* v) override; @@ -3436,8 +3446,10 @@ class NewExp final : public Expression Expression* placement; Expression* argprefix; CtorDeclaration* member; - bool onstack; - bool thrownew; + bool onstack(); + void onstack(bool v); + bool thrownew(); + void thrownew(bool v); Expression* lowering; static NewExp* create(Loc loc, Expression* placement, Expression* thisexp, Type* newtype, Array* arguments); NewExp* syntaxCopy() override; @@ -3584,35 +3596,6 @@ class SliceExp final : public UnaExp Expression* upr; Expression* lwr; VarDeclaration* lengthVar; -private: - struct BitFields final - { - bool upperIsInBounds; - bool lowerIsLessThanUpper; - bool arrayop; - BitFields() : - upperIsInBounds(), - lowerIsLessThanUpper(), - arrayop() - { - } - BitFields(bool upperIsInBounds, bool lowerIsLessThanUpper = false, bool arrayop = false) : - upperIsInBounds(upperIsInBounds), - lowerIsLessThanUpper(lowerIsLessThanUpper), - arrayop(arrayop) - {} - }; - -public: - bool upperIsInBounds() const; - bool upperIsInBounds(bool v); - bool lowerIsLessThanUpper() const; - bool lowerIsLessThanUpper(bool v); - bool arrayop() const; - bool arrayop(bool v); -private: - uint8_t bitFields; -public: SliceExp* syntaxCopy() override; bool isLvalue() override; Optional toBool() override; @@ -3621,9 +3604,6 @@ class SliceExp final : public UnaExp class StringExp final : public Expression { -public: - char postfix; - OwnedBy ownedByCtfe; union { char* string; @@ -3631,11 +3611,10 @@ class StringExp final : public Expression char32_t* dstring; uint64_t* lstring; }; +public: size_t len; uint8_t sz; - bool committed; - bool hexString; - bool cMacro; + char postfix; enum : char { NoPostfix = 0u }; static StringExp* create(Loc loc, const char* s); @@ -3655,33 +3634,8 @@ class StringExp final : public Expression class StructLiteralExp final : public Expression { public: - struct BitFields final - { - bool useStaticInit; - bool isOriginal; - OwnedBy ownedByCtfe; - BitFields() : - useStaticInit(), - isOriginal(false), - ownedByCtfe((OwnedBy)0u) - { - } - BitFields(bool useStaticInit, bool isOriginal = false, OwnedBy ownedByCtfe = (OwnedBy)0u) : - useStaticInit(useStaticInit), - isOriginal(isOriginal), - ownedByCtfe(ownedByCtfe) - {} - }; - - bool useStaticInit() const; - bool useStaticInit(bool v); - bool isOriginal() const; - bool isOriginal(bool v); - OwnedBy ownedByCtfe() const; - OwnedBy ownedByCtfe(OwnedBy v); -private: - uint8_t bitFields; -public: + bool useStaticInit(); + void useStaticInit(bool v); StageFlags stageflags; StructDeclaration* sd; Array* elements; @@ -3731,7 +3685,6 @@ class SymbolExp : public Expression public: Declaration* var; Dsymbol* originalScope; - bool hasOverloads; void accept(Visitor* v) override; }; @@ -3824,7 +3777,6 @@ class UshrExp final : public BinExp class VarExp final : public SymbolExp { public: - bool delegateWasExtracted; static VarExp* create(Loc loc, Declaration* var, bool hasOverloads = true); bool equals(const RootObject* const o) const override; bool isLvalue() override; @@ -3843,7 +3795,6 @@ class VectorExp final : public UnaExp public: TypeVector* to; uint32_t dim; - OwnedBy ownedByCtfe; static VectorExp* create(Loc loc, Expression* e, Type* t); VectorExp* syntaxCopy() override; void accept(Visitor* v) override; @@ -5576,18 +5527,18 @@ struct UnionExp final char errorexp[22LLU]; char realexp[48LLU]; char complexexp[64LLU]; - char symoffexp[56LLU]; - char stringexp[44LLU]; + char symoffexp[48LLU]; + char stringexp[42LLU]; char arrayliteralexp[48LLU]; char assocarrayliteralexp[48LLU]; char structliteralexp[64LLU]; char compoundliteralexp[32LLU]; char nullexp[22LLU]; - char dotvarexp[41LLU]; + char dotvarexp[40LLU]; char addrexp[32LLU]; - char indexexp[50LLU]; - char sliceexp[57LLU]; - char vectorexp[45LLU]; + char indexexp[48LLU]; + char sliceexp[56LLU]; + char vectorexp[44LLU]; }; #pragma pack(pop)