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