mirror of
https://github.com/Z3Prover/z3
synced 2025-05-09 00:35:47 +00:00
Z3 sources
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
3f9edad676
commit
e9eab22e5c
1186 changed files with 381859 additions and 0 deletions
45
lib/for_each_ast.cpp
Normal file
45
lib/for_each_ast.cpp
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*++
|
||||
Copyright (c) 2006 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
for_each_ast.cpp
|
||||
|
||||
Abstract:
|
||||
|
||||
For each ast visitor
|
||||
|
||||
Author:
|
||||
|
||||
Leonardo de Moura (leonardo) 2006-10-18.
|
||||
|
||||
Revision History:
|
||||
|
||||
--*/
|
||||
|
||||
#include"for_each_ast.h"
|
||||
|
||||
struct ast_counter_proc {
|
||||
unsigned m_num;
|
||||
ast_counter_proc():m_num(0) {}
|
||||
void operator()(ast *) { m_num++; }
|
||||
};
|
||||
|
||||
unsigned get_num_nodes(ast * n) {
|
||||
for_each_ast_proc<ast_counter_proc> counter;
|
||||
for_each_ast(counter, n);
|
||||
return counter.m_num;
|
||||
}
|
||||
|
||||
|
||||
bool for_each_parameter(ptr_vector<ast> & stack, ast_mark & visited, unsigned num_args, parameter const * params) {
|
||||
bool result = true;
|
||||
for (unsigned i = 0; i < num_args; i++) {
|
||||
parameter const& p = params[i];
|
||||
if (p.is_ast() && !visited.is_marked(p.get_ast())) {
|
||||
stack.push_back(p.get_ast());
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue