dmd.clone

Builds struct member functions if needed and not defined by the user. Includes opEquals, opAssign, post blit, copy constructor and destructor.

Members

Functions

buildCopyCtor
bool buildCopyCtor(StructDeclaration sd, Scope* sc)

Generates a copy constructor if needCopyCtor() returns true. The generated copy constructor will be of the form: this(ref return scope inout(S) rhs) inout { this.field1 = rhs.field1; this.field2 = rhs.field2; ... }

buildDtors
void buildDtors(AggregateDeclaration ad, Scope* sc)

Create aggregate destructor for struct/class by aggregating all the destructors in userDtors[] with the destructors for all the members. Sets ad's fieldDtor, aggrDtor, dtor and tidtor fields.

buildInv
FuncDeclaration buildInv(AggregateDeclaration ad, Scope* sc)

Create inclusive invariant for struct/class by aggregating all the invariants in invs[].

buildOpAssign
FuncDeclaration buildOpAssign(StructDeclaration sd, Scope* sc)

Build opAssign for a struct.

buildOpEquals
FuncDeclaration buildOpEquals(StructDeclaration sd, Scope* sc)

Build opEquals for struct. const bool opEquals(const S s) { ... }

buildPostBlit
FuncDeclaration buildPostBlit(StructDeclaration sd, Scope* sc)

Create inclusive postblit for struct by aggregating all the postblits in postblits[] with the postblits for all the members. Note the close similarity with AggregateDeclaration::buildDtor(), and the ordering changes (runs forward instead of backwards).

buildXopCmp
FuncDeclaration buildXopCmp(StructDeclaration sd, Scope* sc)

Build _xopCmp for TypeInfo_Struct int _xopCmp(ref const S p) const { return this.opCmp(p); }

buildXopEquals
FuncDeclaration buildXopEquals(StructDeclaration sd, Scope* sc)

Build _xopEquals for TypeInfo_Struct bool _xopEquals(ref const S p) const { return this == p; }

buildXtoHash
FuncDeclaration buildXtoHash(StructDeclaration sd, Scope* sc)

Build __xtoHash for non-bitwise hashing static hash_t xtoHash(ref const S p) nothrow @trusted;

hasIdentityOpAssign
FuncDeclaration hasIdentityOpAssign(AggregateDeclaration ad, Scope* sc)

Check given aggregate actually has an identity opAssign or not.

mergeFuncAttrs
StorageClass mergeFuncAttrs(StorageClass s1, FuncDeclaration f)

Merge function attributes pure, nothrow, @safe, @nogc, and @disable from f into s1.

needOpEquals
bool needOpEquals(StructDeclaration sd)

We need an opEquals for the struct if any fields has an opEquals. Generate one if a user-specified one does not exist.

Meta