Skip to content

Commit d54376b

Browse files
committed
Add push and pop commands
1 parent cc4dbaa commit d54376b

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed

src/solvers/smt2_incremental/smt_commands.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,25 @@ const smt_termt &smt_get_value_commandt::descriptor() const
121121
{
122122
return downcast(find(ID_value));
123123
}
124+
125+
smt_push_commandt::smt_push_commandt(std::size_t levels)
126+
: smt_commandt(ID_smt_push_command)
127+
{
128+
set_size_t(ID_value, levels);
129+
}
130+
131+
size_t smt_push_commandt::levels() const
132+
{
133+
return get_size_t(ID_value);
134+
}
135+
136+
smt_pop_commandt::smt_pop_commandt(std::size_t levels)
137+
: smt_commandt(ID_smt_pop_command)
138+
{
139+
set_size_t(ID_value, levels);
140+
}
141+
142+
size_t smt_pop_commandt::levels() const
143+
{
144+
return get_size_t(ID_value);
145+
}

src/solvers/smt2_incremental/smt_commands.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@ COMMAND_ID(declare_function)
1010
COMMAND_ID(define_function)
1111
COMMAND_ID(exit)
1212
COMMAND_ID(get_value)
13+
COMMAND_ID(pop)
14+
COMMAND_ID(push)
1315
COMMAND_ID(set_logic)
1416
COMMAND_ID(set_option)

src/solvers/smt2_incremental/smt_commands.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,20 @@ class smt_get_value_commandt : public smt_commandt,
7979
const smt_termt &descriptor() const;
8080
};
8181

82+
class smt_push_commandt : public smt_commandt
83+
{
84+
public:
85+
explicit smt_push_commandt(std::size_t levels);
86+
size_t levels() const;
87+
};
88+
89+
class smt_pop_commandt : public smt_commandt
90+
{
91+
public:
92+
explicit smt_pop_commandt(std::size_t levels);
93+
size_t levels() const;
94+
};
95+
8296
class smt_set_logic_commandt : public smt_commandt
8397
{
8498
public:

unit/solvers/smt2_incremental/smt_commands.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,15 @@ TEST_CASE("smt_commandt equality", "[core][smt2_incremental]")
7676
const smt_assert_commandt assert_false{smt_bool_literal_termt{false}};
7777
CHECK_FALSE(assert_true == assert_false);
7878
}
79+
80+
TEST_CASE("smt_push_commandt level", "[core][smt2_incremental]")
81+
{
82+
CHECK(smt_push_commandt(1).levels() == 1);
83+
CHECK(smt_push_commandt(2).levels() == 2);
84+
}
85+
86+
TEST_CASE("smt_pop_commandt level", "[core][smt2_incremental]")
87+
{
88+
CHECK(smt_pop_commandt(1).levels() == 1);
89+
CHECK(smt_pop_commandt(2).levels() == 2);
90+
}

0 commit comments

Comments
 (0)