import { Context , ContextSet } from '../backend/context' ; import { CodeSource , ShValue } from '../backend/sharpValues' ; import { libCallMap as argparseMap } from './argparse' ; import { libCallMap as builtinsMap } from './builtins' ; import { libCallMap as guardMap } from './guard' ; import { LCBase , libCallMap as baseMap } from './libcall' ; import { libCallMap as mathMap } from './math' ; import { libCallMap as numpyMap } from './numpy' ; import { libCallMap as shapeMap } from './shape' ; import { libCallMap as torchMap } from './torch' ; import { libCallMap as torchvisionMap } from './torchvision' ; export type LCParamType = LCBase . BaseParamType ; export type LCImpl = ( ctx : Context < any > , source : CodeSource | undefined ) => ContextSet < ShValue > ; export function registLibCall ( impls , relPath ) { const map = new Map ( ) ; impls . forEach ( ( v , k ) => { map . set ( `${ relPath }.${ k }` , v ) ; } ) ; return map ; } export const libCallMap = new Map ( [ ... baseMap , ... registLibCall ( mathMap , 'math' ) , ... registLibCall ( numpyMap , 'numpy' ) , ... registLibCall ( torchMap , 'torch' ) , ... registLibCall ( torchvisionMap , 'torchvision' ) , ... registLibCall ( shapeMap , 'shape' ) , ... registLibCall ( builtinsMap , 'builtins' ) , ... registLibCall ( argparseMap , 'argparse' ) , ... registLibCall ( guardMap , 'guard' ) , ] ) ;