| 1 | //
 | 
|---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
 | 
|---|
| 3 | //
 | 
|---|
| 4 | // The contents of this file are covered under the licence agreement in the
 | 
|---|
| 5 | // file "LICENCE" distributed with Cforall.
 | 
|---|
| 6 | //
 | 
|---|
| 7 | // Visitor.cc --
 | 
|---|
| 8 | //
 | 
|---|
| 9 | // Author           : Richard C. Bilson
 | 
|---|
| 10 | // Created On       : Mon May 18 07:44:20 2015
 | 
|---|
| 11 | // Last Modified By : Andrew Beach
 | 
|---|
| 12 | // Last Modified On : Mon Jul 24 16:30:00 2017
 | 
|---|
| 13 | // Update Count     : 27
 | 
|---|
| 14 | //
 | 
|---|
| 15 | 
 | 
|---|
| 16 | #include <cassert>        // for assert
 | 
|---|
| 17 | #include <list>           // for list
 | 
|---|
| 18 | 
 | 
|---|
| 19 | #include "Constant.h"     // for Constant
 | 
|---|
| 20 | #include "Declaration.h"  // for DeclarationWithType, ObjectDecl, Declaration
 | 
|---|
| 21 | #include "Expression.h"   // for Expression, ConstantExpr, ImplicitCopyCtorExpr
 | 
|---|
| 22 | #include "Initializer.h"  // for Initializer, Designation, ConstructorInit
 | 
|---|
| 23 | #include "Statement.h"    // for Statement, CatchStmt, AsmStmt, CompoundStmt
 | 
|---|
| 24 | #include "Type.h"         // for Type, Type::ForallList, AttrType, FunctionType
 | 
|---|
| 25 | #include "Visitor.h"
 | 
|---|
| 26 | 
 | 
|---|
| 27 | class Subrange;
 | 
|---|
| 28 | 
 | 
|---|
| 29 | Visitor::Visitor() {}
 | 
|---|
| 30 | 
 | 
|---|
| 31 | Visitor::~Visitor() {}
 | 
|---|
| 32 | 
 | 
|---|
| 33 | void Visitor::visit( ObjectDecl *objectDecl ) {
 | 
|---|
| 34 |         maybeAccept( objectDecl->get_type(), *this );
 | 
|---|
| 35 |         maybeAccept( objectDecl->get_init(), *this );
 | 
|---|
| 36 |         maybeAccept( objectDecl->get_bitfieldWidth(), *this );
 | 
|---|
| 37 | }
 | 
|---|
| 38 | 
 | 
|---|
| 39 | void Visitor::visit( FunctionDecl *functionDecl ) {
 | 
|---|
| 40 |         maybeAccept( functionDecl->get_functionType(), *this );
 | 
|---|
| 41 |         maybeAccept( functionDecl->get_statements(), *this );
 | 
|---|
| 42 | }
 | 
|---|
| 43 | 
 | 
|---|
| 44 | void Visitor::handleAggregateDecl( AggregateDecl *aggregateDecl ) {
 | 
|---|
| 45 |         acceptAll( aggregateDecl->get_parameters(), *this );
 | 
|---|
| 46 |         acceptAll( aggregateDecl->get_members(), *this );
 | 
|---|
| 47 | }
 | 
|---|
| 48 | 
 | 
|---|
| 49 | void Visitor::visit( StructDecl *aggregateDecl ) {
 | 
|---|
| 50 |         handleAggregateDecl( static_cast< AggregateDecl* >( aggregateDecl ) );
 | 
|---|
| 51 | }
 | 
|---|
| 52 | 
 | 
|---|
| 53 | void Visitor::visit( UnionDecl *aggregateDecl ) {
 | 
|---|
| 54 |         handleAggregateDecl( static_cast< AggregateDecl* >( aggregateDecl ) );
 | 
|---|
| 55 | }
 | 
|---|
| 56 | 
 | 
|---|
| 57 | void Visitor::visit( EnumDecl *aggregateDecl ) {
 | 
|---|
| 58 |         handleAggregateDecl( static_cast< AggregateDecl* >( aggregateDecl ) );
 | 
|---|
| 59 | }
 | 
|---|
| 60 | 
 | 
|---|
| 61 | void Visitor::visit( TraitDecl *aggregateDecl ) {
 | 
|---|
| 62 |         handleAggregateDecl( static_cast< AggregateDecl* >( aggregateDecl ) );
 | 
|---|
| 63 | }
 | 
|---|
| 64 | 
 | 
|---|
| 65 | void Visitor::handleNamedTypeDecl( NamedTypeDecl *typeDecl ) {
 | 
|---|
| 66 |         acceptAll( typeDecl->get_parameters(), *this );
 | 
|---|
| 67 |         acceptAll( typeDecl->get_assertions(), *this );
 | 
|---|
| 68 |         maybeAccept( typeDecl->get_base(), *this );
 | 
|---|
| 69 | }
 | 
|---|
| 70 | 
 | 
|---|
| 71 | void Visitor::visit( TypeDecl *typeDecl ) {
 | 
|---|
| 72 |         handleNamedTypeDecl( static_cast< NamedTypeDecl* >( typeDecl ) );
 | 
|---|
| 73 |         maybeAccept( typeDecl->get_init(), *this );
 | 
|---|
| 74 | }
 | 
|---|
| 75 | 
 | 
|---|
| 76 | void Visitor::visit( TypedefDecl *typeDecl ) {
 | 
|---|
| 77 |         handleNamedTypeDecl( static_cast< NamedTypeDecl* >( typeDecl ) );
 | 
|---|
| 78 | }
 | 
|---|
| 79 | 
 | 
|---|
| 80 | void Visitor::visit( AsmDecl *asmDecl ) {
 | 
|---|
| 81 |         maybeAccept( asmDecl->get_stmt(), *this );
 | 
|---|
| 82 | }
 | 
|---|
| 83 | 
 | 
|---|
| 84 | 
 | 
|---|
| 85 | void Visitor::visit( CompoundStmt *compoundStmt ) {
 | 
|---|
| 86 |         acceptAll( compoundStmt->get_kids(), *this );
 | 
|---|
| 87 | }
 | 
|---|
| 88 | 
 | 
|---|
| 89 | void Visitor::visit( ExprStmt *exprStmt ) {
 | 
|---|
| 90 |         maybeAccept( exprStmt->get_expr(), *this );
 | 
|---|
| 91 | }
 | 
|---|
| 92 | 
 | 
|---|
| 93 | void Visitor::visit( AsmStmt *asmStmt ) {
 | 
|---|
| 94 |         maybeAccept( asmStmt->get_instruction(), *this );
 | 
|---|
| 95 |         acceptAll( asmStmt->get_output(), *this );
 | 
|---|
| 96 |         acceptAll( asmStmt->get_input(), *this );
 | 
|---|
| 97 |         acceptAll( asmStmt->get_clobber(), *this );
 | 
|---|
| 98 | }
 | 
|---|
| 99 | 
 | 
|---|
| 100 | void Visitor::visit( IfStmt *ifStmt ) {
 | 
|---|
| 101 |         maybeAccept( ifStmt->get_condition(), *this );
 | 
|---|
| 102 |         maybeAccept( ifStmt->get_thenPart(), *this );
 | 
|---|
| 103 |         maybeAccept( ifStmt->get_elsePart(), *this );
 | 
|---|
| 104 | }
 | 
|---|
| 105 | 
 | 
|---|
| 106 | void Visitor::visit( WhileStmt *whileStmt ) {
 | 
|---|
| 107 |         maybeAccept( whileStmt->get_condition(), *this );
 | 
|---|
| 108 |         maybeAccept( whileStmt->get_body(), *this );
 | 
|---|
| 109 | }
 | 
|---|
| 110 | 
 | 
|---|
| 111 | void Visitor::visit( ForStmt *forStmt ) {
 | 
|---|
| 112 |         acceptAll( forStmt->get_initialization(), *this );
 | 
|---|
| 113 |         maybeAccept( forStmt->get_condition(), *this );
 | 
|---|
| 114 |         maybeAccept( forStmt->get_increment(), *this );
 | 
|---|
| 115 |         maybeAccept( forStmt->get_body(), *this );
 | 
|---|
| 116 | }
 | 
|---|
| 117 | 
 | 
|---|
| 118 | void Visitor::visit( SwitchStmt *switchStmt ) {
 | 
|---|
| 119 |         maybeAccept( switchStmt->get_condition(), *this );
 | 
|---|
| 120 |         acceptAll( switchStmt->get_statements(), *this );
 | 
|---|
| 121 | }
 | 
|---|
| 122 | 
 | 
|---|
| 123 | void Visitor::visit( CaseStmt *caseStmt ) {
 | 
|---|
| 124 |         maybeAccept( caseStmt->get_condition(), *this );
 | 
|---|
| 125 |         acceptAll( caseStmt->get_statements(), *this );
 | 
|---|
| 126 | }
 | 
|---|
| 127 | 
 | 
|---|
| 128 | void Visitor::visit( __attribute__((unused)) BranchStmt *branchStmt ) {
 | 
|---|
| 129 | }
 | 
|---|
| 130 | 
 | 
|---|
| 131 | void Visitor::visit( ReturnStmt *returnStmt ) {
 | 
|---|
| 132 |         maybeAccept( returnStmt->get_expr(), *this );
 | 
|---|
| 133 | }
 | 
|---|
| 134 | 
 | 
|---|
| 135 | void Visitor::visit( ThrowStmt * throwStmt ) {
 | 
|---|
| 136 |         maybeAccept( throwStmt->get_expr(), *this );
 | 
|---|
| 137 |         maybeAccept( throwStmt->get_target(), *this );
 | 
|---|
| 138 | }
 | 
|---|
| 139 | 
 | 
|---|
| 140 | void Visitor::visit( TryStmt *tryStmt ) {
 | 
|---|
| 141 |         maybeAccept( tryStmt->get_block(), *this );
 | 
|---|
| 142 |         acceptAll( tryStmt->get_catchers(), *this );
 | 
|---|
| 143 |         maybeAccept( tryStmt->get_finally(), *this );
 | 
|---|
| 144 | }
 | 
|---|
| 145 | 
 | 
|---|
| 146 | void Visitor::visit( CatchStmt *catchStmt ) {
 | 
|---|
| 147 |         maybeAccept( catchStmt->get_decl(), *this );
 | 
|---|
| 148 |         maybeAccept( catchStmt->get_cond(), *this );
 | 
|---|
| 149 |         maybeAccept( catchStmt->get_body(), *this );
 | 
|---|
| 150 | }
 | 
|---|
| 151 | 
 | 
|---|
| 152 | void Visitor::visit( FinallyStmt *finalStmt ) {
 | 
|---|
| 153 |         maybeAccept( finalStmt->get_block(), *this );
 | 
|---|
| 154 | }
 | 
|---|
| 155 | 
 | 
|---|
| 156 | void Visitor::visit( __attribute__((unused)) NullStmt *nullStmt ) {
 | 
|---|
| 157 | }
 | 
|---|
| 158 | 
 | 
|---|
| 159 | void Visitor::visit( DeclStmt *declStmt ) {
 | 
|---|
| 160 |         maybeAccept( declStmt->get_decl(), *this );
 | 
|---|
| 161 | }
 | 
|---|
| 162 | 
 | 
|---|
| 163 | void Visitor::visit( ImplicitCtorDtorStmt *impCtorDtorStmt ) {
 | 
|---|
| 164 |         maybeAccept( impCtorDtorStmt->get_callStmt(), *this );
 | 
|---|
| 165 | }
 | 
|---|
| 166 | 
 | 
|---|
| 167 | 
 | 
|---|
| 168 | void Visitor::visit( ApplicationExpr *applicationExpr ) {
 | 
|---|
| 169 |         maybeAccept( applicationExpr->get_result(), *this );
 | 
|---|
| 170 |         maybeAccept( applicationExpr->get_function(), *this );
 | 
|---|
| 171 |         acceptAll( applicationExpr->get_args(), *this );
 | 
|---|
| 172 | }
 | 
|---|
| 173 | 
 | 
|---|
| 174 | void Visitor::visit( UntypedExpr *untypedExpr ) {
 | 
|---|
| 175 |         maybeAccept( untypedExpr->get_result(), *this );
 | 
|---|
| 176 |         acceptAll( untypedExpr->get_args(), *this );
 | 
|---|
| 177 | }
 | 
|---|
| 178 | 
 | 
|---|
| 179 | void Visitor::visit( NameExpr *nameExpr ) {
 | 
|---|
| 180 |         maybeAccept( nameExpr->get_result(), *this );
 | 
|---|
| 181 | }
 | 
|---|
| 182 | 
 | 
|---|
| 183 | void Visitor::visit( AddressExpr *addressExpr ) {
 | 
|---|
| 184 |         maybeAccept( addressExpr->get_result(), *this );
 | 
|---|
| 185 |         maybeAccept( addressExpr->get_arg(), *this );
 | 
|---|
| 186 | }
 | 
|---|
| 187 | 
 | 
|---|
| 188 | void Visitor::visit( LabelAddressExpr *labAddressExpr ) {
 | 
|---|
| 189 |         maybeAccept( labAddressExpr->get_result(), *this );
 | 
|---|
| 190 |         maybeAccept( labAddressExpr->get_arg(), *this );
 | 
|---|
| 191 | }
 | 
|---|
| 192 | 
 | 
|---|
| 193 | void Visitor::visit( CastExpr *castExpr ) {
 | 
|---|
| 194 |         maybeAccept( castExpr->get_result(), *this );
 | 
|---|
| 195 |         maybeAccept( castExpr->get_arg(), *this );
 | 
|---|
| 196 | }
 | 
|---|
| 197 | 
 | 
|---|
| 198 | void Visitor::visit( VirtualCastExpr *castExpr ) {
 | 
|---|
| 199 |         maybeAccept( castExpr->get_result(), *this );
 | 
|---|
| 200 |         maybeAccept( castExpr->get_arg(), *this );
 | 
|---|
| 201 | }
 | 
|---|
| 202 | 
 | 
|---|
| 203 | void Visitor::visit( UntypedMemberExpr *memberExpr ) {
 | 
|---|
| 204 |         maybeAccept( memberExpr->get_result(), *this );
 | 
|---|
| 205 |         maybeAccept( memberExpr->get_aggregate(), *this );
 | 
|---|
| 206 |         maybeAccept( memberExpr->get_member(), *this );
 | 
|---|
| 207 | }
 | 
|---|
| 208 | 
 | 
|---|
| 209 | void Visitor::visit( MemberExpr *memberExpr ) {
 | 
|---|
| 210 |         maybeAccept( memberExpr->get_result(), *this );
 | 
|---|
| 211 |         maybeAccept( memberExpr->get_aggregate(), *this );
 | 
|---|
| 212 | }
 | 
|---|
| 213 | 
 | 
|---|
| 214 | void Visitor::visit( VariableExpr *variableExpr ) {
 | 
|---|
| 215 |         maybeAccept( variableExpr->get_result(), *this );
 | 
|---|
| 216 | }
 | 
|---|
| 217 | 
 | 
|---|
| 218 | void Visitor::visit( ConstantExpr *constantExpr ) {
 | 
|---|
| 219 |         maybeAccept( constantExpr->get_result(), *this );
 | 
|---|
| 220 |         maybeAccept( constantExpr->get_constant(), *this );
 | 
|---|
| 221 | }
 | 
|---|
| 222 | 
 | 
|---|
| 223 | void Visitor::visit( SizeofExpr *sizeofExpr ) {
 | 
|---|
| 224 |         maybeAccept( sizeofExpr->get_result(), *this );
 | 
|---|
| 225 |         if ( sizeofExpr->get_isType() ) {
 | 
|---|
| 226 |                 maybeAccept( sizeofExpr->get_type(), *this );
 | 
|---|
| 227 |         } else {
 | 
|---|
| 228 |                 maybeAccept( sizeofExpr->get_expr(), *this );
 | 
|---|
| 229 |         }
 | 
|---|
| 230 | }
 | 
|---|
| 231 | 
 | 
|---|
| 232 | void Visitor::visit( AlignofExpr *alignofExpr ) {
 | 
|---|
| 233 |         maybeAccept( alignofExpr->get_result(), *this );
 | 
|---|
| 234 |         if ( alignofExpr->get_isType() ) {
 | 
|---|
| 235 |                 maybeAccept( alignofExpr->get_type(), *this );
 | 
|---|
| 236 |         } else {
 | 
|---|
| 237 |                 maybeAccept( alignofExpr->get_expr(), *this );
 | 
|---|
| 238 |         }
 | 
|---|
| 239 | }
 | 
|---|
| 240 | 
 | 
|---|
| 241 | void Visitor::visit( UntypedOffsetofExpr *offsetofExpr ) {
 | 
|---|
| 242 |         maybeAccept( offsetofExpr->get_result(), *this );
 | 
|---|
| 243 |         maybeAccept( offsetofExpr->get_type(), *this );
 | 
|---|
| 244 | }
 | 
|---|
| 245 | 
 | 
|---|
| 246 | void Visitor::visit( OffsetofExpr *offsetofExpr ) {
 | 
|---|
| 247 |         maybeAccept( offsetofExpr->get_result(), *this );
 | 
|---|
| 248 |         maybeAccept( offsetofExpr->get_type(), *this );
 | 
|---|
| 249 |         maybeAccept( offsetofExpr->get_member(), *this );
 | 
|---|
| 250 | }
 | 
|---|
| 251 | 
 | 
|---|
| 252 | void Visitor::visit( OffsetPackExpr *offsetPackExpr ) {
 | 
|---|
| 253 |         maybeAccept( offsetPackExpr->get_result(), *this );
 | 
|---|
| 254 |         maybeAccept( offsetPackExpr->get_type(), *this );
 | 
|---|
| 255 | }
 | 
|---|
| 256 | 
 | 
|---|
| 257 | void Visitor::visit( AttrExpr *attrExpr ) {
 | 
|---|
| 258 |         maybeAccept( attrExpr->get_result(), *this );
 | 
|---|
| 259 |         if ( attrExpr->get_isType() ) {
 | 
|---|
| 260 |                 maybeAccept( attrExpr->get_type(), *this );
 | 
|---|
| 261 |         } else {
 | 
|---|
| 262 |                 maybeAccept( attrExpr->get_expr(), *this );
 | 
|---|
| 263 |         }
 | 
|---|
| 264 | }
 | 
|---|
| 265 | 
 | 
|---|
| 266 | void Visitor::visit( LogicalExpr *logicalExpr ) {
 | 
|---|
| 267 |         maybeAccept( logicalExpr->get_result(), *this );
 | 
|---|
| 268 |         maybeAccept( logicalExpr->get_arg1(), *this );
 | 
|---|
| 269 |         maybeAccept( logicalExpr->get_arg2(), *this );
 | 
|---|
| 270 | }
 | 
|---|
| 271 | 
 | 
|---|
| 272 | void Visitor::visit( ConditionalExpr *conditionalExpr ) {
 | 
|---|
| 273 |         maybeAccept( conditionalExpr->get_result(), *this );
 | 
|---|
| 274 |         maybeAccept( conditionalExpr->get_arg1(), *this );
 | 
|---|
| 275 |         maybeAccept( conditionalExpr->get_arg2(), *this );
 | 
|---|
| 276 |         maybeAccept( conditionalExpr->get_arg3(), *this );
 | 
|---|
| 277 | }
 | 
|---|
| 278 | 
 | 
|---|
| 279 | void Visitor::visit( CommaExpr *commaExpr ) {
 | 
|---|
| 280 |         maybeAccept( commaExpr->get_result(), *this );
 | 
|---|
| 281 |         maybeAccept( commaExpr->get_arg1(), *this );
 | 
|---|
| 282 |         maybeAccept( commaExpr->get_arg2(), *this );
 | 
|---|
| 283 | }
 | 
|---|
| 284 | 
 | 
|---|
| 285 | void Visitor::visit( TypeExpr *typeExpr ) {
 | 
|---|
| 286 |         maybeAccept( typeExpr->get_result(), *this );
 | 
|---|
| 287 |         maybeAccept( typeExpr->get_type(), *this );
 | 
|---|
| 288 | }
 | 
|---|
| 289 | 
 | 
|---|
| 290 | void Visitor::visit( AsmExpr *asmExpr ) {
 | 
|---|
| 291 |         maybeAccept( asmExpr->get_inout(), *this );
 | 
|---|
| 292 |         maybeAccept( asmExpr->get_constraint(), *this );
 | 
|---|
| 293 |         maybeAccept( asmExpr->get_operand(), *this );
 | 
|---|
| 294 | }
 | 
|---|
| 295 | 
 | 
|---|
| 296 | void Visitor::visit( ImplicitCopyCtorExpr *impCpCtorExpr ) {
 | 
|---|
| 297 |         maybeAccept( impCpCtorExpr->get_result(), *this );
 | 
|---|
| 298 |         maybeAccept( impCpCtorExpr->get_callExpr(), *this );
 | 
|---|
| 299 |         acceptAll( impCpCtorExpr->get_tempDecls(), *this );
 | 
|---|
| 300 |         acceptAll( impCpCtorExpr->get_returnDecls(), *this );
 | 
|---|
| 301 |         acceptAll( impCpCtorExpr->get_dtors(), *this );
 | 
|---|
| 302 | }
 | 
|---|
| 303 | 
 | 
|---|
| 304 | void Visitor::visit( ConstructorExpr * ctorExpr ) {
 | 
|---|
| 305 |         maybeAccept( ctorExpr->get_result(), *this );
 | 
|---|
| 306 |         maybeAccept( ctorExpr->get_callExpr(), *this );
 | 
|---|
| 307 | }
 | 
|---|
| 308 | 
 | 
|---|
| 309 | void Visitor::visit( CompoundLiteralExpr *compLitExpr ) {
 | 
|---|
| 310 |         maybeAccept( compLitExpr->get_result(), *this );
 | 
|---|
| 311 |         maybeAccept( compLitExpr->get_initializer(), *this );
 | 
|---|
| 312 | }
 | 
|---|
| 313 | 
 | 
|---|
| 314 | void Visitor::visit( RangeExpr *rangeExpr ) {
 | 
|---|
| 315 |         maybeAccept( rangeExpr->get_low(), *this );
 | 
|---|
| 316 |         maybeAccept( rangeExpr->get_high(), *this );
 | 
|---|
| 317 | }
 | 
|---|
| 318 | 
 | 
|---|
| 319 | void Visitor::visit( UntypedTupleExpr *tupleExpr ) {
 | 
|---|
| 320 |         maybeAccept( tupleExpr->get_result(), *this );
 | 
|---|
| 321 |         acceptAll( tupleExpr->get_exprs(), *this );
 | 
|---|
| 322 | }
 | 
|---|
| 323 | 
 | 
|---|
| 324 | void Visitor::visit( TupleExpr *tupleExpr ) {
 | 
|---|
| 325 |         maybeAccept( tupleExpr->get_result(), *this );
 | 
|---|
| 326 |         acceptAll( tupleExpr->get_exprs(), *this );
 | 
|---|
| 327 | }
 | 
|---|
| 328 | 
 | 
|---|
| 329 | void Visitor::visit( TupleIndexExpr *tupleExpr ) {
 | 
|---|
| 330 |         maybeAccept( tupleExpr->get_result(), *this );
 | 
|---|
| 331 |         maybeAccept( tupleExpr->get_tuple(), *this );
 | 
|---|
| 332 | }
 | 
|---|
| 333 | 
 | 
|---|
| 334 | void Visitor::visit( TupleAssignExpr *assignExpr ) {
 | 
|---|
| 335 |         maybeAccept( assignExpr->get_result(), *this );
 | 
|---|
| 336 |         maybeAccept( assignExpr->get_stmtExpr(), *this );
 | 
|---|
| 337 | }
 | 
|---|
| 338 | 
 | 
|---|
| 339 | void Visitor::visit( StmtExpr *stmtExpr ) {
 | 
|---|
| 340 |         maybeAccept( stmtExpr->get_result(), *this );
 | 
|---|
| 341 |         maybeAccept( stmtExpr->get_statements(), *this );
 | 
|---|
| 342 |         acceptAll( stmtExpr->get_returnDecls(), *this );
 | 
|---|
| 343 |         acceptAll( stmtExpr->get_dtors(), *this );
 | 
|---|
| 344 | }
 | 
|---|
| 345 | 
 | 
|---|
| 346 | void Visitor::visit( UniqueExpr *uniqueExpr ) {
 | 
|---|
| 347 |         maybeAccept( uniqueExpr->get_result(), *this );
 | 
|---|
| 348 |         maybeAccept( uniqueExpr->get_expr(), *this );
 | 
|---|
| 349 | }
 | 
|---|
| 350 | 
 | 
|---|
| 351 | void Visitor::visit( UntypedInitExpr * initExpr ) {
 | 
|---|
| 352 |         maybeAccept( initExpr->get_result(), *this );
 | 
|---|
| 353 |         maybeAccept( initExpr->get_expr(), *this );
 | 
|---|
| 354 |         // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
 | 
|---|
| 355 | }
 | 
|---|
| 356 | 
 | 
|---|
| 357 | void Visitor::visit( InitExpr * initExpr ) {
 | 
|---|
| 358 |         maybeAccept( initExpr->get_result(), *this );
 | 
|---|
| 359 |         maybeAccept( initExpr->get_expr(), *this );
 | 
|---|
| 360 |         maybeAccept( initExpr->get_designation(), *this );
 | 
|---|
| 361 | }
 | 
|---|
| 362 | 
 | 
|---|
| 363 | 
 | 
|---|
| 364 | void Visitor::visit( VoidType *voidType ) {
 | 
|---|
| 365 |         acceptAll( voidType->get_forall(), *this );
 | 
|---|
| 366 | }
 | 
|---|
| 367 | 
 | 
|---|
| 368 | void Visitor::visit( BasicType *basicType ) {
 | 
|---|
| 369 |         acceptAll( basicType->get_forall(), *this );
 | 
|---|
| 370 | }
 | 
|---|
| 371 | 
 | 
|---|
| 372 | void Visitor::visit( PointerType *pointerType ) {
 | 
|---|
| 373 |         acceptAll( pointerType->get_forall(), *this );
 | 
|---|
| 374 |         maybeAccept( pointerType->get_base(), *this );
 | 
|---|
| 375 | }
 | 
|---|
| 376 | 
 | 
|---|
| 377 | void Visitor::visit( ArrayType *arrayType ) {
 | 
|---|
| 378 |         acceptAll( arrayType->get_forall(), *this );
 | 
|---|
| 379 |         maybeAccept( arrayType->get_dimension(), *this );
 | 
|---|
| 380 |         maybeAccept( arrayType->get_base(), *this );
 | 
|---|
| 381 | }
 | 
|---|
| 382 | 
 | 
|---|
| 383 | void Visitor::visit( FunctionType *functionType ) {
 | 
|---|
| 384 |         acceptAll( functionType->get_forall(), *this );
 | 
|---|
| 385 |         acceptAll( functionType->get_returnVals(), *this );
 | 
|---|
| 386 |         acceptAll( functionType->get_parameters(), *this );
 | 
|---|
| 387 | }
 | 
|---|
| 388 | 
 | 
|---|
| 389 | void Visitor::handleReferenceToType( ReferenceToType *aggregateUseType ) {
 | 
|---|
| 390 |         acceptAll( aggregateUseType->get_forall(), *this );
 | 
|---|
| 391 |         acceptAll( aggregateUseType->get_parameters(), *this );
 | 
|---|
| 392 | }
 | 
|---|
| 393 | 
 | 
|---|
| 394 | void Visitor::visit( StructInstType *aggregateUseType ) {
 | 
|---|
| 395 |         handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );
 | 
|---|
| 396 | }
 | 
|---|
| 397 | 
 | 
|---|
| 398 | void Visitor::visit( UnionInstType *aggregateUseType ) {
 | 
|---|
| 399 |         handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );
 | 
|---|
| 400 | }
 | 
|---|
| 401 | 
 | 
|---|
| 402 | void Visitor::visit( EnumInstType *aggregateUseType ) {
 | 
|---|
| 403 |         handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );
 | 
|---|
| 404 | }
 | 
|---|
| 405 | 
 | 
|---|
| 406 | void Visitor::visit( TraitInstType *aggregateUseType ) {
 | 
|---|
| 407 |         handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );
 | 
|---|
| 408 |         acceptAll( aggregateUseType->get_members(), *this );
 | 
|---|
| 409 | }
 | 
|---|
| 410 | 
 | 
|---|
| 411 | void Visitor::visit( TypeInstType *aggregateUseType ) {
 | 
|---|
| 412 |         handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );
 | 
|---|
| 413 | }
 | 
|---|
| 414 | 
 | 
|---|
| 415 | void Visitor::visit( TupleType *tupleType ) {
 | 
|---|
| 416 |         acceptAll( tupleType->get_forall(), *this );
 | 
|---|
| 417 |         acceptAll( tupleType->get_types(), *this );
 | 
|---|
| 418 |         acceptAll( tupleType->get_members(), *this );
 | 
|---|
| 419 | }
 | 
|---|
| 420 | 
 | 
|---|
| 421 | void Visitor::visit( TypeofType *typeofType ) {
 | 
|---|
| 422 |         assert( typeofType->get_expr() );
 | 
|---|
| 423 |         typeofType->get_expr()->accept( *this );
 | 
|---|
| 424 | }
 | 
|---|
| 425 | 
 | 
|---|
| 426 | void Visitor::visit( AttrType *attrType ) {
 | 
|---|
| 427 |         if ( attrType->get_isType() ) {
 | 
|---|
| 428 |                 assert( attrType->get_type() );
 | 
|---|
| 429 |                 attrType->get_type()->accept( *this );
 | 
|---|
| 430 |         } else {
 | 
|---|
| 431 |                 assert( attrType->get_expr() );
 | 
|---|
| 432 |                 attrType->get_expr()->accept( *this );
 | 
|---|
| 433 |         } // if
 | 
|---|
| 434 | }
 | 
|---|
| 435 | 
 | 
|---|
| 436 | void Visitor::visit( VarArgsType *varArgsType ) {
 | 
|---|
| 437 |         acceptAll( varArgsType->get_forall(), *this );
 | 
|---|
| 438 | }
 | 
|---|
| 439 | 
 | 
|---|
| 440 | void Visitor::visit( ZeroType *zeroType ) {
 | 
|---|
| 441 |         acceptAll( zeroType->get_forall(), *this );
 | 
|---|
| 442 | }
 | 
|---|
| 443 | 
 | 
|---|
| 444 | void Visitor::visit( OneType *oneType ) {
 | 
|---|
| 445 |         acceptAll( oneType->get_forall(), *this );
 | 
|---|
| 446 | }
 | 
|---|
| 447 | 
 | 
|---|
| 448 | void Visitor::visit( Designation * designation ) {
 | 
|---|
| 449 |         acceptAll( designation->get_designators(), *this );
 | 
|---|
| 450 | }
 | 
|---|
| 451 | 
 | 
|---|
| 452 | void Visitor::visit( SingleInit *singleInit ) {
 | 
|---|
| 453 |         singleInit->get_value()->accept( *this );
 | 
|---|
| 454 | }
 | 
|---|
| 455 | 
 | 
|---|
| 456 | void Visitor::visit( ListInit *listInit ) {
 | 
|---|
| 457 |         acceptAll( listInit->get_designations(), *this );
 | 
|---|
| 458 |         acceptAll( listInit->get_initializers(), *this );
 | 
|---|
| 459 | }
 | 
|---|
| 460 | 
 | 
|---|
| 461 | void Visitor::visit( ConstructorInit *ctorInit ) {
 | 
|---|
| 462 |         maybeAccept( ctorInit->get_ctor(), *this );
 | 
|---|
| 463 |         maybeAccept( ctorInit->get_dtor(), *this );
 | 
|---|
| 464 |         maybeAccept( ctorInit->get_init(), *this );
 | 
|---|
| 465 | }
 | 
|---|
| 466 | 
 | 
|---|
| 467 | 
 | 
|---|
| 468 | void Visitor::visit( __attribute__((unused)) Subrange *subrange ) {}
 | 
|---|
| 469 | 
 | 
|---|
| 470 | 
 | 
|---|
| 471 | void Visitor::visit( __attribute__((unused)) Constant *constant ) {}
 | 
|---|
| 472 | // Local Variables: //
 | 
|---|
| 473 | // tab-width: 4 //
 | 
|---|
| 474 | // mode: c++ //
 | 
|---|
| 475 | // compile-command: "make install" //
 | 
|---|
| 476 | // End: //
 | 
|---|