source: src/SymTab/FixFunction.cc @ ced2e989

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since ced2e989 was 40e636a, checked in by Rob Schluntz <rschlunt@…>, 8 years ago

only generate array dimension constant inside of functions, recursively mutate array types into pointer types in function parameter lists, fix bug where global compound literal object is lost

  • Property mode set to 100644
File size: 2.3 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 : Wed Mar  2 17:31:10 2016
13// Update Count     : 3
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
26        DeclarationWithType * FixFunction::mutate(FunctionDecl *functionDecl) {
27                ObjectDecl *pointer = new ObjectDecl( functionDecl->get_name(), functionDecl->get_storageClass(), functionDecl->get_linkage(), 0, new PointerType( Type::Qualifiers(), functionDecl->get_type()->clone() ), 0 );
28                delete functionDecl;
29                return pointer;
30        }
31
32        Type * FixFunction::mutate(VoidType *voidType) {
33                isVoid = true;
34                return voidType;
35        }
36
37        Type * FixFunction::mutate(BasicType *basicType) {
38                return basicType;
39        }
40
41        Type * FixFunction::mutate(PointerType *pointerType) {
42                return pointerType;
43        }
44
45        Type * FixFunction::mutate(ArrayType *arrayType) {
46                // need to recursively mutate the base type in order for multi-dimensional arrays to work.
47                PointerType *pointerType = new PointerType( arrayType->get_qualifiers(), arrayType->get_base()->clone()->acceptMutator( *this ), maybeClone( arrayType->get_dimension() ), arrayType->get_isVarLen(), arrayType->get_isStatic() );
48                delete arrayType;
49                return pointerType;
50        }
51
52        Type * FixFunction::mutate(StructInstType *aggregateUseType) {
53                return aggregateUseType;
54        }
55
56        Type * FixFunction::mutate(UnionInstType *aggregateUseType) {
57                return aggregateUseType;
58        }
59
60        Type * FixFunction::mutate(EnumInstType *aggregateUseType) {
61                return aggregateUseType;
62        }
63
64        Type * FixFunction::mutate(TraitInstType *aggregateUseType) {
65                return aggregateUseType;
66        }
67
68        Type * FixFunction::mutate(TypeInstType *aggregateUseType) {
69                return aggregateUseType;
70        }
71
72        Type * FixFunction::mutate(TupleType *tupleType) {
73                return tupleType;
74        }
75
76        Type * FixFunction::mutate(VarArgsType *varArgsType) {
77                return varArgsType;
78        }
79} // namespace SymTab
80
81// Local Variables: //
82// tab-width: 4 //
83// mode: c++ //
84// compile-command: "make install" //
85// End: //
Note: See TracBrowser for help on using the repository browser.