MCPcopy Create free account
hub / github.com/callstackincubator/polygen / matchSymbol

Function matchSymbol

packages/codegen/src/codegen/utils.ts:85–102  ·  view source on GitHub ↗
(
  symbol: GeneratedSymbol,
  matcher: SymbolMatchHandler<TResult>
)

Source from the content-addressed store, hash-verified

83 * @param matcher Handler to match the symbol based on its type
84 */
85export 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
105export function matchW2CRType(t?: ValueType): string {

Callers 2

makeDeclarationFunction · 0.85
makeImportFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected