@@ -1362,149 +1362,6 @@ void KOREModule::addDeclaration(sptr<KOREDeclaration> Declaration) {
1362
1362
declarations.push_back (std::move (Declaration));
1363
1363
}
1364
1364
1365
- void KOREDefinition::addModule (sptr<KOREModule> Module) {
1366
- for (const auto &decl : Module->getDeclarations ()) {
1367
- if (auto *sortDecl
1368
- = dynamic_cast <KORECompositeSortDeclaration *>(decl.get ())) {
1369
- sortDeclarations.insert ({sortDecl->getName (), sortDecl});
1370
- auto sort = KORECompositeSort::Create (sortDecl->getName ());
1371
- } else if (
1372
- auto *symbolDecl = dynamic_cast <KORESymbolDeclaration *>(decl.get ())) {
1373
- symbolDeclarations.insert (
1374
- {symbolDecl->getSymbol ()->getName (), symbolDecl});
1375
- } else if (
1376
- auto *aliasDecl = dynamic_cast <KOREAliasDeclaration *>(decl.get ())) {
1377
- aliasDeclarations.insert ({aliasDecl->getSymbol ()->getName (), aliasDecl});
1378
- } else if (auto *axiom = dynamic_cast <KOREAxiomDeclaration *>(decl.get ())) {
1379
- axioms.push_back (axiom);
1380
- }
1381
- }
1382
- modules.push_back (std::move (Module));
1383
- }
1384
-
1385
- void KOREDefinition::addAttribute (sptr<KORECompositePattern> Attribute) {
1386
- std::string name = Attribute->getConstructor ()->getName ();
1387
- attributes.insert ({name, std::move (Attribute)});
1388
- }
1389
-
1390
- void KOREDefinition::insertReservedSymbols () {
1391
- auto mod = KOREModule::Create (" K-RAW-TERM" );
1392
- auto decl = KORESymbolDeclaration::Create (" rawTerm" , true );
1393
- auto sort = KORECompositeSort::Create (" SortKItem" );
1394
-
1395
- decl->getSymbol ()->addSort (sort);
1396
- decl->getSymbol ()->addArgument (sort);
1397
- mod->addDeclaration (std::move (decl));
1398
-
1399
- addModule (std::move (mod));
1400
- }
1401
-
1402
- // NOLINTNEXTLINE(*-cognitive-complexity)
1403
- void KOREDefinition::preprocess () {
1404
- insertReservedSymbols ();
1405
-
1406
- for (auto *axiom : axioms) {
1407
- axiom->pattern = axiom->pattern ->expandAliases (this );
1408
- }
1409
- auto symbols = std::map<std::string, std::vector<KORESymbol *>>{};
1410
- unsigned nextOrdinal = 0 ;
1411
- for (const auto &decl : symbolDeclarations) {
1412
- if (decl.second ->getAttributes ().count (" freshGenerator" )) {
1413
- auto sort = decl.second ->getSymbol ()->getSort ();
1414
- if (sort->isConcrete ()) {
1415
- freshFunctions[dynamic_cast <KORECompositeSort *>(sort.get ())->getName ()]
1416
- = decl.second ->getSymbol ();
1417
- }
1418
- }
1419
- }
1420
- for (auto iter = axioms.begin (); iter != axioms.end ();) {
1421
- auto *axiom = *iter;
1422
- axiom->ordinal = nextOrdinal;
1423
- ordinals[nextOrdinal++] = axiom;
1424
- axiom->pattern ->markSymbols (symbols);
1425
- if (!axiom->isRequired ()) {
1426
- iter = axioms.erase (iter);
1427
- } else {
1428
- ++iter;
1429
- }
1430
- }
1431
- for (auto &module : modules) {
1432
- const auto &declarations = module ->getDeclarations ();
1433
- for (const auto &declaration : declarations) {
1434
- auto *decl = dynamic_cast <KORESymbolDeclaration *>(declaration.get ());
1435
- if (decl == nullptr ) {
1436
- continue ;
1437
- }
1438
- if (decl->isHooked () && decl->getObjectSortVariables ().empty ()) {
1439
- KORESymbol *symbol = decl->getSymbol ();
1440
- symbols.emplace (symbol->getName (), std::vector<KORESymbol *>{symbol});
1441
- }
1442
- }
1443
- }
1444
- for (const auto &entry : symbols) {
1445
- for (auto *symbol : entry.second ) {
1446
- auto *decl = symbolDeclarations.at (symbol->getName ());
1447
- symbol->instantiateSymbol (decl);
1448
- }
1449
- }
1450
- uint32_t nextSymbol = 0 ;
1451
- uint16_t nextLayout = 1 ;
1452
- auto instantiations = std::unordered_map<KORESymbol, uint32_t , HashSymbol>{};
1453
- auto layouts = std::unordered_map<std::string, uint16_t >{};
1454
- auto variables
1455
- = std::unordered_map<std::string, std::pair<uint32_t , uint32_t >>{};
1456
- for (const auto &entry : symbols) {
1457
- uint32_t firstTag = nextSymbol;
1458
- for (auto *symbol : entry.second ) {
1459
- if (symbol->isConcrete ()) {
1460
- if (!instantiations.count (*symbol)) {
1461
- instantiations.emplace (*symbol, nextSymbol++);
1462
- }
1463
- std::string layoutStr = symbol->layoutString (this );
1464
- if (!layouts.count (layoutStr)) {
1465
- layouts.emplace (layoutStr, nextLayout++);
1466
- }
1467
- symbol->firstTag = symbol->lastTag = instantiations.at (*symbol);
1468
- symbol->layout = layouts.at (layoutStr);
1469
- objectSymbols[symbol->firstTag ] = symbol;
1470
- allObjectSymbols[ast_to_string (*symbol)] = symbol;
1471
- }
1472
- }
1473
- uint32_t lastTag = nextSymbol - 1 ;
1474
- if (!entry.second .empty ()) {
1475
- variables.emplace (
1476
- entry.first , std::pair<uint32_t , uint32_t >{firstTag, lastTag});
1477
- }
1478
- }
1479
- for (const auto &entry : symbols) {
1480
- auto range = variables.at (entry.first );
1481
- for (auto *symbol : entry.second ) {
1482
- for (const auto &sort : symbol->getArguments ()) {
1483
- if (sort->isConcrete ()) {
1484
- hookedSorts[dynamic_cast <KORECompositeSort *>(sort.get ())
1485
- ->getCategory (this )]
1486
- = std::dynamic_pointer_cast<KORECompositeSort>(sort);
1487
- }
1488
- }
1489
- if (symbol->getSort ()->isConcrete ()) {
1490
- hookedSorts[dynamic_cast <KORECompositeSort *>(symbol->getSort ().get ())
1491
- ->getCategory (this )]
1492
- = std::dynamic_pointer_cast<KORECompositeSort>(symbol->getSort ());
1493
- }
1494
- if (!symbol->isConcrete ()) {
1495
- if (symbol->isPolymorphic ()) {
1496
- symbol->firstTag = range.first ;
1497
- symbol->lastTag = range.second ;
1498
- auto *decl = symbolDeclarations.at (symbol->getName ());
1499
- if (decl->getAttributes ().count (" sortInjection" )) {
1500
- injSymbol = symbol;
1501
- }
1502
- }
1503
- }
1504
- }
1505
- }
1506
- }
1507
-
1508
1365
// Pretty printer
1509
1366
void KORESortVariable::print (std::ostream &Out, unsigned indent) const {
1510
1367
std::string Indent (indent, ' ' );
0 commit comments