mirror of
https://github.com/dlang/dmd.git
synced 2025-05-06 19:16:03 +03:00
Reduce size of StructLiteralExp (#20779)
This commit is contained in:
parent
63630b4287
commit
0ce59518ed
3 changed files with 98 additions and 32 deletions
|
@ -301,8 +301,14 @@ extern (C++) abstract class Expression : ASTNode
|
||||||
|
|
||||||
Loc loc; // file location
|
Loc loc; // file location
|
||||||
const EXP op; // to minimize use of dynamic_cast
|
const EXP op; // to minimize use of dynamic_cast
|
||||||
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
|
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
|
||||||
|
}
|
||||||
|
import dmd.common.bitfields;
|
||||||
|
mixin(generateBitFields!(BitFields, ubyte));
|
||||||
|
|
||||||
extern (D) this(const ref Loc loc, EXP op) scope @safe
|
extern (D) this(const ref Loc loc, EXP op) scope @safe
|
||||||
{
|
{
|
||||||
|
@ -2126,6 +2132,16 @@ extern (C++) final class AssocArrayLiteralExp : Expression
|
||||||
*/
|
*/
|
||||||
extern (C++) final class StructLiteralExp : 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));
|
||||||
|
StageFlags stageflags;
|
||||||
|
|
||||||
StructDeclaration sd; /// which aggregate this is for
|
StructDeclaration sd; /// which aggregate this is for
|
||||||
Expressions* elements; /// parallels sd.fields[] with null entries for fields to skip
|
Expressions* elements; /// parallels sd.fields[] with null entries for fields to skip
|
||||||
Type stype; /// final type of result (can be different from sd's type)
|
Type stype; /// final type of result (can be different from sd's type)
|
||||||
|
@ -2163,11 +2179,6 @@ extern (C++) final class StructLiteralExp : Expression
|
||||||
inlineScan = 0x10, /// inlineScan is running
|
inlineScan = 0x10, /// inlineScan is running
|
||||||
toCBuffer = 0x20 /// toCBuffer is running
|
toCBuffer = 0x20 /// toCBuffer is running
|
||||||
}
|
}
|
||||||
StageFlags stageflags;
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
extern (D) this(const ref Loc loc, StructDeclaration sd, Expressions* elements, Type stype = null) @safe
|
extern (D) this(const ref Loc loc, StructDeclaration sd, Expressions* elements, Type stype = null) @safe
|
||||||
{
|
{
|
||||||
|
|
|
@ -77,8 +77,12 @@ public:
|
||||||
Type *type; // !=NULL means that semantic() has been run
|
Type *type; // !=NULL means that semantic() has been run
|
||||||
Loc loc; // file location
|
Loc loc; // file location
|
||||||
EXP op; // to minimize use of dynamic_cast
|
EXP op; // to minimize use of dynamic_cast
|
||||||
d_bool parens; // if this is a parenthesized expression
|
uint8_t bitFields;
|
||||||
d_bool rvalue; // consider this an rvalue, even if it is an lvalue
|
|
||||||
|
bool parens() const;
|
||||||
|
bool parens(bool v);
|
||||||
|
bool rvalue() const;
|
||||||
|
bool rvalue(bool v);
|
||||||
|
|
||||||
size_t size() const;
|
size_t size() const;
|
||||||
static void _init();
|
static void _init();
|
||||||
|
@ -431,6 +435,24 @@ public:
|
||||||
class StructLiteralExp final : public Expression
|
class StructLiteralExp final : public Expression
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
uint8_t bitFields;
|
||||||
|
|
||||||
|
// if this is true, use the StructDeclaration's init symbol
|
||||||
|
bool useStaticInit() const;
|
||||||
|
bool useStaticInit(bool v);
|
||||||
|
// used when moving instances to indicate `this is this.origin`
|
||||||
|
bool isOriginal() const;
|
||||||
|
bool isOriginal(bool v);
|
||||||
|
OwnedBy ownedByCtfe() const;
|
||||||
|
OwnedBy ownedByCtfe(OwnedBy v);
|
||||||
|
|
||||||
|
/** anytime when recursive function is calling, 'stageflags' marks with bit flag of
|
||||||
|
* current stage and unmarks before return from this function.
|
||||||
|
* 'inlinecopy' uses similar 'stageflags' and from multiple evaluation 'doInline'
|
||||||
|
* (with infinite recursion) of this expression.
|
||||||
|
*/
|
||||||
|
uint8_t stageflags;
|
||||||
|
|
||||||
StructDeclaration *sd; // which aggregate this is for
|
StructDeclaration *sd; // which aggregate this is for
|
||||||
Expressions *elements; // parallels sd->fields[] with NULL entries for fields to skip
|
Expressions *elements; // parallels sd->fields[] with NULL entries for fields to skip
|
||||||
Type *stype; // final type of result (can be different from sd's type)
|
Type *stype; // final type of result (can be different from sd's type)
|
||||||
|
@ -451,17 +473,6 @@ public:
|
||||||
StructLiteralExp *origin;
|
StructLiteralExp *origin;
|
||||||
|
|
||||||
|
|
||||||
/** anytime when recursive function is calling, 'stageflags' marks with bit flag of
|
|
||||||
* current stage and unmarks before return from this function.
|
|
||||||
* 'inlinecopy' uses similar 'stageflags' and from multiple evaluation 'doInline'
|
|
||||||
* (with infinite recursion) of this expression.
|
|
||||||
*/
|
|
||||||
uint8_t stageflags;
|
|
||||||
|
|
||||||
d_bool useStaticInit; // if this is true, use the StructDeclaration's init symbol
|
|
||||||
d_bool isOriginal; // used when moving instances to indicate `this is this.origin`
|
|
||||||
OwnedBy ownedByCtfe;
|
|
||||||
|
|
||||||
static StructLiteralExp *create(const Loc &loc, StructDeclaration *sd, void *elements, Type *stype = nullptr);
|
static StructLiteralExp *create(const Loc &loc, StructDeclaration *sd, void *elements, Type *stype = nullptr);
|
||||||
bool equals(const RootObject * const o) const override;
|
bool equals(const RootObject * const o) const override;
|
||||||
StructLiteralExp *syntaxCopy() override;
|
StructLiteralExp *syntaxCopy() override;
|
||||||
|
|
|
@ -2206,8 +2206,28 @@ public:
|
||||||
Type* type;
|
Type* type;
|
||||||
Loc loc;
|
Loc loc;
|
||||||
const EXP op;
|
const EXP op;
|
||||||
bool parens;
|
struct BitFields final
|
||||||
bool rvalue;
|
{
|
||||||
|
bool parens;
|
||||||
|
bool rvalue;
|
||||||
|
BitFields() :
|
||||||
|
parens(),
|
||||||
|
rvalue()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
BitFields(bool parens, bool rvalue = false) :
|
||||||
|
parens(parens),
|
||||||
|
rvalue(rvalue)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
bool parens() const;
|
||||||
|
bool parens(bool v);
|
||||||
|
bool rvalue() const;
|
||||||
|
bool rvalue(bool v);
|
||||||
|
private:
|
||||||
|
uint8_t bitFields;
|
||||||
|
public:
|
||||||
size_t size() const;
|
size_t size() const;
|
||||||
static void _init();
|
static void _init();
|
||||||
static void deinitialize();
|
static void deinitialize();
|
||||||
|
@ -3450,6 +3470,34 @@ public:
|
||||||
class StructLiteralExp final : public Expression
|
class StructLiteralExp final : public Expression
|
||||||
{
|
{
|
||||||
public:
|
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:
|
||||||
|
StageFlags stageflags;
|
||||||
StructDeclaration* sd;
|
StructDeclaration* sd;
|
||||||
Array<Expression* >* elements;
|
Array<Expression* >* elements;
|
||||||
Type* stype;
|
Type* stype;
|
||||||
|
@ -3470,10 +3518,6 @@ public:
|
||||||
toCBuffer = 32u,
|
toCBuffer = 32u,
|
||||||
};
|
};
|
||||||
|
|
||||||
StageFlags stageflags;
|
|
||||||
bool useStaticInit;
|
|
||||||
bool isOriginal;
|
|
||||||
OwnedBy ownedByCtfe;
|
|
||||||
static StructLiteralExp* create(const Loc& loc, StructDeclaration* sd, void* elements, Type* stype = nullptr);
|
static StructLiteralExp* create(const Loc& loc, StructDeclaration* sd, void* elements, Type* stype = nullptr);
|
||||||
bool equals(const RootObject* const o) const override;
|
bool equals(const RootObject* const o) const override;
|
||||||
StructLiteralExp* syntaxCopy() override;
|
StructLiteralExp* syntaxCopy() override;
|
||||||
|
@ -5358,18 +5402,18 @@ struct UnionExp final
|
||||||
private:
|
private:
|
||||||
union _AnonStruct_u
|
union _AnonStruct_u
|
||||||
{
|
{
|
||||||
char exp[31LLU];
|
char exp[30LLU];
|
||||||
char integerexp[40LLU];
|
char integerexp[40LLU];
|
||||||
char errorexp[31LLU];
|
char errorexp[30LLU];
|
||||||
char realexp[48LLU];
|
char realexp[48LLU];
|
||||||
char complexexp[64LLU];
|
char complexexp[64LLU];
|
||||||
char symoffexp[64LLU];
|
char symoffexp[64LLU];
|
||||||
char stringexp[59LLU];
|
char stringexp[51LLU];
|
||||||
char arrayliteralexp[56LLU];
|
char arrayliteralexp[48LLU];
|
||||||
char assocarrayliteralexp[56LLU];
|
char assocarrayliteralexp[56LLU];
|
||||||
char structliteralexp[76LLU];
|
char structliteralexp[72LLU];
|
||||||
char compoundliteralexp[40LLU];
|
char compoundliteralexp[40LLU];
|
||||||
char nullexp[31LLU];
|
char nullexp[30LLU];
|
||||||
char dotvarexp[49LLU];
|
char dotvarexp[49LLU];
|
||||||
char addrexp[40LLU];
|
char addrexp[40LLU];
|
||||||
char indexexp[58LLU];
|
char indexexp[58LLU];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue