cfg_test.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. /* ScummVM Tools
  2. *
  3. * ScummVM Tools is the legal property of its developers, whose
  4. * names are too numerous to list here. Please refer to the
  5. * COPYRIGHT file distributed with this source distribution.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  20. */
  21. #include "decompiler/control_flow.h"
  22. #include "decompiler/decompiler_disassembler.h"
  23. #include "decompiler/graph.h"
  24. #include "decompiler/scummv6/engine.h"
  25. #include <gmock/gmock.h>
  26. #include <vector>
  27. #include "make_unique.h"
  28. #define GET(vertex) (boost::get(boost::vertex_name, g, vertex))
  29. TEST(CFG, testUnreachable) {
  30. InstVec insts;
  31. Scumm::v6::Scummv6Engine *engine = new Scumm::v6::Scummv6Engine();
  32. auto d = engine->getDisassembler(insts);
  33. d->open("decompiler/test/unreachable.dmp");
  34. d->disassemble();
  35. ControlFlow *c = new ControlFlow(insts, *engine);
  36. Graph g = c->getGraph();
  37. ASSERT_TRUE(boost::num_vertices(g) == 4);
  38. VertexRange range = boost::vertices(g);
  39. for (VertexIterator it = range.first; it != range.second; ++it) {
  40. GroupPtr gr = GET(*it);
  41. switch ((*gr->_start)->_address) {
  42. case 0:
  43. ASSERT_TRUE(boost::in_degree(*it, g) == 0 && boost::out_degree(*it, g) == 1);
  44. break;
  45. case 2:
  46. ASSERT_TRUE(boost::in_degree(*it, g) == 1 && boost::out_degree(*it, g) == 1);
  47. break;
  48. case 5:
  49. ASSERT_TRUE(boost::in_degree(*it, g) == 0 && boost::out_degree(*it, g) == 1);
  50. break;
  51. case 6:
  52. ASSERT_TRUE(boost::in_degree(*it, g) == 2 && boost::out_degree(*it, g) == 0);
  53. break;
  54. default:
  55. ASSERT_TRUE(false);
  56. }
  57. }
  58. delete c;
  59. delete engine;
  60. };
  61. TEST(CFG, testBranching) {
  62. InstVec insts;
  63. Scumm::v6::Scummv6Engine *engine = new Scumm::v6::Scummv6Engine();
  64. auto d = engine->getDisassembler(insts);
  65. d->open("decompiler/test/branches.dmp");
  66. d->disassemble();
  67. ControlFlow *c = new ControlFlow(insts, *engine);
  68. Graph g = c->getGraph();
  69. ASSERT_TRUE(boost::num_vertices(g) == 4);
  70. VertexRange range = boost::vertices(g);
  71. for (VertexIterator it = range.first; it != range.second; ++it) {
  72. GroupPtr gr = GET(*it);
  73. switch ((*gr->_start)->_address) {
  74. case 0:
  75. ASSERT_TRUE(boost::in_degree(*it, g) == 0 && boost::out_degree(*it, g) == 1);
  76. break;
  77. case 2:
  78. ASSERT_TRUE(boost::in_degree(*it, g) == 1 && boost::out_degree(*it, g) == 2);
  79. break;
  80. case 5:
  81. ASSERT_TRUE(boost::in_degree(*it, g) == 1 && boost::out_degree(*it, g) == 1);
  82. break;
  83. case 6:
  84. ASSERT_TRUE(boost::in_degree(*it, g) == 2 && boost::out_degree(*it, g) == 0);
  85. break;
  86. default:
  87. ASSERT_TRUE(false);
  88. }
  89. }
  90. delete c;
  91. delete engine;
  92. }
  93. TEST(CFG, testGrouping) {
  94. InstVec insts;
  95. auto engine = std::make_unique<Scumm::v6::Scummv6Engine>();
  96. auto d = engine->getDisassembler(insts);
  97. d->open("decompiler/test/branches.dmp");
  98. d->disassemble();
  99. auto c = std::make_unique<ControlFlow>(insts, *engine);
  100. c->createGroups();
  101. Graph g = c->getGraph();
  102. ASSERT_TRUE(boost::num_vertices(g) == 3);
  103. VertexRange range = boost::vertices(g);
  104. for (VertexIterator it = range.first; it != range.second; ++it) {
  105. GroupPtr gr = GET(*it);
  106. switch ((*gr->_start)->_address) {
  107. case 0:
  108. ASSERT_TRUE((*gr->_end)->_address == 2);
  109. ASSERT_TRUE(boost::in_degree(*it, g) == 0 && boost::out_degree(*it, g) == 2);
  110. break;
  111. case 5:
  112. ASSERT_TRUE(boost::in_degree(*it, g) == 1 && boost::out_degree(*it, g) == 1);
  113. break;
  114. case 6:
  115. ASSERT_TRUE(boost::in_degree(*it, g) == 2 && boost::out_degree(*it, g) == 0);
  116. break;
  117. default:
  118. ASSERT_TRUE(false);
  119. break;
  120. }
  121. }
  122. }
  123. // TODO: Fix me, this fails but looks like it shouldn't
  124. TEST(CFG, DISABLED_testShortCircuitDetection) {
  125. InstVec insts;
  126. auto engine = std::make_unique<Scumm::v6::Scummv6Engine>();
  127. auto d = engine->getDisassembler(insts);
  128. d->open("decompiler/test/short-circuit.dmp");
  129. d->disassemble();
  130. auto c = std::make_unique<ControlFlow>(insts, *engine);
  131. c->createGroups();
  132. Graph g = c->getGraph();
  133. ASSERT_TRUE(boost::num_vertices(g) == 3);
  134. }
  135. TEST(CFG, testWhileDetection) {
  136. InstVec insts;
  137. auto engine = std::make_unique<Scumm::v6::Scummv6Engine>();
  138. auto d = engine->getDisassembler(insts);
  139. d->open("decompiler/test/while.dmp");
  140. d->disassemble();
  141. auto c = std::make_unique<ControlFlow>(insts, *engine);
  142. c->createGroups();
  143. Graph g = c->analyze();
  144. VertexRange range = boost::vertices(g);
  145. for (VertexIterator it = range.first; it != range.second; ++it) {
  146. GroupPtr gr = GET(*it);
  147. if ((*gr->_start)->_address == 0)
  148. ASSERT_TRUE(gr->_type == kWhileCondGroupType);
  149. }
  150. }
  151. TEST(CFG, testDoWhileDetection) {
  152. InstVec insts;
  153. auto engine = std::make_unique<Scumm::v6::Scummv6Engine>();
  154. auto d = engine->getDisassembler(insts);
  155. d->open("decompiler/test/while.dmp");
  156. d->disassemble();
  157. auto c = std::make_unique<ControlFlow>(insts, *engine);
  158. c->createGroups();
  159. Graph g = c->analyze();
  160. VertexRange range = boost::vertices(g);
  161. for (VertexIterator it = range.first; it != range.second; ++it) {
  162. GroupPtr gr = GET(*it);
  163. if ((*gr->_start)->_address == 3)
  164. ASSERT_TRUE(gr->_type == kDoWhileCondGroupType);
  165. }
  166. }
  167. TEST(CFG, testBreakDetection) {
  168. InstVec insts;
  169. auto engine = std::make_unique<Scumm::v6::Scummv6Engine>();
  170. auto d = engine->getDisassembler(insts);
  171. d->open("decompiler/test/break-while.dmp");
  172. d->disassemble();
  173. auto c = std::make_unique<ControlFlow>(insts, *engine);
  174. c->createGroups();
  175. Graph g = c->analyze();
  176. VertexRange range = boost::vertices(g);
  177. for (VertexIterator it = range.first; it != range.second; ++it) {
  178. GroupPtr gr = GET(*it);
  179. if ((*gr->_start)->_address == 0x14)
  180. ASSERT_TRUE(gr->_type == kBreakGroupType);
  181. }
  182. insts.clear();
  183. engine = std::make_unique<Scumm::v6::Scummv6Engine>();
  184. d = engine->getDisassembler(insts);
  185. d->open("decompiler/test/break-do-while.dmp");
  186. d->disassemble();
  187. c = std::make_unique<ControlFlow>(insts, *engine);
  188. c->createGroups();
  189. g = c->analyze();
  190. range = boost::vertices(g);
  191. for (VertexIterator it = range.first; it != range.second; ++it) {
  192. GroupPtr gr = GET(*it);
  193. if ((*gr->_start)->_address == 0xA)
  194. ASSERT_TRUE(gr->_type == kBreakGroupType);
  195. }
  196. insts.clear();
  197. engine = std::make_unique<Scumm::v6::Scummv6Engine>();
  198. d = engine->getDisassembler(insts);
  199. d->open("decompiler/test/break-do-while2.dmp");
  200. d->disassemble();
  201. c = std::make_unique<ControlFlow>(insts, *engine);
  202. c->createGroups();
  203. g = c->analyze();
  204. range = boost::vertices(g);
  205. for (VertexIterator it = range.first; it != range.second; ++it) {
  206. GroupPtr gr = GET(*it);
  207. if ((*gr->_start)->_address == 0xD)
  208. ASSERT_TRUE(gr->_type == kBreakGroupType);
  209. }
  210. }
  211. TEST(CFG, testContinueDetection) {
  212. InstVec insts;
  213. auto engine = std::make_unique<Scumm::v6::Scummv6Engine>();
  214. auto d = engine->getDisassembler(insts);
  215. d->open("decompiler/test/continue-while.dmp");
  216. d->disassemble();
  217. auto c = std::make_unique<ControlFlow>(insts, *engine);
  218. c->createGroups();
  219. Graph g = c->analyze();
  220. VertexRange range = boost::vertices(g);
  221. for (VertexIterator it = range.first; it != range.second; ++it) {
  222. GroupPtr gr = GET(*it);
  223. if ((*gr->_start)->_address == 0x14)
  224. ASSERT_TRUE(gr->_type == kContinueGroupType);
  225. if ((*gr->_start)->_address == 0x1a)
  226. ASSERT_TRUE(gr->_type == kNormalGroupType);
  227. }
  228. ;
  229. insts.clear();
  230. engine = std::make_unique<Scumm::v6::Scummv6Engine>();
  231. d = engine->getDisassembler(insts);
  232. d->open("decompiler/test/continue-do-while.dmp");
  233. d->disassemble();
  234. c = std::make_unique<ControlFlow>(insts, *engine);
  235. c->createGroups();
  236. g = c->analyze();
  237. range = boost::vertices(g);
  238. for (VertexIterator it = range.first; it != range.second; ++it) {
  239. GroupPtr gr = GET(*it);
  240. if ((*gr->_start)->_address == 0xA)
  241. ASSERT_TRUE(gr->_type == kContinueGroupType);
  242. }
  243. insts.clear();
  244. engine = std::make_unique<Scumm::v6::Scummv6Engine>();
  245. d = engine->getDisassembler(insts);
  246. d->open("decompiler/test/continue-do-while2.dmp");
  247. d->disassemble();
  248. c = std::make_unique<ControlFlow>(insts, *engine);
  249. c->createGroups();
  250. g = c->analyze();
  251. range = boost::vertices(g);
  252. for (VertexIterator it = range.first; it != range.second; ++it) {
  253. GroupPtr gr = GET(*it);
  254. if ((*gr->_start)->_address == 0xD)
  255. ASSERT_TRUE(gr->_type == kContinueGroupType);
  256. }
  257. }
  258. TEST(CFG, testIfDetection) {
  259. InstVec insts;
  260. auto engine = std::make_unique<Scumm::v6::Scummv6Engine>();
  261. auto d = engine->getDisassembler(insts);
  262. d->open("decompiler/test/if.dmp");
  263. d->disassemble();
  264. auto c = std::make_unique<ControlFlow>(insts, *engine);
  265. c->createGroups();
  266. Graph g = c->analyze();
  267. VertexRange range = boost::vertices(g);
  268. for (VertexIterator it = range.first; it != range.second; ++it) {
  269. GroupPtr gr = GET(*it);
  270. if ((*gr->_start)->_address == 0x0)
  271. ASSERT_TRUE(gr->_type == kIfCondGroupType);
  272. }
  273. insts.clear();
  274. engine = std::make_unique<Scumm::v6::Scummv6Engine>();
  275. d = engine->getDisassembler(insts);
  276. d->open("decompiler/test/break-do-while.dmp");
  277. d->disassemble();
  278. c = std::make_unique<ControlFlow>(insts, *engine);
  279. c->createGroups();
  280. g = c->analyze();
  281. range = boost::vertices(g);
  282. for (VertexIterator it = range.first; it != range.second; ++it) {
  283. GroupPtr gr = GET(*it);
  284. if ((*gr->_start)->_address == 0x0)
  285. ASSERT_TRUE(gr->_type == kIfCondGroupType);
  286. }
  287. insts.clear();
  288. engine = std::make_unique<Scumm::v6::Scummv6Engine>();
  289. d = engine->getDisassembler(insts);
  290. d->open("decompiler/test/break-do-while2.dmp");
  291. d->disassemble();
  292. c = std::make_unique<ControlFlow>(insts, *engine);
  293. c->createGroups();
  294. g = c->analyze();
  295. range = boost::vertices(g);
  296. for (VertexIterator it = range.first; it != range.second; ++it) {
  297. GroupPtr gr = GET(*it);
  298. if ((*gr->_start)->_address == 0x3)
  299. ASSERT_TRUE(gr->_type == kIfCondGroupType);
  300. }
  301. insts.clear();
  302. engine = std::make_unique<Scumm::v6::Scummv6Engine>();
  303. d = engine->getDisassembler(insts);
  304. d->open("decompiler/test/continue-do-while.dmp");
  305. d->disassemble();
  306. c = std::make_unique<ControlFlow>(insts, *engine);
  307. c->createGroups();
  308. g = c->analyze();
  309. range = boost::vertices(g);
  310. for (VertexIterator it = range.first; it != range.second; ++it) {
  311. GroupPtr gr = GET(*it);
  312. if ((*gr->_start)->_address == 0x0)
  313. ASSERT_TRUE(gr->_type == kIfCondGroupType);
  314. }
  315. insts.clear();
  316. engine = std::make_unique<Scumm::v6::Scummv6Engine>();
  317. d = engine->getDisassembler(insts);
  318. d->open("decompiler/test/continue-do-while2.dmp");
  319. d->disassemble();
  320. c = std::make_unique<ControlFlow>(insts, *engine);
  321. c->createGroups();
  322. g = c->analyze();
  323. range = boost::vertices(g);
  324. for (VertexIterator it = range.first; it != range.second; ++it) {
  325. GroupPtr gr = GET(*it);
  326. if ((*gr->_start)->_address == 0x3)
  327. ASSERT_TRUE(gr->_type == kIfCondGroupType);
  328. }
  329. }
  330. TEST(CFG, testElseDetection) {
  331. InstVec insts;
  332. auto engine = std::make_unique<Scumm::v6::Scummv6Engine>();
  333. auto d = engine->getDisassembler(insts);
  334. d->open("decompiler/test/if-else.dmp");
  335. d->disassemble();
  336. auto c = std::make_unique<ControlFlow>(insts, *engine);
  337. c->createGroups();
  338. Graph g = c->analyze();
  339. VertexRange range = boost::vertices(g);
  340. for (VertexIterator it = range.first; it != range.second; ++it) {
  341. GroupPtr gr = GET(*it);
  342. if ((*gr->_start)->_address == 0x10) {
  343. ASSERT_TRUE(gr->_startElse);
  344. ASSERT_TRUE(gr->_endElse.size() == 1 && gr->_endElse[0] == gr);
  345. }
  346. }
  347. insts.clear();
  348. engine = std::make_unique<Scumm::v6::Scummv6Engine>();
  349. d = engine->getDisassembler(insts);
  350. d->open("decompiler/test/if-no-else.dmp");
  351. d->disassemble();
  352. c = std::make_unique<ControlFlow>(insts, *engine);
  353. c->createGroups();
  354. g = c->analyze();
  355. range = boost::vertices(g);
  356. for (VertexIterator it = range.first; it != range.second; ++it) {
  357. GroupPtr gr = GET(*it);
  358. if ((*gr->_start)->_address == 0x0)
  359. ASSERT_TRUE(gr->_type == kIfCondGroupType);
  360. ASSERT_TRUE(!gr->_startElse);
  361. }
  362. }
  363. TEST(CFG, testNestedLoops) {
  364. InstVec insts;
  365. auto engine = std::make_unique<Scumm::v6::Scummv6Engine>();
  366. auto d = engine->getDisassembler(insts);
  367. d->open("decompiler/test/do-while-in-while.dmp");
  368. d->disassemble();
  369. auto c = std::make_unique<ControlFlow>(insts, *engine);
  370. c->createGroups();
  371. Graph g = c->analyze();
  372. VertexRange range = boost::vertices(g);
  373. for (VertexIterator it = range.first; it != range.second; ++it) {
  374. GroupPtr gr = GET(*it);
  375. if ((*gr->_start)->_address == 0x0)
  376. ASSERT_TRUE(gr->_type == kWhileCondGroupType);
  377. if ((*gr->_start)->_address == 0xd)
  378. ASSERT_TRUE(gr->_type == kDoWhileCondGroupType);
  379. }
  380. insts.clear();
  381. engine = std::make_unique<Scumm::v6::Scummv6Engine>();
  382. d = engine->getDisassembler(insts);
  383. d->open("decompiler/test/nested-do-while.dmp");
  384. d->disassemble();
  385. c = std::make_unique<ControlFlow>(insts, *engine);
  386. c->createGroups();
  387. g = c->analyze();
  388. range = boost::vertices(g);
  389. for (VertexIterator it = range.first; it != range.second; ++it) {
  390. GroupPtr gr = GET(*it);
  391. if ((*gr->_start)->_address == 0x6)
  392. ASSERT_TRUE(gr->_type == kDoWhileCondGroupType);
  393. if ((*gr->_start)->_address == 0x10)
  394. ASSERT_TRUE(gr->_type == kDoWhileCondGroupType);
  395. }
  396. insts.clear();
  397. engine = std::make_unique<Scumm::v6::Scummv6Engine>();
  398. d = engine->getDisassembler(insts);
  399. d->open("decompiler/test/nested-while.dmp");
  400. d->disassemble();
  401. c = std::make_unique<ControlFlow>(insts, *engine);
  402. c->createGroups();
  403. g = c->analyze();
  404. range = boost::vertices(g);
  405. for (VertexIterator it = range.first; it != range.second; ++it) {
  406. GroupPtr gr = GET(*it);
  407. if ((*gr->_start)->_address == 0x0)
  408. ASSERT_TRUE(gr->_type == kWhileCondGroupType);
  409. if ((*gr->_start)->_address == 0xa)
  410. ASSERT_TRUE(gr->_type == kWhileCondGroupType);
  411. }
  412. insts.clear();
  413. engine = std::make_unique<Scumm::v6::Scummv6Engine>();
  414. d = engine->getDisassembler(insts);
  415. d->open("decompiler/test/nested-while2.dmp");
  416. d->disassemble();
  417. c = std::make_unique<ControlFlow>(insts, *engine);
  418. c->createGroups();
  419. g = c->analyze();
  420. range = boost::vertices(g);
  421. for (VertexIterator it = range.first; it != range.second; ++it) {
  422. GroupPtr gr = GET(*it);
  423. if ((*gr->_start)->_address == 0x0)
  424. ASSERT_TRUE(gr->_type == kWhileCondGroupType);
  425. if ((*gr->_start)->_address == 0xd)
  426. ASSERT_TRUE(gr->_type == kWhileCondGroupType);
  427. }
  428. insts.clear();
  429. engine = std::make_unique<Scumm::v6::Scummv6Engine>();
  430. d = engine->getDisassembler(insts);
  431. d->open("decompiler/test/while-in-do-while.dmp");
  432. d->disassemble();
  433. c = std::make_unique<ControlFlow>(insts, *engine);
  434. c->createGroups();
  435. g = c->analyze();
  436. range = boost::vertices(g);
  437. for (VertexIterator it = range.first; it != range.second; ++it) {
  438. GroupPtr gr = GET(*it);
  439. if ((*gr->_start)->_address == 0x0)
  440. ASSERT_TRUE(gr->_type == kWhileCondGroupType);
  441. if ((*gr->_start)->_address == 0x10)
  442. ASSERT_TRUE(gr->_type == kDoWhileCondGroupType);
  443. }
  444. insts.clear();
  445. engine = std::make_unique<Scumm::v6::Scummv6Engine>();
  446. d = engine->getDisassembler(insts);
  447. d->open("decompiler/test/while-in-do-while2.dmp");
  448. d->disassemble();
  449. c = std::make_unique<ControlFlow>(insts, *engine);
  450. c->createGroups();
  451. g = c->analyze();
  452. range = boost::vertices(g);
  453. for (VertexIterator it = range.first; it != range.second; ++it) {
  454. GroupPtr gr = GET(*it);
  455. if ((*gr->_start)->_address == 0x3)
  456. ASSERT_TRUE(gr->_type == kWhileCondGroupType);
  457. if ((*gr->_start)->_address == 0x13)
  458. ASSERT_TRUE(gr->_type == kDoWhileCondGroupType);
  459. }
  460. }
  461. // This test requires script-30.dmp from Sam & Max: Hit The Road.
  462. // 6e48faca13e1f6df9341567608962744 *script-30.dmp
  463. // Disabled as mentioned file is copyrighted
  464. TEST(CFG, DISABLED_testSamAndMaxScript30) {
  465. InstVec insts;
  466. auto engine = std::make_unique<Scumm::v6::Scummv6Engine>();
  467. auto d = engine->getDisassembler(insts);
  468. d->open("decompiler/test/script-30.dmp");
  469. d->disassemble();
  470. auto c = std::make_unique<ControlFlow>(insts, *engine);
  471. c->createGroups();
  472. Graph g = c->analyze();
  473. VertexRange range = boost::vertices(g);
  474. for (VertexIterator it = range.first; it != range.second; ++it) {
  475. GroupPtr gr = GET(*it);
  476. switch ((*gr->_start)->_address) {
  477. case 0x6:
  478. ASSERT_TRUE(gr->_type == kWhileCondGroupType);
  479. ASSERT_TRUE(!gr->_startElse);
  480. ASSERT_TRUE(gr->_endElse.empty());
  481. break;
  482. case 0x19:
  483. case 0x3A:
  484. case 0x4F:
  485. case 0x68:
  486. case 0x74: // Allow inclusion of the pop instruction immediately before
  487. case 0x75:
  488. case 0x92:
  489. ASSERT_TRUE(gr->_type == kIfCondGroupType);
  490. ASSERT_TRUE(!gr->_startElse);
  491. ASSERT_TRUE(gr->_endElse.empty());
  492. break;
  493. case 0x8B:
  494. ASSERT_TRUE(gr->_type == kNormalGroupType);
  495. ASSERT_TRUE(gr->_startElse);
  496. ASSERT_TRUE(gr->_endElse.size() == 1 && (*gr->_endElse[0]->_start)->_address == 0x8B);
  497. break;
  498. case 0x91:
  499. ASSERT_TRUE(gr->_type == kNormalGroupType || gr->_type == kIfCondGroupType); // Allow inclusion of the pop instruction immediately before
  500. ASSERT_TRUE(gr->_startElse);
  501. ASSERT_TRUE(gr->_endElse.empty());
  502. break;
  503. case 0xA6:
  504. ASSERT_TRUE(gr->_type == kNormalGroupType);
  505. ASSERT_TRUE(!gr->_startElse);
  506. ASSERT_TRUE(gr->_endElse.size() == 1 && (*gr->_endElse[0]->_start)->_address == 0x91);
  507. break;
  508. default:
  509. ASSERT_TRUE(gr->_type == kNormalGroupType);
  510. ASSERT_TRUE(!gr->_startElse);
  511. ASSERT_TRUE(gr->_endElse.empty());
  512. break;
  513. }
  514. }
  515. }