Skip to content

Commit

Permalink
split into separate function
Browse files Browse the repository at this point in the history
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
  • Loading branch information
NikolajBjorner committed Jan 9, 2023
1 parent 5899fe3 commit 49ee570
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
17 changes: 12 additions & 5 deletions src/ast/rewriter/array_rewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,9 @@ bool array_rewriter::squash_store(unsigned n, expr* const* args, expr_ref& resul
}


br_status array_rewriter::mk_select_core(unsigned num_args, expr * const * args, expr_ref & result) {
SASSERT(num_args >= 2);
expr *arg0 = args[0];
br_status array_rewriter::mk_select_same_store(unsigned num_args, expr * const * args, expr_ref & result) {
expr_ref tmp(m());
expr *arg0 = args[0];
bool first = true;

#define RET(x, status) \
Expand Down Expand Up @@ -228,9 +227,9 @@ br_status array_rewriter::mk_select_core(unsigned num_args, expr * const * args,
if (first) {
result = to_app(arg0)->get_arg(num_args);
first = false;
} else if (result != to_app(arg0)->get_arg(num_args)) {
goto exit;
}
else if (result != to_app(arg0)->get_arg(num_args))
goto exit;
arg0 = to_app(arg0)->get_arg(0);
continue;
}
Expand Down Expand Up @@ -281,6 +280,14 @@ br_status array_rewriter::mk_select_core(unsigned num_args, expr * const * args,
}

exit:
return BR_FAILED;
}

br_status array_rewriter::mk_select_core(unsigned num_args, expr * const * args, expr_ref & result) {
SASSERT(num_args >= 2);
br_status st = mk_select_same_store(num_args, args, result);
if (st != BR_FAILED)
return st;
result.reset();

if (m_util.is_store(args[0])) {
Expand Down
9 changes: 5 additions & 4 deletions src/ast/rewriter/array_rewriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ class array_rewriter {
expr_ref expand_store(expr* s);

bool squash_store(unsigned n, expr* const* args, expr_ref& result);

br_status mk_store_core(unsigned num_args, expr * const * args, expr_ref & result);
br_status mk_select_core(unsigned num_args, expr * const * args, expr_ref & result);
br_status mk_select_same_store(unsigned num_args, expr * const * args, expr_ref & result);
br_status mk_map_core(func_decl * f, unsigned num_args, expr * const * args, expr_ref & result);

public:
array_rewriter(ast_manager & m, params_ref const & p = params_ref()):
Expand All @@ -63,10 +68,6 @@ class array_rewriter {

br_status mk_app_core(func_decl * f, unsigned num_args, expr * const * args, expr_ref & result);

br_status mk_store_core(unsigned num_args, expr * const * args, expr_ref & result);
br_status mk_select_core(unsigned num_args, expr * const * args, expr_ref & result);
br_status mk_map_core(func_decl * f, unsigned num_args, expr * const * args, expr_ref & result);

void mk_store(unsigned num_args, expr * const * args, expr_ref & result);
void mk_select(unsigned num_args, expr * const * args, expr_ref & result);
void mk_map(func_decl * f, unsigned num_args, expr * const * args, expr_ref & result);
Expand Down

0 comments on commit 49ee570

Please sign in to comment.