Expression

Members

Functions

addDtorHook
Expression addDtorHook(Scope* sc)

Destructors are attached to VarDeclarations. Hence, if expression returns a temp that needs a destructor, make sure and create a VarDeclaration for that temp.

addressOf
Expression addressOf()

Take address of expression.

checkModifiable
int checkModifiable(Scope* sc, int flag = 0)

Parameters: sc: scope flag: 1: do not issue error message for invalid modification

checkNogc
bool checkNogc(Scope* sc, FuncDeclaration f)

Calling function f. Check the @nogc-ness, i.e. if we're in a @nogc function we can only call other @nogc functions. Returns true if error occurs.

checkPostblit
bool checkPostblit(Scope* sc, Type t)

Check that the postblit is callable if t is an array of structs. Returns true if error happens.

checkPurity
bool checkPurity(Scope* sc, FuncDeclaration f)

Calling function f. Check the purity, i.e. if we're in a pure function we can only call other pure functions. Returns true if error occurs.

checkPurity
bool checkPurity(Scope* sc, VarDeclaration v)

Accessing variable v. Check for purity and safety violations. Returns true if error occurs.

checkReadModifyWrite
bool checkReadModifyWrite(TOK rmwOp, Expression ex = null)

Check whether the expression allows RMW operations, error with rmw operator diagnostic if not. ex is the RHS expression, or NULL if ++/-- is used (for diagnostics) Returns true if error occurs.

checkSafety
bool checkSafety(Scope* sc, FuncDeclaration f)

Calling function f. Check the safety, i.e. if we're in a @safe function we can only call @safe or @trusted functions. Returns true if error occurs.

checkType
bool checkType()

Check that the expression has a valid type. If not, generates an error "... has no type".

checkValue
bool checkValue()

Check that the expression has a valid value. If not, generates an error "... has no value".

copy
Expression copy()

Does *not* do a deep copy.

deref
Expression deref()

If this is a reference, dereference it.

isBool
bool isBool(bool result)

Does this expression statically evaluate to a boolean 'result' (true or false)?

isLvalue
bool isLvalue()

Return !=0 if expression is an lvalue.

printAST
void printAST(int indent = 0)

Print AST data structure in a nice format.

resolveLoc
Expression resolveLoc(Loc loc, Scope* sc)

Resolve __FILE__, __LINE__, __MODULE__, __FUNCTION__, __PRETTY_FUNCTION__ to loc.

semantic
Expression semantic(Scope* sc)

Semantically analyze Expression. Determine types, fold constants, etc.

toBoolean
Expression toBoolean(Scope* sc)

If expression can be tested for true or false, returns the modified expression. Otherwise returns ErrorExp.

toLvalue
Expression toLvalue(Scope* sc, Expression e)

Give error if we're not an lvalue. If we can, convert expression to be an lvalue.

trySemantic
Expression trySemantic(Scope* sc)

Try to run semantic routines. If they fail, return NULL.

Static functions

combine
Expression combine(Expression e1, Expression e2)

Combine e1 and e2 by CommaExp if both are not NULL.

extractLast
Expression extractLast(Expression e, Expression* pe0)

If 'e' is a tree of commas, returns the leftmost expression by stripping off it from the tree. The remained part of the tree is returned via *pe0. Otherwise 'e' is directly returned and *pe0 is set to NULL.

Meta