extractSideEffect

Build a temporary variable to extract e's evaluation, if e is not trivial.

extractSideEffect
(,
const char[] name
,,,
bool alwaysCopy = false
)

Parameters

sc Scope*

scope

name char[]

name for temporary variable

e0 Expression

a new side effect part will be appended to it.

e Expression

original expression

alwaysCopy bool

if true, build new temporary variable even if e is trivial.

Return Value

When e is trivial and alwaysCopy == false, e itself is returned. Otherwise, a new VarExp is returned. Note: e's lvalue-ness will be handled well by STC.ref_ or STC.rvalue.

Meta