1 // ================================================================ 2 // These evaluate right-hand-side extended values (rxvals) and return the same. 3 // 4 // For scalar (non-extended) right-hand side values, everything is ephemeral as 5 // it propagates up through the concrete syntax tree: e.g. in '$c = $a . $b' the 6 // $a and $b are copied out as ephemerals; in the concat function their 7 // concatenation is computed and the ephemeral input arguments are freed; then 8 // the result is stored in field $c. 9 // 10 // But for extended values (here) everything is copy-on-write: 11 // expression-intermediate values are not always ephemeral. This is due to the 12 // size of the data involved. We can do dump or emit of a nested hashmap stored 13 // in an oosvar or local without copying it; we can do mapdiff of two map-valued 14 // variables while not modifying or copying either argument. 15 // 16 // The boxed_xval_t decorates mlhmmv_value_t (extended value) with an 17 // is_ephemeral flag. The mlhmmv_value_t in turn has a map or a scalar. 18 // ================================================================ 19 20 #ifndef RXVAL_EVALUATORS_H 21 #define RXVAL_EVALUATORS_H 22 23 #include <stdio.h> 24 #include "lib/mvfuncs.h" 25 #include "containers/xvfuncs.h" 26 #include "dsl/mlr_dsl_ast.h" 27 #include "dsl/rval_evaluator.h" 28 #include "dsl/rxval_evaluator.h" 29 #include "dsl/function_manager.h" 30 31 // ================================================================ 32 // rxval_expr_evaluators.c 33 34 // ---------------------------------------------------------------- 35 // Topmost functions: 36 37 rxval_evaluator_t* rxval_evaluator_alloc_from_ast( 38 mlr_dsl_ast_node_t* past, fmgr_t* pfmgr, int type_inferencing, int context_flags); 39 40 // Next level: 41 rxval_evaluator_t* rxval_evaluator_alloc_from_map_literal( 42 mlr_dsl_ast_node_t* past, fmgr_t* pfmgr, int type_inferencing, int context_flags); 43 44 rxval_evaluator_t* rxval_evaluator_alloc_from_function_callsite( 45 mlr_dsl_ast_node_t* past, fmgr_t* pfmgr, int type_inferencing, int context_flags); 46 47 rxval_evaluator_t* rxval_evaluator_alloc_from_nonindexed_local_variable( 48 mlr_dsl_ast_node_t* past, fmgr_t* pfmgr, int type_inferencing, int context_flags); 49 50 rxval_evaluator_t* rxval_evaluator_alloc_from_indexed_local_variable( 51 mlr_dsl_ast_node_t* past, fmgr_t* pfmgr, int type_inferencing, int context_flags); 52 53 rxval_evaluator_t* rxval_evaluator_alloc_from_indexed_function_call( 54 mlr_dsl_ast_node_t* past, fmgr_t* pfmgr, int type_inferencing, int context_flags); 55 56 // Srec assignments have output that is rval not rxval (scalar, not map). But for 57 // indexed function calls we have a function which produces rxval, indexed down by a 58 // keylist, to produce an rval as a final result. This needs special handling. 59 rval_evaluator_t* rval_evaluator_alloc_from_indexed_function_call( 60 mlr_dsl_ast_node_t* past, fmgr_t* pfmgr, int type_inferencing, int context_flags); 61 62 rxval_evaluator_t* rxval_evaluator_alloc_from_oosvar_keylist( 63 mlr_dsl_ast_node_t* past, fmgr_t* pfmgr, int type_inferencing, int context_flags); 64 65 rxval_evaluator_t* rxval_evaluator_alloc_from_full_oosvar( 66 mlr_dsl_ast_node_t* past, fmgr_t* pfmgr, int type_inferencing, int context_flags); 67 68 rxval_evaluator_t* rxval_evaluator_alloc_from_full_srec( 69 mlr_dsl_ast_node_t* past, fmgr_t* pfmgr, int type_inferencing, int context_flags); 70 71 rxval_evaluator_t* rxval_evaluator_alloc_wrapping_rval( 72 mlr_dsl_ast_node_t* past, fmgr_t* pfmgr, int type_inferencing, int context_flags); 73 74 // ================================================================ 75 // rxval_func_evaluators.c 76 77 rxval_evaluator_t* rxval_evaluator_alloc_from_variadic_func( 78 xv_variadic_func_t* pfunc, 79 sllv_t* parg_nodes, 80 fmgr_t* pfmgr, 81 int type_inferencing, 82 int context_flags); 83 84 rxval_evaluator_t* rxval_evaluator_alloc_from_x_x_func( 85 xv_unary_func_t* pfunc, 86 mlr_dsl_ast_node_t* parg1_node, 87 fmgr_t* pfmgr, 88 int type_inferencing, 89 int context_flags); 90 91 rxval_evaluator_t* rxval_evaluator_alloc_from_x_m_func( 92 xv_unary_func_t* pfunc, 93 mlr_dsl_ast_node_t* parg1_node, 94 fmgr_t* pfmgr, 95 int type_inferencing, 96 int context_flags); 97 98 rxval_evaluator_t* rxval_evaluator_alloc_from_x_mx_func( 99 xv_binary_func_t* pfunc, 100 mlr_dsl_ast_node_t* parg1_node, 101 mlr_dsl_ast_node_t* parg2_node, 102 fmgr_t* pfmgr, 103 int type_inferencing, 104 int context_flags); 105 106 rxval_evaluator_t* rxval_evaluator_alloc_from_x_ms_func( 107 xv_binary_func_t* pfunc, 108 mlr_dsl_ast_node_t* parg1_node, 109 mlr_dsl_ast_node_t* parg2_node, 110 fmgr_t* pfmgr, 111 int type_inferencing, 112 int context_flags); 113 114 rxval_evaluator_t* rxval_evaluator_alloc_from_x_ss_func( 115 xv_binary_func_t* pfunc, 116 mlr_dsl_ast_node_t* parg1_node, 117 mlr_dsl_ast_node_t* parg2_node, 118 fmgr_t* pfmgr, 119 int type_inferencing, 120 int context_flags); 121 122 rxval_evaluator_t* rxval_evaluator_alloc_from_x_mss_func( 123 xv_ternary_func_t* pfunc, 124 mlr_dsl_ast_node_t* parg1_node, 125 mlr_dsl_ast_node_t* parg2_node, 126 mlr_dsl_ast_node_t* parg3_node, 127 fmgr_t* pfmgr, 128 int type_inferencing, 129 int context_flags); 130 131 rxval_evaluator_t* rxval_evaluator_alloc_from_x_sss_func( 132 xv_ternary_func_t* pfunc, 133 mlr_dsl_ast_node_t* parg1_node, 134 mlr_dsl_ast_node_t* parg2_node, 135 mlr_dsl_ast_node_t* parg3_node, 136 fmgr_t* pfmgr, 137 int type_inferencing, 138 int context_flags); 139 140 rxval_evaluator_t* rxval_evaluator_alloc_from_A_x_func( 141 xv_unary_func_t* pfunc, 142 mlr_dsl_ast_node_t* parg1_node, 143 fmgr_t* pfmgr, 144 int type_inferencing, 145 int context_flags, 146 char* desc); 147 148 #endif // RXVAL_EVALUATORS_H 149