source: src/SymTab/FixFunction.cc@ 2b7afbd

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 2b7afbd was 0b150ec, checked in by Rob Schluntz <rschlunt@…>, 8 years ago

minor zero_t/one_t prelude changes, simplify prelude generation, memory error fixes

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