dmd.initsem
Semantic analysis of initializers.
License
Source: initsem.d
Documentation: https://dlang.org/phobos/dmd_initsem.html
-
Declaration
ExpressiontoAssocArrayLiteral(ArrayInitializerai);If possible, convert array initializer to associative array initializer.
Parameters
ArrayInitializeraiarray initializer to be converted
Return Value
The converted associative array initializer or ErrorExp if
is not an associative array initializer.ai -
Declaration
InitializerinitializerSemantic(Initializerinit, Scope*sc, ref Typetx, NeedInterpretneedInterpret);Perform semantic analysis on
init.Parameters
InitializerinitInitializer AST node
Scope*sccontext
Typetxtype that the initializer needs to become. If
txis an incomplete type and the initializer completes it, it is updated to be the complete type. ImportC has incomplete typesNeedInterpretneedInterpretif CTFE needs to be run on this, such as if it is the initializer for a const declaration
Return Value
Initializerwith completed semantic analysis,ErrorInitializerif errors were encountered -
Declaration
InitializerinferType(Initializerinit, Scope*sc);Translate
initto anExpressionin order to infer the type.Parameters
InitializerinitInitializerAST nodeScope*sccontext
Return Value
an equivalent
ExpInitializerif successful, orErrorInitializerif it cannot be translated -
Declaration
ExpressioninitializerToExpression(Initializerinit, Typeitype= null, const boolisCfile= false);Translate
initto anExpression.Parameters
InitializerinitInitializerAST nodeTypeitypeif not
null, type to coerce expression toboolisCfiledefault initializers are different with C
Return Value
Expressioncreated,nullif cannot,ErrorExpfor other errors -
Declaration
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
namesand values of aStructInitializerorCallExp, resolve it to a list of expressions to construct aStructLiteralExp.Parameters
StructDeclarationsdstruct
Typettype of struct (potentially including qualifiers such as
constorimmutable)Scope*scscope of the expression initializing the struct
Lociloclocation of expression initializing the struct
Identifier[]namesidentifiers passed in argument list,
nullentries for positional argumentsExpression delegate(size_t i, Type fieldType)getExpfunction that, given an index into
and destination type, returns the initializing expressionnamesLoc delegate(size_t i)getLocfunction that, given an index into
, returns a location for error messagesnamesReturn Value
list of expressions ordered to the struct's fields, or
nullon error