name-neatening

This commit is contained in:
John Kerl 2016-11-22 23:32:21 -05:00
parent 83812f9c9b
commit 6270af47ea
9 changed files with 68 additions and 68 deletions

View file

@ -14,7 +14,7 @@ static local_stack_frame_t* _local_stack_alloc(int size, int ephemeral) {
pframe->pvars = mlr_malloc_or_die(size * sizeof(local_stack_frame_entry_t));
for (int i = 0; i < size; i++) {
local_stack_frame_entry_t* pentry = &pframe->pvars[i];
pentry->value.mlrval = mv_absent(); // xxx make method
pentry->value.terminal_mlrval = mv_absent(); // xxx make method
pentry->value.pnext_level = NULL; // xxx make method
pentry->name = NULL;
// Any type can be written here, unless otherwise specified by a typed definition
@ -34,7 +34,7 @@ void local_stack_frame_free(local_stack_frame_t* pframe) {
if (pframe == NULL)
return;
for (int i = 0; i < pframe->size; i++) {
mv_free(&pframe->pvars[i].value.mlrval); // xxx temp
mv_free(&pframe->pvars[i].value.terminal_mlrval); // xxx temp
}
free(pframe->pvars);
free(pframe);
@ -56,9 +56,9 @@ local_stack_frame_t* local_stack_frame_enter(local_stack_frame_t* pframe) {
// ----------------------------------------------------------------
void local_stack_frame_exit (local_stack_frame_t* pframe) {
MLR_INTERNAL_CODING_ERROR_UNLESS(mv_is_absent(&pframe->pvars[0].value.mlrval)); // xxx temp
MLR_INTERNAL_CODING_ERROR_UNLESS(mv_is_absent(&pframe->pvars[0].value.terminal_mlrval)); // xxx temp
for (int i = 0; i < pframe->size; i++)
mv_free(&pframe->pvars[i].value.mlrval); // xxx temp
mv_free(&pframe->pvars[i].value.terminal_mlrval); // xxx temp
if (!pframe->ephemeral) {
pframe->in_use = FALSE;
LOCAL_STACK_TRACE(printf("LOCAL STACK FRAME NON-EPH EXIT %p %d\n", pframe, pframe->size));
@ -112,7 +112,7 @@ mv_t local_stack_frame_get_scalar_from_indexed(local_stack_frame_t* pframe, // x
if (pbase_xval == NULL) {
printf("VALUE IS NULL\n");
} else if (pbase_xval->is_terminal) {
char* s = mv_alloc_format_val(&pbase_xval->mlrval);
char* s = mv_alloc_format_val(&pbase_xval->terminal_mlrval);
printf("VALUE IS %s\n", s);
free(s);
} else if (pbase_xval->pnext_level == NULL) {
@ -140,7 +140,7 @@ mv_t local_stack_frame_get_scalar_from_indexed(local_stack_frame_t* pframe, // x
if (pxval == NULL) {
return mv_absent();
} else if (pxval->is_terminal) {
return mv_copy(&pxval->mlrval);
return mv_copy(&pxval->terminal_mlrval);
} else {
return mv_absent();
}
@ -161,7 +161,7 @@ mlhmmv_value_t* local_stack_frame_get_extended_from_indexed(local_stack_frame_t*
if (pmvalue == NULL) {
printf("VALUE IS NULL\n");
} else if (pmvalue->is_terminal) {
char* s = mv_alloc_format_val(&pmvalue->mlrval);
char* s = mv_alloc_format_val(&pmvalue->terminal_mlrval);
printf("VALUE IS %s\n", s);
free(s);
} else if (pmvalue->pnext_level == NULL) {
@ -200,7 +200,7 @@ void local_stack_frame_assign_scalar_indexed(local_stack_frame_t* pframe,
// xxx encapsulate
if (pmvalue->is_terminal) {
mv_free(&pmvalue->mlrval);
mv_free(&pmvalue->terminal_mlrval);
pmvalue->is_terminal = FALSE;
pmvalue->pnext_level = mlhmmv_level_alloc();
}
@ -226,7 +226,7 @@ void local_stack_frame_assign_extended_indexed(local_stack_frame_t* pframe, // x
// xxx encapsulate
if (pmvalue->is_terminal) {
mv_free(&pmvalue->mlrval);
mv_free(&pmvalue->terminal_mlrval);
pmvalue->is_terminal = FALSE;
pmvalue->pnext_level = mlhmmv_level_alloc();
}
@ -274,10 +274,10 @@ void local_stack_frame_throw_type_mismatch(local_stack_frame_entry_t* pentry, mv
void local_stack_frame_throw_type_xmismatch(local_stack_frame_entry_t* pentry, mlhmmv_value_t* pxval) {
MLR_INTERNAL_CODING_ERROR_IF(pentry->name == NULL);
char* sval = mv_alloc_format_val_quoting_strings(&pxval->mlrval); // xxx temp
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",
MLR_GLOBALS.bargv0, type_mask_to_desc(pentry->type_mask), pentry->name,
sval, mt_describe_type_simple(pxval->mlrval.type)); // xxx temp -- needs xtype
sval, mt_describe_type_simple(pxval->terminal_mlrval.type)); // xxx temp -- needs xtype
free(sval);
exit(1);
}

View file

@ -95,7 +95,7 @@ static inline mv_t local_stack_frame_get_scalar_from_nonindexed(local_stack_fram
local_stack_frame_entry_t* pentry = &pframe->pvars[vardef_frame_relative_index];
mlhmmv_value_t* pvalue = &pentry->value;
if (pvalue != NULL && pvalue->is_terminal) {
return pvalue->mlrval;
return pvalue->terminal_mlrval;
} else {
return mv_absent();
}
@ -122,8 +122,8 @@ static inline void local_stack_frame_define_scalar(local_stack_frame_t* pframe,
local_stack_frame_throw_type_mismatch(pentry, &val);
}
mv_free(&pentry->value.mlrval); // xxx temp -- make value-free
pentry->value.mlrval = mv_absent();
mv_free(&pentry->value.terminal_mlrval); // xxx temp -- make value-free
pentry->value.terminal_mlrval = mv_absent();
if (mv_is_absent(&val)) {
mv_free(&val); // xxx confusing ownership semantics
@ -144,17 +144,17 @@ static inline void local_stack_frame_define_extended(local_stack_frame_t* pframe
// xxx subroutineize
if (xval.is_terminal) {
if (!(type_mask_from_mv(&xval.mlrval) & pentry->type_mask)) { // xxx temp
local_stack_frame_throw_type_mismatch(pentry, &xval.mlrval);
if (!(type_mask_from_mv(&xval.terminal_mlrval) & pentry->type_mask)) { // xxx temp
local_stack_frame_throw_type_mismatch(pentry, &xval.terminal_mlrval);
}
} else {
if (!(TYPE_MASK_MAP & pentry->type_mask)) { // xxx temp
local_stack_frame_throw_type_mismatch(pentry, &xval.mlrval); // xxx allow xvals
local_stack_frame_throw_type_mismatch(pentry, &xval.terminal_mlrval); // xxx allow xvals
}
}
// xxx temp -- make a single method
if (xval.is_terminal && mv_is_absent(&xval.mlrval)) {
if (xval.is_terminal && mv_is_absent(&xval.terminal_mlrval)) {
mlhmmv_free_submap(xval); // xxx confusing ownership semantics
} else {
mlhmmv_free_submap(pentry->value); // xxx rename
@ -176,7 +176,7 @@ static inline void local_stack_frame_assign_scalar_nonindexed(local_stack_frame_
}
// xxx temp -- make a single method
mv_free(&pentry->value.mlrval); // xxx temp -- make value-free
mv_free(&pentry->value.terminal_mlrval); // xxx temp -- make value-free
pentry->value = mlhmmv_value_transfer_terminal(val); // xxx deep-copy?
}
@ -189,17 +189,17 @@ static inline void local_stack_frame_assign_extended_nonindexed(local_stack_fram
// xxx subroutineize
if (xval.is_terminal) {
if (!(type_mask_from_mv(&xval.mlrval) & pentry->type_mask)) { // xxx temp
local_stack_frame_throw_type_mismatch(pentry, &xval.mlrval);
if (!(type_mask_from_mv(&xval.terminal_mlrval) & pentry->type_mask)) { // xxx temp
local_stack_frame_throw_type_mismatch(pentry, &xval.terminal_mlrval);
}
} else {
if (!(TYPE_MASK_MAP & pentry->type_mask)) { // xxx temp
local_stack_frame_throw_type_mismatch(pentry, &xval.mlrval); // xxx allow xvals
local_stack_frame_throw_type_mismatch(pentry, &xval.terminal_mlrval); // xxx allow xvals
}
}
// xxx temp -- make a single method
mv_free(&pentry->value.mlrval); // xxx temp -- make value-free
mv_free(&pentry->value.terminal_mlrval); // xxx temp -- make value-free
// xxx temp -- make a single method
mlhmmv_free_submap(pentry->value); // xxx rename
@ -227,7 +227,7 @@ static inline void local_stack_subframe_enter(local_stack_frame_t* pframe, int c
LOCAL_STACK_BOUNDS_CHECK(pframe, "CLEAR", FALSE, pframe->subframe_base+i);
local_stack_frame_entry_t* pentry = &psubframe[i];
pentry->value.is_terminal = TRUE; // xxx make inline method in mlhmmv for all of this
mv_reset(&pentry->value.mlrval);
mv_reset(&pentry->value.terminal_mlrval);
pentry->type_mask = TYPE_MASK_ANY;
}
pframe->subframe_base += count;

View file

@ -132,7 +132,7 @@ void mlhmmv_free(mlhmmv_t* pmap) {
static void mlhmmv_level_free(mlhmmv_level_t* plevel) {
for (mlhmmv_level_entry_t* pentry = plevel->phead; pentry != NULL; pentry = pentry->pnext) {
if (pentry->level_value.is_terminal) {
mv_free(&pentry->level_value.mlrval);
mv_free(&pentry->level_value.terminal_mlrval);
} else {
mlhmmv_level_free(pentry->level_value.pnext_level);
}
@ -213,7 +213,7 @@ static void mlhmmv_level_put_no_enlarge(mlhmmv_level_t* plevel, sllmve_t* prest_
if (prest_keys->pnext == NULL) {
pentry->level_value.is_terminal = TRUE;
pentry->level_value.mlrval = mv_copy(pterminal_value);
pentry->level_value.terminal_mlrval = mv_copy(pterminal_value);
} else {
pentry->level_value.is_terminal = FALSE;
pentry->level_value.pnext_level = mlhmmv_level_alloc();
@ -241,16 +241,16 @@ static void mlhmmv_level_put_no_enlarge(mlhmmv_level_t* plevel, sllmve_t* prest_
} else if (plevel->states[index] == OCCUPIED) { // Existing key found in chain
if (prest_keys->pnext == NULL) { // Place the terminal at this level
if (pentry->level_value.is_terminal) {
mv_free(&pentry->level_value.mlrval);
mv_free(&pentry->level_value.terminal_mlrval);
} else {
mlhmmv_level_free(pentry->level_value.pnext_level);
}
pentry->level_value.is_terminal = TRUE;
pentry->level_value.mlrval = mv_copy(pterminal_value);
pentry->level_value.terminal_mlrval = mv_copy(pterminal_value);
} else { // The terminal will be placed at a deeper level
if (pentry->level_value.is_terminal) {
mv_free(&pentry->level_value.mlrval);
mv_free(&pentry->level_value.terminal_mlrval);
pentry->level_value.is_terminal = FALSE;
pentry->level_value.pnext_level = mlhmmv_level_alloc();
}
@ -339,7 +339,7 @@ mv_t* mlhmmv_get_terminal(mlhmmv_t* pmap, sllmv_t* pmvkeys, int* perror) {
*perror = MLHMMV_ERROR_KEYLIST_TOO_SHALLOW;
return NULL;
}
return &plevel_entry->level_value.mlrval;
return &plevel_entry->level_value.terminal_mlrval;
}
mv_t* mlhmmv_get_terminal_from_level(mlhmmv_level_t* plevel, sllmv_t* pmvkeys, int* perror) {
@ -351,7 +351,7 @@ mv_t* mlhmmv_get_terminal_from_level(mlhmmv_level_t* plevel, sllmv_t* pmvkeys, i
*perror = MLHMMV_ERROR_KEYLIST_TOO_SHALLOW;
return NULL;
}
return &plevel_entry->level_value.mlrval;
return &plevel_entry->level_value.terminal_mlrval;
}
// ----------------------------------------------------------------
@ -431,7 +431,7 @@ static mlhmmv_level_t* mlhmmv_get_or_create_level_aux_no_enlarge(mlhmmv_level_t*
} else if (plevel->states[index] == OCCUPIED) { // Existing key found in chain
if (pentry->level_value.is_terminal) {
mv_free(&pentry->level_value.mlrval);
mv_free(&pentry->level_value.terminal_mlrval);
pentry->level_value.is_terminal = FALSE;
pentry->level_value.pnext_level = mlhmmv_level_alloc();
}
@ -599,7 +599,7 @@ static void mlhmmv_remove_aux(mlhmmv_level_t* plevel, sllmve_t* prestkeys, int*
pentry->pnext->pprev = pentry->pprev;
}
if (pentry->level_value.is_terminal) {
mv_free(&pentry->level_value.mlrval);
mv_free(&pentry->level_value.terminal_mlrval);
} else {
mlhmmv_level_free(pentry->level_value.pnext_level);
}
@ -640,7 +640,7 @@ static void mlhmmv_remove_aux(mlhmmv_level_t* plevel, sllmve_t* prestkeys, int*
// 2. Free the memory for the node and its descendants
if (pentry->level_value.is_terminal) {
mv_free(&pentry->level_value.mlrval);
mv_free(&pentry->level_value.terminal_mlrval);
} else {
mlhmmv_level_free(pentry->level_value.pnext_level);
}
@ -655,7 +655,7 @@ void mlhmmv_clear_level(mlhmmv_level_t* plevel) {
for (mlhmmv_level_entry_t* pentry = plevel->phead; pentry != NULL; pentry = pentry->pnext) {
if (pentry->level_value.is_terminal) {
mv_free(&pentry->level_value.mlrval);
mv_free(&pentry->level_value.terminal_mlrval);
} else {
mlhmmv_level_free(pentry->level_value.pnext_level);
}
@ -684,7 +684,7 @@ mlhmmv_value_t mlhmmv_copy_aux(mlhmmv_value_t* pvalue) { // xxx rename
if (pvalue->is_terminal) {
return (mlhmmv_value_t) {
.is_terminal = TRUE,
.mlrval = mv_copy(&pvalue->mlrval),
.terminal_mlrval = mv_copy(&pvalue->terminal_mlrval),
.pnext_level = NULL,
};
@ -706,7 +706,7 @@ mlhmmv_value_t mlhmmv_copy_aux(mlhmmv_value_t* pvalue) { // xxx rename
return (mlhmmv_value_t) {
.is_terminal = FALSE,
.mlrval = mv_absent(),
.terminal_mlrval = mv_absent(),
.pnext_level = pdst_level,
};
}
@ -728,7 +728,7 @@ mlhmmv_value_t mlhmmv_copy_submap_from_root(mlhmmv_t* pmap, sllmv_t* pmvkeys) {
} else {
return (mlhmmv_value_t) {
.is_terminal = FALSE,
.mlrval = mv_absent(),
.terminal_mlrval = mv_absent(),
.pnext_level = NULL,
};
}
@ -737,7 +737,7 @@ mlhmmv_value_t mlhmmv_copy_submap_from_root(mlhmmv_t* pmap, sllmv_t* pmvkeys) {
void mlhmmv_free_submap(mlhmmv_value_t submap) {
if (submap.is_terminal) {
mv_free(&submap.mlrval);
mv_free(&submap.terminal_mlrval);
} else if (submap.pnext_level != NULL) {
mlhmmv_level_free(submap.pnext_level);
}
@ -846,7 +846,7 @@ static void mlhmmv_level_put_value_no_enlarge(mlhmmv_level_t* plevel, sllmve_t*
} else if (plevel->states[index] == OCCUPIED) { // Existing key found in chain
if (prest_keys->pnext == NULL) { // Place the terminal at this level
if (pentry->level_value.is_terminal) {
mv_free(&pentry->level_value.mlrval);
mv_free(&pentry->level_value.terminal_mlrval);
} else {
mlhmmv_level_free(pentry->level_value.pnext_level);
}
@ -854,7 +854,7 @@ static void mlhmmv_level_put_value_no_enlarge(mlhmmv_level_t* plevel, sllmve_t*
} else { // The terminal will be placed at a deeper level
if (pentry->level_value.is_terminal) {
mv_free(&pentry->level_value.mlrval);
mv_free(&pentry->level_value.terminal_mlrval);
pentry->level_value.is_terminal = FALSE;
pentry->level_value.pnext_level = mlhmmv_level_alloc();
}
@ -980,7 +980,7 @@ void mlhmmv_to_lrecs(mlhmmv_t* pmap, sllmv_t* pkeys, sllmv_t* pnames, sllv_t* po
lrec_t* poutrec = lrec_unbacked_alloc();
lrec_put(poutrec,
mv_alloc_format_val(pfirstkey),
mv_alloc_format_val(&ptop_entry->level_value.mlrval), FREE_ENTRY_KEY|FREE_ENTRY_VALUE);
mv_alloc_format_val(&ptop_entry->level_value.terminal_mlrval), FREE_ENTRY_KEY|FREE_ENTRY_VALUE);
sllv_append(poutrecs, poutrec);
} else {
// E.g. '@v = {...}' at the top level of the mlhmmv: the map value keyed by oosvar-name 'v' is itself a hashmap.
@ -1021,7 +1021,7 @@ void mlhmmv_level_to_lrecs(mlhmmv_level_t* plevel, sllmv_t* pkeys, sllmv_t* pnam
lrec_t* poutrec = lrec_unbacked_alloc();
lrec_put(poutrec,
mv_alloc_format_val(pfirstkey),
mv_alloc_format_val(&ptop_entry->level_value.mlrval), FREE_ENTRY_KEY|FREE_ENTRY_VALUE);
mv_alloc_format_val(&ptop_entry->level_value.terminal_mlrval), FREE_ENTRY_KEY|FREE_ENTRY_VALUE);
sllv_append(poutrecs, poutrec);
} else {
// E.g. '@v = {...}' at the top level of the mlhmmv: the map value keyed by oosvar-name 'v' is itself a hashmap.
@ -1057,7 +1057,7 @@ static void mlhmmv_to_lrecs_aux_across_records(
if (plevel_value->is_terminal) {
lrec_put(pnextrec,
mlr_strdup_or_die(prefix),
mv_alloc_format_val(&plevel_value->mlrval), FREE_ENTRY_KEY|FREE_ENTRY_VALUE);
mv_alloc_format_val(&plevel_value->terminal_mlrval), FREE_ENTRY_KEY|FREE_ENTRY_VALUE);
sllv_append(poutrecs, pnextrec);
} else {
mlhmmv_to_lrecs_aux_across_records(pe->level_value.pnext_level,
@ -1081,7 +1081,7 @@ static void mlhmmv_to_lrecs_aux_across_records(
free(temp);
lrec_put(pnextrec,
next_prefix,
mv_alloc_format_val(&plevel_value->mlrval),
mv_alloc_format_val(&plevel_value->terminal_mlrval),
FREE_ENTRY_KEY|FREE_ENTRY_VALUE);
} else if (do_full_prefixing) {
char* temp = mv_alloc_format_val(&pe->level_key);
@ -1120,7 +1120,7 @@ static void mlhmmv_to_lrecs_aux_within_record(
if (plevel_value->is_terminal) {
lrec_put(poutrec,
next_prefix,
mv_alloc_format_val(&plevel_value->mlrval),
mv_alloc_format_val(&plevel_value->terminal_mlrval),
FREE_ENTRY_KEY|FREE_ENTRY_VALUE);
} else {
mlhmmv_to_lrecs_aux_within_record(plevel_value->pnext_level, next_prefix, poutrec,
@ -1138,14 +1138,14 @@ void mlhmmv_to_lrecs_lashed(mlhmmv_value_t** ptop_values, int num_submaps, mv_t*
// First is primary and rest are lashed to it (lookups with same keys as primary).
if (ptop_values[0] == NULL) {
// No such entry in the mlhmmv results in no output records
} else if (ptop_values[0]->is_terminal && mv_is_present(&ptop_values[0]->mlrval)) {
} else if (ptop_values[0]->is_terminal && mv_is_present(&ptop_values[0]->terminal_mlrval)) {
lrec_t* poutrec = lrec_unbacked_alloc();
for (int i = 0; i < num_submaps; i++) {
// E.g. '@v = 3' at the top level of the mlhmmv.
if (ptop_values[i]->is_terminal && mv_is_present(&ptop_values[i]->mlrval)) {
if (ptop_values[i]->is_terminal && mv_is_present(&ptop_values[i]->terminal_mlrval)) {
lrec_put(poutrec,
mv_alloc_format_val(&pbasenames[i]),
mv_alloc_format_val(&ptop_values[i]->mlrval), FREE_ENTRY_KEY|FREE_ENTRY_VALUE);
mv_alloc_format_val(&ptop_values[i]->terminal_mlrval), FREE_ENTRY_KEY|FREE_ENTRY_VALUE);
}
}
sllv_append(poutrecs, poutrec);
@ -1213,7 +1213,7 @@ static void mlhmmv_to_lrecs_aux_across_records_lashed(
if (plevel_value != NULL && plevel_value->is_terminal) {
lrec_put(pnextrec,
mlr_strdup_or_die(prefixes[i]),
mv_alloc_format_val(&plevel_value->mlrval), FREE_ENTRY_KEY|FREE_ENTRY_VALUE);
mv_alloc_format_val(&plevel_value->terminal_mlrval), FREE_ENTRY_KEY|FREE_ENTRY_VALUE);
}
}
sllv_append(poutrecs, pnextrec);
@ -1253,7 +1253,7 @@ static void mlhmmv_to_lrecs_aux_across_records_lashed(
: mlr_strdup_or_die(temp);
lrec_put(pnextrec,
name,
mv_alloc_format_val(&plevel_value->mlrval),
mv_alloc_format_val(&plevel_value->terminal_mlrval),
FREE_ENTRY_KEY|FREE_ENTRY_VALUE);
}
}
@ -1327,7 +1327,7 @@ static void mlhmmv_to_lrecs_aux_within_record_lashed(
: mlr_strdup_or_die(temp);
lrec_put(poutrec,
name,
mv_alloc_format_val(&plevel_value->mlrval),
mv_alloc_format_val(&plevel_value->terminal_mlrval),
FREE_ENTRY_KEY|FREE_ENTRY_VALUE);
}
}
@ -1418,7 +1418,7 @@ void mlhmmv_level_print_stacked(mlhmmv_level_t* plevel, int depth,
fprintf(ostream, ": ");
if (pentry->level_value.is_terminal) {
mlhmmv_print_terminal(&pentry->level_value.mlrval, quote_values_always, ostream);
mlhmmv_print_terminal(&pentry->level_value.terminal_mlrval, quote_values_always, ostream);
if (pentry->pnext != NULL)
fprintf(ostream, ",\n");
@ -1457,11 +1457,11 @@ static void mlhmmv_level_print_single_line(mlhmmv_level_t* plevel, int depth,
fprintf(ostream, ": ");
if (pentry->level_value.is_terminal) {
char* level_value_string = mv_alloc_format_val(&pentry->level_value.mlrval);
char* level_value_string = mv_alloc_format_val(&pentry->level_value.terminal_mlrval);
if (quote_values_always) {
fprintf(ostream, "\"%s\"", level_value_string);
} else if (pentry->level_value.mlrval.type == MT_STRING) {
} else if (pentry->level_value.terminal_mlrval.type == MT_STRING) {
double unused;
if (mlr_try_float_from_string(level_value_string, &unused)) {
fprintf(ostream, "%s", level_value_string);

View file

@ -33,7 +33,7 @@ struct _mlhmmv_level_t; // forward reference
typedef struct _mlhmmv_value_t {
int is_terminal;
// xxx needs absent/null initters respectively in the .c file
mv_t mlrval; // xxx rename to terminal_mlrval
mv_t terminal_mlrval;
struct _mlhmmv_level_t* pnext_level;
} mlhmmv_value_t;
@ -54,7 +54,7 @@ typedef unsigned char mlhmmv_level_entry_state_t;
//
// This is a hot path for non-map local-variable assignments.
static inline mlhmmv_value_t mlhmmv_value_transfer_terminal(mv_t val) { // xxx temp?
return (mlhmmv_value_t) {.is_terminal = TRUE, .mlrval = val, .pnext_level = NULL};
return (mlhmmv_value_t) {.is_terminal = TRUE, .terminal_mlrval = val, .pnext_level = NULL};
}
// ----------------------------------------------------------------

View file

@ -453,7 +453,7 @@ static mv_t rval_evaluator_udf_callsite_process(void* pvstate, variables_t* pvar
pstate->pdefsite_state->pvstate, pstate->arity, pstate->args, pvars);
if (retval.is_terminal) {
return retval.mlrval;
return retval.terminal_mlrval;
} else {
return mv_absent();
}

View file

@ -253,7 +253,7 @@ static void handle_for_oosvar_aux(
// Bind the v-name to the terminal mlrval:
local_stack_frame_t* pframe = local_stack_get_top_frame(pvars->plocal_stack);
local_stack_frame_define_scalar(pframe, pstate->v_variable_name, pstate->v_frame_relative_index,
pstate->v_type_mask, mv_copy(&submap.mlrval));
pstate->v_type_mask, mv_copy(&submap.terminal_mlrval));
// Execute the loop-body statements:
pstatement->pblock_handler(pstatement->pblock, pvars, pcst_outputs);
}
@ -605,7 +605,7 @@ static void handle_for_local_map_aux(
// Bind the v-name to the terminal mlrval:
local_stack_frame_t* pframe = local_stack_get_top_frame(pvars->plocal_stack);
local_stack_frame_define_scalar(pframe, pstate->v_variable_name, pstate->v_frame_relative_index,
pstate->v_type_mask, mv_copy(&submap.mlrval));
pstate->v_type_mask, mv_copy(&submap.terminal_mlrval));
// Execute the loop-body statements:
pstatement->pblock_handler(pstatement->pblock, pvars, pcst_outputs);
}
@ -949,7 +949,7 @@ static void handle_for_map_literal_aux(
// Bind the v-name to the terminal mlrval:
local_stack_frame_t* pframe = local_stack_get_top_frame(pvars->plocal_stack);
local_stack_frame_define_scalar(pframe, pstate->v_variable_name, pstate->v_frame_relative_index,
pstate->v_type_mask, mv_copy(&psubmap->mlrval));
pstate->v_type_mask, mv_copy(&psubmap->terminal_mlrval));
// Execute the loop-body statements:
pstatement->pblock_handler(pstatement->pblock, pvars, pcst_outputs);
}

View file

@ -92,7 +92,7 @@ static void handle_full_srec_assignment(
if (pval->is_terminal) { // xxx else collapse-down using json separator?
char* skey = mv_alloc_format_val(pkey);
mv_t val = boxed_xval.is_ephemeral ? pval->mlrval : mv_copy(&pval->mlrval);
mv_t val = boxed_xval.is_ephemeral ? pval->terminal_mlrval : mv_copy(&pval->terminal_mlrval);
// Write typed mlrval output to the typed overlay rather than into the lrec
// (which holds only string values).
//
@ -264,7 +264,7 @@ static void handle_nonindexed_local_variable_assignment_from_xval(
rxval_evaluator_t* prhs_xevaluator = pstate->prhs_xevaluator;
boxed_xval_t boxed_xval = prhs_xevaluator->pprocess_func(prhs_xevaluator->pvstate, pvars);
if (!boxed_xval.xval.is_terminal || mv_is_present(&boxed_xval.xval.mlrval)) {
if (!boxed_xval.xval.is_terminal || mv_is_present(&boxed_xval.xval.terminal_mlrval)) {
local_stack_frame_t* pframe = local_stack_get_top_frame(pvars->plocal_stack);
if (boxed_xval.is_ephemeral) {
local_stack_frame_assign_extended_nonindexed(pframe, pstate->lhs_frame_relative_index,
@ -354,7 +354,7 @@ static void handle_indexed_local_variable_assignment_from_xval(
rxval_evaluator_t* prhs_xevaluator = pstate->prhs_xevaluator;
boxed_xval_t boxed_xval = prhs_xevaluator->pprocess_func(prhs_xevaluator->pvstate, pvars);
if (!boxed_xval.xval.is_terminal || mv_is_present(&boxed_xval.xval.mlrval)) {
if (!boxed_xval.xval.is_terminal || mv_is_present(&boxed_xval.xval.terminal_mlrval)) {
local_stack_frame_t* pframe = local_stack_get_top_frame(pvars->plocal_stack);
if (boxed_xval.is_ephemeral) {
local_stack_frame_assign_extended_indexed(pframe, pstate->lhs_frame_relative_index,
@ -444,7 +444,7 @@ static void handle_oosvar_assignment_from_xval(
rxval_evaluator_t* prhs_xevaluator = pstate->prhs_xevaluator;
boxed_xval_t boxed_xval = prhs_xevaluator->pprocess_func(prhs_xevaluator->pvstate, pvars);
if (!boxed_xval.xval.is_terminal || mv_is_present(&boxed_xval.xval.mlrval)) {
if (!boxed_xval.xval.is_terminal || mv_is_present(&boxed_xval.xval.terminal_mlrval)) {
if (boxed_xval.is_ephemeral) {
mlhmmv_put_value_at_level_aux(pvars->poosvars->proot_level, plhskeys->phead, &boxed_xval.xval);
} else {

View file

@ -1397,7 +1397,7 @@ static void handle_dump(
boxed_xval_t boxed_xval = ptarget_xevaluator->pprocess_func(ptarget_xevaluator->pvstate, pvars);
if (boxed_xval.xval.is_terminal) {
mlhmmv_print_terminal(&boxed_xval.xval.mlrval, FALSE, pstate->stdfp);
mlhmmv_print_terminal(&boxed_xval.xval.terminal_mlrval, FALSE, pstate->stdfp);
fprintf(pstate->stdfp, "\n");
} else {
mlhmmv_level_print_stacked(boxed_xval.xval.pnext_level, 0, FALSE, FALSE, "", pstate->stdfp); // xxx mk simpler call w/ dfl args
@ -1426,7 +1426,7 @@ static void handle_dump_to_file(
boxed_xval_t boxed_xval = ptarget_xevaluator->pprocess_func(ptarget_xevaluator->pvstate, pvars);
if (boxed_xval.xval.is_terminal) {
mlhmmv_print_terminal(&boxed_xval.xval.mlrval, FALSE, outfp);
mlhmmv_print_terminal(&boxed_xval.xval.terminal_mlrval, FALSE, outfp);
fprintf(outfp, "\n");
} else if (boxed_xval.xval.pnext_level != NULL) {
mlhmmv_level_print_stacked(boxed_xval.xval.pnext_level, 0, FALSE, FALSE, "", outfp); // xxx mk simpler call w/ dfl args

View file

@ -31,8 +31,8 @@ MAPVAR CHECKLIST:
* debt-reduction
~ get a grip on copy/reference semantics for all mv cases.
- valgrinds
! vg.out.000 @neatener !
- xxxes
- xval.is_terminal -> xval_is_terminal(&xval) reading pnext_level == NULL. omit separate flag.
- prune unused functions
! get rid of ALL callsites where i return mv/mxv by struct-value but do not copy string-pointers
- local-stack renames