cfg_test.cpp 19 KB

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