View source code
Display the source code in dmd/sideeffect.d from which this page was generated on github.
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 local clone.

Function dmd.sideeffect.extractSideEffect

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

Expression extractSideEffect (
  dmd.dscope.Scope* sc,
  const(char[]) name,
  ref Expression e0,
  Expression e,
  bool alwaysCopy = false
);

Parameters

NameDescription
sc scope
name name for temporary variable
e0 a new side effect part will be appended to it.
e original expression
alwaysCopy if true, build new temporary variable even if e is trivial.

Returns

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.

Authors

Walter Bright

License

Boost License 1.0