コード例 #1
0
const RecVec *SetTheory::expand(Record *Set) {
  // Check existing entries for Set and return early.
  ExpandMap::iterator I = Expansions.find(Set);
  if (I != Expansions.end())
    return &I->second;

  // This is the first time we see Set. Find a suitable expander.
  try {
    const std::vector<Record*> &SC = Set->getSuperClasses();
    for (unsigned i = 0, e = SC.size(); i != e; ++i) {
      // Skip unnamed superclasses.
      if (!dynamic_cast<const StringInit *>(SC[i]->getNameInit()))
        continue;
      if (Expander *Exp = Expanders.lookup(SC[i]->getName())) {
        // This breaks recursive definitions.
        RecVec &EltVec = Expansions[Set];
        RecSet Elts;
        Exp->expand(*this, Set, Elts);
        EltVec.assign(Elts.begin(), Elts.end());
        return &EltVec;
      }
    }
  } catch (const std::string &Error) {
    throw TGError(Set->getLoc(), Error);
  }

  // Set is not expandable.
  return 0;
}
コード例 #2
0
ファイル: SetTheory.cpp プロジェクト: 0x00evil/llvm
const RecVec *SetTheory::expand(Record *Set) {
  // Check existing entries for Set and return early.
  ExpandMap::iterator I = Expansions.find(Set);
  if (I != Expansions.end())
    return &I->second;

  // This is the first time we see Set. Find a suitable expander.
  const std::vector<Record*> &SC = Set->getSuperClasses();
  for (unsigned i = 0, e = SC.size(); i != e; ++i) {
    // Skip unnamed superclasses.
    if (!dyn_cast<StringInit>(SC[i]->getNameInit()))
      continue;
    auto I = Expanders.find(SC[i]->getName());
    if (I != Expanders.end()) {
      // This breaks recursive definitions.
      RecVec &EltVec = Expansions[Set];
      RecSet Elts;
      I->second->expand(*this, Set, Elts);
      EltVec.assign(Elts.begin(), Elts.end());
      return &EltVec;
    }
  }

  // Set is not expandable.
  return nullptr;
}