Esempio n. 1
0
bool Solver::BCP(unsigned start_at_stack_ofs) {
	for (unsigned int i = start_at_stack_ofs; i < literal_stack_.size(); i++) {
		LiteralID unLit = literal_stack_[i].neg();
		//BEGIN Propagate Bin Clauses
		for (auto bt = literal(unLit).binary_links_.begin();
				*bt != SENTINEL_LIT; bt++) {
			if (isResolved(*bt)) {
				setConflictState(unLit, *bt);
				return false;
			}
			setLiteralIfFree(*bt, Antecedent(unLit));
		}
		//END Propagate Bin Clauses
		for (auto itcl = literal(unLit).watch_list_.rbegin();
				*itcl != SENTINEL_CL; itcl++) {
			bool isLitA = (*beginOf(*itcl) == unLit);
			auto p_watchLit = beginOf(*itcl) + 1 - isLitA;
			auto p_otherLit = beginOf(*itcl) + isLitA;

			if (isSatisfied(*p_otherLit))
				continue;
			auto itL = beginOf(*itcl) + 2;
			while (isResolved(*itL))
				itL++;
			// either we found a free or satisfied lit
			if (*itL != SENTINEL_LIT) {
				literal(*itL).addWatchLinkTo(*itcl);
				swap(*itL, *p_watchLit);
				*itcl = literal(unLit).watch_list_.back();
				literal(unLit).watch_list_.pop_back();
			} else {
				// or p_unLit stays resolved
				// and we have hence no free literal left
				// for p_otherLit remain poss: Active or Resolved
				if (setLiteralIfFree(*p_otherLit, Antecedent(*itcl))) { // implication
					if (isLitA)
						swap(*p_otherLit, *p_watchLit);
				} else {
					setConflictState(*itcl);
					return false;
				}
			}
		}
	}
	return true;
}
Esempio n. 2
0
void
Symbol::appendOverload(Symbol *symbol)
{
    bool resolved = isResolved();
    if (resolved) MU_GC_BEGIN_CHANGE_STUBBORN(this);
    if ( _overload ) symbol->_overload = _overload;
    _overload = symbol;
    if (resolved) MU_GC_END_CHANGE_STUBBORN(this);
}
Esempio n. 3
0
void Bundle::addExtensionBundle(Bundle* pExtensionBundle)
{
	if (isResolved())
	{
		{
			Poco::FastMutex::ScopedLock lock(_extensionBundlesMutex);
		
			_extensionBundles.insert(Bundle::Ptr(pExtensionBundle, true));
		}
		_pProperties->addProperties(pExtensionBundle->_pProperties, -static_cast<int>(_extensionBundles.size()), true);
	}
	else throw BundleStateException("addExtensionBundle() requires at least RESOLVED state");
}
Esempio n. 4
0
void
Symbol::addAnonymousSymbol(Symbol *symbol)
{
#if 0
    bool resolved = isResolved();
    if (resolved) MU_GC_BEGIN_CHANGE_STUBBORN(this);
    assert(!symbol->_scope);
    symbol->_scope = this;
    symbol->load();
    if (resolved) MU_GC_END_CHANGE_STUBBORN(this);
#endif
    addSymbol(symbol);
}
Esempio n. 5
0
void 
Symbol::addSymbol(Symbol *symbol)
{
    bool resolved = isResolved();
    if (resolved) MU_GC_BEGIN_CHANGE_STUBBORN(this);
    if ( !_symbolTable ) _symbolTable = new SymbolTable();
    _symbolTable->add(symbol);

    assert(!symbol->_scope);
    symbol->_scope = this;
    symbol->load();
    if (resolved) MU_GC_END_CHANGE_STUBBORN(this);
}
Esempio n. 6
0
// Return true if we successfully sent an ARP request, false otherwise
bool IPv4Handler::resolveMac(SwitchState* state, IPAddressV4 dest) {
  // need to find out our own IP and MAC addresses so that we can send the
  // ARP request out. Since the request will be broadcast, there is no need to
  // worry about which port to send the packet out.

  // TODO: assume vrf 0 now
  auto routeTable = state->getRouteTables()->getRouteTableIf(RouterID(0));
  if (!routeTable) {
    throw FbossError("No routing tables found");
  }

  auto route = routeTable->getRibV4()->longestMatch(dest);
  if (!route || !route->isResolved()) {
    // No way to reach dest
    return false;
  }

  auto intfs = state->getInterfaces();
  auto nhs = route->getForwardInfo().getNexthops();
  for (auto nh : nhs) {
    auto intf = intfs->getInterfaceIf(nh.intf);
    if (intf) {
      auto source = intf->getAddressToReach(nh.nexthop)->first.asV4();
      auto target = route->isConnected() ? dest : nh.nexthop.asV4();
      if (source == target) {
        // This packet is for us.  Don't send ARP requess for our own IP.
        continue;
      }

      auto vlanID = intf->getVlanID();
      auto vlan = state->getVlans()->getVlanIf(vlanID);
      if (vlan) {
        auto entry = vlan->getArpTable()->getEntryIf(target);
        if (entry == nullptr) {
          // No entry in ARP table, send ARP request
          auto mac = intf->getMac();
          ArpHandler::sendArpRequest(sw_, vlanID, mac, source, target);

          // Notify the updater that we sent an arp request
          sw_->getNeighborUpdater()->sentArpRequest(vlanID, target);
        } else {
          VLOG(4) << "not sending arp for " << target.str() << ", "
                  << ((entry->isPending()) ? "pending " : "")
                  << "entry already exists";
        }
      }
    }
  }

  return true;
}
Esempio n. 7
0
QualifiedName
Symbol::fullyQualifiedName() const
{
    if (!isResolved()) resolve();
    if (!scope()) return name();
    String qname;
    
    const Symbol* g = globalScope();

    for (const Symbol *s = this; s && s->scope(); s = s->scope()) 
    {
	qname.insert(0, s->name().c_str());
        if (s->scope() != g) qname.insert(0, ".");
    }

    return context()->internName(qname);
}