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