source: src/SymTab/FixFunction.cc @ 33218c6

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 33218c6 was 30f9072, checked in by Thierry Delisle <tdelisle@…>, 7 years ago

More cleanup on the headers

  • Property mode set to 100644
File size: 2.9 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// FixFunction.cc --
8//
9// Author           : Richard C. Bilson
10// Created On       : Sun May 17 16:19:49 2015
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Mon Mar  6 23:36:59 2017
13// Update Count     : 6
14//
15
16#include "FixFunction.h"
17
18#include <list>                   // for list
19
20#include "Common/utility.h"       // for maybeClone
21#include "SynTree/Declaration.h"  // for FunctionDecl, ObjectDecl, Declarati...
22#include "SynTree/Type.h"         // for ArrayType, PointerType, Type, Basic...
23
24namespace SymTab {
25        FixFunction::FixFunction() : isVoid( false ) {}
26
27        DeclarationWithType * FixFunction::mutate(FunctionDecl *functionDecl) {
28                ObjectDecl *pointer = new ObjectDecl( functionDecl->get_name(), functionDecl->get_storageClasses(), functionDecl->get_linkage(), 0, new PointerType( Type::Qualifiers(), functionDecl->get_type() ), 0, functionDecl->get_attributes() );
29                functionDecl->get_attributes().clear();
30                // can't delete function type because it may contain assertions, but can't transfer ownership without a clone since set_type checks for nullptr
31                functionDecl->set_type( functionDecl->get_type()->clone() );
32                delete functionDecl;
33                return pointer;
34        }
35
36        Type * FixFunction::mutate(VoidType *voidType) {
37                isVoid = true;
38                return voidType;
39        }
40
41        Type * FixFunction::mutate(BasicType *basicType) {
42                return basicType;
43        }
44
45        Type * FixFunction::mutate(PointerType *pointerType) {
46                return pointerType;
47        }
48
49        Type * FixFunction::mutate(ArrayType *arrayType) {
50                // need to recursively mutate the base type in order for multi-dimensional arrays to work.
51                PointerType *pointerType = new PointerType( arrayType->get_qualifiers(), arrayType->get_base()->clone()->acceptMutator( *this ), maybeClone( arrayType->get_dimension() ), arrayType->get_isVarLen(), arrayType->get_isStatic() );
52                delete arrayType;
53                return pointerType;
54        }
55
56        Type * FixFunction::mutate(StructInstType *aggregateUseType) {
57                return aggregateUseType;
58        }
59
60        Type * FixFunction::mutate(UnionInstType *aggregateUseType) {
61                return aggregateUseType;
62        }
63
64        Type * FixFunction::mutate(EnumInstType *aggregateUseType) {
65                return aggregateUseType;
66        }
67
68        Type * FixFunction::mutate(TraitInstType *aggregateUseType) {
69                return aggregateUseType;
70        }
71
72        Type * FixFunction::mutate(TypeInstType *aggregateUseType) {
73                return aggregateUseType;
74        }
75
76        Type * FixFunction::mutate(TupleType *tupleType) {
77                return tupleType;
78        }
79
80        Type * FixFunction::mutate(VarArgsType *varArgsType) {
81                return varArgsType;
82        }
83
84        Type * FixFunction::mutate(ZeroType *zeroType) {
85                return zeroType;
86        }
87
88        Type * FixFunction::mutate(OneType *oneType) {
89                return oneType;
90        }
91} // namespace SymTab
92
93// Local Variables: //
94// tab-width: 4 //
95// mode: c++ //
96// compile-command: "make install" //
97// End: //
Note: See TracBrowser for help on using the repository browser.