* Returns used name. May return InlinedUsedName when the export is inlined to a primitive. * @param {string | undefined} fallbackName fallback name for used exports with no name * @param {RuntimeSpec} runtime check usage for this runtime only * @returns {string | InlinedUsedName | false} used
(fallbackName, runtime)
| 1482 | * @returns {string | InlinedUsedName | false} used name |
| 1483 | */ |
| 1484 | getUsedName(fallbackName, runtime) { |
| 1485 | if (this._hasUseInRuntimeInfo) { |
| 1486 | if (this._globalUsed !== undefined) { |
| 1487 | if (this._globalUsed === UsageState.Unused) return false; |
| 1488 | } else { |
| 1489 | if (this._usedInRuntime === undefined) return false; |
| 1490 | if (typeof runtime === "string") { |
| 1491 | if (!this._usedInRuntime.has(runtime)) { |
| 1492 | return false; |
| 1493 | } |
| 1494 | } else if (runtime !== undefined) { |
| 1495 | // Unused unless at least one runtime in the set is used; loop avoids |
| 1496 | // allocating an array from the runtime set on this hot path. |
| 1497 | let anyUsed = false; |
| 1498 | for (const r of runtime) { |
| 1499 | if (this._usedInRuntime.has(r)) { |
| 1500 | anyUsed = true; |
| 1501 | break; |
| 1502 | } |
| 1503 | } |
| 1504 | if (!anyUsed) return false; |
| 1505 | } |
| 1506 | } |
| 1507 | } |
| 1508 | if (this._usedName !== null) return this._usedName; |
| 1509 | return /** @type {string | false} */ (this.name || fallbackName); |
| 1510 | } |
| 1511 | |
| 1512 | /** |
| 1513 | * Checks whether this export info has used name. |
no test coverage detected