dmd.expressionsem
Semantic analysis of expressions.
Specification: ($LINK2 https://dlang.org/spec/expression.html, Expressions)
License
Source: expressionsem.d
Documentation: https://dlang.org/phobos/dmd_expressionsem.html
-
Declaration
bool
expressionsToString
(ref OutBufferbuf
, Scope*sc
, Expressions*exps
);Perform semantic analysis and CTFE on expressions to produce a string.
Parameters
OutBuffer
buf
append generated string to buffer
Scope*
sc
context
Expressions*
exps
array of Expressions
Return Value
true
on error -
Declaration
StringExp
semanticString
(Scope*sc
, Expressionexp
, const char*s
);Resolve
as a compile-time known string.exp
Parameters
Scope*
sc
scope
Expression
exp
Expression which expected as a string
char*
s
What the string is expected for, will be used in error diagnostic.
Return Value
String literal, or
null
if error happens. -
Declaration
Expression
resolveOpDollar
(Scope*sc
, ArrayExpae
, Expression*pe0
);Runs semantic on
ae
.arguments. Declares temporary variables if '$' was used. -
Declaration
Expression
resolveOpDollar
(Scope*sc
, ArrayExpae
, IntervalExpie
, Expression*pe0
);Runs semantic on se.lwr and se.upr. Declares a temporary variable if '$' was used.
Return Value
ae
, or ErrorExp if errors occurred -
Declaration
bool
arrayExpressionSemantic
(Expression[]exps
, Scope*sc
, boolpreserveErrors
= false);Perform semantic() on an array of Expressions.
-
Declaration
Expression
resolvePropertiesOnly
(Scope*sc
, Expressione1
);If
e1
is a property function (template), resolve it. -
Declaration
Expression
symbolToExp
(Dsymbols
, const ref Locloc
, Scope*sc
, boolhasOverloads
);Turn symbol
into the expression it represents.s
Parameters
Dsymbol
s
symbol to resolve
Loc
loc
location of use of
s
Scope*
sc
context
bool
hasOverloads
applies if
represents a function.s
true
means it's
overloaded and will be resolved later,false
means it's
the exact function symbol.Return Value
turned into an expression,s
ErrorExp
if an error occurred -
Declaration
Package
resolveIsPackage
(Dsymbolsym
);Determines whether a symbol represents a module or package (Used as a helper for is(type == module) and is(type == package))
Parameters
Dsymbol
sym
the symbol to be checked
Return Value
the symbol which
represents (orsym
null
if it doesn't represent aPackage
) -
Declaration
Expression
trySemantic
(Expressionexp
, Scope*sc
);Try to run semantic routines. If they fail, return NULL.
-
Declaration
Expression
unaSemantic
(UnaExpe
, Scope*sc
);Helper function for easy error propagation. If error occurs, returns ErrorExp. Otherwise returns NULL.
-
Declaration
Expression
binSemantic
(BinExpe
, Scope*sc
);Helper function for easy error propagation. If error occurs, returns ErrorExp. Otherwise returns NULL.
-
Declaration
Expression
dotIdSemanticProp
(DotIdExpexp
, Scope*sc
, intflag
);Resolve properties, i.e.
e1.ident
, without seeing UFCS.Parameters
DotIdExp
exp
expression to resolve
Scope*
sc
context
int
flag
if 1 then do not emit error messages, just return
null
Return Value
resolved expression,
null
if error -
Declaration
bool
checkSharedAccess
(Expressione
, Scope*sc
, boolreturnRef
= false);If expression is shared, check that we can access it. Give error message if not.
Parameters
Expression
e
expression to check
Scope*
sc
context
bool
returnRef
Whether this expression is for a
return
statement off aref
function, in which case a single level of dereference is allowed (e
.g.shared(int)*
).Return Value
true
on error -
Declaration
bool
checkAddressVar
(Scope*sc
, Expressionexp
, VarDeclarationv
);Determine if
, which gets its address taken, can do so safely.exp
Parameters
Scope*
sc
context
Expression
exp
expression having its address taken
VarDeclaration
v
the variable getting its address taken
Return Value
true
if ok,false
for error -
Declaration
bool
checkAddressable
(Expressione
, Scope*sc
);This check ensures that the object in
exp
can have its address taken, or issue a diagnostic error.Parameters
Expression
e
expression to check
Scope*
sc
context
Return Value
true
if the expression is addressable -
Declaration
Expression
getThisSkipNestedFuncs
(const ref Locloc
, Scope*sc
, Dsymbols
, AggregateDeclarationad
, Expressione1
, Typet
, Dsymbolvar
, boolflag
= false);Helper function for
getRightThis()
. Getsthis
of the next outer aggregate.Parameters
Loc
loc
location to use for error messages
Scope*
sc
context
Dsymbol
s
the parent symbol of the existing
this
AggregateDeclaration
ad
struct or class we need the correct
this
forExpression
e1
existing
this
Type
t
type of the existing
this
Dsymbol
var
the specific member of
ad
we're accessingbool
flag
if
true
, returnnull
instead of throwing an errorReturn Value
Expression representing the
this
for thevar
-
Declaration
VarDeclaration
makeThis2Argument
(const ref Locloc
, Scope*sc
, FuncDeclarationfd
);Make a dual-context container for use as a
this
argument.Parameters
Loc
loc
location to use for error messages
Scope*
sc
current scope
FuncDeclaration
fd
target function that will take the
this
argumentReturn Value
Temporary closure variable.
Note: The function
is added to the nested references of the newly created variable such that a closure is made for the variable when the address offd
is taken.fd
-
Declaration
bool
verifyHookExist
(const ref Locloc
, ref Scopesc
, Identifierid
, stringdescription
, Identifiermodule_
= Id.object);Make sure that the runtime hook
exists.id
Parameters
Loc
loc
location to use for error messages
Scope
sc
current scope
Identifier
id
the hook identifier
string
description
what the hook does
Identifier
module_
what module the hook is located in
Return Value
a
bool
indicating if the hook is present. -
Declaration
Expression
getVarExp
(EnumMemberem
, const ref Locloc
, Scope*sc
);Returns
as a VariableExpem
Parameters
EnumMember
em
the EnumMember to wrap
Loc
loc
location of use of
em
Scope*
sc
scope of use of
em
Return Value
VarExp referenceing
or ErrorExp ifem
if disabled/deprecatedem
-
Declaration
Expression
toBoolean
(Expressionexp
, Scope*sc
);Try to treat
as a boolean,exp
Parameters
Expression
exp
the expression
Scope*
sc
scope to evalute
inexp
Return Value
Modified expression on success, ErrorExp on error