mirror of
https://github.com/johnkerl/miller.git
synced 2026-07-22 07:30:43 +00:00
clean up mapvar typecheck
This commit is contained in:
parent
f3e898ec5f
commit
7698471e6a
4 changed files with 26 additions and 21 deletions
|
|
@ -123,7 +123,11 @@ static inline void local_stack_frame_define(local_stack_frame_t* pframe, char* v
|
|||
|
||||
// xxx temp -- make a single method
|
||||
mv_free(&pentry->value.u.mlrval); // xxx temp -- make value-free
|
||||
pentry->value = mlhmmv_value_transfer_terminal(val); // xxx deep-copy?
|
||||
if (mv_is_absent(&val)) {
|
||||
mv_free(&val); // xxx confusing ownership semantics
|
||||
} else {
|
||||
pentry->value = mlhmmv_value_transfer_terminal(val); // xxx deep-copy?
|
||||
}
|
||||
}
|
||||
|
||||
static inline void local_stack_frame_xdefine(local_stack_frame_t* pframe, char* variable_name, // xxx rename
|
||||
|
|
@ -148,8 +152,12 @@ static inline void local_stack_frame_xdefine(local_stack_frame_t* pframe, char*
|
|||
}
|
||||
|
||||
// xxx temp -- make a single method
|
||||
mlhmmv_free_submap(pentry->value); // xxx rename
|
||||
pentry->value = xval;
|
||||
if (xval.is_terminal && mv_is_absent(&xval.u.mlrval)) {
|
||||
mlhmmv_free_submap(xval); // xxx confusing ownership semantics
|
||||
} else {
|
||||
mlhmmv_free_submap(pentry->value); // xxx rename
|
||||
pentry->value = xval;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -239,14 +239,11 @@ static void handle_local_variable_definition_from_val( // xxx mapvar
|
|||
|
||||
rval_evaluator_t* prhs_evaluator = pstate->prhs_evaluator;
|
||||
mv_t val = prhs_evaluator->pprocess_func(prhs_evaluator->pvstate, pvars);
|
||||
if (mv_is_present(&val)) {
|
||||
local_stack_frame_t* pframe = local_stack_get_top_frame(pvars->plocal_stack);
|
||||
local_stack_frame_define(pframe,
|
||||
pstate->lhs_variable_name, pstate->lhs_frame_relative_index,
|
||||
pstate->lhs_type_mask, val);
|
||||
} else {
|
||||
mv_free(&val);
|
||||
}
|
||||
|
||||
local_stack_frame_t* pframe = local_stack_get_top_frame(pvars->plocal_stack);
|
||||
local_stack_frame_define(pframe,
|
||||
pstate->lhs_variable_name, pstate->lhs_frame_relative_index,
|
||||
pstate->lhs_type_mask, val);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
|
@ -260,14 +257,10 @@ static void handle_local_variable_definition_from_xval( // xxx mapvar
|
|||
rxval_evaluator_t* prhs_xevaluator = pstate->prhs_xevaluator;
|
||||
mlhmmv_value_t xval = prhs_xevaluator->pprocess_func(prhs_xevaluator->pvstate, pvars);
|
||||
|
||||
if (!xval.is_terminal || mv_is_present(&xval.u.mlrval)) { // xxx funcify
|
||||
local_stack_frame_t* pframe = local_stack_get_top_frame(pvars->plocal_stack);
|
||||
local_stack_frame_xdefine(pframe, // xxx rename
|
||||
pstate->lhs_variable_name, pstate->lhs_frame_relative_index, pstate->lhs_type_mask,
|
||||
xval);
|
||||
} else {
|
||||
mlhmmv_free_submap(xval); // xxx rename
|
||||
}
|
||||
local_stack_frame_t* pframe = local_stack_get_top_frame(pvars->plocal_stack);
|
||||
local_stack_frame_xdefine(pframe, // xxx rename
|
||||
pstate->lhs_variable_name, pstate->lhs_frame_relative_index, pstate->lhs_type_mask,
|
||||
xval);
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
|
|
|
|||
|
|
@ -5375,7 +5375,7 @@ run_mlr --from $indir/xyz2 put -q 'c[1][2] = 3; @o = c; dump @o'
|
|||
announce MAPVAR ASSIGNMENTS TO MAP-TYPED LOCAL
|
||||
|
||||
run_mlr --from $indir/xyz2 put -q 'map o = {"a":1, "b": {"x":8,"y":9}, "c":3}; dump o'
|
||||
run_mlr --from $indir/xyz2 put -q 'map o = @o; dump o'
|
||||
mlr_expect_fail --from $indir/xyz2 put -q 'map o = @o; dump o'
|
||||
run_mlr --from $indir/xyz2 put -q 'map o = {"a":1, "b": {"x":8,"y":9}, "c":3}; o = o; dump o'
|
||||
mlr_expect_fail --from $indir/xyz2 put -q '@a = 1; map o = @a; dump o'
|
||||
run_mlr --from $indir/xyz2 put -q '@b[1] = 2; map o = @b; dump o'
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
================================================================
|
||||
BUGFIXES
|
||||
|
||||
:D
|
||||
* mlr --from ./reg_test/input/xyz2 put -q 'a = 1; map o = a; dump o'
|
||||
UMR?
|
||||
|
||||
================================================================
|
||||
NON-RELEASE:
|
||||
|
|
@ -117,6 +118,9 @@ k assign LHS localvar ? assign RHS oosvar
|
|||
k assign LHS localvar ? assign RHS localvar
|
||||
- assign LHS localvar ? assign RHS func-retval
|
||||
|
||||
----------------------------------------------------------------
|
||||
* 'not yet' UT cases
|
||||
|
||||
----------------------------------------------------------------
|
||||
! we are going to need builtin functions which deal with maps.
|
||||
- length(@map) and length(map), proxy for NF. make it work with length({...}) and length($*).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue