| 249 | /*******************************************************************/ |
| 250 | |
| 251 | struct amrex_parser* |
| 252 | amrex_parser_new () |
| 253 | { |
| 254 | auto *my_parser = (struct amrex_parser*) std::malloc(sizeof(struct amrex_parser)); |
| 255 | |
| 256 | my_parser->sz_mempool = parser_ast_size(parser_workspace.root); |
| 257 | my_parser->p_root = std::malloc(my_parser->sz_mempool); |
| 258 | my_parser->p_free = my_parser->p_root; |
| 259 | |
| 260 | my_parser->ast = parser_ast_dup(my_parser, parser_workspace.root); |
| 261 | |
| 262 | amrex_parser_delete_ptrs(); |
| 263 | |
| 264 | if ((char*)my_parser->p_root + my_parser->sz_mempool != (char*)my_parser->p_free) { |
| 265 | amrex::Abort("amrex_parser_new: error in memory size"); |
| 266 | } |
| 267 | |
| 268 | std::map<std::string,double> local_consts; |
| 269 | parser_ast_optimize(my_parser->ast, local_consts); |
| 270 | if (my_parser->ast == nullptr) { |
| 271 | amrex::Abort("amrex::Parser: expression optimizes to nothing"); |
| 272 | } |
| 273 | parser_ast_sort(my_parser->ast); |
| 274 | |
| 275 | return my_parser; |
| 276 | } |
| 277 | |
| 278 | void |
| 279 | amrex_parser_delete (struct amrex_parser* parser) |
no test coverage detected