source: src/SymTab/FixFunction.cc@ 982832e

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since 982832e was c3acf0aa, checked in by Thierry Delisle <tdelisle@…>, 8 years ago

More header cleaning

  • Property mode set to 100644
File size: 2.9 KB
RevLine 
[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
[51b73452]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...
[c3acf0aa]22#include "SynTree/Expression.h" // for Expression
[30f9072]23#include "SynTree/Type.h" // for ArrayType, PointerType, Type, Basic...
[51b73452]24
25namespace SymTab {
[a7c90d4]26 FixFunction::FixFunction() : isVoid( false ) {}
[51b73452]27
[0dd3a2f]28 DeclarationWithType * FixFunction::mutate(FunctionDecl *functionDecl) {
[0b150ec]29 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]30 functionDecl->get_attributes().clear();
[0b150ec]31 // can't delete function type because it may contain assertions, but can't transfer ownership without a clone since set_type checks for nullptr
32 functionDecl->set_type( functionDecl->get_type()->clone() );
[0dd3a2f]33 delete functionDecl;
34 return pointer;
35 }
[51b73452]36
[0dd3a2f]37 Type * FixFunction::mutate(VoidType *voidType) {
38 isVoid = true;
39 return voidType;
40 }
[51b73452]41
[0dd3a2f]42 Type * FixFunction::mutate(BasicType *basicType) {
43 return basicType;
44 }
[51b73452]45
[0dd3a2f]46 Type * FixFunction::mutate(PointerType *pointerType) {
47 return pointerType;
48 }
[51b73452]49
[0dd3a2f]50 Type * FixFunction::mutate(ArrayType *arrayType) {
[40e636a]51 // need to recursively mutate the base type in order for multi-dimensional arrays to work.
52 PointerType *pointerType = new PointerType( arrayType->get_qualifiers(), arrayType->get_base()->clone()->acceptMutator( *this ), maybeClone( arrayType->get_dimension() ), arrayType->get_isVarLen(), arrayType->get_isStatic() );
[0dd3a2f]53 delete arrayType;
54 return pointerType;
55 }
[51b73452]56
[0dd3a2f]57 Type * FixFunction::mutate(StructInstType *aggregateUseType) {
58 return aggregateUseType;
59 }
[51b73452]60
[0dd3a2f]61 Type * FixFunction::mutate(UnionInstType *aggregateUseType) {
62 return aggregateUseType;
63 }
[51b73452]64
[0dd3a2f]65 Type * FixFunction::mutate(EnumInstType *aggregateUseType) {
66 return aggregateUseType;
67 }
[51b73452]68
[4040425]69 Type * FixFunction::mutate(TraitInstType *aggregateUseType) {
[0dd3a2f]70 return aggregateUseType;
71 }
[51b73452]72
[0dd3a2f]73 Type * FixFunction::mutate(TypeInstType *aggregateUseType) {
74 return aggregateUseType;
75 }
[51b73452]76
[0dd3a2f]77 Type * FixFunction::mutate(TupleType *tupleType) {
78 return tupleType;
79 }
[44b7088]80
81 Type * FixFunction::mutate(VarArgsType *varArgsType) {
82 return varArgsType;
83 }
[89e6ffc]84
85 Type * FixFunction::mutate(ZeroType *zeroType) {
86 return zeroType;
87 }
88
89 Type * FixFunction::mutate(OneType *oneType) {
90 return oneType;
91 }
[51b73452]92} // namespace SymTab
[0dd3a2f]93
94// Local Variables: //
95// tab-width: 4 //
96// mode: c++ //
97// compile-command: "make install" //
98// End: //
Note: See TracBrowser for help on using the repository browser.