(candidate, obj)
| 8805 | this._base_count = {}; |
| 8806 | } |
| 8807 | create_name(candidate, obj) { |
| 8808 | if (obj && this._obj_to_name.has(obj)) { |
| 8809 | return self._obj_to_name.get(obj); |
| 8810 | } |
| 8811 | candidate = candidate || '_unnamed'; |
| 8812 | candidate = /^\d+$/.test(candidate) ? `_${candidate}` : candidate; |
| 8813 | candidate = candidate.replace(/[^0-9a-zA-Z_]+/, '_'); |
| 8814 | const match = candidate.match(/(.*)_(\d+)$"/); |
| 8815 | let base = candidate; |
| 8816 | let num = null; |
| 8817 | if (match) { |
| 8818 | [, base] = match; |
| 8819 | num = parseInt(match[2], 10); |
| 8820 | } |
| 8821 | candidate = num ? `${base}_${num}` : base; |
| 8822 | if (!num) { |
| 8823 | num = this._base_count[base] || 0; |
| 8824 | } |
| 8825 | while (this._used_names.has(candidate) || this._is_illegal_name(candidate, obj)) { |
| 8826 | num += 1; |
| 8827 | candidate = `${base}_${num}`; |
| 8828 | } |
| 8829 | this._used_names.add(candidate); |
| 8830 | this._base_count[base] = num; |
| 8831 | if (obj) { |
| 8832 | this._obj_to_name[obj] = candidate; |
| 8833 | } else { |
| 8834 | this._unassociated_names.add(candidate); |
| 8835 | } |
| 8836 | return candidate; |
| 8837 | } |
| 8838 | _is_illegal_name(/* name, obj */) { |
| 8839 | /* |
| 8840 | if name in keyword.kwlist: |
no test coverage detected