| 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 : Peter A. Buhr
|
|---|
| 12 | // Last Modified On : Thu Aug 17 15:39:38 2017
|
|---|
| 13 | // Update Count : 29
|
|---|
| 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 | acceptAll( ifStmt->get_initialization(), *this );
|
|---|
| 102 | maybeAccept( ifStmt->get_condition(), *this );
|
|---|
| 103 | maybeAccept( ifStmt->get_thenPart(), *this );
|
|---|
| 104 | maybeAccept( ifStmt->get_elsePart(), *this );
|
|---|
| 105 | }
|
|---|
| 106 |
|
|---|
| 107 | void Visitor::visit( WhileStmt *whileStmt ) {
|
|---|
| 108 | maybeAccept( whileStmt->get_condition(), *this );
|
|---|
| 109 | maybeAccept( whileStmt->get_body(), *this );
|
|---|
| 110 | }
|
|---|
| 111 |
|
|---|
| 112 | void Visitor::visit( ForStmt *forStmt ) {
|
|---|
| 113 | acceptAll( forStmt->get_initialization(), *this );
|
|---|
| 114 | maybeAccept( forStmt->get_condition(), *this );
|
|---|
| 115 | maybeAccept( forStmt->get_increment(), *this );
|
|---|
| 116 | maybeAccept( forStmt->get_body(), *this );
|
|---|
| 117 | }
|
|---|
| 118 |
|
|---|
| 119 | void Visitor::visit( SwitchStmt *switchStmt ) {
|
|---|
| 120 | maybeAccept( switchStmt->get_condition(), *this );
|
|---|
| 121 | acceptAll( switchStmt->get_statements(), *this );
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 | void Visitor::visit( CaseStmt *caseStmt ) {
|
|---|
| 125 | maybeAccept( caseStmt->get_condition(), *this );
|
|---|
| 126 | acceptAll( caseStmt->get_statements(), *this );
|
|---|
| 127 | }
|
|---|
| 128 |
|
|---|
| 129 | void Visitor::visit( __attribute__((unused)) BranchStmt *branchStmt ) {
|
|---|
| 130 | }
|
|---|
| 131 |
|
|---|
| 132 | void Visitor::visit( ReturnStmt *returnStmt ) {
|
|---|
| 133 | maybeAccept( returnStmt->get_expr(), *this );
|
|---|
| 134 | }
|
|---|
| 135 |
|
|---|
| 136 | void Visitor::visit( ThrowStmt * throwStmt ) {
|
|---|
| 137 | maybeAccept( throwStmt->get_expr(), *this );
|
|---|
| 138 | maybeAccept( throwStmt->get_target(), *this );
|
|---|
| 139 | }
|
|---|
| 140 |
|
|---|
| 141 | void Visitor::visit( TryStmt *tryStmt ) {
|
|---|
| 142 | maybeAccept( tryStmt->get_block(), *this );
|
|---|
| 143 | acceptAll( tryStmt->get_catchers(), *this );
|
|---|
| 144 | maybeAccept( tryStmt->get_finally(), *this );
|
|---|
| 145 | }
|
|---|
| 146 |
|
|---|
| 147 | void Visitor::visit( CatchStmt *catchStmt ) {
|
|---|
| 148 | maybeAccept( catchStmt->get_decl(), *this );
|
|---|
| 149 | maybeAccept( catchStmt->get_cond(), *this );
|
|---|
| 150 | maybeAccept( catchStmt->get_body(), *this );
|
|---|
| 151 | }
|
|---|
| 152 |
|
|---|
| 153 | void Visitor::visit( FinallyStmt *finalStmt ) {
|
|---|
| 154 | maybeAccept( finalStmt->get_block(), *this );
|
|---|
| 155 | }
|
|---|
| 156 |
|
|---|
| 157 | void Visitor::visit( WaitForStmt *waitforStmt ) {
|
|---|
| 158 | for( auto & clause : waitforStmt->clauses ) {
|
|---|
| 159 | maybeAccept( clause.target.function, *this );
|
|---|
| 160 | acceptAll( clause.target.arguments, *this );
|
|---|
| 161 |
|
|---|
| 162 | maybeAccept( clause.statement, *this );
|
|---|
| 163 | maybeAccept( clause.condition, *this );
|
|---|
| 164 | }
|
|---|
| 165 |
|
|---|
| 166 | maybeAccept( waitforStmt->timeout.time, *this );
|
|---|
| 167 | maybeAccept( waitforStmt->timeout.statement, *this );
|
|---|
| 168 | maybeAccept( waitforStmt->timeout.condition, *this );
|
|---|
| 169 | maybeAccept( waitforStmt->orelse.statement, *this );
|
|---|
| 170 | maybeAccept( waitforStmt->orelse.condition, *this );
|
|---|
| 171 | }
|
|---|
| 172 |
|
|---|
| 173 | void Visitor::visit( __attribute__((unused)) NullStmt *nullStmt ) {
|
|---|
| 174 | }
|
|---|
| 175 |
|
|---|
| 176 | void Visitor::visit( DeclStmt *declStmt ) {
|
|---|
| 177 | maybeAccept( declStmt->get_decl(), *this );
|
|---|
| 178 | }
|
|---|
| 179 |
|
|---|
| 180 | void Visitor::visit( ImplicitCtorDtorStmt *impCtorDtorStmt ) {
|
|---|
| 181 | maybeAccept( impCtorDtorStmt->get_callStmt(), *this );
|
|---|
| 182 | }
|
|---|
| 183 |
|
|---|
| 184 |
|
|---|
| 185 | void Visitor::visit( ApplicationExpr *applicationExpr ) {
|
|---|
| 186 | maybeAccept( applicationExpr->get_result(), *this );
|
|---|
| 187 | maybeAccept( applicationExpr->get_function(), *this );
|
|---|
| 188 | acceptAll( applicationExpr->get_args(), *this );
|
|---|
| 189 | }
|
|---|
| 190 |
|
|---|
| 191 | void Visitor::visit( UntypedExpr *untypedExpr ) {
|
|---|
| 192 | maybeAccept( untypedExpr->get_result(), *this );
|
|---|
| 193 | acceptAll( untypedExpr->get_args(), *this );
|
|---|
| 194 | }
|
|---|
| 195 |
|
|---|
| 196 | void Visitor::visit( NameExpr *nameExpr ) {
|
|---|
| 197 | maybeAccept( nameExpr->get_result(), *this );
|
|---|
| 198 | }
|
|---|
| 199 |
|
|---|
| 200 | void Visitor::visit( AddressExpr *addressExpr ) {
|
|---|
| 201 | maybeAccept( addressExpr->get_result(), *this );
|
|---|
| 202 | maybeAccept( addressExpr->get_arg(), *this );
|
|---|
| 203 | }
|
|---|
| 204 |
|
|---|
| 205 | void Visitor::visit( LabelAddressExpr *labAddressExpr ) {
|
|---|
| 206 | maybeAccept( labAddressExpr->get_result(), *this );
|
|---|
| 207 | maybeAccept( labAddressExpr->get_arg(), *this );
|
|---|
| 208 | }
|
|---|
| 209 |
|
|---|
| 210 | void Visitor::visit( CastExpr *castExpr ) {
|
|---|
| 211 | maybeAccept( castExpr->get_result(), *this );
|
|---|
| 212 | maybeAccept( castExpr->get_arg(), *this );
|
|---|
| 213 | }
|
|---|
| 214 |
|
|---|
| 215 | void Visitor::visit( VirtualCastExpr *castExpr ) {
|
|---|
| 216 | maybeAccept( castExpr->get_result(), *this );
|
|---|
| 217 | maybeAccept( castExpr->get_arg(), *this );
|
|---|
| 218 | }
|
|---|
| 219 |
|
|---|
| 220 | void Visitor::visit( UntypedMemberExpr *memberExpr ) {
|
|---|
| 221 | maybeAccept( memberExpr->get_result(), *this );
|
|---|
| 222 | maybeAccept( memberExpr->get_aggregate(), *this );
|
|---|
| 223 | maybeAccept( memberExpr->get_member(), *this );
|
|---|
| 224 | }
|
|---|
| 225 |
|
|---|
| 226 | void Visitor::visit( MemberExpr *memberExpr ) {
|
|---|
| 227 | maybeAccept( memberExpr->get_result(), *this );
|
|---|
| 228 | maybeAccept( memberExpr->get_aggregate(), *this );
|
|---|
| 229 | }
|
|---|
| 230 |
|
|---|
| 231 | void Visitor::visit( VariableExpr *variableExpr ) {
|
|---|
| 232 | maybeAccept( variableExpr->get_result(), *this );
|
|---|
| 233 | }
|
|---|
| 234 |
|
|---|
| 235 | void Visitor::visit( ConstantExpr *constantExpr ) {
|
|---|
| 236 | maybeAccept( constantExpr->get_result(), *this );
|
|---|
| 237 | maybeAccept( constantExpr->get_constant(), *this );
|
|---|
| 238 | }
|
|---|
| 239 |
|
|---|
| 240 | void Visitor::visit( SizeofExpr *sizeofExpr ) {
|
|---|
| 241 | maybeAccept( sizeofExpr->get_result(), *this );
|
|---|
| 242 | if ( sizeofExpr->get_isType() ) {
|
|---|
| 243 | maybeAccept( sizeofExpr->get_type(), *this );
|
|---|
| 244 | } else {
|
|---|
| 245 | maybeAccept( sizeofExpr->get_expr(), *this );
|
|---|
| 246 | }
|
|---|
| 247 | }
|
|---|
| 248 |
|
|---|
| 249 | void Visitor::visit( AlignofExpr *alignofExpr ) {
|
|---|
| 250 | maybeAccept( alignofExpr->get_result(), *this );
|
|---|
| 251 | if ( alignofExpr->get_isType() ) {
|
|---|
| 252 | maybeAccept( alignofExpr->get_type(), *this );
|
|---|
| 253 | } else {
|
|---|
| 254 | maybeAccept( alignofExpr->get_expr(), *this );
|
|---|
| 255 | }
|
|---|
| 256 | }
|
|---|
| 257 |
|
|---|
| 258 | void Visitor::visit( UntypedOffsetofExpr *offsetofExpr ) {
|
|---|
| 259 | maybeAccept( offsetofExpr->get_result(), *this );
|
|---|
| 260 | maybeAccept( offsetofExpr->get_type(), *this );
|
|---|
| 261 | }
|
|---|
| 262 |
|
|---|
| 263 | void Visitor::visit( OffsetofExpr *offsetofExpr ) {
|
|---|
| 264 | maybeAccept( offsetofExpr->get_result(), *this );
|
|---|
| 265 | maybeAccept( offsetofExpr->get_type(), *this );
|
|---|
| 266 | maybeAccept( offsetofExpr->get_member(), *this );
|
|---|
| 267 | }
|
|---|
| 268 |
|
|---|
| 269 | void Visitor::visit( OffsetPackExpr *offsetPackExpr ) {
|
|---|
| 270 | maybeAccept( offsetPackExpr->get_result(), *this );
|
|---|
| 271 | maybeAccept( offsetPackExpr->get_type(), *this );
|
|---|
| 272 | }
|
|---|
| 273 |
|
|---|
| 274 | void Visitor::visit( AttrExpr *attrExpr ) {
|
|---|
| 275 | maybeAccept( attrExpr->get_result(), *this );
|
|---|
| 276 | if ( attrExpr->get_isType() ) {
|
|---|
| 277 | maybeAccept( attrExpr->get_type(), *this );
|
|---|
| 278 | } else {
|
|---|
| 279 | maybeAccept( attrExpr->get_expr(), *this );
|
|---|
| 280 | }
|
|---|
| 281 | }
|
|---|
| 282 |
|
|---|
| 283 | void Visitor::visit( LogicalExpr *logicalExpr ) {
|
|---|
| 284 | maybeAccept( logicalExpr->get_result(), *this );
|
|---|
| 285 | maybeAccept( logicalExpr->get_arg1(), *this );
|
|---|
| 286 | maybeAccept( logicalExpr->get_arg2(), *this );
|
|---|
| 287 | }
|
|---|
| 288 |
|
|---|
| 289 | void Visitor::visit( ConditionalExpr *conditionalExpr ) {
|
|---|
| 290 | maybeAccept( conditionalExpr->get_result(), *this );
|
|---|
| 291 | maybeAccept( conditionalExpr->get_arg1(), *this );
|
|---|
| 292 | maybeAccept( conditionalExpr->get_arg2(), *this );
|
|---|
| 293 | maybeAccept( conditionalExpr->get_arg3(), *this );
|
|---|
| 294 | }
|
|---|
| 295 |
|
|---|
| 296 | void Visitor::visit( CommaExpr *commaExpr ) {
|
|---|
| 297 | maybeAccept( commaExpr->get_result(), *this );
|
|---|
| 298 | maybeAccept( commaExpr->get_arg1(), *this );
|
|---|
| 299 | maybeAccept( commaExpr->get_arg2(), *this );
|
|---|
| 300 | }
|
|---|
| 301 |
|
|---|
| 302 | void Visitor::visit( TypeExpr *typeExpr ) {
|
|---|
| 303 | maybeAccept( typeExpr->get_result(), *this );
|
|---|
| 304 | maybeAccept( typeExpr->get_type(), *this );
|
|---|
| 305 | }
|
|---|
| 306 |
|
|---|
| 307 | void Visitor::visit( AsmExpr *asmExpr ) {
|
|---|
| 308 | maybeAccept( asmExpr->get_inout(), *this );
|
|---|
| 309 | maybeAccept( asmExpr->get_constraint(), *this );
|
|---|
| 310 | maybeAccept( asmExpr->get_operand(), *this );
|
|---|
| 311 | }
|
|---|
| 312 |
|
|---|
| 313 | void Visitor::visit( ImplicitCopyCtorExpr *impCpCtorExpr ) {
|
|---|
| 314 | maybeAccept( impCpCtorExpr->get_result(), *this );
|
|---|
| 315 | maybeAccept( impCpCtorExpr->get_callExpr(), *this );
|
|---|
| 316 | acceptAll( impCpCtorExpr->get_tempDecls(), *this );
|
|---|
| 317 | acceptAll( impCpCtorExpr->get_returnDecls(), *this );
|
|---|
| 318 | acceptAll( impCpCtorExpr->get_dtors(), *this );
|
|---|
| 319 | }
|
|---|
| 320 |
|
|---|
| 321 | void Visitor::visit( ConstructorExpr * ctorExpr ) {
|
|---|
| 322 | maybeAccept( ctorExpr->get_result(), *this );
|
|---|
| 323 | maybeAccept( ctorExpr->get_callExpr(), *this );
|
|---|
| 324 | }
|
|---|
| 325 |
|
|---|
| 326 | void Visitor::visit( CompoundLiteralExpr *compLitExpr ) {
|
|---|
| 327 | maybeAccept( compLitExpr->get_result(), *this );
|
|---|
| 328 | maybeAccept( compLitExpr->get_initializer(), *this );
|
|---|
| 329 | }
|
|---|
| 330 |
|
|---|
| 331 | void Visitor::visit( RangeExpr *rangeExpr ) {
|
|---|
| 332 | maybeAccept( rangeExpr->get_low(), *this );
|
|---|
| 333 | maybeAccept( rangeExpr->get_high(), *this );
|
|---|
| 334 | }
|
|---|
| 335 |
|
|---|
| 336 | void Visitor::visit( UntypedTupleExpr *tupleExpr ) {
|
|---|
| 337 | maybeAccept( tupleExpr->get_result(), *this );
|
|---|
| 338 | acceptAll( tupleExpr->get_exprs(), *this );
|
|---|
| 339 | }
|
|---|
| 340 |
|
|---|
| 341 | void Visitor::visit( TupleExpr *tupleExpr ) {
|
|---|
| 342 | maybeAccept( tupleExpr->get_result(), *this );
|
|---|
| 343 | acceptAll( tupleExpr->get_exprs(), *this );
|
|---|
| 344 | }
|
|---|
| 345 |
|
|---|
| 346 | void Visitor::visit( TupleIndexExpr *tupleExpr ) {
|
|---|
| 347 | maybeAccept( tupleExpr->get_result(), *this );
|
|---|
| 348 | maybeAccept( tupleExpr->get_tuple(), *this );
|
|---|
| 349 | }
|
|---|
| 350 |
|
|---|
| 351 | void Visitor::visit( TupleAssignExpr *assignExpr ) {
|
|---|
| 352 | maybeAccept( assignExpr->get_result(), *this );
|
|---|
| 353 | maybeAccept( assignExpr->get_stmtExpr(), *this );
|
|---|
| 354 | }
|
|---|
| 355 |
|
|---|
| 356 | void Visitor::visit( StmtExpr *stmtExpr ) {
|
|---|
| 357 | maybeAccept( stmtExpr->get_result(), *this );
|
|---|
| 358 | maybeAccept( stmtExpr->get_statements(), *this );
|
|---|
| 359 | acceptAll( stmtExpr->get_returnDecls(), *this );
|
|---|
| 360 | acceptAll( stmtExpr->get_dtors(), *this );
|
|---|
| 361 | }
|
|---|
| 362 |
|
|---|
| 363 | void Visitor::visit( UniqueExpr *uniqueExpr ) {
|
|---|
| 364 | maybeAccept( uniqueExpr->get_result(), *this );
|
|---|
| 365 | maybeAccept( uniqueExpr->get_expr(), *this );
|
|---|
| 366 | }
|
|---|
| 367 |
|
|---|
| 368 | void Visitor::visit( UntypedInitExpr * initExpr ) {
|
|---|
| 369 | maybeAccept( initExpr->get_result(), *this );
|
|---|
| 370 | maybeAccept( initExpr->get_expr(), *this );
|
|---|
| 371 | // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
|
|---|
| 372 | }
|
|---|
| 373 |
|
|---|
| 374 | void Visitor::visit( InitExpr * initExpr ) {
|
|---|
| 375 | maybeAccept( initExpr->get_result(), *this );
|
|---|
| 376 | maybeAccept( initExpr->get_expr(), *this );
|
|---|
| 377 | maybeAccept( initExpr->get_designation(), *this );
|
|---|
| 378 | }
|
|---|
| 379 |
|
|---|
| 380 |
|
|---|
| 381 | void Visitor::visit( VoidType *voidType ) {
|
|---|
| 382 | acceptAll( voidType->get_forall(), *this );
|
|---|
| 383 | }
|
|---|
| 384 |
|
|---|
| 385 | void Visitor::visit( BasicType *basicType ) {
|
|---|
| 386 | acceptAll( basicType->get_forall(), *this );
|
|---|
| 387 | }
|
|---|
| 388 |
|
|---|
| 389 | void Visitor::visit( PointerType *pointerType ) {
|
|---|
| 390 | acceptAll( pointerType->get_forall(), *this );
|
|---|
| 391 | // xxx - should PointerType visit/mutate dimension?
|
|---|
| 392 | maybeAccept( pointerType->get_base(), *this );
|
|---|
| 393 | }
|
|---|
| 394 |
|
|---|
| 395 | void Visitor::visit( ArrayType *arrayType ) {
|
|---|
| 396 | acceptAll( arrayType->get_forall(), *this );
|
|---|
| 397 | maybeAccept( arrayType->get_dimension(), *this );
|
|---|
| 398 | maybeAccept( arrayType->get_base(), *this );
|
|---|
| 399 | }
|
|---|
| 400 |
|
|---|
| 401 | void Visitor::visit( ReferenceType *refType ) {
|
|---|
| 402 | acceptAll( refType->get_forall(), *this );
|
|---|
| 403 | maybeAccept( refType->get_base(), *this );
|
|---|
| 404 | }
|
|---|
| 405 |
|
|---|
| 406 | void Visitor::visit( FunctionType *functionType ) {
|
|---|
| 407 | acceptAll( functionType->get_forall(), *this );
|
|---|
| 408 | acceptAll( functionType->get_returnVals(), *this );
|
|---|
| 409 | acceptAll( functionType->get_parameters(), *this );
|
|---|
| 410 | }
|
|---|
| 411 |
|
|---|
| 412 | void Visitor::handleReferenceToType( ReferenceToType *aggregateUseType ) {
|
|---|
| 413 | acceptAll( aggregateUseType->get_forall(), *this );
|
|---|
| 414 | acceptAll( aggregateUseType->get_parameters(), *this );
|
|---|
| 415 | }
|
|---|
| 416 |
|
|---|
| 417 | void Visitor::visit( StructInstType *aggregateUseType ) {
|
|---|
| 418 | handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );
|
|---|
| 419 | }
|
|---|
| 420 |
|
|---|
| 421 | void Visitor::visit( UnionInstType *aggregateUseType ) {
|
|---|
| 422 | handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );
|
|---|
| 423 | }
|
|---|
| 424 |
|
|---|
| 425 | void Visitor::visit( EnumInstType *aggregateUseType ) {
|
|---|
| 426 | handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );
|
|---|
| 427 | }
|
|---|
| 428 |
|
|---|
| 429 | void Visitor::visit( TraitInstType *aggregateUseType ) {
|
|---|
| 430 | handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );
|
|---|
| 431 | }
|
|---|
| 432 |
|
|---|
| 433 | void Visitor::visit( TypeInstType *aggregateUseType ) {
|
|---|
| 434 | handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );
|
|---|
| 435 | }
|
|---|
| 436 |
|
|---|
| 437 | void Visitor::visit( TupleType *tupleType ) {
|
|---|
| 438 | acceptAll( tupleType->get_forall(), *this );
|
|---|
| 439 | acceptAll( tupleType->get_types(), *this );
|
|---|
| 440 | acceptAll( tupleType->get_members(), *this );
|
|---|
| 441 | }
|
|---|
| 442 |
|
|---|
| 443 | void Visitor::visit( TypeofType *typeofType ) {
|
|---|
| 444 | assert( typeofType->get_expr() );
|
|---|
| 445 | typeofType->get_expr()->accept( *this );
|
|---|
| 446 | }
|
|---|
| 447 |
|
|---|
| 448 | void Visitor::visit( AttrType *attrType ) {
|
|---|
| 449 | if ( attrType->get_isType() ) {
|
|---|
| 450 | assert( attrType->get_type() );
|
|---|
| 451 | attrType->get_type()->accept( *this );
|
|---|
| 452 | } else {
|
|---|
| 453 | assert( attrType->get_expr() );
|
|---|
| 454 | attrType->get_expr()->accept( *this );
|
|---|
| 455 | } // if
|
|---|
| 456 | }
|
|---|
| 457 |
|
|---|
| 458 | void Visitor::visit( VarArgsType *varArgsType ) {
|
|---|
| 459 | acceptAll( varArgsType->get_forall(), *this );
|
|---|
| 460 | }
|
|---|
| 461 |
|
|---|
| 462 | void Visitor::visit( ZeroType *zeroType ) {
|
|---|
| 463 | acceptAll( zeroType->get_forall(), *this );
|
|---|
| 464 | }
|
|---|
| 465 |
|
|---|
| 466 | void Visitor::visit( OneType *oneType ) {
|
|---|
| 467 | acceptAll( oneType->get_forall(), *this );
|
|---|
| 468 | }
|
|---|
| 469 |
|
|---|
| 470 | void Visitor::visit( Designation * designation ) {
|
|---|
| 471 | acceptAll( designation->get_designators(), *this );
|
|---|
| 472 | }
|
|---|
| 473 |
|
|---|
| 474 | void Visitor::visit( SingleInit *singleInit ) {
|
|---|
| 475 | singleInit->get_value()->accept( *this );
|
|---|
| 476 | }
|
|---|
| 477 |
|
|---|
| 478 | void Visitor::visit( ListInit *listInit ) {
|
|---|
| 479 | acceptAll( listInit->get_designations(), *this );
|
|---|
| 480 | acceptAll( listInit->get_initializers(), *this );
|
|---|
| 481 | }
|
|---|
| 482 |
|
|---|
| 483 | void Visitor::visit( ConstructorInit *ctorInit ) {
|
|---|
| 484 | maybeAccept( ctorInit->get_ctor(), *this );
|
|---|
| 485 | maybeAccept( ctorInit->get_dtor(), *this );
|
|---|
| 486 | maybeAccept( ctorInit->get_init(), *this );
|
|---|
| 487 | }
|
|---|
| 488 |
|
|---|
| 489 |
|
|---|
| 490 | void Visitor::visit( __attribute__((unused)) Subrange *subrange ) {}
|
|---|
| 491 |
|
|---|
| 492 |
|
|---|
| 493 | void Visitor::visit( __attribute__((unused)) Constant *constant ) {}
|
|---|
| 494 | // Local Variables: //
|
|---|
| 495 | // tab-width: 4 //
|
|---|
| 496 | // mode: c++ //
|
|---|
| 497 | // compile-command: "make install" //
|
|---|
| 498 | // End: //
|
|---|