mirror of
https://github.com/johnkerl/miller.git
synced 2026-07-22 07:30:43 +00:00
60 lines
1.9 KiB
C
60 lines
1.9 KiB
C
#ifndef FUNCTION_MANAGER_H
|
|
#define FUNCTION_MANAGER_H
|
|
|
|
#include "containers/lhmsv.h"
|
|
#include "containers/mlr_dsl_ast.h" // xxx factor out this dependency?
|
|
#include "mapping/rval_evaluator.h"
|
|
#include "mapping/type_inference.h"
|
|
|
|
// ----------------------------------------------------------------
|
|
// xxx make static in fmgr
|
|
|
|
typedef enum _func_class_t {
|
|
FUNC_CLASS_ARITHMETIC,
|
|
FUNC_CLASS_MATH,
|
|
FUNC_CLASS_BOOLEAN,
|
|
FUNC_CLASS_STRING,
|
|
FUNC_CLASS_CONVERSION,
|
|
FUNC_CLASS_TIME
|
|
} func_class_t;
|
|
|
|
typedef enum _arity_check_t {
|
|
ARITY_CHECK_PASS,
|
|
ARITY_CHECK_FAIL,
|
|
ARITY_CHECK_NO_SUCH
|
|
} arity_check_t;
|
|
|
|
// xxx move to fcn manager, along with move functions -> methods there
|
|
typedef struct _function_lookup_t {
|
|
func_class_t function_class;
|
|
char* function_name;
|
|
int arity;
|
|
char* usage_string;
|
|
} function_lookup_t;
|
|
|
|
extern function_lookup_t FUNCTION_LOOKUP_TABLE[];
|
|
|
|
// ----------------------------------------------------------------
|
|
|
|
typedef struct _fmgr_t {
|
|
function_lookup_t * function_lookup_table;
|
|
lhmsv_t* pUDF_names_to_evaluators;
|
|
} fmgr_t;
|
|
|
|
fmgr_t* fmgr_alloc();
|
|
void fmgr_free(fmgr_t* pfmgr);
|
|
// xxx disallow redefine ?
|
|
void fmgr_install_UDF(fmgr_t* pfmgr, char* name, rval_evaluator_t* pevaluator);
|
|
rval_evaluator_t* fmgr_alloc_evaluator(fmgr_t* pfmgr, char* name);
|
|
|
|
// xxx morph these into methods:
|
|
void rval_evaluator_list_functions(FILE* output_stream, char* leader);
|
|
// Pass function_name == NULL to get usage for all functions:
|
|
void rval_evaluator_function_usage(FILE* output_stream, char* function_name);
|
|
void rval_evaluator_list_all_functions_raw(FILE* output_stream);
|
|
void check_arity_with_report(function_lookup_t fcn_lookup_table[], char* function_name,
|
|
int user_provided_arity);
|
|
rval_evaluator_t* rval_evaluator_alloc_from_operator_or_function(mlr_dsl_ast_node_t* pnode,
|
|
int type_inferencing, int context_flags, function_lookup_t* fcn_lookup_table);
|
|
|
|
#endif // FUNCTION_MANAGER_H
|