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