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.initsem

Semantic analysis of initializers.
Authors:

Source initsem.d

Expression toAssocArrayLiteral(ArrayInitializer ai);
If possible, convert array initializer to associative array initializer.
Parameters:
ArrayInitializer ai array initializer to be converted
Returns:
The converted associative array initializer or ErrorExp if ai is not an associative array initializer.
Initializer initializerSemantic(Initializer init, Scope* sc, ref Type tx, NeedInterpret needInterpret);
Perform semantic analysis on init.
Parameters:
Initializer init Initializer AST node
Scope* sc context
Type tx type that the initializer needs to become. If tx is an incomplete type and the initializer completes it, it is updated to be the complete type. ImportC has incomplete types
NeedInterpret needInterpret if CTFE needs to be run on this, such as if it is the initializer for a const declaration
Returns:
Initializer with completed semantic analysis, ErrorInitializer if errors were encountered
Initializer inferType(Initializer init, Scope* sc);
Translate init to an Expression in order to infer the type.
Parameters:
Initializer init Initializer AST node
Scope* sc context
Returns:
an equivalent ExpInitializer if successful, or ErrorInitializer if it cannot be translated
Expression initializerToExpression(Initializer init, Type itype = null, const bool isCfile = false);
Translate init to an Expression.
Parameters:
Initializer init Initializer AST node
Type itype if not null, type to coerce expression to
bool isCfile default initializers are different with C
Returns:
Expression created, null if cannot, ErrorExp for other errors
Expressions* resolveStructLiteralNamedArgs(StructDeclaration sd, Type t, Scope* sc, Loc iloc, size_t argCount, scope Identifier delegate(size_t i) getArgName, scope Expression delegate(size_t i, Type fieldType) getExp, scope Loc delegate(size_t i) getArgLoc, scope Loc delegate(size_t i) getNameLoc);
Given the names and values of a StructInitializer or CallExp, resolve it to a list of expressions to construct a StructLiteralExp.
Parameters:
StructDeclaration sd struct
Type t type of struct (potentially including qualifiers such as const or immutable)
Scope* sc scope of the expression initializing the struct
Loc iloc location of expression initializing the struct
size_t argCount count of argumnet present
Expression delegate(size_t i, Type fieldType) getExp function that, given an index into argNames and destination type, returns the initializing expression
Identifier delegate(size_t i) getArgName function that, given an index into argNames, returns the name of argument for error messages
Loc delegate(size_t i) getArgLoc function that, given an index into argNames, returns a location of argument for error messages
Loc delegate(size_t i) getNameLoc function that, given an index into argNames, returns a location of that name for error messages
Returns:
list of expressions ordered to the struct's fields, or null on error