Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] tailored_alloc/delete: make connection_table a CRTP base class #230

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ endif
ifeq (${TOOLCHAIN},clang)
CXXFLAGS_STD = -std=c++11
CXXFLAGS_EARLY += -march=native -fPIC
CXXFLAGS_EARLY += -W -Wall -Wextra -Werror -pedantic
CXXFLAGS_EARLY += -W -Wall -Wextra -Wsuggest-override -Werror -pedantic
CXXFLAGS_EARLY += -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-maybe-uninitialized -Wno-unknown-warning-option
CXXFLAGS_EARLY += -Wno-invalid-offsetof -Wno-overloaded-virtual
CXXFLAGS_EARLY += -Wno-invalid-offsetof
endif

ifeq (${TOOLCHAIN},gcc)
Expand Down
12 changes: 6 additions & 6 deletions arbitrile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ struct hrmap_arbi : hrmap {
void verify() override { }

transmatrix adj(heptagon *h, int dl) override {
return get_adj(current_or_slided(), id_of(h), dl, h->c.move(dl) ? h->c.spin(dl) : -1);
return get_adj(current_or_slided(), id_of(h), dl, h->c().move(dl) ? h->c().spin(dl) : -1);
}

heptagon *create_step(heptagon *h, int d) override {
Expand Down Expand Up @@ -737,7 +737,7 @@ struct hrmap_arbi : hrmap {
transmatrix T = v[i].second;
heptagon *h2 = v[i].first;
if(eqmatrix(T, goal)) {
h->c.connect(d, h2, e, m);
h->c().connect(d, h2, e, m);
return h2;
}
for(int i=0; i<h2->type; i++) {
Expand All @@ -754,7 +754,7 @@ struct hrmap_arbi : hrmap {
h1->zebraval = xt;
h1->c7 = newCell(h1->type, h1);
h1->emeraldval = h->emeraldval ^ m;
h->c.connect(d, h1, e, m);
h->c().connect(d, h1, e, m);

return h1;
}
Expand Down Expand Up @@ -789,7 +789,7 @@ struct hrmap_arbi : hrmap {
println(hlog, "err = ", err);
max_err = err;
}
h->c.connect(d, p2.first, oth%p2.first->type, m);
h->c().connect(d, p2.first, oth%p2.first->type, m);
return p2.first;
}
}
Expand All @@ -800,14 +800,14 @@ struct hrmap_arbi : hrmap {
h1->zebraval = xt;
h1->c7 = newCell(h1->type, h1);
h1->emeraldval = h->emeraldval ^ m;
h->c.connect(d, h1, e, m);
h->c().connect(d, h1, e, m);

arbi_matrix[h1] = make_pair(alt, T);
altmap[alt].emplace_back(h1, T);
return h1;
}

transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) override {
transmatrix relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint) override {
return relative_matrix_recursive(h2, h1);
}

Expand Down
34 changes: 17 additions & 17 deletions archimedean.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,28 +554,28 @@ struct hrmap_archimedean : hrmap {
heptspin hs(origin, 0);
heptagon *hnew = build_child(hs, current.get_adj(hs));
for(int s=1; s<2*current.N; s++)
origin->c.connect(s, hnew, s, false);
origin->c().connect(s, hnew, s, false);
}
else if(current.real_faces == 0) {
may_create_step(origin, 0);
heptagon *o0 = origin->move(0);
may_create_step(origin, 1);
heptagon *o1 = origin->move(1);
for(int s=1; s<2*current.N; s+=2)
o0->c.connect(s, o1, 2*current.N-s, false);
o0->c().connect(s, o1, 2*current.N-s, false);
for(int s=2; s<2*current.N; s+=2) {
heptspin hs(o0, s);
heptagon *hnew = build_child(hs, current.get_adj(hs));
// no need to specify archimedean_gmatrix and altmap
hnew->c.connect(1, heptspin(o1, 2*current.N-s));
hnew->c().connect(1, heptspin(o1, 2*current.N-s));
}
o1->c.connect(1, o0, 2*current.N-1, false);
o1->c().connect(1, o0, 2*current.N-1, false);
}
else if(origin->degree() == 2) {
may_create_step(origin, 0);
may_create_step(origin, 1);
origin->move(0)->c.connect(1, origin->move(1), 2*current.N-1, false);
origin->move(1)->c.connect(1, origin->move(0), 2*current.N-1, false);
origin->move(0)->c().connect(1, origin->move(1), 2*current.N-1, false);
origin->move(1)->c().connect(1, origin->move(0), 2*current.N-1, false);
}

cgi.base_distlimit = 0;
Expand Down Expand Up @@ -706,7 +706,7 @@ struct hrmap_archimedean : hrmap {
return calc_relative_matrix(c->cmove(dir), c, C0);
}

transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) override {
transmatrix relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint) override {
if(use_gmatrix && gmatrix0.count(h2->c7) && gmatrix0.count(h1->c7))
return inverse_shift(gmatrix0[h1->c7], gmatrix0[h2->c7]);
transmatrix gm = Id, where = Id;
Expand Down Expand Up @@ -749,19 +749,19 @@ struct hrmap_archimedean : hrmap {
if(PURE) {
if(arcm::id_of(c->master) < arcm::current.N * 2) {
heptspin hs = heptspin(c->master, d) + wstep + 2 + wstep + 1;
c->c.connect(d, hs.at->c7, hs.spin, hs.mirrored);
c->c().connect(d, hs.at->c7, hs.spin, hs.mirrored);
}
else c->c.connect(d, c, d, false);
else c->c().connect(d, c, d, false);
}
else if(DUAL) {
if(arcm::id_of(c->master) >= arcm::current.N * 2) {
heptagon *h2 = createStep(c->master, d*2);
int d1 = c->master->c.spin(d*2);
c->c.connect(d, h2->c7, d1/2, false);
int d1 = c->master->c().spin(d*2);
c->c().connect(d, h2->c7, d1/2, false);
}
else {
printf("bad connection\n");
c->c.connect(d,c,d,false);
c->c().connect(d,c,d,false);
}
}
else hrmap::find_cell_connection(c, d);
Expand Down Expand Up @@ -848,16 +848,16 @@ void connect_digons_too(heptspin h1, heptspin h2) {
h1--, h2++;
heptagon *hnew = build_child(h1, current.get_adj(h1));
// no need to specify archimedean_gmatrix and altmap
hnew->c.connect(1, h2);
hnew->c().connect(1, h2);
h1--, h2++;
DEBB(DF_GEOM, (format("OL2 %p.%d ~ %p.%d\n", hr::voidp(h1.at), h1.spin, hr::voidp(h2.at), h2.spin)));
h1.at->c.connect(h1.spin, h2);
h1.at->c().connect(h1.spin, h2);
}
}

void connectHeptagons(heptspin hi, heptspin hs) {
DEBB(DF_GEOM, (format("OLD %p.%d ~ %p.%d\n", hr::voidp(hi.at), hi.spin, hr::voidp(hs.at), hs.spin)));
if(hi.at->move(hi.spin) == hs.at && hi.at->c.spin(hi.spin) == hs.spin) {
if(hi.at->move(hi.spin) == hs.at && hi.at->c().spin(hi.spin) == hs.spin) {
DEBB(DF_GEOM, (format("WARNING: already connected\n")));
return;
}
Expand All @@ -869,7 +869,7 @@ void connectHeptagons(heptspin hi, heptspin hs) {
DEBB(DF_GEOM, (format("ERROR: already connected right\n")));
throw hr_archimedean_error("Archimedean error: already connected right");
}
hi.at->c.connect(hi.spin, hs);
hi.at->c().connect(hi.spin, hs);

auto p = current.get_adj(hi);
if(current.tilegroup[p.first] != current.tilegroup[id_of(hs.at)]) {
Expand Down Expand Up @@ -915,7 +915,7 @@ transmatrix archimedean_tiling::adjcell_matrix(heptagon *h, int d) {

heptagon *h2 = h->move(d);

int d2 = h->c.spin(d);
int d2 = h->c().spin(d);
auto& t2 = get_triangle(h2, d2);

return spin(-t1.first) * xpush(t1.second) * spin(M_PI + t2.first);
Expand Down
4 changes: 2 additions & 2 deletions asonov.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,13 @@ struct hrmap_asonov : hrmap {
auto p = coords[parent];
auto q = p.addmove(d);
auto child = get_at(q);
parent->c.connect(d, child, (d + 6) % 12, false);
parent->c().connect(d, child, (d + 6) % 12, false);
return child;
}

transmatrix adj(heptagon *h, int i) override { return adjmatrix(i); }

virtual transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) override {
transmatrix relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint) override {
for(int a=0; a<S7; a++) if(h2 == h1->move(a)) return adjmatrix(a);
return coord_to_matrix(coords[h2], coords[h1]);
}
Expand Down
8 changes: 4 additions & 4 deletions attack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ EX void killIvy(cell *c, eMonster who) {
if(checkOrb(who, itOrbStone)) petrify(c, waPetrified, c->monst);
c->monst = moIvyDead; // NEWYEARFIX
for(int i=0; i<c->type; i++) if(c->move(i))
if(isIvy(c->move(i)) && c->move(i)->mondir == c->c.spin(i))
if(isIvy(c->move(i)) && c->move(i)->mondir == c->c().spin(i))
killIvy(c->move(i), who), kills[moIvyDead]++;
}

Expand Down Expand Up @@ -414,7 +414,7 @@ EX void killMutantIvy(cell *c, eMonster who) {
changes.ccell(c);
removeIvy(c);
for(int i=0; i<c->type; i++)
if(c->move(i)->mondir == c->c.spin(i) && (isMutantIvy(c->move(i)) || c->move(i)->monst == moFriendlyIvy))
if(c->move(i)->mondir == c->c().spin(i) && (isMutantIvy(c->move(i)) || c->move(i)->monst == moFriendlyIvy))
kills[c->move(i)->monst]++, killMutantIvy(c->move(i), who);
if(c->land == laClearing) clearing::imput(c);
}
Expand Down Expand Up @@ -774,7 +774,7 @@ EX void killMonster(cell *c, eMonster who, flagtype deathflags IS(0)) {
cell *c2 = proper(c, c->mondir) ? c->move(c->mondir) : nullptr;
if(!c2) c2 = c; /* should not happen */
for(int i=0; i<c2->type; i++)
if(c2->move(i)->monst == moIvyWait && c2->move(i)->mondir == c2->c.spin(i))
if(c2->move(i)->monst == moIvyWait && c2->move(i)->mondir == c2->c().spin(i))
qty++;
if(c2->monst == moIvyRoot || qty) {
c->monst = moIvyNext;
Expand Down Expand Up @@ -1028,7 +1028,7 @@ EX void pushMonster(const movei& mi) {
moveMonster(mi);
if(mi.t->monst) {
mi.t->mondir = id;
other->mondir = mi.t->c.spin(id);
other->mondir = mi.t->c().spin(id);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion barriers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ EX void buildCrossroads2(cell *c) {

for(int d=0; d<c2->type; d++)
if(emeraldtable[h2][d] == h3) {
int nh = emeraldtable[h2][(42+d + c->c.spin(i) - j) % c2->type];
int nh = emeraldtable[h2][(42+d + c->c().spin(i) - j) % c2->type];
if(c->landparam>0 && c->landparam != nh) {
printf("CONFLICT\n");
raiseBuggyGeneration(c, "CONFLICT");
Expand Down
8 changes: 4 additions & 4 deletions bigstuff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ EX void buildEquidistant(cell *c) {
else {
// if(qcv != 1) { printf("qcv = %d\n", qcv); exit(1); }
cell *c2 = c->move(sid);
int bsid = c->c.spin(sid);
int bsid = c->c().spin(sid);
for(int j=0; j<c2->type; j++) {
int q = gmod(bsid+j, c2->type);
cell *c3 = c2->move(q);
Expand Down Expand Up @@ -677,7 +677,7 @@ EX void buildEquidistant(cell *c) {
}
else if(WDIM == 3 && c->landparam % skip != 1 && c->move(up) && c->move(up)->landflags)
c->landflags = 1;
else if(WDIM == 3 && c->landparam % skip == 1 && c->move(up) && c->move(up)->c.spin(up) == (c->c.spin(up)) && c->move(up)->move(up)->landflags)
else if(WDIM == 3 && c->landparam % skip == 1 && c->move(up) && c->move(up)->c().spin(up) == (c->c().spin(up)) && c->move(up)->move(up)->landflags)
c->landflags = 1;
if(c->landflags) c->wall = (WDIM == 3 ? waTrunk3 : waTrunk);
}
Expand Down Expand Up @@ -792,7 +792,7 @@ EX void buildEquidistant(cell *c) {
else for(int j=0; j<c2->type; j++) {
cell *c3 = c2->move(j);
if(c3 && c3->landparam < c2->landparam && c3->landflags)
if(c->c.spin(i) == (j+3)%c2->type || c->c.spin(i) == (j+c2->type-3)%c2->type)
if(c->c().spin(i) == (j+3)%c2->type || c->c().spin(i) == (j+c2->type-3)%c2->type)
ok = true;
}
if(ok) {
Expand Down Expand Up @@ -1895,7 +1895,7 @@ EX void gen_temple(cell *c) {
if(c->master->zebraval % 5 != 1) c->wall = waColumn;
}
else if(geometry == gHoroTris || geometry == gHoroRec) {
if(c->c.spin(bt::updir()) != 0) c->wall = waColumn;
if(c->c().spin(bt::updir()) != 0) c->wall = waColumn;
}
else if(geometry == gKiteDart3) {
if(kite::getshape(c->master) == kite::pKite) c->wall = waColumn;
Expand Down
Loading