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:
License:
Source initsem.d
Documentation https://dlang.org/phobos/dmd_initsem.html
- Expression
toAssocArrayLiteral(ArrayInitializerai); - If possible, convert array initializer to associative array initializer.Parameters:
ArrayInitializer aiarray initializer to be converted Returns:The converted associative array initializer or ErrorExp ifaiis not an associative array initializer. - Initializer
initializerSemantic(Initializerinit, Scope*sc, ref Typetx, NeedInterpretneedInterpret); - Perform semantic analysis on init.Parameters:
Initializer initInitializer AST node Scope* sccontext Type txtype 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 needInterpretif 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(Initializerinit, Scope*sc); - Translate init to an Expression in order to infer the type.Parameters:
Initializer initInitializer AST node Scope* sccontext Returns:an equivalent ExpInitializer if successful, or ErrorInitializer if it cannot be translated - Expression
initializerToExpression(Initializerinit, Typeitype= null, const boolisCfile= false); - Translate init to an Expression.Parameters:
Initializer initInitializer AST node Type itypeif not null, type to coerce expression to bool isCfiledefault initializers are different with C Returns:Expression created, null if cannot, ErrorExp for other errors - Expressions*
resolveStructLiteralNamedArgs(StructDeclarationsd, Typet, Scope*sc, Lociloc, Identifier[]names, scope Expression delegate(size_t i, Type fieldType)getExp, scope Loc delegate(size_t i)getLoc); - Given the names and values of a StructInitializer or CallExp, resolve it to a list of expressions to construct a StructLiteralExp.Parameters:
StructDeclaration sdstruct Type ttype of struct (potentially including qualifiers such as const or immutable) Scope* scscope of the expression initializing the struct Loc iloclocation of expression initializing the struct Identifier[] namesidentifiers passed in argument list, null entries for positional arguments Expression delegate(size_t i, Type fieldType) getExpfunction that, given an index into namesand destination type, returns the initializing expressionLoc delegate(size_t i) getLocfunction that, given an index into names, returns a location for error messagesReturns:list of expressions ordered to the struct's fields, or null on error
Copyright © 1999-2025 by the D Language Foundation | Page generated by
Ddoc on Mon Mar 31 10:27:57 2025