function addCatchOrFinallyStates(kind, enclosingMap, tryStates) {
  for (let i = 0; i < tryStates.length; i++) {
    let tryState = tryStates[i];
    if (tryState.kind === kind) {
      for (let j = 0; j < tryState.tryStates.length; j++) {
        let id = tryState.tryStates[j];
        enclosingMap[id] = tryState;
      }
    }
    addCatchOrFinallyStates(kind, enclosingMap, tryState.nestedTrys);
  }
}
@param {TryState.Kind} kind
@param {Object} enclosingMap map of state IDs to FinallyState.
@param {Array.<TryState>} tryStates