Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Pass.impl.hpp

    r17a0228a r10a1225  
    571571        __pass::indexer::addType( pass, 0, node );
    572572
    573         VISIT( maybe_accept( node, &TypedefDecl::assertions ); )
     573        maybe_accept( node, &TypedefDecl::assertions );
    574574
    575575        VISIT_END( Decl, node );
     
    626626// ExprStmt
    627627template< typename pass_t >
    628 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::ExprStmt * node ) {
     628const ast::Stmt * ast::Pass< pass_t >::visit( const ExprStmt * node ) {
    629629        VISIT_START( node );
    630630
     
    666666const ast::Stmt * ast::Pass< pass_t >::visit( const ast::IfStmt * node ) {
    667667        VISIT_START( node );
    668 
    669668        VISIT({
    670669                // if statements introduce a level of scope (for the initialization)
     
    675674                maybe_accept( node, &IfStmt::elsePart );
    676675        })
    677 
    678676        VISIT_END( Stmt, node );
    679677}
     
    682680// WhileStmt
    683681template< typename pass_t >
    684 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::WhileStmt * node ) {
     682const ast::Stmt * ast::Pass< pass_t >::visit( const WhileStmt * node ) {
    685683        VISIT_START( node );
    686684
     
    912910}
    913911
    914 //--------------------------------------------------------------------------
    915 // ApplicationExpr
    916 template< typename pass_t >
    917 const ast::Expr * ast::Pass< pass_t >::visit( const ast::ApplicationExpr * node ) {
    918         VISIT_START( node );
    919 
    920         VISIT(
    921                 {
    922                         guard_indexer guard { *this };
    923                         maybe_accept( node, &ApplicationExpr::result );
    924                 }
    925                 maybe_accept( node, &ApplicationExpr::func );
    926                 maybe_accept( node, &ApplicationExpr::args );
    927         )
    928 
    929         VISIT_END( Expr, node );
    930 }
    931 
    932 //--------------------------------------------------------------------------
    933 // UntypedExpr
    934 template< typename pass_t >
    935 const ast::Expr * ast::Pass< pass_t >::visit( const ast::UntypedExpr * node ) {
    936         VISIT_START( node );
    937 
    938         VISIT(
    939                 {
    940                         guard_indexer guard { *this };
    941                         maybe_accept( node, &UntypedExpr::result );
    942                 }
    943 
    944                 maybe_accept( node, &UntypedExpr::args );
    945         )
    946 
    947         VISIT_END( Expr, node );
    948 }
    949 
    950 //--------------------------------------------------------------------------
    951 // NameExpr
    952 template< typename pass_t >
    953 const ast::Expr * ast::Pass< pass_t >::visit( const ast::NameExpr * node ) {
    954         VISIT_START( node );
    955 
    956         VISIT({
    957                 guard_indexer guard { *this };
    958                 maybe_accept( node, &NameExpr::result );
    959         })
    960 
    961         VISIT_END( Expr, node );
    962 }
    963 
    964 //--------------------------------------------------------------------------
    965 // CastExpr
    966 template< typename pass_t >
    967 const ast::Expr * ast::Pass< pass_t >::visit( const ast::CastExpr * node ) {
    968         VISIT_START( node );
    969 
    970         VISIT({
    971                         guard_indexer guard { *this };
    972                         maybe_accept( node, &CastExpr::result );
    973                 }
    974                 maybe_accept( node, &CastExpr::arg );
    975         )
    976 
    977         VISIT_END( Expr, node );
    978 }
    979 
    980 //--------------------------------------------------------------------------
    981 // KeywordCastExpr
    982 template< typename pass_t >
    983 const ast::Expr * ast::Pass< pass_t >::visit( const ast::KeywordCastExpr * node ) {
    984         VISIT_START( node );
    985 
    986         VISIT({
    987                         guard_indexer guard { *this };
    988                         maybe_accept( node, &KeywordCastExpr::result );
    989                 }
    990                 maybe_accept( node, &KeywordCastExpr::arg );
    991         )
    992 
    993         VISIT_END( Expr, node );
    994 }
    995 
    996 //--------------------------------------------------------------------------
    997 // VirtualCastExpr
    998 template< typename pass_t >
    999 const ast::Expr * ast::Pass< pass_t >::visit( const ast::VirtualCastExpr * node ) {
    1000         VISIT_START( node );
    1001 
    1002         VISIT({
    1003                         guard_indexer guard { *this };
    1004                         maybe_accept( node, &VirtualCastExpr::result );
    1005                 }
    1006                 maybe_accept( node, &VirtualCastExpr::arg );
    1007         )
    1008 
    1009         VISIT_END( Expr, node );
    1010 }
    1011 
    1012 //--------------------------------------------------------------------------
    1013 // AddressExpr
    1014 template< typename pass_t >
    1015 const ast::Expr * ast::Pass< pass_t >::visit( const ast::AddressExpr * node ) {
    1016         VISIT_START( node );
    1017 
    1018         VISIT({
    1019                         guard_indexer guard { *this };
    1020                         maybe_accept( node, &AddressExpr::result );
    1021                 }
    1022                 maybe_accept( node, &AddressExpr::arg );
    1023         )
    1024 
    1025         VISIT_END( Expr, node );
    1026 }
    1027 
    1028 //--------------------------------------------------------------------------
    1029 // LabelAddressExpr
    1030 template< typename pass_t >
    1031 const ast::Expr * ast::Pass< pass_t >::visit( const ast::LabelAddressExpr * node ) {
    1032         VISIT_START( node );
    1033 
    1034         VISIT({
    1035                 guard_indexer guard { *this };
    1036                 maybe_accept( node, &LabelAddressExpr::result );
    1037         })
    1038 
    1039         VISIT_END( Expr, node );
    1040 }
    1041 
    1042 //--------------------------------------------------------------------------
    1043 // UntypedMemberExpr
    1044 template< typename pass_t >
    1045 const ast::Expr * ast::Pass< pass_t >::visit( const ast::UntypedMemberExpr * node ) {
    1046         VISIT_START( node );
    1047 
    1048         VISIT({
    1049                         guard_indexer guard { *this };
    1050                         maybe_accept( node, &UntypedMemberExpr::result );
    1051                 }
    1052                 maybe_accept( node, &UntypedMemberExpr::aggregate );
    1053                 maybe_accept( node, &UntypedMemberExpr::member    );
    1054         )
    1055 
    1056         VISIT_END( Expr, node );
    1057 }
    1058 
    1059 //--------------------------------------------------------------------------
    1060 // MemberExpr
    1061 template< typename pass_t >
    1062 const ast::Expr * ast::Pass< pass_t >::visit( const ast::MemberExpr * node ) {
    1063         VISIT_START( node );
    1064 
    1065         VISIT({
    1066                         guard_indexer guard { *this };
    1067                         maybe_accept( node, &MemberExpr::result );
    1068                 }
    1069                 maybe_accept( node, &MemberExpr::aggregate );
    1070         )
    1071 
    1072         VISIT_END( Expr, node );
    1073 }
    1074 
    1075 //--------------------------------------------------------------------------
    1076 // VariableExpr
    1077 template< typename pass_t >
    1078 const ast::Expr * ast::Pass< pass_t >::visit( const ast::VariableExpr * node ) {
    1079         VISIT_START( node );
    1080 
    1081         VISIT({
    1082                 guard_indexer guard { *this };
    1083                 maybe_accept( node, &VariableExpr::result );
    1084         })
    1085 
    1086         VISIT_END( Expr, node );
    1087 }
    1088 
    1089 //--------------------------------------------------------------------------
    1090 // ConstantExpr
    1091 template< typename pass_t >
    1092 const ast::Expr * ast::Pass< pass_t >::visit( const ast::ConstantExpr * node ) {
    1093         VISIT_START( node );
    1094 
    1095         VISIT({
    1096                 guard_indexer guard { *this };
    1097                 maybe_accept( node, &ConstantExpr::result );
    1098         })
    1099 
    1100         VISIT_END( Expr, node );
    1101 }
    1102 
    1103 //--------------------------------------------------------------------------
    1104 // SizeofExpr
    1105 template< typename pass_t >
    1106 const ast::Expr * ast::Pass< pass_t >::visit( const ast::SizeofExpr * node ) {
    1107         VISIT_START( node );
    1108 
    1109         VISIT({
    1110                         guard_indexer guard { *this };
    1111                         maybe_accept( node, &SizeofExpr::result );
    1112                 }
    1113                 if ( node->type ) {
    1114                         maybe_accept( node, &SizeofExpr::type );
    1115                 } else {
    1116                         maybe_accept( node, &SizeofExpr::expr );
    1117                 }
    1118         )
    1119 
    1120         VISIT_END( Expr, node );
    1121 }
    1122 
    1123 //--------------------------------------------------------------------------
    1124 // AlignofExpr
    1125 template< typename pass_t >
    1126 const ast::Expr * ast::Pass< pass_t >::visit( const ast::AlignofExpr * node ) {
    1127         VISIT_START( node );
    1128 
    1129         VISIT({
    1130                         guard_indexer guard { *this };
    1131                         maybe_accept( node, &AlignofExpr::result );
    1132                 }
    1133                 if ( node->type ) {
    1134                         maybe_accept( node, &AlignofExpr::type );
    1135                 } else {
    1136                         maybe_accept( node, &AlignofExpr::expr );
    1137                 }
    1138         )
    1139 
    1140         VISIT_END( Expr, node );
    1141 }
    1142 
    1143 //--------------------------------------------------------------------------
    1144 // UntypedOffsetofExpr
    1145 template< typename pass_t >
    1146 const ast::Expr * ast::Pass< pass_t >::visit( const ast::UntypedOffsetofExpr * node ) {
    1147         VISIT_START( node );
    1148 
    1149         VISIT({
    1150                         guard_indexer guard { *this };
    1151                         maybe_accept( node, &UntypedOffsetofExpr::result );
    1152                 }
    1153                 maybe_accept( node, &UntypedOffsetofExpr::type   );
    1154         )
    1155 
    1156         VISIT_END( Expr, node );
    1157 }
    1158 
    1159 //--------------------------------------------------------------------------
    1160 // OffsetofExpr
    1161 template< typename pass_t >
    1162 const ast::Expr * ast::Pass< pass_t >::visit( const ast::OffsetofExpr * node ) {
    1163         VISIT_START( node );
    1164 
    1165         VISIT({
    1166                         guard_indexer guard { *this };
    1167                         maybe_accept( node, &OffsetofExpr::result );
    1168                 }
    1169                 maybe_accept( node, &OffsetofExpr::type   );
    1170         )
    1171 
    1172         VISIT_END( Expr, node );
    1173 }
    1174 
    1175 //--------------------------------------------------------------------------
    1176 // OffsetPackExpr
    1177 template< typename pass_t >
    1178 const ast::Expr * ast::Pass< pass_t >::visit( const ast::OffsetPackExpr * node ) {
    1179         VISIT_START( node );
    1180 
    1181         VISIT({
    1182                         guard_indexer guard { *this };
    1183                         maybe_accept( node, &OffsetPackExpr::result );
    1184                 }
    1185                 maybe_accept( node, &OffsetPackExpr::type   );
    1186         )
    1187 
    1188         VISIT_END( Expr, node );
    1189 }
    1190 
    1191 //--------------------------------------------------------------------------
    1192 // LogicalExpr
    1193 template< typename pass_t >
    1194 const ast::Expr * ast::Pass< pass_t >::visit( const ast::LogicalExpr * node ) {
    1195         VISIT_START( node );
    1196 
    1197         VISIT({
    1198                         guard_indexer guard { *this };
    1199                         maybe_accept( node, &LogicalExpr::result );
    1200                 }
    1201                 maybe_accept( node, &LogicalExpr::arg1 );
    1202                 maybe_accept( node, &LogicalExpr::arg2 );
    1203         )
    1204 
    1205         VISIT_END( Expr, node );
    1206 }
    1207 
    1208 //--------------------------------------------------------------------------
    1209 // ConditionalExpr
    1210 template< typename pass_t >
    1211 const ast::Expr * ast::Pass< pass_t >::visit( const ast::ConditionalExpr * node ) {
    1212         VISIT_START( node );
    1213 
    1214         VISIT({
    1215                         guard_indexer guard { *this };
    1216                         maybe_accept( node, &ConditionalExpr::result );
    1217                 }
    1218                 maybe_accept( node, &ConditionalExpr::arg1 );
    1219                 maybe_accept( node, &ConditionalExpr::arg2 );
    1220                 maybe_accept( node, &ConditionalExpr::arg3 );
    1221         )
    1222 
    1223         VISIT_END( Expr, node );
    1224 }
    1225 
    1226 //--------------------------------------------------------------------------
    1227 // CommaExpr
    1228 template< typename pass_t >
    1229 const ast::Expr * ast::Pass< pass_t >::visit( const ast::CommaExpr * node ) {
    1230         VISIT_START( node );
    1231 
    1232         VISIT({
    1233                         guard_indexer guard { *this };
    1234                         maybe_accept( node, &CommaExpr::result );
    1235                 }
    1236                 maybe_accept( node, &CommaExpr::arg1 );
    1237                 maybe_accept( node, &CommaExpr::arg2 );
    1238         )
    1239 
    1240         VISIT_END( Expr, node );
    1241 }
    1242 
    1243 //--------------------------------------------------------------------------
    1244 // TypeExpr
    1245 template< typename pass_t >
    1246 const ast::Expr * ast::Pass< pass_t >::visit( const ast::TypeExpr * node ) {
    1247         VISIT_START( node );
    1248 
    1249         VISIT({
    1250                         guard_indexer guard { *this };
    1251                         maybe_accept( node, &TypeExpr::result );
    1252                 }
    1253                 maybe_accept( node, &TypeExpr::type );
    1254         )
    1255 
    1256         VISIT_END( Expr, node );
    1257 }
    1258 
    1259 //--------------------------------------------------------------------------
    1260 // AsmExpr
    1261 template< typename pass_t >
    1262 const ast::Expr * ast::Pass< pass_t >::visit( const ast::AsmExpr * node ) {
    1263         VISIT_START( node );
    1264 
    1265         VISIT({
    1266                         guard_indexer guard { *this };
    1267                         maybe_accept( node, &AsmExpr::result );
    1268                 }
    1269                 maybe_accept( node, &AsmExpr::inout      );
    1270                 maybe_accept( node, &AsmExpr::constraint );
    1271                 maybe_accept( node, &AsmExpr::operand    );
    1272         )
    1273 
    1274         VISIT_END( Expr, node );
    1275 }
    1276 
    1277 //--------------------------------------------------------------------------
    1278 // ImplicitCopyCtorExpr
    1279 template< typename pass_t >
    1280 const ast::Expr * ast::Pass< pass_t >::visit( const ast::ImplicitCopyCtorExpr * node ) {
    1281         VISIT_START( node );
    1282 
    1283         VISIT({
    1284                         guard_indexer guard { *this };
    1285                         maybe_accept( node, &ImplicitCopyCtorExpr::result );
    1286                 }
    1287                 maybe_accept( node, &ImplicitCopyCtorExpr::callExpr    );
    1288                 maybe_accept( node, &ImplicitCopyCtorExpr::tempDecls   );
    1289                 maybe_accept( node, &ImplicitCopyCtorExpr::returnDecls );
    1290                 maybe_accept( node, &ImplicitCopyCtorExpr::dtors       );
    1291         )
    1292 
    1293         VISIT_END( Expr, node );
    1294 }
    1295 
    1296 //--------------------------------------------------------------------------
    1297 // ConstructorExpr
    1298 template< typename pass_t >
    1299 const ast::Expr * ast::Pass< pass_t >::visit( const ast::ConstructorExpr * node ) {
    1300         VISIT_START( node );
    1301 
    1302         VISIT({
    1303                         guard_indexer guard { *this };
    1304                         maybe_accept( node, &ConstructorExpr::result );
    1305                 }
    1306                 maybe_accept( node, &ConstructorExpr::callExpr );
    1307         )
    1308 
    1309         VISIT_END( Expr, node );
    1310 }
    1311 
    1312 //--------------------------------------------------------------------------
    1313 // CompoundLiteralExpr
    1314 template< typename pass_t >
    1315 const ast::Expr * ast::Pass< pass_t >::visit( const ast::CompoundLiteralExpr * node ) {
    1316         VISIT_START( node );
    1317 
    1318         VISIT({
    1319                         guard_indexer guard { *this };
    1320                         maybe_accept( node, &CompoundLiteralExpr::result );
    1321                 }
    1322                 maybe_accept( node, &CompoundLiteralExpr::init );
    1323         )
    1324 
    1325         VISIT_END( Expr, node );
    1326 }
    1327 
    1328 //--------------------------------------------------------------------------
    1329 // RangeExpr
    1330 template< typename pass_t >
    1331 const ast::Expr * ast::Pass< pass_t >::visit( const ast::RangeExpr * node ) {
    1332         VISIT_START( node );
    1333 
    1334         VISIT({
    1335                         guard_indexer guard { *this };
    1336                         maybe_accept( node, &RangeExpr::result );
    1337                 }
    1338                 maybe_accept( node, &RangeExpr::low    );
    1339                 maybe_accept( node, &RangeExpr::high   );
    1340         )
    1341 
    1342         VISIT_END( Expr, node );
    1343 }
    1344 
    1345 //--------------------------------------------------------------------------
    1346 // UntypedTupleExpr
    1347 template< typename pass_t >
    1348 const ast::Expr * ast::Pass< pass_t >::visit( const ast::UntypedTupleExpr * node ) {
    1349         VISIT_START( node );
    1350 
    1351         VISIT({
    1352                         guard_indexer guard { *this };
    1353                         maybe_accept( node, &UntypedTupleExpr::result );
    1354                 }
    1355                 maybe_accept( node, &UntypedTupleExpr::exprs  );
    1356         )
    1357 
    1358         VISIT_END( Expr, node );
    1359 }
    1360 
    1361 //--------------------------------------------------------------------------
    1362 // TupleExpr
    1363 template< typename pass_t >
    1364 const ast::Expr * ast::Pass< pass_t >::visit( const ast::TupleExpr * node ) {
    1365         VISIT_START( node );
    1366 
    1367         VISIT({
    1368                         guard_indexer guard { *this };
    1369                         maybe_accept( node, &TupleExpr::result );
    1370                 }
    1371                 maybe_accept( node, &TupleExpr::exprs  );
    1372         )
    1373 
    1374         VISIT_END( Expr, node );
    1375 }
    1376 
    1377 //--------------------------------------------------------------------------
    1378 // TupleIndexExpr
    1379 template< typename pass_t >
    1380 const ast::Expr * ast::Pass< pass_t >::visit( const ast::TupleIndexExpr * node ) {
    1381         VISIT_START( node );
    1382 
    1383         VISIT({
    1384                         guard_indexer guard { *this };
    1385                         maybe_accept( node, &TupleIndexExpr::result );
    1386                 }
    1387                 maybe_accept( node, &TupleIndexExpr::tuple  );
    1388         )
    1389 
    1390         VISIT_END( Expr, node );
    1391 }
    1392 
    1393 //--------------------------------------------------------------------------
    1394 // TupleAssignExpr
    1395 template< typename pass_t >
    1396 const ast::Expr * ast::Pass< pass_t >::visit( const ast::TupleAssignExpr * node ) {
    1397         VISIT_START( node );
    1398 
    1399         VISIT({
    1400                         guard_indexer guard { *this };
    1401                         maybe_accept( node, &TupleAssignExpr::result );
    1402                 }
    1403                 maybe_accept( node, &TupleAssignExpr::stmtExpr );
    1404         )
    1405 
    1406         VISIT_END( Expr, node );
    1407 }
    1408 
    1409 //--------------------------------------------------------------------------
    1410 // StmtExpr
    1411 template< typename pass_t >
    1412 const ast::Expr * ast::Pass< pass_t >::visit( const ast::StmtExpr * node ) {
    1413         VISIT_START( node );
    1414 
    1415         VISIT(// don't want statements from outer CompoundStmts to be added to this StmtExpr
    1416                 // get the stmts that will need to be spliced in
    1417                 auto stmts_before = __pass::stmtsToAddBefore( pass, 0);
    1418                 auto stmts_after  = __pass::stmtsToAddAfter ( pass, 0);
    1419 
    1420                 // These may be modified by subnode but most be restored once we exit this statemnet.
    1421                 ValueGuardPtr< const ast::TypeSubstitution * > __old_env( __pass::env( pass, 0) );
    1422                 ValueGuardPtr< typename std::remove_pointer< decltype(stmts_before) >::type > __old_decls_before( stmts_before );
    1423                 ValueGuardPtr< typename std::remove_pointer< decltype(stmts_after ) >::type > __old_decls_after ( stmts_after  );
    1424 
    1425                 {
    1426                         guard_indexer guard { *this };
    1427                         maybe_accept( node, &StmtExpr::result );
    1428                 }
    1429                 maybe_accept( node, &StmtExpr::stmts       );
    1430                 maybe_accept( node, &StmtExpr::returnDecls );
    1431                 maybe_accept( node, &StmtExpr::dtors       );
    1432         )
    1433 
    1434         VISIT_END( Expr, node );
    1435 }
    1436 
    1437 //--------------------------------------------------------------------------
    1438 // UniqueExpr
    1439 template< typename pass_t >
    1440 const ast::Expr * ast::Pass< pass_t >::visit( const ast::UniqueExpr * node ) {
    1441         VISIT_START( node );
    1442 
    1443         VISIT({
    1444                         guard_indexer guard { *this };
    1445                         maybe_accept( node, &UniqueExpr::result );
    1446                 }
    1447                 maybe_accept( node, &UniqueExpr::expr   );
    1448         )
    1449 
    1450         VISIT_END( Expr, node );
    1451 }
    1452 
    1453 //--------------------------------------------------------------------------
    1454 // UntypedInitExpr
    1455 template< typename pass_t >
    1456 const ast::Expr * ast::Pass< pass_t >::visit( const ast::UntypedInitExpr * node ) {
    1457         VISIT_START( node );
    1458 
    1459         VISIT({
    1460                         guard_indexer guard { *this };
    1461                         maybe_accept( node, &UntypedInitExpr::result );
    1462                 }
    1463                 maybe_accept( node, &UntypedInitExpr::expr   );
    1464                 // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
    1465         )
    1466 
    1467         VISIT_END( Expr, node );
    1468 }
    1469 
    1470 //--------------------------------------------------------------------------
    1471 // InitExpr
    1472 template< typename pass_t >
    1473 const ast::Expr * ast::Pass< pass_t >::visit( const ast::InitExpr * node ) {
    1474         VISIT_START( node );
    1475 
    1476         VISIT({
    1477                         guard_indexer guard { *this };
    1478                         maybe_accept( node, &InitExpr::result );
    1479                 }
    1480                 maybe_accept( node, &InitExpr::expr   );
    1481                 maybe_accept( node, &InitExpr::designation );
    1482         )
    1483 
    1484         VISIT_END( Expr, node );
    1485 }
    1486 
    1487 //--------------------------------------------------------------------------
    1488 // DeletedExpr
    1489 template< typename pass_t >
    1490 const ast::Expr * ast::Pass< pass_t >::visit( const ast::DeletedExpr * node ) {
    1491         VISIT_START( node );
    1492 
    1493         VISIT({
    1494                         guard_indexer guard { *this };
    1495                         maybe_accept( node, &DeletedExpr::result );
    1496                 }
    1497                 maybe_accept( node, &DeletedExpr::expr );
    1498                 // don't visit deleteStmt, because it is a pointer to somewhere else in the tree.
    1499         )
    1500 
    1501         VISIT_END( Expr, node );
    1502 }
    1503 
    1504 //--------------------------------------------------------------------------
    1505 // DefaultArgExpr
    1506 template< typename pass_t >
    1507 const ast::Expr * ast::Pass< pass_t >::visit( const ast::DefaultArgExpr * node ) {
    1508         VISIT_START( node );
    1509 
    1510         VISIT({
    1511                         guard_indexer guard { *this };
    1512                         maybe_accept( node, &DefaultArgExpr::result );
    1513                 }
    1514                 maybe_accept( node, &DefaultArgExpr::expr );
    1515         )
    1516 
    1517         VISIT_END( Expr, node );
    1518 }
    1519 
    1520 //--------------------------------------------------------------------------
    1521 // GenericExpr
    1522 template< typename pass_t >
    1523 const ast::Expr * ast::Pass< pass_t >::visit( const ast::GenericExpr * node ) {
    1524         VISIT_START( node );
    1525 
    1526         VISIT({
    1527                         guard_indexer guard { *this };
    1528                         maybe_accept( node, &GenericExpr::result );
    1529                 }
    1530                 maybe_accept( node, &GenericExpr::control );
    1531 
    1532                 std::vector<GenericExpr::Association> new_kids;
    1533                 new_kids.reserve(node->associations.size());
    1534                 bool mutated = false;
    1535                 for( const auto & assoc : node->associations ) {
    1536                         Type * type = nullptr;
    1537                         if( assoc.type ) {
    1538                                 guard_indexer guard { *this };
    1539                                 type = assoc.type->accept( *this );
    1540                                 if( type != assoc.type ) mutated = true;
    1541                         }
    1542                         Expr * expr = nullptr;
    1543                         if( assoc.expr ) {
    1544                                 expr = assoc.expr->accept( *this );
    1545                                 if( expr != assoc.expr ) mutated = true;
    1546                         }
    1547                         new_kids.emplace_back( type, expr );
    1548                 }
    1549 
    1550                 if(mutated) {
    1551                         auto n = mutate(node);
    1552                         n->associations = std::move( new_kids );
    1553                         node = n;
    1554                 }
    1555         )
    1556 
    1557         VISIT_END( Expr, node );
    1558 }
     912
    1559913
    1560914
     
    1616970}
    1617971
    1618 // //--------------------------------------------------------------------------
    1619 // // TypeSubstitution
    1620 // template< typename pass_t >
    1621 // const ast::TypeSubstitution * ast::Pass< pass_t >::visit( const ast::TypeSubstitution * node ) {
    1622 //      VISIT_START( node );
    1623 
    1624 //      VISIT(
    1625 //              {
    1626 //                      bool mutated = false;
    1627 //                      std::unordered_map< std::string, ast::ptr< ast::Type > > new_map;
    1628 //                      for ( const auto & p : node->typeEnv ) {
    1629 //                              guard_indexer guard { *this };
    1630 //                              auto new_node = p.second->accept( *this );
    1631 //                              if (new_node != p.second) mutated = false;
    1632 //                              new_map.insert({ p.first, new_node });
    1633 //                      }
    1634 //                      if (mutated) {
    1635 //                              auto new_node = mutate( node );
    1636 //                              new_node->typeEnv.swap( new_map );
    1637 //                              node = new_node;
    1638 //                      }
    1639 //              }
    1640 
    1641 //              {
    1642 //                      bool mutated = false;
    1643 //                      std::unordered_map< std::string, ast::ptr< ast::Expr > > new_map;
    1644 //                      for ( const auto & p : node->varEnv ) {
    1645 //                              guard_indexer guard { *this };
    1646 //                              auto new_node = p.second->accept( *this );
    1647 //                              if (new_node != p.second) mutated = false;
    1648 //                              new_map.insert({ p.first, new_node });
    1649 //                      }
    1650 //                      if (mutated) {
    1651 //                              auto new_node = mutate( node );
    1652 //                              new_node->varEnv.swap( new_map );
    1653 //                              node = new_node;
    1654 //                      }
    1655 //              }
    1656 //      )
    1657 
    1658 //      VISIT_END( TypeSubstitution, node );
    1659 // }
     972//--------------------------------------------------------------------------
     973// TypeSubstitution
     974template< typename pass_t >
     975const ast::TypeSubstitution * ast::Pass< pass_t >::visit( const ast::TypeSubstitution * node ) {
     976        VISIT_START( node );
     977
     978        VISIT(
     979                {
     980                        bool mutated = false;
     981                        std::unordered_map< std::string, ast::ptr< ast::Type > > new_map;
     982                        for ( const auto & p : node->typeEnv ) {
     983                                guard_indexer guard { *this };
     984                                auto new_node = p.second->accept( *this );
     985                                if (new_node != p.second) mutated = false;
     986                                new_map.insert({ p.first, new_node });
     987                        }
     988                        if (mutated) {
     989                                auto new_node = mutate( node );
     990                                new_node->typeEnv.swap( new_map );
     991                                node = new_node;
     992                        }
     993                }
     994
     995                {
     996                        bool mutated = false;
     997                        std::unordered_map< std::string, ast::ptr< ast::Expr > > new_map;
     998                        for ( const auto & p : node->varEnv ) {
     999                                guard_indexer guard { *this };
     1000                                auto new_node = p.second->accept( *this );
     1001                                if (new_node != p.second) mutated = false;
     1002                                new_map.insert({ p.first, new_node });
     1003                        }
     1004                        if (mutated) {
     1005                                auto new_node = mutate( node );
     1006                                new_node->varEnv.swap( new_map );
     1007                                node = new_node;
     1008                        }
     1009                }
     1010        )
     1011
     1012        VISIT_END( TypeSubstitution, node );
     1013}
    16601014
    16611015#undef VISIT_START
Note: See TracChangeset for help on using the changeset viewer.