use NGHolder::foo in favour of NFAGraph::foo

This commit is contained in:
Alex Coyte
2016-07-07 14:07:12 +10:00
committed by Matthew Barr
parent 2471b770a8
commit 691b08d170
29 changed files with 177 additions and 190 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Intel Corporation
* Copyright (c) 2015-2016, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -119,7 +119,7 @@ NFAVertex findReformable(const NGHolder &g, const set<NFAVertex> &starts,
}
if (dotq.empty()) {
return NFAGraph::null_vertex();
return NGHolder::null_vertex();
}
const DotInfo &dot = dotq.top();
@@ -165,10 +165,10 @@ void reformAnchoredRepeatsComponent(NGHolder &g,
return;
}
NFAVertex dotV = NFAGraph::null_vertex();
NFAVertex dotV = NGHolder::null_vertex();
set<NFAVertex> otherV;
dotV = findReformable(g, compAnchoredStarts, otherV);
if (dotV == NFAGraph::null_vertex()) {
if (dotV == NGHolder::null_vertex()) {
DEBUG_PRINTF("no candidate reformable dot found.\n");
return;
}
@@ -268,10 +268,10 @@ void reformUnanchoredRepeatsComponent(NGHolder &g,
}
while (true) {
NFAVertex dotV = NFAGraph::null_vertex();
NFAVertex dotV = NGHolder::null_vertex();
set<NFAVertex> otherV;
dotV = findReformable(g, compUnanchoredStarts, otherV);
if (dotV == NFAGraph::null_vertex()) {
if (dotV == NGHolder::null_vertex()) {
DEBUG_PRINTF("no candidate reformable dot found.\n");
return;
}
@@ -464,7 +464,7 @@ void collapseVariableDotRepeat(NGHolder &g, NFAVertex start,
// The first of our optional dots must be connected to start. The jump edge
// past it will be verified in gatherParticipants(). If start is
// graph.start, it should not be connected to startDs.
NFAVertex initialDot = NFAGraph::null_vertex();
NFAVertex initialDot = NGHolder::null_vertex();
for (auto v : adjacent_vertices_range(start, g)) {
if (is_special(v, g)) {
continue;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Intel Corporation
* Copyright (c) 2015-2016, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -131,7 +131,7 @@ NFABuilderImpl::~NFABuilderImpl() {
NFAVertex NFABuilderImpl::getVertex(Position pos) const {
assert(id2vertex.size() >= pos);
const NFAVertex v = id2vertex[pos];
assert(v != NFAGraph::null_vertex());
assert(v != NGHolder::null_vertex());
assert(graph->g[v].index == pos);
return v;
}

View File

@@ -58,7 +58,7 @@ namespace ue2 {
struct StateInfo {
StateInfo(NFAVertex v, const CharReach &cr) : vertex(v), reach(cr) {}
StateInfo() : vertex(NFAGraph::null_vertex()) {}
StateInfo() : vertex(NGHolder::null_vertex()) {}
NFAVertex vertex;
CharReach reach;
};

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Intel Corporation
* Copyright (c) 2015-2016, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -294,21 +294,21 @@ bool anchorPatternWithBoundedRepeat(NGWrapper &g, const depth &minWidth,
static
NFAVertex findSingleCyclic(const NGHolder &g) {
NFAVertex v = NFAGraph::null_vertex();
NFAVertex v = NGHolder::null_vertex();
for (const auto &e : edges_range(g)) {
if (source(e, g) == target(e, g)) {
if (source(e, g) == g.startDs) {
continue;
}
if (v != NFAGraph::null_vertex()) {
if (v != NGHolder::null_vertex()) {
// More than one cyclic vertex.
return NFAGraph::null_vertex();
return NGHolder::null_vertex();
}
v = source(e, g);
}
}
if (v != NFAGraph::null_vertex()) {
if (v != NGHolder::null_vertex()) {
DEBUG_PRINTF("cyclic is %u\n", g[v].index);
assert(!is_special(v, g));
}
@@ -359,11 +359,11 @@ bool transformMinLengthToRepeat(const ReportManager &rm, NGWrapper &g) {
// The graph must contain a single cyclic vertex (other than startDs), and
// that vertex can have one pred and one successor.
NFAVertex cyclic = findSingleCyclic(g);
if (cyclic == NFAGraph::null_vertex()) {
if (cyclic == NGHolder::null_vertex()) {
return false;
}
NFAGraph::adjacency_iterator ai, ae;
NGHolder::adjacency_iterator ai, ae;
tie(ai, ae) = adjacent_vertices(g.start, g);
if (*ai == g.startDs) {
++ai;
@@ -411,7 +411,7 @@ bool transformMinLengthToRepeat(const ReportManager &rm, NGWrapper &g) {
// Check the cyclic state is A-OK.
v = getSoleDestVertex(g, cyclic);
if (v == NFAGraph::null_vertex()) {
if (v == NGHolder::null_vertex()) {
DEBUG_PRINTF("cyclic has more than one successor\n");
return false;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Intel Corporation
* Copyright (c) 2015-2016, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -89,11 +89,11 @@ void populateInit(const NGHolder &g, const flat_set<NFAVertex> &unused,
}
v_by_index->clear();
v_by_index->resize(num_vertices(g), NFAGraph::null_vertex());
v_by_index->resize(num_vertices(g), NGHolder::null_vertex());
for (auto v : vertices_range(g)) {
u32 v_index = g[v].index;
assert((*v_by_index)[v_index] == NFAGraph::null_vertex());
assert((*v_by_index)[v_index] == NGHolder::null_vertex());
(*v_by_index)[v_index] = v;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Intel Corporation
* Copyright (c) 2015-2016, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -154,7 +154,7 @@ void clear_out_edges(NFAVertex v, NGHolder &h) {
}
void clear_graph(NGHolder &h) {
NFAGraph::vertex_iterator vi, ve;
NGHolder::vertex_iterator vi, ve;
for (tie(vi, ve) = vertices(h); vi != ve;) {
NFAVertex v = *vi;
++vi;

View File

@@ -171,7 +171,7 @@ bool is_special(const NFAVertex v, const GraphT &g) {
}
static really_inline
std::pair<NFAGraph::adjacency_iterator, NFAGraph::adjacency_iterator>
std::pair<NGHolder::adjacency_iterator, NGHolder::adjacency_iterator>
adjacent_vertices(NFAVertex v, const NGHolder &h) {
return adjacent_vertices(v, h.g);
}
@@ -182,7 +182,7 @@ std::pair<NFAEdge, bool> edge(NFAVertex u, NFAVertex v, const NGHolder &h) {
}
static really_inline
std::pair<NFAGraph::edge_iterator, NFAGraph::edge_iterator>
std::pair<NGHolder::edge_iterator, NGHolder::edge_iterator>
edges(const NGHolder &h) {
return edges(h.g);
}
@@ -193,13 +193,13 @@ size_t in_degree(NFAVertex v, const NGHolder &h) {
}
static really_inline
std::pair<NFAGraph::in_edge_iterator, NFAGraph::in_edge_iterator>
std::pair<NGHolder::in_edge_iterator, NGHolder::in_edge_iterator>
in_edges(NFAVertex v, const NGHolder &h) {
return in_edges(v, h.g);
}
static really_inline
std::pair<NFAGraph::inv_adjacency_iterator, NFAGraph::inv_adjacency_iterator>
std::pair<NGHolder::inv_adjacency_iterator, NGHolder::inv_adjacency_iterator>
inv_adjacent_vertices(NFAVertex v, const NGHolder &h) {
return inv_adjacent_vertices(v, h.g);
}
@@ -210,7 +210,7 @@ size_t out_degree(NFAVertex v, const NGHolder &h) {
}
static really_inline
std::pair<NFAGraph::out_edge_iterator, NFAGraph::out_edge_iterator>
std::pair<NGHolder::out_edge_iterator, NGHolder::out_edge_iterator>
out_edges(NFAVertex v, const NGHolder &h) {
return out_edges(v, h.g);
}
@@ -226,7 +226,7 @@ NFAVertex target(const NFAEdge &e, const NGHolder &h) {
}
static really_inline
std::pair<NFAGraph::vertex_iterator, NFAGraph::vertex_iterator>
std::pair<NGHolder::vertex_iterator, NGHolder::vertex_iterator>
vertices(const NGHolder &h) {
return vertices(h.g);
}

View File

@@ -164,7 +164,7 @@ void makeTopStates(NGHolder &g, map<u32, NFAVertex> &tops,
assert(!contains(tops, t));
NFAVertex s = NFAGraph::null_vertex();
NFAVertex s = NGHolder::null_vertex();
flat_set<NFAVertex> succs;
insert(&succs, top.second);

View File

@@ -658,7 +658,7 @@ NFAVertex get_sds_or_proxy(const NGHolder &g) {
return g.startDs;
}
NFAVertex v = NFAGraph::null_vertex();
NFAVertex v = NGHolder::null_vertex();
for (auto w : adjacent_vertices_range(g.start, g)) {
if (w != g.startDs) {
if (!v) {
@@ -693,8 +693,8 @@ NFAVertex get_sds_or_proxy(const NGHolder &g) {
static
NFAVertex find_next(const NFAVertex v, const NGHolder &g) {
NFAVertex res = NFAGraph::null_vertex();
for (NFAVertex u : adjacent_vertices_range(v, g)) {
NFAVertex res = NGHolder::null_vertex();
for (NFAVertex u : adjacent_vertices_range(v, g)) {
if (u != v) {
res = u;
break;
@@ -736,7 +736,7 @@ MultibyteAccelInfo nfaCheckMultiAccel(const NGHolder &g,
// find our start vertex
NFAVertex cur = find_next(v, g);
if (cur == NFAGraph::null_vertex()) {
if (cur == NGHolder::null_vertex()) {
DEBUG_PRINTF("invalid start vertex\n");
return MultibyteAccelInfo();
}

View File

@@ -173,11 +173,11 @@ void populateInit(const NGHolder &g, const flat_set<NFAVertex> &unused,
}
v_by_index->clear();
v_by_index->resize(num_vertices(g), NFAGraph::null_vertex());
v_by_index->resize(num_vertices(g), NGHolder::null_vertex());
for (auto v : vertices_range(g)) {
u32 vert_id = g[v].index;
assert((*v_by_index)[vert_id] == NFAGraph::null_vertex());
assert((*v_by_index)[vert_id] == NGHolder::null_vertex());
(*v_by_index)[vert_id] = v;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Intel Corporation
* Copyright (c) 2015-2016, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -135,7 +135,7 @@ void findWidths(const NGHolder &g,
// Wire our entries to start and our exits to accept.
for (auto v : ri.vertices) {
NFAVertex v_new = mapping[v];
assert(v_new != NFAGraph::null_vertex());
assert(v_new != NGHolder::null_vertex());
if (isRegionEntry(g, v, region_map) &&
!edge(rg.start, v_new, rg).second) {

View File

@@ -472,7 +472,7 @@ bool doComponent(RoseBuild &rose, ReportManager &rm, NGHolder &g, NFAVertex a,
}
NFAVertex puffv = nodes.back();
assert(puffv != NFAGraph::null_vertex());
assert(puffv != NGHolder::null_vertex());
u32 width = countChain(g, nodes.back());
flat_set<ReportID> chain_reports;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Intel Corporation
* Copyright (c) 2015-2016, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -158,7 +158,7 @@ void populateContainers(const NGHolder &g, VertexInfoMap &infoMap) {
static
void inplaceIntersection(vector<NFAVertex> &vset1,
const flat_set<NFAVertex> &vset2) {
const NFAVertex GONE = NFAGraph::null_vertex();
const NFAVertex GONE = NGHolder::null_vertex();
vector<NFAVertex>::iterator it = vset1.begin(), ite = vset1.end();
flat_set<NFAVertex>::const_iterator jt = vset2.begin(), jte = vset2.end();

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Intel Corporation
* Copyright (c) 2015-2016, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -1202,7 +1202,7 @@ CharReach predReach(const NGHolder &g, NFAVertex v) {
static
void filterMap(const NGHolder &subg,
ue2::unordered_map<NFAVertex, NFAVertex> &vmap) {
NFAGraph::vertex_iterator vi, ve;
NGHolder::vertex_iterator vi, ve;
tie(vi, ve) = vertices(subg);
const ue2::unordered_set<NFAVertex> remaining_verts(vi, ve);

View File

@@ -780,7 +780,7 @@ bool literalIsWholeGraph(const NGHolder &g, const ue2_literal &lit) {
NFAVertex v = g.accept;
for (auto it = lit.rbegin(), ite = lit.rend(); it != ite; ++it) {
NFAGraph::inv_adjacency_iterator ai, ae;
NGHolder::inv_adjacency_iterator ai, ae;
tie(ai, ae) = inv_adjacent_vertices(v, g);
if (ai == ae) {
assert(0); // no predecessors?

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Intel Corporation
* Copyright (c) 2015-2016, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -384,7 +384,7 @@ makePrefix(const NGHolder &g, const ue2::unordered_map<NFAVertex, u32> &regions,
add_edge(prefix.accept, prefix.acceptEod, prefix);
assert(!next_enters.empty());
assert(next_enters.front() != NFAGraph::null_vertex());
assert(next_enters.front() != NGHolder::null_vertex());
u32 dead_region = regions.at(next_enters.front());
DEBUG_PRINTF("curr_region %u, dead_region %u\n",
regions.at(curr_exits.front()), dead_region);
@@ -2537,7 +2537,7 @@ bool doHaigLitHaigSom(NG &ng, NGHolder &g,
RoseInVertex v = add_vertex(RoseInVertexProps::makeLiteral(lit), ig);
bool lhs_all_vac = true;
NFAGraph::adjacency_iterator ai, ae;
NGHolder::adjacency_iterator ai, ae;
for (tie(ai, ae) = adjacent_vertices(lhs->startDs, *lhs);
ai != ae && lhs_all_vac; ++ai) {
if (!is_special(*ai, *lhs)) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Intel Corporation
* Copyright (c) 2015-2016, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -369,7 +369,7 @@ map<NFAVertex, NFAStateSet> findSquashers(const NGHolder &g, som_type som) {
buildPDomTree(g, pdom_tree);
// Build list of vertices by state ID and a set of init states.
vector<NFAVertex> vByIndex(numStates, NFAGraph::null_vertex());
vector<NFAVertex> vByIndex(numStates, NGHolder::null_vertex());
NFAStateSet initStates(numStates);
smgb_cache cache(g);
@@ -394,7 +394,7 @@ map<NFAVertex, NFAStateSet> findSquashers(const NGHolder &g, som_type som) {
for (u32 i = 0; i < numStates; i++) {
NFAVertex v = vByIndex[i];
assert(v != NFAGraph::null_vertex());
assert(v != NGHolder::null_vertex());
const CharReach &cr = g[v].char_reach;
/* only non-init cyclics can be squashers */

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Intel Corporation
* Copyright (c) 2015-2016, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -184,7 +184,7 @@ u32 commonPrefixLength(const NGHolder &ga,
size_t a_count = 0;
size_t b_count = 0;
NFAGraph::out_edge_iterator ei, ee;
NGHolder::out_edge_iterator ei, ee;
for (tie(ei, ee) = out_edges(a[i], ga); ok && ei != ee; ++ei) {
u32 sid = a_state_ids.at(target(*ei, ga));
if (sid == NO_STATE || sid >= max) {
@@ -213,7 +213,7 @@ u32 commonPrefixLength(const NGHolder &ga,
}
}
NFAGraph::adjacency_iterator ai, ae;
NGHolder::adjacency_iterator ai, ae;
for (tie(ai, ae) = adjacent_vertices(b[i], gb); ok && ai != ae;
++ai) {
u32 sid = b_state_ids.at(*ai);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Intel Corporation
* Copyright (c) 2015-2016, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -78,26 +78,26 @@ depth maxDistFromStartOfData(const NFAVertexDepth &vd) {
}
NFAVertex getSoleDestVertex(const NGHolder &g, NFAVertex a) {
assert(a != NFAGraph::null_vertex());
assert(a != NGHolder::null_vertex());
NFAGraph::out_edge_iterator ii, iie;
NGHolder::out_edge_iterator ii, iie;
tie(ii, iie) = out_edges(a, g);
if (ii == iie) {
return NFAGraph::null_vertex();
return NGHolder::null_vertex();
}
NFAVertex b = target(*ii, g);
if (a == b) {
++ii;
if (ii == iie) {
return NFAGraph::null_vertex();
return NGHolder::null_vertex();
}
b = target(*ii, g);
if (++ii != iie) {
return NFAGraph::null_vertex();
return NGHolder::null_vertex();
}
} else if (++ii != iie && (target(*ii, g) != a || ++ii != iie)) {
return NFAGraph::null_vertex();
return NGHolder::null_vertex();
}
assert(a != b);
@@ -105,23 +105,23 @@ NFAVertex getSoleDestVertex(const NGHolder &g, NFAVertex a) {
}
NFAVertex getSoleSourceVertex(const NGHolder &g, NFAVertex a) {
assert(a != NFAGraph::null_vertex());
assert(a != NGHolder::null_vertex());
u32 idegree = in_degree(a, g);
if (idegree != 1 && !(idegree == 2 && hasSelfLoop(a, g))) {
return NFAGraph::null_vertex();
return NGHolder::null_vertex();
}
NFAGraph::in_edge_iterator ii, iie;
NGHolder::in_edge_iterator ii, iie;
tie(ii, iie) = in_edges(a, g);
if (ii == iie) {
return NFAGraph::null_vertex();
return NGHolder::null_vertex();
}
NFAVertex b = source(*ii, g);
if (a == b) {
++ii;
if (ii == iie) {
return NFAGraph::null_vertex();
return NGHolder::null_vertex();
}
b = source(*ii, g);
@@ -321,7 +321,7 @@ bool can_match_at_eod(const NGHolder &h) {
}
bool can_only_match_at_eod(const NGHolder &g) {
NFAGraph::in_edge_iterator ie, ee;
NGHolder::in_edge_iterator ie, ee;
tie(ie, ee) = in_edges(g.accept, g);
return ie == ee;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Intel Corporation
* Copyright (c) 2015-2016, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -65,7 +65,7 @@ bool is_dot(NFAVertex v, const GraphT &g) {
template<class U>
static really_inline
void succ(const NGHolder &g, NFAVertex v, U *s) {
NFAGraph::adjacency_iterator ai, ae;
NGHolder::adjacency_iterator ai, ae;
tie(ai, ae) = adjacent_vertices(v, g);
s->insert(ai, ae);
}
@@ -74,14 +74,14 @@ void succ(const NGHolder &g, NFAVertex v, U *s) {
template<class U>
static really_inline
void pred(const NGHolder &g, NFAVertex v, U *p) {
NFAGraph::inv_adjacency_iterator it, ite;
NGHolder::inv_adjacency_iterator it, ite;
tie(it, ite) = inv_adjacent_vertices(v, g);
p->insert(it, ite);
}
/** returns a vertex with an out edge from v and is not v.
* v must have exactly one out-edge excluding self-loops.
* will return NFAGraph::null_vertex() if the preconditions don't hold.
* will return NGHolder::null_vertex() if the preconditions don't hold.
*/
NFAVertex getSoleDestVertex(const NGHolder &g, NFAVertex v);