( symbol: GeneratedSymbol, matcher: SymbolMatchHandler<TResult> )
| 83 | * @param matcher Handler to match the symbol based on its type |
| 84 | */ |
| 85 | export function matchSymbol<TResult = void>( |
| 86 | symbol: GeneratedSymbol, |
| 87 | matcher: SymbolMatchHandler<TResult> |
| 88 | ): TResult { |
| 89 | switch (symbol.target.kind) { |
| 90 | case 'function': |
| 91 | return matcher.func(symbol as GeneratedSymbol<GeneratedModuleFunction>); |
| 92 | case 'global': |
| 93 | return matcher.global(symbol as GeneratedSymbol<ModuleGlobal>); |
| 94 | case 'memory': |
| 95 | return matcher.memory(symbol as GeneratedSymbol<ModuleMemory>); |
| 96 | case 'table': |
| 97 | return matcher.table(symbol as GeneratedSymbol<ModuleTable>); |
| 98 | default: |
| 99 | // @ts-ignore |
| 100 | throw new SymbolMatchError(symbol.target.kind); |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | // TODO: workaround a bug(?) that all types are returned as either none, u32 or f64 |
| 105 | export function matchW2CRType(t?: ValueType): string { |
no outgoing calls
no test coverage detected