import { CallExpr } from "../Expr" ; import { ExprEvaluatorContext , OperatorDescriptorMap } from "../ExprEvaluator" ; const operators = { "to-boolean" : { call : ( context , call ) => { return Boolean ( context . evaluate ( call . args [ 0 ] ) ) ; } } , "to-string" : { call : ( context , call ) => { return String ( context . evaluate ( call . args [ 0 ] ) ) ; } } , "to-number" : { call : ( context , call ) => { for ( const arg of call . args ) { const value = Number ( context . evaluate ( arg ) ) ; if ( ! isNaN ( value ) ) { return value ; } } throw new Error ( "cannot convert the value to a number" ) ; } } } ; export const CastOperators = operators ; export type CastOperatorNames = keyof typeof operators ;