source: src/SynTree/Mutator.cc @ cfaf9be

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since cfaf9be was cfaf9be, checked in by Rob Schluntz <rschlunt@…>, 6 years ago

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

  • Property mode set to 100644
File size: 3.5 KB
Line 
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// Mutator.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:37 2017
13// Update Count     : 27
14//
15
16#include <cassert>             // for assert
17#include <list>                // for list
18
19#include "Attribute.h"         // for Attribute
20#include "Declaration.h"       // for ObjectDecl, Declaration, DeclarationWi...
21#include "Expression.h"        // for Expression, ConstantExpr, ConditionalExpr
22#include "Initializer.h"       // for ConstructorInit, Initializer, Designation
23#include "Mutator.h"
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;
30
31Mutator::Mutator() {}
32
33Mutator::~Mutator() {}
34
35Type * Mutator::mutate( TupleType *tupleType ) {
36        mutateAll( tupleType->get_forall(), *this );
37        mutateAll( tupleType->get_types(), *this );
38        mutateAll( tupleType->get_members(), *this );
39        return tupleType;
40}
41
42Type * Mutator::mutate( TypeofType *typeofType ) {
43        assert( typeofType->get_expr() );
44        typeofType->set_expr( typeofType->get_expr()->acceptMutator( *this ) );
45        return typeofType;
46}
47
48Type * Mutator::mutate( AttrType *attrType ) {
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;
57}
58
59Type * Mutator::mutate( VarArgsType *varArgsType ) {
60        mutateAll( varArgsType->get_forall(), *this );
61        return varArgsType;
62}
63
64Type * Mutator::mutate( ZeroType *zeroType ) {
65        mutateAll( zeroType->get_forall(), *this );
66        return zeroType;
67}
68
69Type * Mutator::mutate( OneType *oneType ) {
70        mutateAll( oneType->get_forall(), *this );
71        return oneType;
72}
73
74
75Designation * Mutator::mutate( Designation * designation ) {
76        mutateAll( designation->get_designators(), *this );
77        return designation;
78}
79
80Initializer * Mutator::mutate( SingleInit *singleInit ) {
81        singleInit->set_value( singleInit->get_value()->acceptMutator( *this ) );
82        return singleInit;
83}
84
85Initializer * Mutator::mutate( ListInit *listInit ) {
86        mutateAll( listInit->get_designations(), *this );
87        mutateAll( listInit->get_initializers(), *this );
88        return listInit;
89}
90
91Initializer * Mutator::mutate( ConstructorInit *ctorInit ) {
92        ctorInit->set_ctor( maybeMutate( ctorInit->get_ctor(), *this ) );
93        ctorInit->set_dtor( maybeMutate( ctorInit->get_dtor(), *this ) );
94        ctorInit->set_init( maybeMutate( ctorInit->get_init(), *this ) );
95        return ctorInit;
96}
97
98
99Subrange * Mutator::mutate( Subrange *subrange ) {
100        return subrange;
101}
102
103
104Constant * Mutator::mutate( Constant *constant ) {
105        return constant;
106}
107
108Attribute * Mutator::mutate( Attribute * attribute ) {
109        mutateAll( attribute->parameters, *this );
110        return attribute;
111}
112
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
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.