From 4ed8e1b5c54ada2027b7dab4dfd08ef9c09acdd9 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Mon, 3 Oct 2016 18:28:08 -0400 Subject: [PATCH] neaten --- c/mapping/mapper_put_or_filter.c | 3 ++- c/mapping/mlr_dsl_cst.c | 1 - c/mapping/mlr_dsl_cst.h | 4 ++-- c/todo.txt | 14 +++++++------- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/c/mapping/mapper_put_or_filter.c b/c/mapping/mapper_put_or_filter.c index 009d7e1be..d212df6a0 100644 --- a/c/mapping/mapper_put_or_filter.c +++ b/c/mapping/mapper_put_or_filter.c @@ -407,8 +407,9 @@ static void mapper_put_or_filter_free(mapper_t* pmapper) { mlhmmv_free(pstate->poosvars); bind_stack_free(pstate->pbind_stack); loop_stack_free(pstate->ploop_stack); - // The AST is pointed to by the CST and will be freed by the CST destructor mlr_dsl_cst_free(pstate->pcst); + // Free what's left of the stripped AST after the CST reorganized it. + mlr_dsl_ast_free(pstate->past); free(pstate->pwriter_opts); free(pstate); diff --git a/c/mapping/mlr_dsl_cst.c b/c/mapping/mlr_dsl_cst.c index 40218ee75..f68493864 100644 --- a/c/mapping/mlr_dsl_cst.c +++ b/c/mapping/mlr_dsl_cst.c @@ -195,7 +195,6 @@ void mlr_dsl_cst_free(mlr_dsl_cst_t* pcst) { } analyzed_ast_free(pcst->paast); - mlr_dsl_ast_free(pcst->past); free(pcst); } diff --git a/c/mapping/mlr_dsl_cst.h b/c/mapping/mlr_dsl_cst.h index a59a60cce..ee2831f79 100644 --- a/c/mapping/mlr_dsl_cst.h +++ b/c/mapping/mlr_dsl_cst.h @@ -249,8 +249,8 @@ typedef struct _mlr_dsl_cst_t { // Notes: // * do_final_filter is FALSE for mlr put, TRUE for mlr filter. // * negate_final_filter is TRUE for mlr filter -x. -// * The CST object retains the AST pointer (in order to reuse its strings etc. with minimal copying) -// and will free the AST in the CST destructor. +// * The CST object strips nodes off the raw AST, constructed by the Lemon parser, in order +// to do analysis on it. Nonetheless the caller should free what's left. mlr_dsl_cst_t* mlr_dsl_cst_alloc(mlr_dsl_ast_t* past, int type_inferencing, int flush_every_record, int do_final_filter, int negate_final_filter); diff --git a/c/todo.txt b/c/todo.txt index d8aaaf193..fd712a2cc 100644 --- a/c/todo.txt +++ b/c/todo.txt @@ -19,13 +19,13 @@ FUNCTIONALITY FOR 4.6.0: (issue is computation is dominated by lhmsv_get/put/string_hash_func.) o 1st AST pass: pivot around to have begin, end, main, funcs, subrs - - all begin statements -> one list - - all end statements -> one list - - all func defs -> one list - - all subr defs -> one list - - all else -> main-statements list - - sllv_pop/append to make it quick - ? cst_pre_analyze_t struct or some such? + k all begin statements -> one list + k all end statements -> one list + k all func defs -> one list + k all subr defs -> one list + k all else -> main-statements list + k sllv_pop/append to make it quick + k cst_pre_analyze_t struct or some such? ? ctor-0 frindex field @ mlr_dsl_ast_node_t? o 2nd AST pass: analyze each for max depth: local def, write, read. adapt existing lmhsv/resolve logic. o 3rd AST pass: rewrite localvar names w/ frame-relative indices