(
luaTarget: LuaTarget,
emitHost: EmitHost,
luaContents: string[]
)
| 290 | } |
| 291 | |
| 292 | export function findUsedLualibFeatures( |
| 293 | luaTarget: LuaTarget, |
| 294 | emitHost: EmitHost, |
| 295 | luaContents: string[] |
| 296 | ): Set<LuaLibFeature> { |
| 297 | const features = new Set<LuaLibFeature>(); |
| 298 | const exportToFeatureMap = getLuaLibExportToFeatureMap(luaTarget, emitHost); |
| 299 | |
| 300 | for (const lua of luaContents) { |
| 301 | const regex = /^local (\w+) = ____lualib\.(\w+)$/gm; |
| 302 | while (true) { |
| 303 | const match = regex.exec(lua); |
| 304 | if (!match) break; |
| 305 | const [, localName, exportName] = match; |
| 306 | if (localName !== exportName) continue; |
| 307 | const feature = exportToFeatureMap.get(exportName); |
| 308 | if (feature) features.add(feature); |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | return features; |
| 313 | } |
no test coverage detected