SOLVER_StateT Solver::countSAT() { retStateT state = RESOLVED; while (true) { while (component_analyzer_.findNextRemainingComponentOf(stack_.top())) { decideLiteral(); if (stopwatch_.timeBoundBroken()) return TIMEOUT; if (stopwatch_.interval_tick()) printOnlineStats(); while (!bcp()) { state = resolveConflict(); if (state == BACKTRACK) break; } if (state == BACKTRACK) break; } state = backtrack(); if (state == EXIT) return SUCCESS; while (state != PROCESS_COMPONENT && !bcp()) { state = resolveConflict(); if (state == BACKTRACK) { state = backtrack(); if (state == EXIT) return SUCCESS; } } } return SUCCESS; }
void Test30() { BCPWriter bcp("writetest.bcp"); uint id = bcp.createFile("Adrien", 6); uint id2 = bcp.createFile("^('o')>", 7); char* txt = "This fabulous text file will be compressed to not waste some precious space in the BCP file. I will be unimpressed if it won't."; char* txt2 = "Repeat repeat repeat repeat repeat repeat again and again and again and repeat again and again and repeat again."; uint id3 = bcp.createFile(txt, strlen(txt)); uint id4 = bcp.createFile(txt2, strlen(txt2)); bcp.root.insertFile(id, "author.txt"); auto fd = bcp.root.addDir("Folder"); fd->insertFile(id2, "cool.txt"); bcp.root.insertFile(id3, "compressed.txt"); bcp.root.insertFile(id4, "repeat.txt"); bcp.finalize(); }
int main() { int ia[] = {0, 1, 2, 2, 0, 1, 2, 3}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); int ib[] = {0, 1, 2, 3, 0, 1, 2, 3}; const unsigned sb = sizeof(ib)/sizeof(ib[0]); ((void)sb); // unused in c++11 typedef input_iterator<const int*> II; typedef random_access_iterator<const int*> RAI; typedef std::equal_to<int> EQ; assert(std::mismatch(II(ia), II(ia + sa), II(ib), EQ()) == (std::pair<II, II>(II(ia+3), II(ib+3)))); assert(std::mismatch(RAI(ia), RAI(ia + sa), RAI(ib), EQ()) == (std::pair<RAI, RAI>(RAI(ia+3), RAI(ib+3)))); binary_counting_predicate<EQ, int> bcp((EQ())); assert(std::mismatch(RAI(ia), RAI(ia + sa), RAI(ib), std::ref(bcp)) == (std::pair<RAI, RAI>(RAI(ia+3), RAI(ib+3)))); assert(bcp.count() > 0 && bcp.count() < sa); bcp.reset(); #if TEST_STD_VER >= 14 assert(std::mismatch(II(ia), II(ia + sa), II(ib), II(ib + sb), EQ()) == (std::pair<II, II>(II(ia+3), II(ib+3)))); assert(std::mismatch(RAI(ia), RAI(ia + sa), RAI(ib), RAI(ib + sb), EQ()) == (std::pair<RAI, RAI>(RAI(ia+3), RAI(ib+3)))); assert(std::mismatch(II(ia), II(ia + sa), II(ib), II(ib + sb), std::ref(bcp)) == (std::pair<II, II>(II(ia+3), II(ib+3)))); assert(bcp.count() > 0 && bcp.count() < std::min(sa, sb)); #endif assert(std::mismatch(ia, ia + sa, ib, EQ()) == (std::pair<int*,int*>(ia+3,ib+3))); #if TEST_STD_VER >= 14 assert(std::mismatch(ia, ia + sa, ib, ib + sb, EQ()) == (std::pair<int*,int*>(ia+3,ib+3))); assert(std::mismatch(ia, ia + sa, ib, ib + 2, EQ()) == (std::pair<int*,int*>(ia+2,ib+2))); #endif }
int interpretedVFrame::bci() const { return method()->bci_from(bcp()); }
static ConstantPoolCacheEntry* cache_entry(JavaThread *thread) { return cache_entry_at(thread, Bytes::get_native_u2(bcp(thread) + 1)); }
static int number_of_dimensions(JavaThread *thread) { return bcp(thread)[3]; }
static Bytecode bytecode(JavaThread *thread) { return Bytecode(method(thread), bcp(thread)); }
static Bytecodes::Code code(JavaThread *thread) { // pass method to avoid calling unsafe bcp_to_method (partial fix 4926272) return Bytecodes::code_at(method(thread), bcp(thread)); }
static bool is_breakpoint(JavaThread *thread) { return Bytecodes::code_or_bp_at(bcp(thread)) == Bytecodes::_breakpoint; }
static int two_byte_index(JavaThread *thread, int bci) { return Bytes::get_Java_u2(bcp(thread, bci) + 1); }
static void process (void) { int i, * clause, lit, tmp, var, changed, failed; for (i = 0; i < n; i++) { clause = clauses[i]; if (!clause[0]) { LOG (msg ("found empty clause %d", i)); inconsistent = 1; return; } if (clause[1]) continue; lit = clause[0]; tmp = val (lit); if (tmp > 0) continue; if (tmp < 0) { LOG (msg ("found contradictory unit clause %d", i)); inconsistent = 1; return; } LOG (msg ("implying %d by unit clause %d", lit, i)); assign (lit); } if (!bcp ()) { msg ("initial top level propagation failed"); inconsistent = 1; return; } do { changed = 0; for (var = 1; var <= m; var++) { if (val (var)) continue; lit = var; decide (lit); failed = !bcp (); backtrack (); if (failed) { FOUND_FAILED_LITERAL: changed = 1; LOG (msg ("failed literal %d", lit)); assign (-lit); if (!bcp ()) { msg ("top level propagation in round %d failed", rounds); inconsistent = 1; return; } } else { lit = -var; decide (lit); failed = !bcp (); backtrack (); if (failed) goto FOUND_FAILED_LITERAL; } } rounds++; msg ("%d units after round %d", units, rounds); } while (changed); }
static Bytecode* bytecode(JavaThread *thread) { return Bytecode_at(bcp(thread)); }
static ConstantPoolCacheEntry* cache_entry(JavaThread *thread) { return method(thread)->constants()->cache()->entry_at(Bytes::get_native_u2(bcp(thread) + 1)); }
static int one_byte_index(JavaThread *thread) { return bcp(thread)[1]; }
static Bytecodes::Code code(JavaThread *thread) { return Bytecodes::code_at(bcp(thread)); }
int Bytecode_invoke::index() const { return Bytes::get_Java_u2(bcp() + 1); }