source: src/SymTab/FixFunction.cc@ cb43451

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 cb43451 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
Line 
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//
7// FixFunction.cc --
8//
9// Author : Richard C. Bilson
10// Created On : Sun May 17 16:19:49 2015
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Mon Mar 6 23:36:59 2017
13// Update Count : 6
14//
15
16#include "FixFunction.h"
17#include "SynTree/Declaration.h"
18#include "SynTree/Type.h"
19#include "SynTree/Expression.h"
20#include "Common/utility.h"
21
22namespace SymTab {
23 FixFunction::FixFunction() : isVoid( false ) {}
24
25 DeclarationWithType * FixFunction::mutate(FunctionDecl *functionDecl) {
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() );
27 functionDecl->get_attributes().clear();
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() );
30 delete functionDecl;
31 return pointer;
32 }
33
34 Type * FixFunction::mutate(VoidType *voidType) {
35 isVoid = true;
36 return voidType;
37 }
38
39 Type * FixFunction::mutate(BasicType *basicType) {
40 return basicType;
41 }
42
43 Type * FixFunction::mutate(PointerType *pointerType) {
44 return pointerType;
45 }
46
47 Type * FixFunction::mutate(ArrayType *arrayType) {
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() );
50 delete arrayType;
51 return pointerType;
52 }
53
54 Type * FixFunction::mutate(StructInstType *aggregateUseType) {
55 return aggregateUseType;
56 }
57
58 Type * FixFunction::mutate(UnionInstType *aggregateUseType) {
59 return aggregateUseType;
60 }
61
62 Type * FixFunction::mutate(EnumInstType *aggregateUseType) {
63 return aggregateUseType;
64 }
65
66 Type * FixFunction::mutate(TraitInstType *aggregateUseType) {
67 return aggregateUseType;
68 }
69
70 Type * FixFunction::mutate(TypeInstType *aggregateUseType) {
71 return aggregateUseType;
72 }
73
74 Type * FixFunction::mutate(TupleType *tupleType) {
75 return tupleType;
76 }
77
78 Type * FixFunction::mutate(VarArgsType *varArgsType) {
79 return varArgsType;
80 }
81
82 Type * FixFunction::mutate(ZeroType *zeroType) {
83 return zeroType;
84 }
85
86 Type * FixFunction::mutate(OneType *oneType) {
87 return oneType;
88 }
89} // namespace SymTab
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.