From d81407b83eb640ba1b2412dc243b87ef68f8e2cf Mon Sep 17 00:00:00 2001 From: John Kerl Date: Wed, 23 Nov 2016 09:09:48 -0500 Subject: [PATCH] mlhmmv reorg --- c/containers/local_stack.c | 20 ++--- c/containers/local_stack.h | 24 +++--- c/containers/mlhmmv.c | 86 +++++++++---------- c/containers/mlhmmv.h | 34 ++++---- c/mapping/function_manager.c | 2 +- c/mapping/function_manager.h | 2 +- c/mapping/mapper_put_or_filter.c | 6 +- c/mapping/mlr_dsl_cst_for_map_statements.c | 32 +++---- c/mapping/mlr_dsl_cst_func_subr.c | 12 +-- .../mlr_dsl_cst_map_assignment_statements.c | 14 +-- c/mapping/mlr_dsl_cst_output_statements.c | 12 +-- c/mapping/mlr_dsl_cst_return_statements.c | 20 ++--- c/mapping/rval_evaluator.h | 4 +- c/mapping/rxval_expr_evaluators.c | 26 +++--- 14 files changed, 147 insertions(+), 147 deletions(-) diff --git a/c/containers/local_stack.c b/c/containers/local_stack.c index fe27f868e..c00babf65 100644 --- a/c/containers/local_stack.c +++ b/c/containers/local_stack.c @@ -105,10 +105,10 @@ mv_t local_stack_frame_get_scalar_from_indexed(local_stack_frame_t* pframe, // x LOCAL_STACK_BOUNDS_CHECK(pframe, "GET", FALSE, vardef_frame_relative_index); local_stack_frame_entry_t* pentry = &pframe->pvars[vardef_frame_relative_index]; - mlhmmv_value_t* pbase_xval = &pentry->value; + mlhmmv_xvalue_t* pbase_xval = &pentry->value; #ifdef LOCAL_STACK_TRACE_ENABLE - // xxx needs an mlhmmv_value_print + // xxx needs an mlhmmv_xvalue_print if (pbase_xval == NULL) { printf("VALUE IS NULL\n"); } else if (pbase_xval->is_terminal) { @@ -127,7 +127,7 @@ mv_t local_stack_frame_get_scalar_from_indexed(local_stack_frame_t* pframe, // x // xxx this is a mess; clean it up. int error = 0; // Maybe null - mlhmmv_value_t* pxval; + mlhmmv_xvalue_t* pxval; if (pmvkeys == NULL || pmvkeys->length == 0) { pxval = pbase_xval; } else { @@ -147,17 +147,17 @@ mv_t local_stack_frame_get_scalar_from_indexed(local_stack_frame_t* pframe, // x } // ---------------------------------------------------------------- -mlhmmv_value_t* local_stack_frame_get_extended_from_indexed(local_stack_frame_t* pframe, // xxx rename w/ 'reference' in name +mlhmmv_xvalue_t* local_stack_frame_get_extended_from_indexed(local_stack_frame_t* pframe, // xxx rename w/ 'reference' in name int vardef_frame_relative_index, sllmv_t* pmvkeys) { LOCAL_STACK_TRACE(printf("LOCAL STACK FRAME %p GET %d\n", pframe, vardef_frame_relative_index)); LOCAL_STACK_BOUNDS_CHECK(pframe, "GET", FALSE, vardef_frame_relative_index); local_stack_frame_entry_t* pentry = &pframe->pvars[vardef_frame_relative_index]; - mlhmmv_value_t* pmvalue = &pentry->value; + mlhmmv_xvalue_t* pmvalue = &pentry->value; #ifdef LOCAL_STACK_TRACE_ENABLE - // xxx needs an mlhmmv_value_print + // xxx needs an mlhmmv_xvalue_print if (pmvalue == NULL) { printf("VALUE IS NULL\n"); } else if (pmvalue->is_terminal) { @@ -196,7 +196,7 @@ void local_stack_frame_assign_scalar_indexed(local_stack_frame_t* pframe, local_stack_frame_throw_type_mismatch(pentry, &terminal_value); } - mlhmmv_value_t* pmvalue = &pentry->value; + mlhmmv_xvalue_t* pmvalue = &pentry->value; // xxx encapsulate if (pmvalue->is_terminal) { @@ -212,7 +212,7 @@ void local_stack_frame_assign_scalar_indexed(local_stack_frame_t* pframe, void local_stack_frame_assign_extended_indexed(local_stack_frame_t* pframe, // xxx rename int vardef_frame_relative_index, sllmv_t* pmvkeys, - mlhmmv_value_t new_value) // xxx by ptr + mlhmmv_xvalue_t new_value) // xxx by ptr { LOCAL_STACK_TRACE(printf("LOCAL STACK FRAME %p SET %d\n", pframe, vardef_frame_relative_index)); LOCAL_STACK_BOUNDS_CHECK(pframe, "ASSIGN", TRUE, vardef_frame_relative_index); @@ -222,7 +222,7 @@ void local_stack_frame_assign_extended_indexed(local_stack_frame_t* pframe, // x local_stack_frame_throw_type_xmismatch(pentry, &new_value); } - mlhmmv_value_t* pmvalue = &pentry->value; + mlhmmv_xvalue_t* pmvalue = &pentry->value; // xxx encapsulate if (pmvalue->is_terminal) { @@ -272,7 +272,7 @@ void local_stack_frame_throw_type_mismatch(local_stack_frame_entry_t* pentry, mv exit(1); } -void local_stack_frame_throw_type_xmismatch(local_stack_frame_entry_t* pentry, mlhmmv_value_t* pxval) { +void local_stack_frame_throw_type_xmismatch(local_stack_frame_entry_t* pentry, mlhmmv_xvalue_t* pxval) { MLR_INTERNAL_CODING_ERROR_IF(pentry->name == NULL); char* sval = mv_alloc_format_val_quoting_strings(&pxval->terminal_mlrval); // xxx temp fprintf(stderr, "%s: %s type assertion for variable %s unmet by value %s with type %s.\n", diff --git a/c/containers/local_stack.h b/c/containers/local_stack.h index 25be4c266..783e8dd9a 100644 --- a/c/containers/local_stack.h +++ b/c/containers/local_stack.h @@ -20,7 +20,7 @@ // ================================================================ typedef struct _local_stack_frame_entry_t { char* name; // For type-check error messages. Not strduped; the caller must ensure extent. - mlhmmv_value_t value; + mlhmmv_xvalue_t value; int type_mask; } local_stack_frame_entry_t; @@ -83,7 +83,7 @@ void local_stack_bounds_check(local_stack_frame_t* pframe, char* op, int set, in local_stack_frame_t* local_stack_frame_enter(local_stack_frame_t* pframe); void local_stack_frame_exit(local_stack_frame_t* pframe); void local_stack_frame_throw_type_mismatch(local_stack_frame_entry_t* pentry, mv_t* pval); -void local_stack_frame_throw_type_xmismatch(local_stack_frame_entry_t* pentry, mlhmmv_value_t* pxval); // xxx temp +void local_stack_frame_throw_type_xmismatch(local_stack_frame_entry_t* pentry, mlhmmv_xvalue_t* pxval); // xxx temp // ---------------------------------------------------------------- static inline mv_t local_stack_frame_get_scalar_from_nonindexed(local_stack_frame_t* pframe, @@ -93,7 +93,7 @@ static inline mv_t local_stack_frame_get_scalar_from_nonindexed(local_stack_fram LOCAL_STACK_BOUNDS_CHECK(pframe, "GET", FALSE, vardef_frame_relative_index); // xxx encapsulate local_stack_frame_entry_t* pentry = &pframe->pvars[vardef_frame_relative_index]; - mlhmmv_value_t* pvalue = &pentry->value; + mlhmmv_xvalue_t* pvalue = &pentry->value; if (pvalue != NULL && pvalue->is_terminal) { return pvalue->terminal_mlrval; } else { @@ -104,7 +104,7 @@ static inline mv_t local_stack_frame_get_scalar_from_nonindexed(local_stack_fram mv_t local_stack_frame_get_scalar_from_indexed(local_stack_frame_t* pframe, // xxx rename int vardef_frame_relative_index, sllmv_t* pmvkeys); -mlhmmv_value_t* local_stack_frame_get_extended_from_indexed(local_stack_frame_t* pframe, // xxx rename +mlhmmv_xvalue_t* local_stack_frame_get_extended_from_indexed(local_stack_frame_t* pframe, // xxx rename int vardef_frame_relative_index, sllmv_t* pmvkeys); // ---------------------------------------------------------------- @@ -128,12 +128,12 @@ static inline void local_stack_frame_define_scalar(local_stack_frame_t* pframe, if (mv_is_absent(&val)) { mv_free(&val); // xxx confusing ownership semantics } else { - pentry->value = mlhmmv_value_wrap_terminal(val); // xxx deep-copy? + pentry->value = mlhmmv_xvalue_wrap_terminal(val); // xxx deep-copy? } } static inline void local_stack_frame_define_extended(local_stack_frame_t* pframe, char* variable_name, // xxx rename - int vardef_frame_relative_index, int type_mask, mlhmmv_value_t xval) + int vardef_frame_relative_index, int type_mask, mlhmmv_xvalue_t xval) { LOCAL_STACK_TRACE(printf("LOCAL STACK FRAME %p SET %d\n", pframe, vardef_frame_relative_index)); LOCAL_STACK_BOUNDS_CHECK(pframe, "ASSIGN", TRUE, vardef_frame_relative_index); @@ -155,9 +155,9 @@ static inline void local_stack_frame_define_extended(local_stack_frame_t* pframe // xxx temp -- make a single method if (xval.is_terminal && mv_is_absent(&xval.terminal_mlrval)) { - mlhmmv_value_free(xval); // xxx confusing ownership semantics + mlhmmv_xvalue_free(xval); // xxx confusing ownership semantics } else { - mlhmmv_value_free(pentry->value); // xxx rename + mlhmmv_xvalue_free(pentry->value); // xxx rename pentry->value = xval; } } @@ -177,11 +177,11 @@ static inline void local_stack_frame_assign_scalar_nonindexed(local_stack_frame_ // xxx temp -- make a single method mv_free(&pentry->value.terminal_mlrval); // xxx temp -- make value-free - pentry->value = mlhmmv_value_wrap_terminal(val); // xxx deep-copy? + pentry->value = mlhmmv_xvalue_wrap_terminal(val); // xxx deep-copy? } static inline void local_stack_frame_assign_extended_nonindexed(local_stack_frame_t* pframe, // xxx rename - int vardef_frame_relative_index, mlhmmv_value_t xval) + int vardef_frame_relative_index, mlhmmv_xvalue_t xval) { LOCAL_STACK_TRACE(printf("LOCAL STACK FRAME %p SET %d\n", pframe, vardef_frame_relative_index)); LOCAL_STACK_BOUNDS_CHECK(pframe, "ASSIGN", TRUE, vardef_frame_relative_index); @@ -202,7 +202,7 @@ static inline void local_stack_frame_assign_extended_nonindexed(local_stack_fram mv_free(&pentry->value.terminal_mlrval); // xxx temp -- make value-free // xxx temp -- make a single method - mlhmmv_value_free(pentry->value); // xxx rename + mlhmmv_xvalue_free(pentry->value); // xxx rename pentry->value = xval; } @@ -212,7 +212,7 @@ void local_stack_frame_assign_scalar_indexed(local_stack_frame_t* pframe, void local_stack_frame_assign_extended_indexed(local_stack_frame_t* pframe, // xxx rename int vardef_frame_relative_index, sllmv_t* pmvkeys, - mlhmmv_value_t terminal_value); + mlhmmv_xvalue_t terminal_value); // ---------------------------------------------------------------- // Frames are entered/exited for each curly-braced statement block, including diff --git a/c/containers/mlhmmv.c b/c/containers/mlhmmv.c index d22c38d0f..0095a3f47 100644 --- a/c/containers/mlhmmv.c +++ b/c/containers/mlhmmv.c @@ -28,25 +28,25 @@ static void mlhmmv_level_free(mlhmmv_level_t* plevel); static int mlhmmv_level_find_index_for_key(mlhmmv_level_t* plevel, mv_t* plevel_key, int* pideal_index); static void mlhmmv_level_put_no_enlarge(mlhmmv_level_t* plevel, sllmve_t* prest_keys, mv_t* pterminal_value); -static void mlhmmv_level_move(mlhmmv_level_t* plevel, mv_t* plevel_key, mlhmmv_value_t* plevel_value); +static void mlhmmv_level_move(mlhmmv_level_t* plevel, mv_t* plevel_key, mlhmmv_xvalue_t* plevel_value); static mlhmmv_level_entry_t* mlhmmv_get_entry_at_level(mlhmmv_level_t* plevel, sllmve_t* prestkeys, int* perror); static mlhmmv_level_t* mlhmmv_get_or_create_level_aux(mlhmmv_level_t* plevel, sllmve_t* prest_keys); static mlhmmv_level_t* mlhmmv_get_or_create_level_aux_no_enlarge(mlhmmv_level_t* plevel, sllmve_t* prest_keys); -static void mlhmmv_put_value_at_level(mlhmmv_root_t* pmap, sllmv_t* pmvkeys, mlhmmv_value_t* pvalue); +static void mlhmmv_put_value_at_level(mlhmmv_root_t* pmap, sllmv_t* pmvkeys, mlhmmv_xvalue_t* pvalue); static mlhmmv_level_entry_t* mlhmmv_get_next_level_entry(mlhmmv_level_t* pmap, mv_t* plevel_key, int* pindex); -static mlhmmv_value_t* mlhmmv_get_next_level_entry_value(mlhmmv_level_t* pmap, mv_t* plevel_key); +static mlhmmv_xvalue_t* mlhmmv_get_next_level_entry_value(mlhmmv_level_t* pmap, mv_t* plevel_key); static void mlhmmv_remove_aux(mlhmmv_level_t* plevel, sllmve_t* prestkeys, int* pemptied, int depth); static void mlhmmv_level_put_value_no_enlarge(mlhmmv_level_t* plevel, sllmve_t* prest_keys, - mlhmmv_value_t* pvalue); + mlhmmv_xvalue_t* pvalue); static void mlhmmv_level_enlarge(mlhmmv_level_t* plevel); -// xxx needs to be public -- rename -- static mlhmmv_value_t mlhmmv_value_copy(mlhmmv_value_t* pvalue); -static sllv_t* mlhmmv_copy_keys_from_submap_aux(mlhmmv_value_t* pvalue); +// xxx needs to be public -- rename -- static mlhmmv_xvalue_t mlhmmv_xvalue_copy(mlhmmv_xvalue_t* pvalue); +static sllv_t* mlhmmv_copy_keys_from_submap_aux(mlhmmv_xvalue_t* pvalue); static void mlhmmv_to_lrecs_aux_across_records(mlhmmv_level_t* plevel, char* prefix, sllmve_t* prestnames, lrec_t* ptemplate, sllv_t* poutrecs, int do_full_prefixing, char* flatten_separator); @@ -89,8 +89,8 @@ mlhmmv_root_t* mlhmmv_root_alloc() { return pmap; } -mlhmmv_value_t mlhmmv_value_alloc_empty_map() { - mlhmmv_value_t xval = (mlhmmv_value_t) { +mlhmmv_xvalue_t mlhmmv_xvalue_alloc_empty_map() { + mlhmmv_xvalue_t xval = (mlhmmv_xvalue_t) { .is_terminal = FALSE, .pnext_level = mlhmmv_level_alloc() }; @@ -276,8 +276,8 @@ mlhmmv_level_t* mlhmmv_level_put_empty_map(mlhmmv_level_t* plevel, sllmve_t* pre .ptail = prest_keys, .length = 1 }; - mlhmmv_value_t* pxval = mlhmmv_level_look_up_and_ref_xvalue(plevel, &s, &error); - *pxval = mlhmmv_value_alloc_empty_map(); + mlhmmv_xvalue_t* pxval = mlhmmv_level_look_up_and_ref_xvalue(plevel, &s, &error); + *pxval = mlhmmv_xvalue_alloc_empty_map(); return pxval->pnext_level; } @@ -294,7 +294,7 @@ mlhmmv_level_t* mlhmmv_level_put_empty_map(mlhmmv_level_t* plevel, sllmve_t* pre // level_key = "e", level_value = non-terminal ["f"] => terminal_value = 7. // level_key = 6, level_value = terminal_value = "g". -static void mlhmmv_level_move(mlhmmv_level_t* plevel, mv_t* plevel_key, mlhmmv_value_t* plevel_value) { +static void mlhmmv_level_move(mlhmmv_level_t* plevel, mv_t* plevel_key, mlhmmv_xvalue_t* plevel_value) { int ideal_index = 0; int index = mlhmmv_level_find_index_for_key(plevel, plevel_key, &ideal_index); mlhmmv_level_entry_t* pentry = &plevel->entries[index]; @@ -496,7 +496,7 @@ static mlhmmv_level_entry_t* mlhmmv_get_next_level_entry(mlhmmv_level_t* plevel, } } -static mlhmmv_value_t* mlhmmv_get_next_level_entry_value(mlhmmv_level_t* plevel, mv_t* plevel_key) { +static mlhmmv_xvalue_t* mlhmmv_get_next_level_entry_value(mlhmmv_level_t* plevel, mv_t* plevel_key) { if (plevel == NULL) return NULL; mlhmmv_level_entry_t* pentry = mlhmmv_get_next_level_entry(plevel, plevel_key, NULL); @@ -507,7 +507,7 @@ static mlhmmv_value_t* mlhmmv_get_next_level_entry_value(mlhmmv_level_t* plevel, } // ---------------------------------------------------------------- -mlhmmv_value_t* mlhmmv_level_look_up_and_ref_xvalue(mlhmmv_level_t* pstart_level, sllmv_t* pmvkeys, int* perror) { +mlhmmv_xvalue_t* mlhmmv_level_look_up_and_ref_xvalue(mlhmmv_level_t* pstart_level, sllmv_t* pmvkeys, int* perror) { *perror = MLHMMV_ERROR_NONE; sllmve_t* prest_keys = pmvkeys->phead; if (prest_keys == NULL) { @@ -677,14 +677,14 @@ void mlhmmv_root_copy_submap(mlhmmv_root_t* pmap, sllmv_t* ptokeys, sllmv_t* pfr mlhmmv_level_entry_t* pfromentry = mlhmmv_get_entry_at_level(pmap->proot_level, pfromkeys->phead, &error); if (pfromentry != NULL) { - mlhmmv_value_t submap = mlhmmv_value_copy(&pfromentry->level_value); + mlhmmv_xvalue_t submap = mlhmmv_xvalue_copy(&pfromentry->level_value); mlhmmv_put_value_at_level(pmap, ptokeys, &submap); } } -mlhmmv_value_t mlhmmv_value_copy(mlhmmv_value_t* pvalue) { // xxx rename +mlhmmv_xvalue_t mlhmmv_xvalue_copy(mlhmmv_xvalue_t* pvalue) { // xxx rename if (pvalue->is_terminal) { - return (mlhmmv_value_t) { + return (mlhmmv_xvalue_t) { .is_terminal = TRUE, .terminal_mlrval = mv_copy(&pvalue->terminal_mlrval), .pnext_level = NULL, @@ -702,11 +702,11 @@ mlhmmv_value_t mlhmmv_value_copy(mlhmmv_value_t* pvalue) { // xxx rename psubentry = psubentry->pnext) { sllmve_t e = { .value = psubentry->level_key, .free_flags = 0, .pnext = NULL }; - mlhmmv_value_t next_value = mlhmmv_value_copy(&psubentry->level_value); + mlhmmv_xvalue_t next_value = mlhmmv_xvalue_copy(&psubentry->level_value); mlhmmv_level_put_xvalue(pdst_level, &e, &next_value); } - return (mlhmmv_value_t) { + return (mlhmmv_xvalue_t) { .is_terminal = FALSE, .terminal_mlrval = mv_absent(), .pnext_level = pdst_level, @@ -715,20 +715,20 @@ mlhmmv_value_t mlhmmv_value_copy(mlhmmv_value_t* pvalue) { // xxx rename } // ---------------------------------------------------------------- -mlhmmv_value_t mlhmmv_root_copy_xvalue(mlhmmv_root_t* pmap, sllmv_t* pmvkeys) { +mlhmmv_xvalue_t mlhmmv_root_copy_xvalue(mlhmmv_root_t* pmap, sllmv_t* pmvkeys) { int error; if (pmvkeys == NULL || pmvkeys->length == 0) { - mlhmmv_value_t root_value = (mlhmmv_value_t) { + mlhmmv_xvalue_t root_value = (mlhmmv_xvalue_t) { .is_terminal = FALSE, .pnext_level = pmap->proot_level, }; - return mlhmmv_value_copy(&root_value); + return mlhmmv_xvalue_copy(&root_value); } else { mlhmmv_level_entry_t* pfromentry = mlhmmv_get_entry_at_level(pmap->proot_level, pmvkeys->phead, &error); if (pfromentry != NULL) { - return mlhmmv_value_copy(&pfromentry->level_value); + return mlhmmv_xvalue_copy(&pfromentry->level_value); } else { - return (mlhmmv_value_t) { + return (mlhmmv_xvalue_t) { .is_terminal = FALSE, .terminal_mlrval = mv_absent(), .pnext_level = NULL, @@ -737,7 +737,7 @@ mlhmmv_value_t mlhmmv_root_copy_xvalue(mlhmmv_root_t* pmap, sllmv_t* pmvkeys) { } } -void mlhmmv_value_free(mlhmmv_value_t submap) { +void mlhmmv_xvalue_free(mlhmmv_xvalue_t submap) { if (submap.is_terminal) { mv_free(&submap.terminal_mlrval); } else if (submap.pnext_level != NULL) { @@ -749,7 +749,7 @@ void mlhmmv_value_free(mlhmmv_value_t submap) { sllv_t* mlhmmv_root_copy_keys_from_submap(mlhmmv_root_t* pmap, sllmv_t* pmvkeys) { int error; if (pmvkeys->length == 0) { - mlhmmv_value_t root_value = (mlhmmv_value_t) { + mlhmmv_xvalue_t root_value = (mlhmmv_xvalue_t) { .is_terminal = FALSE, .pnext_level = pmap->proot_level, }; @@ -764,7 +764,7 @@ sllv_t* mlhmmv_root_copy_keys_from_submap(mlhmmv_root_t* pmap, sllmv_t* pmvkeys) } } -static sllv_t* mlhmmv_copy_keys_from_submap_aux(mlhmmv_value_t* pvalue) { +static sllv_t* mlhmmv_copy_keys_from_submap_aux(mlhmmv_xvalue_t* pvalue) { sllv_t* pkeys = sllv_alloc(); if (!pvalue->is_terminal) { @@ -780,7 +780,7 @@ static sllv_t* mlhmmv_copy_keys_from_submap_aux(mlhmmv_value_t* pvalue) { } // xxx code dedupe -sllv_t* mlhmmv_value_copy_keys(mlhmmv_value_t* pmvalue, sllmv_t* pmvkeys) { +sllv_t* mlhmmv_xvalue_copy_keys(mlhmmv_xvalue_t* pmvalue, sllmv_t* pmvkeys) { int error; if (pmvkeys == NULL || pmvkeys->length == 0) { return mlhmmv_copy_keys_from_submap_aux(pmvalue); @@ -797,18 +797,18 @@ sllv_t* mlhmmv_value_copy_keys(mlhmmv_value_t* pmvalue, sllmv_t* pmvkeys) { } // ---------------------------------------------------------------- -static void mlhmmv_put_value_at_level(mlhmmv_root_t* pmap, sllmv_t* pmvkeys, mlhmmv_value_t* pvalue) { +static void mlhmmv_put_value_at_level(mlhmmv_root_t* pmap, sllmv_t* pmvkeys, mlhmmv_xvalue_t* pvalue) { mlhmmv_level_put_xvalue(pmap->proot_level, pmvkeys->phead, pvalue); } -void mlhmmv_level_put_xvalue(mlhmmv_level_t* plevel, sllmve_t* prest_keys, mlhmmv_value_t* pvalue) { +void mlhmmv_level_put_xvalue(mlhmmv_level_t* plevel, sllmve_t* prest_keys, mlhmmv_xvalue_t* pvalue) { if ((plevel->num_occupied + plevel->num_freed) >= (plevel->array_length * LOAD_FACTOR)) mlhmmv_level_enlarge(plevel); mlhmmv_level_put_value_no_enlarge(plevel, prest_keys, pvalue); } static void mlhmmv_level_put_value_no_enlarge(mlhmmv_level_t* plevel, sllmve_t* prest_keys, - mlhmmv_value_t* pvalue) + mlhmmv_xvalue_t* pvalue) { mv_t* plevel_key = &prest_keys->value; int ideal_index = 0; @@ -1051,7 +1051,7 @@ static void mlhmmv_to_lrecs_aux_across_records( if (prestnames != NULL) { // If there is a namelist entry, pull it out to its own field on the output lrecs. for (mlhmmv_level_entry_t* pe = plevel->phead; pe != NULL; pe = pe->pnext) { - mlhmmv_value_t* plevel_value = &pe->level_value; + mlhmmv_xvalue_t* plevel_value = &pe->level_value; lrec_t* pnextrec = lrec_copy(ptemplate); lrec_put(pnextrec, mv_alloc_format_val(&prestnames->value), @@ -1074,7 +1074,7 @@ static void mlhmmv_to_lrecs_aux_across_records( lrec_t* pnextrec = lrec_copy(ptemplate); int emit = TRUE; for (mlhmmv_level_entry_t* pe = plevel->phead; pe != NULL; pe = pe->pnext) { - mlhmmv_value_t* plevel_value = &pe->level_value; + mlhmmv_xvalue_t* plevel_value = &pe->level_value; if (plevel_value->is_terminal) { char* temp = mv_alloc_format_val(&pe->level_key); char* next_prefix = do_full_prefixing @@ -1113,7 +1113,7 @@ static void mlhmmv_to_lrecs_aux_within_record( char* flatten_separator) { for (mlhmmv_level_entry_t* pe = plevel->phead; pe != NULL; pe = pe->pnext) { - mlhmmv_value_t* plevel_value = &pe->level_value; + mlhmmv_xvalue_t* plevel_value = &pe->level_value; char* temp = mv_alloc_format_val(&pe->level_key); char* next_prefix = do_full_prefixing ? mlr_paste_3_strings(prefix, flatten_separator, temp) @@ -1133,7 +1133,7 @@ static void mlhmmv_to_lrecs_aux_within_record( } // ---------------------------------------------------------------- -void mlhmmv_xvalues_to_lrecs_lashed(mlhmmv_value_t** ptop_values, int num_submaps, mv_t* pbasenames, sllmv_t* pnames, +void mlhmmv_xvalues_to_lrecs_lashed(mlhmmv_xvalue_t** ptop_values, int num_submaps, mv_t* pbasenames, sllmv_t* pnames, sllv_t* poutrecs, int do_full_prefixing, char* flatten_separator) { @@ -1203,7 +1203,7 @@ static void mlhmmv_to_lrecs_aux_across_records_lashed( // First is iterated over and the rest are lashed (lookups with same keys as primary). if (pplevels[0] != NULL) { for (mlhmmv_level_entry_t* pe = pplevels[0]->phead; pe != NULL; pe = pe->pnext) { - mlhmmv_value_t* pfirst_level_value = &pe->level_value; + mlhmmv_xvalue_t* pfirst_level_value = &pe->level_value; lrec_t* pnextrec = lrec_copy(ptemplate); lrec_put(pnextrec, mv_alloc_format_val(&prestnames->value), @@ -1211,7 +1211,7 @@ static void mlhmmv_to_lrecs_aux_across_records_lashed( if (pfirst_level_value->is_terminal) { for (int i = 0; i < num_levels; i++) { - mlhmmv_value_t* plevel_value = mlhmmv_get_next_level_entry_value(pplevels[i], &pe->level_key); + mlhmmv_xvalue_t* plevel_value = mlhmmv_get_next_level_entry_value(pplevels[i], &pe->level_key); if (plevel_value != NULL && plevel_value->is_terminal) { lrec_put(pnextrec, mlr_strdup_or_die(prefixes[i]), @@ -1222,7 +1222,7 @@ static void mlhmmv_to_lrecs_aux_across_records_lashed( } else { mlhmmv_level_t** ppnext_levels = mlr_malloc_or_die(num_levels * sizeof(mlhmmv_level_t*)); for (int i = 0; i < num_levels; i++) { - mlhmmv_value_t* plevel_value = mlhmmv_get_next_level_entry_value(pplevels[i], &pe->level_key); + mlhmmv_xvalue_t* plevel_value = mlhmmv_get_next_level_entry_value(pplevels[i], &pe->level_key); if (plevel_value == NULL || plevel_value->is_terminal) { ppnext_levels[i] = NULL; } else { @@ -1248,7 +1248,7 @@ static void mlhmmv_to_lrecs_aux_across_records_lashed( if (pe->level_value.is_terminal) { char* temp = mv_alloc_format_val(&pe->level_key); for (int i = 0; i < num_levels; i++) { - mlhmmv_value_t* plevel_value = mlhmmv_get_next_level_entry_value(pplevels[i], &pe->level_key); + mlhmmv_xvalue_t* plevel_value = mlhmmv_get_next_level_entry_value(pplevels[i], &pe->level_key); if (plevel_value != NULL && plevel_value->is_terminal) { char* name = do_full_prefixing ? mlr_paste_3_strings(prefixes[i], flatten_separator, temp) @@ -1265,7 +1265,7 @@ static void mlhmmv_to_lrecs_aux_across_records_lashed( mlhmmv_level_t** ppnext_levels = mlr_malloc_or_die(num_levels * sizeof(mlhmmv_level_t*)); char** next_prefixes = mlr_malloc_or_die(num_levels * sizeof(char*)); for (int i = 0; i < num_levels; i++) { - mlhmmv_value_t* plevel_value = mlhmmv_get_next_level_entry_value(pplevels[i], &pe->level_key); + mlhmmv_xvalue_t* plevel_value = mlhmmv_get_next_level_entry_value(pplevels[i], &pe->level_key); if (plevel_value != NULL && !plevel_value->is_terminal) { ppnext_levels[i] = plevel_value->pnext_level; next_prefixes[i] = mlr_paste_3_strings(prefixes[i], flatten_separator, temp); @@ -1287,7 +1287,7 @@ static void mlhmmv_to_lrecs_aux_across_records_lashed( } else { mlhmmv_level_t** ppnext_levels = mlr_malloc_or_die(num_levels * sizeof(mlhmmv_level_t*)); for (int i = 0; i < num_levels; i++) { - mlhmmv_value_t* plevel_value = mlhmmv_get_next_level_entry_value(pplevels[i], &pe->level_key); + mlhmmv_xvalue_t* plevel_value = mlhmmv_get_next_level_entry_value(pplevels[i], &pe->level_key); if (plevel_value->is_terminal) { ppnext_levels[i] = NULL; } else { @@ -1318,11 +1318,11 @@ static void mlhmmv_to_lrecs_aux_within_record_lashed( char* flatten_separator) { for (mlhmmv_level_entry_t* pe = pplevels[0]->phead; pe != NULL; pe = pe->pnext) { - mlhmmv_value_t* pfirst_level_value = &pe->level_value; + mlhmmv_xvalue_t* pfirst_level_value = &pe->level_value; char* temp = mv_alloc_format_val(&pe->level_key); if (pfirst_level_value->is_terminal) { for (int i = 0; i < num_levels; i++) { - mlhmmv_value_t* plevel_value = mlhmmv_get_next_level_entry_value(pplevels[i], &pe->level_key); + mlhmmv_xvalue_t* plevel_value = mlhmmv_get_next_level_entry_value(pplevels[i], &pe->level_key); if (plevel_value != NULL && plevel_value->is_terminal) { char* name = do_full_prefixing ? mlr_paste_3_strings(prefixes[i], flatten_separator, temp) @@ -1337,7 +1337,7 @@ static void mlhmmv_to_lrecs_aux_within_record_lashed( mlhmmv_level_t** ppnext_levels = mlr_malloc_or_die(num_levels * sizeof(mlhmmv_level_t*)); char** next_prefixes = mlr_malloc_or_die(num_levels * sizeof(char*)); for (int i = 0; i < num_levels; i++) { - mlhmmv_value_t* plevel_value = mlhmmv_get_next_level_entry_value(pplevels[i], &pe->level_key); + mlhmmv_xvalue_t* plevel_value = mlhmmv_get_next_level_entry_value(pplevels[i], &pe->level_key); if (plevel_value->is_terminal) { ppnext_levels[i] = NULL; next_prefixes[i] = NULL; diff --git a/c/containers/mlhmmv.h b/c/containers/mlhmmv.h index 957ce884c..aa1033b77 100644 --- a/c/containers/mlhmmv.h +++ b/c/containers/mlhmmv.h @@ -33,22 +33,22 @@ void mlhmmv_print_terminal(mv_t* pmv, int quote_values_always, FILE* ostream); // ---------------------------------------------------------------- struct _mlhmmv_level_t; // forward reference -typedef struct _mlhmmv_value_t { +// The 'x' is for extended: this can hold a scalar or a map. +typedef struct _mlhmmv_xvalue_t { int is_terminal; - // audit for absent/null initters respectively in the .c file - mv_t terminal_mlrval; + mv_t terminal_mlrval; // xxx audit for absent/null initters respectively in the .c file struct _mlhmmv_level_t* pnext_level; -} mlhmmv_value_t; +} mlhmmv_xvalue_t; -mlhmmv_value_t mlhmmv_value_alloc_empty_map(); -mlhmmv_value_t mlhmmv_value_copy(mlhmmv_value_t* pvalue); -void mlhmmv_value_free(mlhmmv_value_t submap); +mlhmmv_xvalue_t mlhmmv_xvalue_alloc_empty_map(); +mlhmmv_xvalue_t mlhmmv_xvalue_copy(mlhmmv_xvalue_t* pvalue); +void mlhmmv_xvalue_free(mlhmmv_xvalue_t submap); // Used by for-loops over map-valued local variables -sllv_t* mlhmmv_value_copy_keys(mlhmmv_value_t* pmvalue, sllmv_t* pmvkeys); +sllv_t* mlhmmv_xvalue_copy_keys(mlhmmv_xvalue_t* pmvalue, sllmv_t* pmvkeys); void mlhmmv_xvalues_to_lrecs_lashed( - mlhmmv_value_t** ptop_values, + mlhmmv_xvalue_t** ptop_values, int num_submaps, mv_t* pbasenames, sllmv_t* pnames, @@ -60,21 +60,21 @@ void mlhmmv_xvalues_to_lrecs_lashed( typedef struct _mlhmmv_level_entry_t { int ideal_index; mv_t level_key; - mlhmmv_value_t level_value; // terminal mlrval, or another hashmap + mlhmmv_xvalue_t level_value; // terminal mlrval, or another hashmap struct _mlhmmv_level_entry_t *pprev; struct _mlhmmv_level_entry_t *pnext; } mlhmmv_level_entry_t; typedef unsigned char mlhmmv_level_entry_state_t; -// Store a mlrval into the mlhmmv_value without copying, implicitly transferring +// Store a mlrval into the mlhmmv_xvalue without copying, implicitly transferring // ownership of the mlrval's free_flags. This means the mlrval will be freed -// when the mlhmmv_value is freed, so the caller should make a copy first if +// when the mlhmmv_xvalue is freed, so the caller should make a copy first if // necessary. // // This is a hot path for non-map local-variable assignments. -static inline mlhmmv_value_t mlhmmv_value_wrap_terminal(mv_t val) { - return (mlhmmv_value_t) {.is_terminal = TRUE, .terminal_mlrval = val, .pnext_level = NULL}; +static inline mlhmmv_xvalue_t mlhmmv_xvalue_wrap_terminal(mv_t val) { + return (mlhmmv_xvalue_t) {.is_terminal = TRUE, .terminal_mlrval = val, .pnext_level = NULL}; } // ---------------------------------------------------------------- @@ -94,9 +94,9 @@ mlhmmv_level_t* mlhmmv_level_alloc(); void mlhmmv_clear_level(mlhmmv_level_t* plevel); mv_t* mlhmmv_level_look_up_and_ref_terminal(mlhmmv_level_t* plevel, sllmv_t* pmvkeys, int* perror); -mlhmmv_value_t* mlhmmv_level_look_up_and_ref_xvalue (mlhmmv_level_t* plevel, sllmv_t* pmvkeys, int* perror); +mlhmmv_xvalue_t* mlhmmv_level_look_up_and_ref_xvalue (mlhmmv_level_t* plevel, sllmv_t* pmvkeys, int* perror); mlhmmv_level_t* mlhmmv_level_put_empty_map (mlhmmv_level_t* plevel, sllmve_t* prest_keys); -void mlhmmv_level_put_xvalue (mlhmmv_level_t* plevel, sllmve_t* prest_keys, mlhmmv_value_t* pvalue); +void mlhmmv_level_put_xvalue (mlhmmv_level_t* plevel, sllmve_t* prest_keys, mlhmmv_xvalue_t* pvalue); void mlhmmv_level_put_terminal (mlhmmv_level_t* plevel, sllmve_t* prest_keys, mv_t* pterminal_value); void mlhmmv_level_to_lrecs (mlhmmv_level_t* plevel, sllmv_t* pkeys, sllmv_t* pnames, sllv_t* poutrecs, int do_full_prefixing, char* flatten_separator); @@ -140,7 +140,7 @@ void mlhmmv_root_copy_submap(mlhmmv_root_t* pmap, sllmv_t* ptokeys, sllmv_t* pfr // For for-loop-over-oosvar, wherein we need to copy the submap before iterating over it // (since the iteration may modify it). If the keys don't index a submap, then the return // value has is_terminal = TRUE and pnext_level = NULL. -mlhmmv_value_t mlhmmv_root_copy_xvalue(mlhmmv_root_t* pmap, sllmv_t* pmvkeys); +mlhmmv_xvalue_t mlhmmv_root_copy_xvalue(mlhmmv_root_t* pmap, sllmv_t* pmvkeys); // Used by for-loops over oosvars sllv_t* mlhmmv_root_copy_keys_from_submap(mlhmmv_root_t* pmap, sllmv_t* pmvkeys); diff --git a/c/mapping/function_manager.c b/c/mapping/function_manager.c index 4765f2f9e..570d9b77a 100644 --- a/c/mapping/function_manager.c +++ b/c/mapping/function_manager.c @@ -449,7 +449,7 @@ static mv_t rval_evaluator_udf_callsite_process(void* pvstate, variables_t* pvar // Functions returning map values in a scalar context get their return values treated as // absent-null. (E.g. f() returns a map and g() returns an int and the statement is '$x // = f() + g()'.) Non-scalar-context return values are handled separately (not here). - mlhmmv_value_t retval = pstate->pdefsite_state->pprocess_func( + mlhmmv_xvalue_t retval = pstate->pdefsite_state->pprocess_func( pstate->pdefsite_state->pvstate, pstate->arity, pstate->args, pvars); if (retval.is_terminal) { diff --git a/c/mapping/function_manager.h b/c/mapping/function_manager.h index 8023efe94..1e883a6b1 100644 --- a/c/mapping/function_manager.h +++ b/c/mapping/function_manager.h @@ -13,7 +13,7 @@ // be called: pvstate it its own state (whatever that is), and it defines its // own process and free functions implementing this interface. -typedef mlhmmv_value_t udf_defsite_process_func_t(void* pvstate, int arity, mv_t* pargs, variables_t* pvars); +typedef mlhmmv_xvalue_t udf_defsite_process_func_t(void* pvstate, int arity, mv_t* pargs, variables_t* pvars); typedef void udf_defsite_free_func_t(void* pvstate); typedef struct _udf_defsite_state_t { diff --git a/c/mapping/mapper_put_or_filter.c b/c/mapping/mapper_put_or_filter.c index 91ab61014..4b69f4f9d 100644 --- a/c/mapping/mapper_put_or_filter.c +++ b/c/mapping/mapper_put_or_filter.c @@ -502,7 +502,7 @@ static sllv_t* mapper_put_or_filter_process(lrec_t* pinrec, context_t* pctx, voi .ploop_stack = pstate->ploop_stack, .return_state = { .returned = FALSE, - .retval = mlhmmv_value_wrap_terminal(mv_absent()), + .retval = mlhmmv_xvalue_wrap_terminal(mv_absent()), }, .trace_execution = pstate->trace_execution, }; @@ -531,7 +531,7 @@ static sllv_t* mapper_put_or_filter_process(lrec_t* pinrec, context_t* pctx, voi .ploop_stack = pstate->ploop_stack, .return_state = { .returned = FALSE, - .retval = mlhmmv_value_wrap_terminal(mv_absent()), + .retval = mlhmmv_xvalue_wrap_terminal(mv_absent()), }, .trace_execution = pstate->trace_execution, }; @@ -564,7 +564,7 @@ static sllv_t* mapper_put_or_filter_process(lrec_t* pinrec, context_t* pctx, voi .ploop_stack = pstate->ploop_stack, .return_state = { .returned = FALSE, - .retval = mlhmmv_value_wrap_terminal(mv_absent()), + .retval = mlhmmv_xvalue_wrap_terminal(mv_absent()), }, .trace_execution = pstate->trace_execution, }; diff --git a/c/mapping/mlr_dsl_cst_for_map_statements.c b/c/mapping/mlr_dsl_cst_for_map_statements.c index 0dfda532b..16777bd87 100644 --- a/c/mapping/mlr_dsl_cst_for_map_statements.c +++ b/c/mapping/mlr_dsl_cst_for_map_statements.c @@ -8,7 +8,7 @@ static void handle_for_oosvar_aux( mlr_dsl_cst_statement_t* pstatement, variables_t* pvars, cst_outputs_t* pcst_outputs, - mlhmmv_value_t submap, + mlhmmv_xvalue_t submap, char** prest_for_k_variable_names, int* prest_for_k_frame_relative_indices, int* prest_for_k_frame_type_masks, @@ -18,7 +18,7 @@ static void handle_for_local_map_aux( mlr_dsl_cst_statement_t* pstatement, variables_t* pvars, cst_outputs_t* pcst_outputs, - mlhmmv_value_t submap, + mlhmmv_xvalue_t submap, char** prest_for_k_variable_names, int* prest_for_k_frame_relative_indices, int* prest_for_k_frame_type_masks, @@ -28,7 +28,7 @@ static void handle_for_map_literal_aux( mlr_dsl_cst_statement_t* pstatement, variables_t* pvars, cst_outputs_t* pcst_outputs, - mlhmmv_value_t* psubmap, + mlhmmv_xvalue_t* psubmap, char** prest_for_k_variable_names, int* prest_for_k_frame_relative_indices, int* prest_for_k_frame_type_masks, @@ -179,7 +179,7 @@ static void handle_for_oosvar( // Locate and copy the submap indexed by the keylist. E.g. in 'for ((k1, k2), v in @a[3][$4]) { ... }', the // submap is indexed by ["a", 3, $4]. Copy it for the very likely case that it is being updated inside the // for-loop. - mlhmmv_value_t submap = mlhmmv_root_copy_xvalue(pvars->poosvars, ptarget_keylist); + mlhmmv_xvalue_t submap = mlhmmv_root_copy_xvalue(pvars->poosvars, ptarget_keylist); if (!submap.is_terminal && submap.pnext_level != NULL) { // Recurse over the for-k-names, e.g. ["k1", "k2"], on each call descending one level @@ -199,7 +199,7 @@ static void handle_for_oosvar( } } - mlhmmv_value_free(submap); + mlhmmv_xvalue_free(submap); loop_stack_pop(pvars->ploop_stack); local_stack_subframe_exit(pframe, pstatement->pblock->subframe_var_count); @@ -211,7 +211,7 @@ static void handle_for_oosvar_aux( mlr_dsl_cst_statement_t* pstatement, variables_t* pvars, cst_outputs_t* pcst_outputs, - mlhmmv_value_t submap, + mlhmmv_xvalue_t submap, char** prest_for_k_variable_names, int* prest_for_k_frame_relative_indices, int* prest_for_k_type_masks, @@ -523,11 +523,11 @@ static void handle_for_local_map( // indexed by [3, $4]. Copy it for the very likely case that it is being updated inside the // for-loop. - mlhmmv_value_t *psubmap = local_stack_frame_get_extended_from_indexed(pframe, + mlhmmv_xvalue_t *psubmap = local_stack_frame_get_extended_from_indexed(pframe, pstate->target_frame_relative_index, ptarget_keylist); if (psubmap != NULL) { - mlhmmv_value_t submap = mlhmmv_value_copy(psubmap); + mlhmmv_xvalue_t submap = mlhmmv_xvalue_copy(psubmap); local_stack_subframe_enter(pframe, pstatement->pblock->subframe_var_count); loop_stack_push(pvars->ploop_stack); @@ -550,7 +550,7 @@ static void handle_for_local_map( } } - mlhmmv_value_free(submap); + mlhmmv_xvalue_free(submap); loop_stack_pop(pvars->ploop_stack); local_stack_subframe_exit(pframe, pstatement->pblock->subframe_var_count); @@ -563,7 +563,7 @@ static void handle_for_local_map_aux( mlr_dsl_cst_statement_t* pstatement, variables_t* pvars, cst_outputs_t* pcst_outputs, - mlhmmv_value_t submap, + mlhmmv_xvalue_t submap, char** prest_for_k_variable_names, int* prest_for_k_frame_relative_indices, int* prest_for_k_type_masks, @@ -719,9 +719,9 @@ static void handle_for_local_map_key_only( local_stack_frame_t* pframe = local_stack_get_top_frame(pvars->plocal_stack); - mlhmmv_value_t *psubmap = local_stack_frame_get_extended_from_indexed(pframe, + mlhmmv_xvalue_t *psubmap = local_stack_frame_get_extended_from_indexed(pframe, pstate->target_frame_relative_index, ptarget_keylist); - sllv_t* pkeys = mlhmmv_value_copy_keys(psubmap, NULL); // xxx refactor w/o null + sllv_t* pkeys = mlhmmv_xvalue_copy_keys(psubmap, NULL); // xxx refactor w/o null local_stack_subframe_enter(pframe, pstatement->pblock->subframe_var_count); loop_stack_push(pvars->ploop_stack); @@ -896,7 +896,7 @@ static void handle_for_map_literal( } if (boxed_xval.is_ephemeral) { - mlhmmv_value_free(boxed_xval.xval); + mlhmmv_xvalue_free(boxed_xval.xval); } loop_stack_pop(pvars->ploop_stack); @@ -907,7 +907,7 @@ static void handle_for_map_literal_aux( mlr_dsl_cst_statement_t* pstatement, variables_t* pvars, cst_outputs_t* pcst_outputs, - mlhmmv_value_t* psubmap, + mlhmmv_xvalue_t* psubmap, char** prest_for_k_variable_names, int* prest_for_k_frame_relative_indices, int* prest_for_k_type_masks, @@ -1043,7 +1043,7 @@ static void handle_for_map_literal_key_only( boxed_xval_t boxed_xval = pstate->ptarget_xevaluator->pprocess_func( pstate->ptarget_xevaluator->pvstate, pvars); - sllv_t* pkeys = mlhmmv_value_copy_keys(&boxed_xval.xval, NULL); // xxx refactor w/o null + sllv_t* pkeys = mlhmmv_xvalue_copy_keys(&boxed_xval.xval, NULL); // xxx refactor w/o null local_stack_frame_t* pframe = local_stack_get_top_frame(pvars->plocal_stack); local_stack_subframe_enter(pframe, pstatement->pblock->subframe_var_count); @@ -1075,6 +1075,6 @@ static void handle_for_map_literal_key_only( sllv_free(pkeys); if (boxed_xval.is_ephemeral) { - mlhmmv_value_free(boxed_xval.xval); // xxx rename + mlhmmv_xvalue_free(boxed_xval.xval); // xxx rename } } diff --git a/c/mapping/mlr_dsl_cst_func_subr.c b/c/mapping/mlr_dsl_cst_func_subr.c index fa9499640..d4474da85 100644 --- a/c/mapping/mlr_dsl_cst_func_subr.c +++ b/c/mapping/mlr_dsl_cst_func_subr.c @@ -4,7 +4,7 @@ #include "mlr_dsl_cst.h" #include "context_flags.h" -static mlhmmv_value_t cst_udf_process_callback(void* pvstate, int arity, mv_t* args, variables_t* pvars); +static mlhmmv_xvalue_t cst_udf_process_callback(void* pvstate, int arity, mv_t* args, variables_t* pvars); static void cst_udf_free_callback(void* pvstate); // ---------------------------------------------------------------- @@ -127,10 +127,10 @@ void mlr_dsl_cst_free_udf(cst_udf_state_t* pstate) { // ---------------------------------------------------------------- // Callback function for the function manager to invoke into here -static mlhmmv_value_t cst_udf_process_callback(void* pvstate, int arity, mv_t* args, variables_t* pvars) { +static mlhmmv_xvalue_t cst_udf_process_callback(void* pvstate, int arity, mv_t* args, variables_t* pvars) { cst_udf_state_t* pstate = pvstate; cst_top_level_statement_block_t* ptop_level_block = pstate->ptop_level_block; - mlhmmv_value_t retval = mlhmmv_value_wrap_terminal(mv_absent()); + mlhmmv_xvalue_t retval = mlhmmv_xvalue_wrap_terminal(mv_absent()); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Push stack and bind parameters to arguments @@ -162,7 +162,7 @@ static mlhmmv_value_t cst_udf_process_callback(void* pvstate, int arity, mv_t* a } if (pvars->return_state.returned) { retval = pvars->return_state.retval; // xxx mapvar - pvars->return_state.retval = mlhmmv_value_wrap_terminal(mv_absent()); + pvars->return_state.retval = mlhmmv_xvalue_wrap_terminal(mv_absent()); pvars->return_state.returned = FALSE; break; } @@ -177,7 +177,7 @@ static mlhmmv_value_t cst_udf_process_callback(void* pvstate, int arity, mv_t* a } if (pvars->return_state.returned) { retval = pvars->return_state.retval; // xxx mapvar - pvars->return_state.retval = mlhmmv_value_wrap_terminal(mv_absent()); + pvars->return_state.retval = mlhmmv_xvalue_wrap_terminal(mv_absent()); pvars->return_state.returned = FALSE; break; } @@ -412,7 +412,7 @@ void mlr_dsl_cst_free_subroutine(subr_defsite_t* pstate) { } // ---------------------------------------------------------------- -void mlr_dsl_cst_execute_subroutine(subr_defsite_t* pstate, variables_t* pvars, // xxx mv_t -> mlhmmv_value_t +void mlr_dsl_cst_execute_subroutine(subr_defsite_t* pstate, variables_t* pvars, // xxx mv_t -> mlhmmv_xvalue_t cst_outputs_t* pcst_outputs, int callsite_arity, mv_t* args) { cst_top_level_statement_block_t* ptop_level_block = pstate->ptop_level_block; diff --git a/c/mapping/mlr_dsl_cst_map_assignment_statements.c b/c/mapping/mlr_dsl_cst_map_assignment_statements.c index 4aa937334..8c32069ff 100644 --- a/c/mapping/mlr_dsl_cst_map_assignment_statements.c +++ b/c/mapping/mlr_dsl_cst_map_assignment_statements.c @@ -88,7 +88,7 @@ static void handle_full_srec_assignment( if (!boxed_xval.xval.is_terminal) { for (mlhmmv_level_entry_t* pe = boxed_xval.xval.pnext_level->phead; pe != NULL; pe = pe->pnext) { mv_t* pkey = &pe->level_key; - mlhmmv_value_t* pval = &pe->level_value; + mlhmmv_xvalue_t* pval = &pe->level_value; if (pval->is_terminal) { // xxx else collapse-down using json separator? char* skey = mv_alloc_format_val(pkey); @@ -112,10 +112,10 @@ static void handle_full_srec_assignment( } } if (boxed_xval.is_ephemeral) { - mlhmmv_value_free(boxed_xval.xval); + mlhmmv_xvalue_free(boxed_xval.xval); } } else { - mlhmmv_value_free(boxed_xval.xval); + mlhmmv_xvalue_free(boxed_xval.xval); } } @@ -192,7 +192,7 @@ static void handle_local_variable_definition_from_xval( } else { local_stack_frame_define_extended(pframe, pstate->lhs_variable_name, pstate->lhs_frame_relative_index, pstate->lhs_type_mask, - mlhmmv_value_copy(&boxed_xval.xval)); + mlhmmv_xvalue_copy(&boxed_xval.xval)); } } @@ -271,7 +271,7 @@ static void handle_nonindexed_local_variable_assignment_from_xval( boxed_xval.xval); } else { local_stack_frame_assign_extended_nonindexed(pframe, pstate->lhs_frame_relative_index, - mlhmmv_value_copy(&boxed_xval.xval)); + mlhmmv_xvalue_copy(&boxed_xval.xval)); } } } @@ -361,7 +361,7 @@ static void handle_indexed_local_variable_assignment_from_xval( pmvkeys, boxed_xval.xval); } else { local_stack_frame_assign_extended_indexed(pframe, pstate->lhs_frame_relative_index, - pmvkeys, mlhmmv_value_copy(&boxed_xval.xval)); + pmvkeys, mlhmmv_xvalue_copy(&boxed_xval.xval)); } } @@ -448,7 +448,7 @@ static void handle_oosvar_assignment_from_xval( if (boxed_xval.is_ephemeral) { mlhmmv_level_put_xvalue(pvars->poosvars->proot_level, plhskeys->phead, &boxed_xval.xval); } else { - mlhmmv_value_t copy_xval = mlhmmv_value_copy(&boxed_xval.xval); + mlhmmv_xvalue_t copy_xval = mlhmmv_xvalue_copy(&boxed_xval.xval); mlhmmv_level_put_xvalue(pvars->poosvars->proot_level, plhskeys->phead, ©_xval); } } diff --git a/c/mapping/mlr_dsl_cst_output_statements.c b/c/mapping/mlr_dsl_cst_output_statements.c index cbd33ef1e..3ccf0ad59 100644 --- a/c/mapping/mlr_dsl_cst_output_statements.c +++ b/c/mapping/mlr_dsl_cst_output_statements.c @@ -869,7 +869,7 @@ static void record_emitter_from_local_variable( if (names_all_non_null_or_error) { local_stack_frame_t* pframe = local_stack_get_top_frame(pvars->plocal_stack); - mlhmmv_value_t* pmval = local_stack_frame_get_extended_from_indexed(pframe, + mlhmmv_xvalue_t* pmval = local_stack_frame_get_extended_from_indexed(pframe, pstate->localvar_frame_relative_index, NULL); if (pmval != NULL) { @@ -938,7 +938,7 @@ static void record_emitter_from_map_literal( } if (boxed_xval.is_ephemeral) { - mlhmmv_value_free(boxed_xval.xval); + mlhmmv_xvalue_free(boxed_xval.xval); } sllmv_free(pmvkeys); @@ -1277,7 +1277,7 @@ static void handle_emit_lashed_common( boxed_xval_t* pboxed_xvals = mlr_malloc_or_die( pstate->num_emit_lashed_items * sizeof(boxed_xval_t)); // xxx comment - mlhmmv_value_t** ptop_values = mlr_malloc_or_die( + mlhmmv_xvalue_t** ptop_values = mlr_malloc_or_die( pstate->num_emit_lashed_items * sizeof(mlhmmv_level_entry_t*)); for (int i = 0; i < pstate->num_emit_lashed_items; i++) { emit_lashed_item_t* pitem = pstate->ppitems[i]; @@ -1291,7 +1291,7 @@ static void handle_emit_lashed_common( for (int i = 0; i < pstate->num_emit_lashed_items; i++) { if (pboxed_xvals[i].is_ephemeral) { - mlhmmv_value_free(pboxed_xvals[i].xval); + mlhmmv_xvalue_free(pboxed_xvals[i].xval); } } @@ -1404,7 +1404,7 @@ static void handle_dump( } if (!boxed_xval.xval.is_terminal && boxed_xval.is_ephemeral) { - mlhmmv_value_free(boxed_xval.xval); + mlhmmv_xvalue_free(boxed_xval.xval); } } @@ -1440,6 +1440,6 @@ static void handle_dump_to_file( mv_free(&filename_mv); if (!boxed_xval.xval.is_terminal && boxed_xval.is_ephemeral) { - mlhmmv_value_free(boxed_xval.xval); + mlhmmv_xvalue_free(boxed_xval.xval); } } diff --git a/c/mapping/mlr_dsl_cst_return_statements.c b/c/mapping/mlr_dsl_cst_return_statements.c index 9680c5674..1f71ca727 100644 --- a/c/mapping/mlr_dsl_cst_return_statements.c +++ b/c/mapping/mlr_dsl_cst_return_statements.c @@ -178,7 +178,7 @@ static void handle_return_value_from_local_non_map_variable( { return_value_from_local_non_map_variable_state_t* pstate = pstatement->pvstate; - pvars->return_state.retval = mlhmmv_value_wrap_terminal( // xxx mapvars + pvars->return_state.retval = mlhmmv_xvalue_wrap_terminal( // xxx mapvars pstate->preturn_value_evaluator->pprocess_func( pstate->preturn_value_evaluator->pvstate, pvars)); pvars->return_state.returned = TRUE; @@ -249,17 +249,17 @@ static void handle_return_value_from_indexed_local_variable( if (all_non_null_or_error) { local_stack_frame_t* pframe = local_stack_get_top_frame(pvars->plocal_stack); - mlhmmv_value_t* pmvalue = local_stack_frame_get_extended_from_indexed(pframe, + mlhmmv_xvalue_t* pmvalue = local_stack_frame_get_extended_from_indexed(pframe, pstate->rhs_frame_relative_index, pmvkeys); if (pmvalue == NULL) { - pvars->return_state.retval = mlhmmv_value_wrap_terminal(mv_absent()); + pvars->return_state.retval = mlhmmv_xvalue_wrap_terminal(mv_absent()); } else { - pvars->return_state.retval = mlhmmv_value_copy(pmvalue); + pvars->return_state.retval = mlhmmv_xvalue_copy(pmvalue); } } else { - pvars->return_state.retval = mlhmmv_value_wrap_terminal(mv_absent()); + pvars->return_state.retval = mlhmmv_xvalue_wrap_terminal(mv_absent()); } sllmv_free(pmvkeys); @@ -314,7 +314,7 @@ static void handle_return_value_from_oosvar( { return_value_from_oosvar_state_t* pstate = pstatement->pvstate; - pvars->return_state.retval = mlhmmv_value_wrap_terminal( // xxx mapvars + pvars->return_state.retval = mlhmmv_xvalue_wrap_terminal( // xxx mapvars pstate->preturn_value_evaluator->pprocess_func( pstate->preturn_value_evaluator->pvstate, pvars)); pvars->return_state.returned = TRUE; @@ -367,7 +367,7 @@ static void handle_return_value_from_full_oosvar( { return_value_from_full_oosvar_state_t* pstate = pstatement->pvstate; - pvars->return_state.retval = mlhmmv_value_wrap_terminal( // xxx mapvars + pvars->return_state.retval = mlhmmv_xvalue_wrap_terminal( // xxx mapvars pstate->preturn_value_evaluator->pprocess_func( pstate->preturn_value_evaluator->pvstate, pvars)); pvars->return_state.returned = TRUE; @@ -420,7 +420,7 @@ static void handle_return_value_from_full_srec( { return_value_from_full_srec_state_t* pstate = pstatement->pvstate; - pvars->return_state.retval = mlhmmv_value_wrap_terminal( // xxx mapvars + pvars->return_state.retval = mlhmmv_xvalue_wrap_terminal( // xxx mapvars pstate->preturn_value_evaluator->pprocess_func( pstate->preturn_value_evaluator->pvstate, pvars)); pvars->return_state.returned = TRUE; @@ -473,7 +473,7 @@ static void handle_return_value_from_function_callsite( { return_value_from_function_callsite_state_t* pstate = pstatement->pvstate; - pvars->return_state.retval = mlhmmv_value_wrap_terminal( // xxx mapvars + pvars->return_state.retval = mlhmmv_xvalue_wrap_terminal( // xxx mapvars pstate->preturn_value_evaluator->pprocess_func( pstate->preturn_value_evaluator->pvstate, pvars)); pvars->return_state.returned = TRUE; @@ -526,7 +526,7 @@ static void handle_return_value_from_non_map_valued( { return_value_from_non_map_valued_state_t* pstate = pstatement->pvstate; - pvars->return_state.retval = mlhmmv_value_wrap_terminal( // xxx mapvars + pvars->return_state.retval = mlhmmv_xvalue_wrap_terminal( // xxx mapvars pstate->preturn_value_evaluator->pprocess_func( pstate->preturn_value_evaluator->pvstate, pvars)); pvars->return_state.returned = TRUE; diff --git a/c/mapping/rval_evaluator.h b/c/mapping/rval_evaluator.h index acfb4cf18..792b8448e 100644 --- a/c/mapping/rval_evaluator.h +++ b/c/mapping/rval_evaluator.h @@ -40,7 +40,7 @@ // ---------------------------------------------------------------- // xxx needs to be in a different header file typedef struct _return_state_t { - mlhmmv_value_t retval; + mlhmmv_xvalue_t retval; int returned; } return_state_t; @@ -82,7 +82,7 @@ typedef struct _rval_evaluator_t { // data copied out of srecs. It is FALSE when the pointer is into an existing // data structure's memory (e.g. oosvars or locals). typedef struct _boxed_xval_t { - mlhmmv_value_t xval; + mlhmmv_xvalue_t xval; int is_ephemeral; } boxed_xval_t; diff --git a/c/mapping/rxval_expr_evaluators.c b/c/mapping/rxval_expr_evaluators.c index fd2470acb..0aa16bb8d 100644 --- a/c/mapping/rxval_expr_evaluators.c +++ b/c/mapping/rxval_expr_evaluators.c @@ -189,7 +189,7 @@ static void rxval_evaluator_from_map_literal_aux( sllmve_t e = { .value = mvkey, .free_flags = 0, .pnext = NULL }; boxed_xval_t boxed_xval = pkvpair->pxval_evaluator->pprocess_func(pkvpair->pxval_evaluator->pvstate, pvars); if (!boxed_xval.xval.is_terminal && !boxed_xval.is_ephemeral) { - mlhmmv_value_t copy_xval = mlhmmv_value_copy(&boxed_xval.xval); + mlhmmv_xvalue_t copy_xval = mlhmmv_xvalue_copy(&boxed_xval.xval); mlhmmv_level_put_xvalue(plevel, &e, ©_xval); } else { mlhmmv_level_put_xvalue(plevel, &e, &boxed_xval.xval); @@ -205,7 +205,7 @@ static void rxval_evaluator_from_map_literal_aux( static boxed_xval_t rxval_evaluator_from_map_literal_func(void* pvstate, variables_t* pvars) { rxval_evaluator_from_map_literal_state_t* pstate = pvstate; - mlhmmv_value_t xval = mlhmmv_value_alloc_empty_map(); + mlhmmv_xvalue_t xval = mlhmmv_xvalue_alloc_empty_map(); rxval_evaluator_from_map_literal_aux(pstate, pstate->proot_list_evaluator, xval.pnext_level, pvars); @@ -263,11 +263,11 @@ typedef struct _rxval_evaluator_from_nonindexed_local_variable_state_t { static boxed_xval_t rxval_evaluator_from_nonindexed_local_variable_func(void* pvstate, variables_t* pvars) { rxval_evaluator_from_nonindexed_local_variable_state_t* pstate = pvstate; local_stack_frame_t* pframe = local_stack_get_top_frame(pvars->plocal_stack); - mlhmmv_value_t* pxval = local_stack_frame_get_extended_from_indexed( + mlhmmv_xvalue_t* pxval = local_stack_frame_get_extended_from_indexed( pframe, pstate->vardef_frame_relative_index, NULL); if (pxval == NULL) { return (boxed_xval_t) { - .xval = mlhmmv_value_wrap_terminal(mv_absent()), + .xval = mlhmmv_xvalue_wrap_terminal(mv_absent()), .is_ephemeral = FALSE, }; } else { @@ -314,12 +314,12 @@ static boxed_xval_t rxval_evaluator_from_indexed_local_variable_func(void* pvsta if (all_non_null_or_error) { local_stack_frame_t* pframe = local_stack_get_top_frame(pvars->plocal_stack); - mlhmmv_value_t* pxval = local_stack_frame_get_extended_from_indexed(pframe, pstate->vardef_frame_relative_index, + mlhmmv_xvalue_t* pxval = local_stack_frame_get_extended_from_indexed(pframe, pstate->vardef_frame_relative_index, pmvkeys); sllmv_free(pmvkeys); if (pxval == NULL) { return (boxed_xval_t) { - .xval = mlhmmv_value_wrap_terminal(mv_absent()), + .xval = mlhmmv_xvalue_wrap_terminal(mv_absent()), .is_ephemeral = FALSE, }; } else { @@ -331,7 +331,7 @@ static boxed_xval_t rxval_evaluator_from_indexed_local_variable_func(void* pvsta } else { sllmv_free(pmvkeys); return (boxed_xval_t) { - .xval = mlhmmv_value_wrap_terminal(mv_absent()), + .xval = mlhmmv_xvalue_wrap_terminal(mv_absent()), .is_ephemeral = TRUE, }; } @@ -379,7 +379,7 @@ static boxed_xval_t rxval_evaluator_from_oosvar_keylist_func(void* pvstate, vari if (all_non_null_or_error) { int lookup_error = FALSE; - mlhmmv_value_t* pxval = mlhmmv_level_look_up_and_ref_xvalue(pvars->poosvars->proot_level, + mlhmmv_xvalue_t* pxval = mlhmmv_level_look_up_and_ref_xvalue(pvars->poosvars->proot_level, pmvkeys, &lookup_error); sllmv_free(pmvkeys); if (pxval != NULL) { @@ -389,14 +389,14 @@ static boxed_xval_t rxval_evaluator_from_oosvar_keylist_func(void* pvstate, vari }; } else { return (boxed_xval_t) { - .xval = mlhmmv_value_wrap_terminal(mv_absent()), + .xval = mlhmmv_xvalue_wrap_terminal(mv_absent()), .is_ephemeral = TRUE, }; } } else { sllmv_free(pmvkeys); return (boxed_xval_t) { - .xval = mlhmmv_value_wrap_terminal(mv_absent()), + .xval = mlhmmv_xvalue_wrap_terminal(mv_absent()), .is_ephemeral = TRUE, }; } @@ -433,7 +433,7 @@ rxval_evaluator_t* rxval_evaluator_alloc_from_oosvar_keylist( static boxed_xval_t rxval_evaluator_from_full_oosvar_func(void* pvstate, variables_t* pvars) { return (boxed_xval_t) { .is_ephemeral = FALSE, - .xval = (mlhmmv_value_t) { + .xval = (mlhmmv_xvalue_t) { .is_terminal = FALSE, .pnext_level = pvars->poosvars->proot_level, }, @@ -458,7 +458,7 @@ rxval_evaluator_t* rxval_evaluator_alloc_from_full_oosvar( static boxed_xval_t rxval_evaluator_from_full_srec_func(void* pvstate, variables_t* pvars) { boxed_xval_t boxed_xval; boxed_xval.is_ephemeral = TRUE; - boxed_xval.xval = mlhmmv_value_alloc_empty_map(); + boxed_xval.xval = mlhmmv_xvalue_alloc_empty_map(); for (lrece_t* pe = pvars->pinrec->phead; pe != NULL; pe = pe->pnext) { // mlhmmv_level_put_terminal will copy mv keys and values so we needn't (and shouldn't) @@ -501,7 +501,7 @@ static boxed_xval_t rxval_evaluator_wrapping_rval_func(void* pvstate, variables_ rval_evaluator_t* prval_evaluator = pstate->prval_evaluator; mv_t val = prval_evaluator->pprocess_func(prval_evaluator->pvstate, pvars); return (boxed_xval_t) { - .xval = mlhmmv_value_wrap_terminal(val), + .xval = mlhmmv_xvalue_wrap_terminal(val), .is_ephemeral = FALSE, // verify reference semantics for RHS evaluators! }; }