Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
a local clone.
dmd.aggregate
Defines a Dsymbol representing an aggregate, which is a struct, union or class.
Specification Structs, Unions, Class.
Authors:
License:
Source aggregate.d
Documentation https://dlang.org/phobos/dmd_aggregate.html
- enum
ClassKind
: ubyte; - The ClassKind enum is used in AggregateDeclaration AST nodes to specify the linkage type of the struct/class/interface or if it is an anonymous class. If the class is anonymous it is also considered to be a D class.
d
- the aggregate is a d(efault) class
cpp
- the aggregate is a C++ struct/class/interface
objc
- the aggregate is an Objective-C class/interface
c
- the aggregate is a C struct
- @safe const(char)*
ClassKindToChars
(ClassKindc
); - Give a nice string for a class kind for error messagesParameters:
ClassKind c
class kind Returns:0-terminated string forc
- struct
MangleOverride
; - If an aggregate has a pargma(mangle, ...) this holds the information to mangle.
- abstract class
AggregateDeclaration
: dmd.dsymbol.ScopeDsymbol; - Abstract aggregate as a common ancestor for Class- and StructDeclaration.
- Type
type
; - StorageClass
storage_class
; - uint
structsize
; - size of struct
- uint
alignsize
; - size of struct for alignment purposes
- VarDeclarations
fields
; - VarDeclaration fields
- Dsymbol
deferred
; - any deferred semantic2() or semantic3() symbol
- ClassKind
classKind
; - specifies whether this is a D, C++, Objective-C or anonymous struct/class/interface
- CPPMANGLE
cppmangle
; - Specify whether to mangle the aggregate as a class or a struct This information is used by the MSVC mangler Only valid for class and struct. TODO: Merge with ClassKind ?
- MangleOverride*
pMangleOverride
; - overridden symbol with pragma(mangle, "...") if not null
- Dsymbol
enclosing
; - !=null if is nested pointing to the dsymbol that directly enclosing it.
- The function that enclosing it (nested struct and class)
- The class that enclosing it (nested class only)
- If enclosing aggregate is template, its enclosing dsymbol.
See AggregateDeclaraton::makeNested for the details. - VarDeclaration
vthis
; - 'this' parameter if this aggregate is nested
- VarDeclaration
vthis2
; - 'this' parameter if this aggregate is a template and is nested
- FuncDeclarations
invs
; - Array of invariants
- FuncDeclaration
inv
; - Merged invariant calling all members of invs
- Dsymbol
ctor
; - CtorDeclaration or TemplateDeclaration
- CtorDeclaration
defaultCtor
; - default constructor - should have no arguments, because it would be stored in TypeInfo_Class.defaultConstructor
- AliasThis
aliasthis
; - forward unresolved lookups to aliasthis
- DtorDeclarations
userDtors
; - user-defined destructors (~this()) - mixins can yield multiple ones
- DtorDeclaration
aggrDtor
; - aggregate destructor calling userDtors and fieldDtor (and base class aggregate dtor for C++ classes)
- DtorDeclaration
dtor
; - the aggregate destructor exposed as __xdtor alias
- DtorDeclaration
tidtor
; - (same as aggrDtor, except for C++ classes with virtual dtor on Windows)aggregate destructor used in TypeInfo (must have extern(D) ABI)
- DtorDeclaration
fieldDtor
; - function destructing (non-inherited) fields
- Expression
getRTInfo
; - pointer to GC info generated by object.RTInfo(this)
- Visibility
visibility
; - bool
noDefaultCtor
; - no default construction
- bool
disableNew
; - disallow allocations using new
- Sizeok
sizeok
; - set when structsize contains valid data
- Scope*
newScope
(Scope*sc
); - Create a new scope from sc. semantic, semantic2 and semantic3 will use this for aggregate members.
- final size_t
nonHiddenFields
(); - Returns:The total number of fields minus the number of hidden fields.
- final bool
determineSize
(const ref Locloc
); - Collect all instance fields, then determine instance size.Returns:false if failed to determine the size.
- final bool
checkOverlappedFields
(); - Calculate field[i].overlapped and overlapUnsafe, and check that all of explicit field initializers have unique memory space on instance.Returns:true if any errors happen.
- final bool
fill
(const ref Locloc
, ref Expressionselements
, boolctorinit
); - Fill out remainder of elements[] with default initializers for fields[].Parameters:
Loc loc
location Expressions elements
explicit arguments which given to construct object. bool ctorinit
true if the elements will be used for default initialization. Returns:false if any errors occur. Otherwise, returns true and the missing arguments will be pushed in elements[]. - final void
setDeprecated
(); - Flag this aggregate as deprecated
- final const bool
isNested
(); - Returns true if there's an extra member which is the 'this' pointer to the enclosing context (enclosing aggregate or function)
- final Dsymbol
searchCtor
(); - Look for constructor declaration.
- void*
sinit
; - initializer symbol
- int
apply
(Dsymbolsymbol
, int function(Dsymbol, void*)fp
, void*ctx
); - Iterate this dsymbol or members of this scoped dsymbol, then call
fp
with the found symbol and params.Parameters:Dsymbol symbol
the dsymbol or parent of members to call fp on int function(Dsymbol, void*) fp
function pointer to process the iterated symbol. If it returns nonzero, the iteration will be aborted. void* ctx
context parameter passed to fp. Returns:nonzero if the iteration is aborted by the return value of fp, or 0 if it's completed. - pure nothrow @safe uint
alignmember
(structalign_talignment
, uintmemalignsize
, uintoffset
); - Do byte or word alignment as necessary. Align sizes of 0, as we may not know array sizes yet.Parameters:
structalign_t alignment
struct alignment that is in effect uint memalignsize
natural alignment of field uint offset
offset to be aligned Returns:aligned offset - pure nothrow @safe uint
placeField
(ref uintnextoffset
, uintmemsize
, uintmemalignsize
, structalign_talignment
, ref uintaggsize
, ref uintaggalignsize
, boolisunion
); - Place a field (mem) into an aggregate (agg), which can be a struct, union or classParameters:
uint nextoffset
location just past the end of the previous field in the aggregate. Updated to be just past the end of this field to be placed, i.e. the future nextoffset uint memsize
size of field uint memalignsize
natural alignment of field structalign_t alignment
alignment in effect for this field uint aggsize
size of aggregate (updated) uint aggalignsize
alignment of aggregate (updated) bool isunion
the aggregate is a union Returns:aligned offset to place field at
Copyright © 1999-2024 by the D Language Foundation | Page generated by
Ddoc on (no date time)