source: src/SynTree/Mutator.cc@ 1f37ed02

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since 1f37ed02 was cfaf9be, checked in by Rob Schluntz <rschlunt@…>, 8 years ago

Make all Visitor/Mutator functions pure virtual, remove unused Visitor/Mutator code

  • Property mode set to 100644
File size: 3.5 KB
RevLine 
[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// Mutator.cc --
[0dd3a2f]8//
9// Author : Richard C. Bilson
10// Created On : Mon May 18 07:44:20 2015
[6d49ea3]11// Last Modified By : Peter A. Buhr
12// Last Modified On : Thu Aug 17 15:39:37 2017
13// Update Count : 27
[0dd3a2f]14//
15
[ea6332d]16#include <cassert> // for assert
17#include <list> // for list
18
[5ea7a22]19#include "Attribute.h" // for Attribute
[ea6332d]20#include "Declaration.h" // for ObjectDecl, Declaration, DeclarationWi...
21#include "Expression.h" // for Expression, ConstantExpr, ConditionalExpr
22#include "Initializer.h" // for ConstructorInit, Initializer, Designation
[51b73452]23#include "Mutator.h"
[ea6332d]24#include "Statement.h" // for Statement, CatchStmt, AsmStmt, ForStmt
25#include "Type.h" // for Type, Type::ForallList, AttrType, Arra...
26#include "TypeSubstitution.h" // for TypeSubstitution
27
28class Constant;
29class Subrange;
[51b73452]30
[d9a0e76]31Mutator::Mutator() {}
[51b73452]32
[d9a0e76]33Mutator::~Mutator() {}
[51b73452]34
[135b431]35Type * Mutator::mutate( TupleType *tupleType ) {
[0dd3a2f]36 mutateAll( tupleType->get_forall(), *this );
37 mutateAll( tupleType->get_types(), *this );
[62423350]38 mutateAll( tupleType->get_members(), *this );
[0dd3a2f]39 return tupleType;
[51b73452]40}
41
[135b431]42Type * Mutator::mutate( TypeofType *typeofType ) {
[0dd3a2f]43 assert( typeofType->get_expr() );
44 typeofType->set_expr( typeofType->get_expr()->acceptMutator( *this ) );
45 return typeofType;
[51b73452]46}
47
[135b431]48Type * Mutator::mutate( AttrType *attrType ) {
[0dd3a2f]49 if ( attrType->get_isType() ) {
50 assert( attrType->get_type() );
51 attrType->set_type( attrType->get_type()->acceptMutator( *this ) );
52 } else {
53 assert( attrType->get_expr() );
54 attrType->set_expr( attrType->get_expr()->acceptMutator( *this ) );
55 }
56 return attrType;
[51b73452]57}
58
[135b431]59Type * Mutator::mutate( VarArgsType *varArgsType ) {
[44b7088]60 mutateAll( varArgsType->get_forall(), *this );
61 return varArgsType;
62}
63
[135b431]64Type * Mutator::mutate( ZeroType *zeroType ) {
[89e6ffc]65 mutateAll( zeroType->get_forall(), *this );
66 return zeroType;
67}
68
[135b431]69Type * Mutator::mutate( OneType *oneType ) {
[89e6ffc]70 mutateAll( oneType->get_forall(), *this );
71 return oneType;
72}
73
[e994912]74
[135b431]75Designation * Mutator::mutate( Designation * designation ) {
[e4d829b]76 mutateAll( designation->get_designators(), *this );
77 return designation;
78}
79
[135b431]80Initializer * Mutator::mutate( SingleInit *singleInit ) {
[0dd3a2f]81 singleInit->set_value( singleInit->get_value()->acceptMutator( *this ) );
82 return singleInit;
[51b73452]83}
84
[135b431]85Initializer * Mutator::mutate( ListInit *listInit ) {
[e4d829b]86 mutateAll( listInit->get_designations(), *this );
[0dd3a2f]87 mutateAll( listInit->get_initializers(), *this );
88 return listInit;
[51b73452]89}
90
[135b431]91Initializer * Mutator::mutate( ConstructorInit *ctorInit ) {
[71f4e4f]92 ctorInit->set_ctor( maybeMutate( ctorInit->get_ctor(), *this ) );
[d5556a3]93 ctorInit->set_dtor( maybeMutate( ctorInit->get_dtor(), *this ) );
[71f4e4f]94 ctorInit->set_init( maybeMutate( ctorInit->get_init(), *this ) );
95 return ctorInit;
96}
97
[e994912]98
[135b431]99Subrange * Mutator::mutate( Subrange *subrange ) {
[0dd3a2f]100 return subrange;
[51b73452]101}
102
[e994912]103
[135b431]104Constant * Mutator::mutate( Constant *constant ) {
[0dd3a2f]105 return constant;
[51b73452]106}
[0dd3a2f]107
[5ea7a22]108Attribute * Mutator::mutate( Attribute * attribute ) {
109 mutateAll( attribute->parameters, *this );
110 return attribute;
111}
112
[447c356]113TypeSubstitution * Mutator::mutate( TypeSubstitution * sub ) {
114 for ( auto & p : sub->typeEnv ) {
115 p.second = maybeMutate( p.second, *this );
116 }
117 for ( auto & p : sub->varEnv ) {
118 p.second = maybeMutate( p.second, *this );
119 }
120 return sub;
121}
122
[0dd3a2f]123// Local Variables: //
124// tab-width: 4 //
125// mode: c++ //
126// compile-command: "make install" //
127// End: //
Note: See TracBrowser for help on using the repository browser.