[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" |
---|
[30f9072] | 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... |
---|
[51b7345] | 23 | |
---|
| 24 | namespace SymTab { |
---|
[a7c90d4] | 25 | FixFunction::FixFunction() : isVoid( false ) {} |
---|
[51b7345] | 26 | |
---|
[0dd3a2f] | 27 | DeclarationWithType * FixFunction::mutate(FunctionDecl *functionDecl) { |
---|
[0b150ec] | 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() ); |
---|
[0a86a30] | 29 | functionDecl->get_attributes().clear(); |
---|
[0b150ec] | 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() ); |
---|
[0dd3a2f] | 32 | delete functionDecl; |
---|
| 33 | return pointer; |
---|
| 34 | } |
---|
[51b7345] | 35 | |
---|
[0dd3a2f] | 36 | Type * FixFunction::mutate(VoidType *voidType) { |
---|
| 37 | isVoid = true; |
---|
| 38 | return voidType; |
---|
| 39 | } |
---|
[51b7345] | 40 | |
---|
[0dd3a2f] | 41 | Type * FixFunction::mutate(BasicType *basicType) { |
---|
| 42 | return basicType; |
---|
| 43 | } |
---|
[51b7345] | 44 | |
---|
[0dd3a2f] | 45 | Type * FixFunction::mutate(PointerType *pointerType) { |
---|
| 46 | return pointerType; |
---|
| 47 | } |
---|
[51b7345] | 48 | |
---|
[0dd3a2f] | 49 | Type * FixFunction::mutate(ArrayType *arrayType) { |
---|
[40e636a] | 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() ); |
---|
[0dd3a2f] | 52 | delete arrayType; |
---|
| 53 | return pointerType; |
---|
| 54 | } |
---|
[51b7345] | 55 | |
---|
[0dd3a2f] | 56 | Type * FixFunction::mutate(StructInstType *aggregateUseType) { |
---|
| 57 | return aggregateUseType; |
---|
| 58 | } |
---|
[51b7345] | 59 | |
---|
[0dd3a2f] | 60 | Type * FixFunction::mutate(UnionInstType *aggregateUseType) { |
---|
| 61 | return aggregateUseType; |
---|
| 62 | } |
---|
[51b7345] | 63 | |
---|
[0dd3a2f] | 64 | Type * FixFunction::mutate(EnumInstType *aggregateUseType) { |
---|
| 65 | return aggregateUseType; |
---|
| 66 | } |
---|
[51b7345] | 67 | |
---|
[4040425] | 68 | Type * FixFunction::mutate(TraitInstType *aggregateUseType) { |
---|
[0dd3a2f] | 69 | return aggregateUseType; |
---|
| 70 | } |
---|
[51b7345] | 71 | |
---|
[0dd3a2f] | 72 | Type * FixFunction::mutate(TypeInstType *aggregateUseType) { |
---|
| 73 | return aggregateUseType; |
---|
| 74 | } |
---|
[51b7345] | 75 | |
---|
[0dd3a2f] | 76 | Type * FixFunction::mutate(TupleType *tupleType) { |
---|
| 77 | return tupleType; |
---|
| 78 | } |
---|
[44b7088] | 79 | |
---|
| 80 | Type * FixFunction::mutate(VarArgsType *varArgsType) { |
---|
| 81 | return varArgsType; |
---|
| 82 | } |
---|
[89e6ffc] | 83 | |
---|
| 84 | Type * FixFunction::mutate(ZeroType *zeroType) { |
---|
| 85 | return zeroType; |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | Type * FixFunction::mutate(OneType *oneType) { |
---|
| 89 | return oneType; |
---|
| 90 | } |
---|
[51b7345] | 91 | } // namespace SymTab |
---|
[0dd3a2f] | 92 | |
---|
| 93 | // Local Variables: // |
---|
| 94 | // tab-width: 4 // |
---|
| 95 | // mode: c++ // |
---|
| 96 | // compile-command: "make install" // |
---|
| 97 | // End: // |
---|