| 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( __attribute__((unused)) NullStmt *nullStmt ) {
|
|---|
| 158 | }
|
|---|
| 159 |
|
|---|
| 160 | void Visitor::visit( DeclStmt *declStmt ) {
|
|---|
| 161 | maybeAccept( declStmt->get_decl(), *this );
|
|---|
| 162 | }
|
|---|
| 163 |
|
|---|
| 164 | void Visitor::visit( ImplicitCtorDtorStmt *impCtorDtorStmt ) {
|
|---|
| 165 | maybeAccept( impCtorDtorStmt->get_callStmt(), *this );
|
|---|
| 166 | }
|
|---|
| 167 |
|
|---|
| 168 |
|
|---|
| 169 | void Visitor::visit( ApplicationExpr *applicationExpr ) {
|
|---|
| 170 | maybeAccept( applicationExpr->get_result(), *this );
|
|---|
| 171 | maybeAccept( applicationExpr->get_function(), *this );
|
|---|
| 172 | acceptAll( applicationExpr->get_args(), *this );
|
|---|
| 173 | }
|
|---|
| 174 |
|
|---|
| 175 | void Visitor::visit( UntypedExpr *untypedExpr ) {
|
|---|
| 176 | maybeAccept( untypedExpr->get_result(), *this );
|
|---|
| 177 | acceptAll( untypedExpr->get_args(), *this );
|
|---|
| 178 | }
|
|---|
| 179 |
|
|---|
| 180 | void Visitor::visit( NameExpr *nameExpr ) {
|
|---|
| 181 | maybeAccept( nameExpr->get_result(), *this );
|
|---|
| 182 | }
|
|---|
| 183 |
|
|---|
| 184 | void Visitor::visit( AddressExpr *addressExpr ) {
|
|---|
| 185 | maybeAccept( addressExpr->get_result(), *this );
|
|---|
| 186 | maybeAccept( addressExpr->get_arg(), *this );
|
|---|
| 187 | }
|
|---|
| 188 |
|
|---|
| 189 | void Visitor::visit( LabelAddressExpr *labAddressExpr ) {
|
|---|
| 190 | maybeAccept( labAddressExpr->get_result(), *this );
|
|---|
| 191 | maybeAccept( labAddressExpr->get_arg(), *this );
|
|---|
| 192 | }
|
|---|
| 193 |
|
|---|
| 194 | void Visitor::visit( CastExpr *castExpr ) {
|
|---|
| 195 | maybeAccept( castExpr->get_result(), *this );
|
|---|
| 196 | maybeAccept( castExpr->get_arg(), *this );
|
|---|
| 197 | }
|
|---|
| 198 |
|
|---|
| 199 | void Visitor::visit( VirtualCastExpr *castExpr ) {
|
|---|
| 200 | maybeAccept( castExpr->get_result(), *this );
|
|---|
| 201 | maybeAccept( castExpr->get_arg(), *this );
|
|---|
| 202 | }
|
|---|
| 203 |
|
|---|
| 204 | void Visitor::visit( UntypedMemberExpr *memberExpr ) {
|
|---|
| 205 | maybeAccept( memberExpr->get_result(), *this );
|
|---|
| 206 | maybeAccept( memberExpr->get_aggregate(), *this );
|
|---|
| 207 | maybeAccept( memberExpr->get_member(), *this );
|
|---|
| 208 | }
|
|---|
| 209 |
|
|---|
| 210 | void Visitor::visit( MemberExpr *memberExpr ) {
|
|---|
| 211 | maybeAccept( memberExpr->get_result(), *this );
|
|---|
| 212 | maybeAccept( memberExpr->get_aggregate(), *this );
|
|---|
| 213 | }
|
|---|
| 214 |
|
|---|
| 215 | void Visitor::visit( VariableExpr *variableExpr ) {
|
|---|
| 216 | maybeAccept( variableExpr->get_result(), *this );
|
|---|
| 217 | }
|
|---|
| 218 |
|
|---|
| 219 | void Visitor::visit( ConstantExpr *constantExpr ) {
|
|---|
| 220 | maybeAccept( constantExpr->get_result(), *this );
|
|---|
| 221 | maybeAccept( constantExpr->get_constant(), *this );
|
|---|
| 222 | }
|
|---|
| 223 |
|
|---|
| 224 | void Visitor::visit( SizeofExpr *sizeofExpr ) {
|
|---|
| 225 | maybeAccept( sizeofExpr->get_result(), *this );
|
|---|
| 226 | if ( sizeofExpr->get_isType() ) {
|
|---|
| 227 | maybeAccept( sizeofExpr->get_type(), *this );
|
|---|
| 228 | } else {
|
|---|
| 229 | maybeAccept( sizeofExpr->get_expr(), *this );
|
|---|
| 230 | }
|
|---|
| 231 | }
|
|---|
| 232 |
|
|---|
| 233 | void Visitor::visit( AlignofExpr *alignofExpr ) {
|
|---|
| 234 | maybeAccept( alignofExpr->get_result(), *this );
|
|---|
| 235 | if ( alignofExpr->get_isType() ) {
|
|---|
| 236 | maybeAccept( alignofExpr->get_type(), *this );
|
|---|
| 237 | } else {
|
|---|
| 238 | maybeAccept( alignofExpr->get_expr(), *this );
|
|---|
| 239 | }
|
|---|
| 240 | }
|
|---|
| 241 |
|
|---|
| 242 | void Visitor::visit( UntypedOffsetofExpr *offsetofExpr ) {
|
|---|
| 243 | maybeAccept( offsetofExpr->get_result(), *this );
|
|---|
| 244 | maybeAccept( offsetofExpr->get_type(), *this );
|
|---|
| 245 | }
|
|---|
| 246 |
|
|---|
| 247 | void Visitor::visit( OffsetofExpr *offsetofExpr ) {
|
|---|
| 248 | maybeAccept( offsetofExpr->get_result(), *this );
|
|---|
| 249 | maybeAccept( offsetofExpr->get_type(), *this );
|
|---|
| 250 | maybeAccept( offsetofExpr->get_member(), *this );
|
|---|
| 251 | }
|
|---|
| 252 |
|
|---|
| 253 | void Visitor::visit( OffsetPackExpr *offsetPackExpr ) {
|
|---|
| 254 | maybeAccept( offsetPackExpr->get_result(), *this );
|
|---|
| 255 | maybeAccept( offsetPackExpr->get_type(), *this );
|
|---|
| 256 | }
|
|---|
| 257 |
|
|---|
| 258 | void Visitor::visit( AttrExpr *attrExpr ) {
|
|---|
| 259 | maybeAccept( attrExpr->get_result(), *this );
|
|---|
| 260 | if ( attrExpr->get_isType() ) {
|
|---|
| 261 | maybeAccept( attrExpr->get_type(), *this );
|
|---|
| 262 | } else {
|
|---|
| 263 | maybeAccept( attrExpr->get_expr(), *this );
|
|---|
| 264 | }
|
|---|
| 265 | }
|
|---|
| 266 |
|
|---|
| 267 | void Visitor::visit( LogicalExpr *logicalExpr ) {
|
|---|
| 268 | maybeAccept( logicalExpr->get_result(), *this );
|
|---|
| 269 | maybeAccept( logicalExpr->get_arg1(), *this );
|
|---|
| 270 | maybeAccept( logicalExpr->get_arg2(), *this );
|
|---|
| 271 | }
|
|---|
| 272 |
|
|---|
| 273 | void Visitor::visit( ConditionalExpr *conditionalExpr ) {
|
|---|
| 274 | maybeAccept( conditionalExpr->get_result(), *this );
|
|---|
| 275 | maybeAccept( conditionalExpr->get_arg1(), *this );
|
|---|
| 276 | maybeAccept( conditionalExpr->get_arg2(), *this );
|
|---|
| 277 | maybeAccept( conditionalExpr->get_arg3(), *this );
|
|---|
| 278 | }
|
|---|
| 279 |
|
|---|
| 280 | void Visitor::visit( CommaExpr *commaExpr ) {
|
|---|
| 281 | maybeAccept( commaExpr->get_result(), *this );
|
|---|
| 282 | maybeAccept( commaExpr->get_arg1(), *this );
|
|---|
| 283 | maybeAccept( commaExpr->get_arg2(), *this );
|
|---|
| 284 | }
|
|---|
| 285 |
|
|---|
| 286 | void Visitor::visit( TypeExpr *typeExpr ) {
|
|---|
| 287 | maybeAccept( typeExpr->get_result(), *this );
|
|---|
| 288 | maybeAccept( typeExpr->get_type(), *this );
|
|---|
| 289 | }
|
|---|
| 290 |
|
|---|
| 291 | void Visitor::visit( AsmExpr *asmExpr ) {
|
|---|
| 292 | maybeAccept( asmExpr->get_inout(), *this );
|
|---|
| 293 | maybeAccept( asmExpr->get_constraint(), *this );
|
|---|
| 294 | maybeAccept( asmExpr->get_operand(), *this );
|
|---|
| 295 | }
|
|---|
| 296 |
|
|---|
| 297 | void Visitor::visit( ImplicitCopyCtorExpr *impCpCtorExpr ) {
|
|---|
| 298 | maybeAccept( impCpCtorExpr->get_result(), *this );
|
|---|
| 299 | maybeAccept( impCpCtorExpr->get_callExpr(), *this );
|
|---|
| 300 | acceptAll( impCpCtorExpr->get_tempDecls(), *this );
|
|---|
| 301 | acceptAll( impCpCtorExpr->get_returnDecls(), *this );
|
|---|
| 302 | acceptAll( impCpCtorExpr->get_dtors(), *this );
|
|---|
| 303 | }
|
|---|
| 304 |
|
|---|
| 305 | void Visitor::visit( ConstructorExpr * ctorExpr ) {
|
|---|
| 306 | maybeAccept( ctorExpr->get_result(), *this );
|
|---|
| 307 | maybeAccept( ctorExpr->get_callExpr(), *this );
|
|---|
| 308 | }
|
|---|
| 309 |
|
|---|
| 310 | void Visitor::visit( CompoundLiteralExpr *compLitExpr ) {
|
|---|
| 311 | maybeAccept( compLitExpr->get_result(), *this );
|
|---|
| 312 | maybeAccept( compLitExpr->get_initializer(), *this );
|
|---|
| 313 | }
|
|---|
| 314 |
|
|---|
| 315 | void Visitor::visit( RangeExpr *rangeExpr ) {
|
|---|
| 316 | maybeAccept( rangeExpr->get_low(), *this );
|
|---|
| 317 | maybeAccept( rangeExpr->get_high(), *this );
|
|---|
| 318 | }
|
|---|
| 319 |
|
|---|
| 320 | void Visitor::visit( UntypedTupleExpr *tupleExpr ) {
|
|---|
| 321 | maybeAccept( tupleExpr->get_result(), *this );
|
|---|
| 322 | acceptAll( tupleExpr->get_exprs(), *this );
|
|---|
| 323 | }
|
|---|
| 324 |
|
|---|
| 325 | void Visitor::visit( TupleExpr *tupleExpr ) {
|
|---|
| 326 | maybeAccept( tupleExpr->get_result(), *this );
|
|---|
| 327 | acceptAll( tupleExpr->get_exprs(), *this );
|
|---|
| 328 | }
|
|---|
| 329 |
|
|---|
| 330 | void Visitor::visit( TupleIndexExpr *tupleExpr ) {
|
|---|
| 331 | maybeAccept( tupleExpr->get_result(), *this );
|
|---|
| 332 | maybeAccept( tupleExpr->get_tuple(), *this );
|
|---|
| 333 | }
|
|---|
| 334 |
|
|---|
| 335 | void Visitor::visit( TupleAssignExpr *assignExpr ) {
|
|---|
| 336 | maybeAccept( assignExpr->get_result(), *this );
|
|---|
| 337 | maybeAccept( assignExpr->get_stmtExpr(), *this );
|
|---|
| 338 | }
|
|---|
| 339 |
|
|---|
| 340 | void Visitor::visit( StmtExpr *stmtExpr ) {
|
|---|
| 341 | maybeAccept( stmtExpr->get_result(), *this );
|
|---|
| 342 | maybeAccept( stmtExpr->get_statements(), *this );
|
|---|
| 343 | acceptAll( stmtExpr->get_returnDecls(), *this );
|
|---|
| 344 | acceptAll( stmtExpr->get_dtors(), *this );
|
|---|
| 345 | }
|
|---|
| 346 |
|
|---|
| 347 | void Visitor::visit( UniqueExpr *uniqueExpr ) {
|
|---|
| 348 | maybeAccept( uniqueExpr->get_result(), *this );
|
|---|
| 349 | maybeAccept( uniqueExpr->get_expr(), *this );
|
|---|
| 350 | }
|
|---|
| 351 |
|
|---|
| 352 | void Visitor::visit( UntypedInitExpr * initExpr ) {
|
|---|
| 353 | maybeAccept( initExpr->get_result(), *this );
|
|---|
| 354 | maybeAccept( initExpr->get_expr(), *this );
|
|---|
| 355 | // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
|
|---|
| 356 | }
|
|---|
| 357 |
|
|---|
| 358 | void Visitor::visit( InitExpr * initExpr ) {
|
|---|
| 359 | maybeAccept( initExpr->get_result(), *this );
|
|---|
| 360 | maybeAccept( initExpr->get_expr(), *this );
|
|---|
| 361 | maybeAccept( initExpr->get_designation(), *this );
|
|---|
| 362 | }
|
|---|
| 363 |
|
|---|
| 364 |
|
|---|
| 365 | void Visitor::visit( VoidType *voidType ) {
|
|---|
| 366 | acceptAll( voidType->get_forall(), *this );
|
|---|
| 367 | }
|
|---|
| 368 |
|
|---|
| 369 | void Visitor::visit( BasicType *basicType ) {
|
|---|
| 370 | acceptAll( basicType->get_forall(), *this );
|
|---|
| 371 | }
|
|---|
| 372 |
|
|---|
| 373 | void Visitor::visit( PointerType *pointerType ) {
|
|---|
| 374 | acceptAll( pointerType->get_forall(), *this );
|
|---|
| 375 | maybeAccept( pointerType->get_base(), *this );
|
|---|
| 376 | }
|
|---|
| 377 |
|
|---|
| 378 | void Visitor::visit( ArrayType *arrayType ) {
|
|---|
| 379 | acceptAll( arrayType->get_forall(), *this );
|
|---|
| 380 | maybeAccept( arrayType->get_dimension(), *this );
|
|---|
| 381 | maybeAccept( arrayType->get_base(), *this );
|
|---|
| 382 | }
|
|---|
| 383 |
|
|---|
| 384 | void Visitor::visit( FunctionType *functionType ) {
|
|---|
| 385 | acceptAll( functionType->get_forall(), *this );
|
|---|
| 386 | acceptAll( functionType->get_returnVals(), *this );
|
|---|
| 387 | acceptAll( functionType->get_parameters(), *this );
|
|---|
| 388 | }
|
|---|
| 389 |
|
|---|
| 390 | void Visitor::handleReferenceToType( ReferenceToType *aggregateUseType ) {
|
|---|
| 391 | acceptAll( aggregateUseType->get_forall(), *this );
|
|---|
| 392 | acceptAll( aggregateUseType->get_parameters(), *this );
|
|---|
| 393 | }
|
|---|
| 394 |
|
|---|
| 395 | void Visitor::visit( StructInstType *aggregateUseType ) {
|
|---|
| 396 | handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );
|
|---|
| 397 | }
|
|---|
| 398 |
|
|---|
| 399 | void Visitor::visit( UnionInstType *aggregateUseType ) {
|
|---|
| 400 | handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );
|
|---|
| 401 | }
|
|---|
| 402 |
|
|---|
| 403 | void Visitor::visit( EnumInstType *aggregateUseType ) {
|
|---|
| 404 | handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );
|
|---|
| 405 | }
|
|---|
| 406 |
|
|---|
| 407 | void Visitor::visit( TraitInstType *aggregateUseType ) {
|
|---|
| 408 | handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );
|
|---|
| 409 | acceptAll( aggregateUseType->get_members(), *this );
|
|---|
| 410 | }
|
|---|
| 411 |
|
|---|
| 412 | void Visitor::visit( TypeInstType *aggregateUseType ) {
|
|---|
| 413 | handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );
|
|---|
| 414 | }
|
|---|
| 415 |
|
|---|
| 416 | void Visitor::visit( TupleType *tupleType ) {
|
|---|
| 417 | acceptAll( tupleType->get_forall(), *this );
|
|---|
| 418 | acceptAll( tupleType->get_types(), *this );
|
|---|
| 419 | acceptAll( tupleType->get_members(), *this );
|
|---|
| 420 | }
|
|---|
| 421 |
|
|---|
| 422 | void Visitor::visit( TypeofType *typeofType ) {
|
|---|
| 423 | assert( typeofType->get_expr() );
|
|---|
| 424 | typeofType->get_expr()->accept( *this );
|
|---|
| 425 | }
|
|---|
| 426 |
|
|---|
| 427 | void Visitor::visit( AttrType *attrType ) {
|
|---|
| 428 | if ( attrType->get_isType() ) {
|
|---|
| 429 | assert( attrType->get_type() );
|
|---|
| 430 | attrType->get_type()->accept( *this );
|
|---|
| 431 | } else {
|
|---|
| 432 | assert( attrType->get_expr() );
|
|---|
| 433 | attrType->get_expr()->accept( *this );
|
|---|
| 434 | } // if
|
|---|
| 435 | }
|
|---|
| 436 |
|
|---|
| 437 | void Visitor::visit( VarArgsType *varArgsType ) {
|
|---|
| 438 | acceptAll( varArgsType->get_forall(), *this );
|
|---|
| 439 | }
|
|---|
| 440 |
|
|---|
| 441 | void Visitor::visit( ZeroType *zeroType ) {
|
|---|
| 442 | acceptAll( zeroType->get_forall(), *this );
|
|---|
| 443 | }
|
|---|
| 444 |
|
|---|
| 445 | void Visitor::visit( OneType *oneType ) {
|
|---|
| 446 | acceptAll( oneType->get_forall(), *this );
|
|---|
| 447 | }
|
|---|
| 448 |
|
|---|
| 449 | void Visitor::visit( Designation * designation ) {
|
|---|
| 450 | acceptAll( designation->get_designators(), *this );
|
|---|
| 451 | }
|
|---|
| 452 |
|
|---|
| 453 | void Visitor::visit( SingleInit *singleInit ) {
|
|---|
| 454 | singleInit->get_value()->accept( *this );
|
|---|
| 455 | }
|
|---|
| 456 |
|
|---|
| 457 | void Visitor::visit( ListInit *listInit ) {
|
|---|
| 458 | acceptAll( listInit->get_designations(), *this );
|
|---|
| 459 | acceptAll( listInit->get_initializers(), *this );
|
|---|
| 460 | }
|
|---|
| 461 |
|
|---|
| 462 | void Visitor::visit( ConstructorInit *ctorInit ) {
|
|---|
| 463 | maybeAccept( ctorInit->get_ctor(), *this );
|
|---|
| 464 | maybeAccept( ctorInit->get_dtor(), *this );
|
|---|
| 465 | maybeAccept( ctorInit->get_init(), *this );
|
|---|
| 466 | }
|
|---|
| 467 |
|
|---|
| 468 |
|
|---|
| 469 | void Visitor::visit( __attribute__((unused)) Subrange *subrange ) {}
|
|---|
| 470 |
|
|---|
| 471 |
|
|---|
| 472 | void Visitor::visit( __attribute__((unused)) Constant *constant ) {}
|
|---|
| 473 | // Local Variables: //
|
|---|
| 474 | // tab-width: 4 //
|
|---|
| 475 | // mode: c++ //
|
|---|
| 476 | // compile-command: "make install" //
|
|---|
| 477 | // End: //
|
|---|