Changeset 17a0228a


Ignore:
Timestamp:
May 21, 2019, 2:27:53 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
51ff278
Parents:
dccc091
Message:

Added more visit passes

Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Expr.hpp

    rdccc091 r17a0228a  
    503503};
    504504
    505 /// The application of a function to a set of parameters, along with a set of copy constructor 
     505/// The application of a function to a set of parameters, along with a set of copy constructor
    506506/// calls, one for each argument
    507507class ImplicitCopyCtorExpr final : public Expr {
     
    603603};
    604604
    605 /// A multiple- or mass-assignment operation, or a tuple ctor/dtor expression. 
    606 /// multiple-assignment: both sides of the assignment have tuple type, 
     605/// A multiple- or mass-assignment operation, or a tuple ctor/dtor expression.
     606/// multiple-assignment: both sides of the assignment have tuple type,
    607607///     e.g. `[a, b, c] = [d, e, f];`
    608608/// mass-assignment: left-hand side has tuple type and right-hand side does not:
     
    612612        ptr<StmtExpr> stmtExpr;
    613613
    614         TupleAssignExpr( 
    615                 const CodeLocation & loc, std::vector<ptr<Expr>> && assigns, 
     614        TupleAssignExpr(
     615                const CodeLocation & loc, std::vector<ptr<Expr>> && assigns,
    616616                std::vector<ptr<ObjectDecl>> && tempDecls );
    617        
     617
    618618        const Expr * accept( Visitor & v ) const override { return v.visit( this ); }
    619619private:
  • src/AST/Fwd.hpp

    rdccc091 r17a0228a  
    1515
    1616#pragma once
     17
     18#include <string>
    1719
    1820#include "AST/Node.hpp"
     
    134136
    135137template < typename ... Params >
    136 std::string toString( const Params & ... params );
     138std::string toString( const Params & ... params ) {
     139        #warning not implemented
     140        return "";
     141}
    137142
    138143typedef unsigned int UniqueId;
  • src/AST/Pass.impl.hpp

    rdccc091 r17a0228a  
    571571        __pass::indexer::addType( pass, 0, node );
    572572
    573         maybe_accept( node, &TypedefDecl::assertions );
     573        VISIT( 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 ExprStmt * node ) {
     628const ast::Stmt * ast::Pass< pass_t >::visit( const ast::ExprStmt * node ) {
    629629        VISIT_START( node );
    630630
     
    666666const ast::Stmt * ast::Pass< pass_t >::visit( const ast::IfStmt * node ) {
    667667        VISIT_START( node );
     668
    668669        VISIT({
    669670                // if statements introduce a level of scope (for the initialization)
     
    674675                maybe_accept( node, &IfStmt::elsePart );
    675676        })
     677
    676678        VISIT_END( Stmt, node );
    677679}
     
    680682// WhileStmt
    681683template< typename pass_t >
    682 const ast::Stmt * ast::Pass< pass_t >::visit( const WhileStmt * node ) {
     684const ast::Stmt * ast::Pass< pass_t >::visit( const ast::WhileStmt * node ) {
    683685        VISIT_START( node );
    684686
     
    910912}
    911913
    912 
     914//--------------------------------------------------------------------------
     915// ApplicationExpr
     916template< typename pass_t >
     917const 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
     934template< typename pass_t >
     935const 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
     952template< typename pass_t >
     953const 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
     966template< typename pass_t >
     967const 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
     982template< typename pass_t >
     983const 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
     998template< typename pass_t >
     999const 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
     1014template< typename pass_t >
     1015const 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
     1030template< typename pass_t >
     1031const 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
     1044template< typename pass_t >
     1045const 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
     1061template< typename pass_t >
     1062const 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
     1077template< typename pass_t >
     1078const 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
     1091template< typename pass_t >
     1092const 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
     1105template< typename pass_t >
     1106const 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
     1125template< typename pass_t >
     1126const 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
     1145template< typename pass_t >
     1146const 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
     1161template< typename pass_t >
     1162const 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
     1177template< typename pass_t >
     1178const 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
     1193template< typename pass_t >
     1194const 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
     1210template< typename pass_t >
     1211const 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
     1228template< typename pass_t >
     1229const 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
     1245template< typename pass_t >
     1246const 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
     1261template< typename pass_t >
     1262const 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
     1279template< typename pass_t >
     1280const 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
     1298template< typename pass_t >
     1299const 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
     1314template< typename pass_t >
     1315const 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
     1330template< typename pass_t >
     1331const 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
     1347template< typename pass_t >
     1348const 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
     1363template< typename pass_t >
     1364const 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
     1379template< typename pass_t >
     1380const 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
     1395template< typename pass_t >
     1396const 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
     1411template< typename pass_t >
     1412const 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
     1439template< typename pass_t >
     1440const 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
     1455template< typename pass_t >
     1456const 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
     1472template< typename pass_t >
     1473const 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
     1489template< typename pass_t >
     1490const 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
     1506template< typename pass_t >
     1507const 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
     1522template< typename pass_t >
     1523const 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}
    9131559
    9141560
     
    9701616}
    9711617
    972 //--------------------------------------------------------------------------
    973 // TypeSubstitution
    974 template< typename pass_t >
    975 const 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 }
     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// }
    10141660
    10151661#undef VISIT_START
  • src/main.cc

    rdccc091 r17a0228a  
    4040#include "Common/Stats.h"
    4141#include "Common/PassVisitor.h"
    42 // #include "AST/Pass.hpp"
    4342#include "Common/SemanticError.h"           // for SemanticError
    4443#include "Common/UnimplementedError.h"      // for UnimplementedError
Note: See TracChangeset for help on using the changeset viewer.