readVariable method

Value readVariable(
  1. Variable variable,
  2. BasicBlock block
)

Reads a variable's value in a block.

If the variable is not defined locally, searches predecessors and inserts phi functions as needed. The result is resolved through substitution chains from eliminated trivial phis.

Implementation

Value readVariable(Variable variable, BasicBlock block) {
  final localDef = _currentDef[block.id]?[variable.name];
  if (localDef != null) {
    return _resolveValue(localDef);
  }
  return _readVariableRecursive(variable, block);
}