source: src/SymTab/FixFunction.cc@ a6dd5b0

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors ctor deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox memory 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 a6dd5b0 was 40e636a, checked in by Rob Schluntz <rschlunt@…>, 9 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
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
[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
22namespace SymTab {
[0dd3a2f]23 FixFunction::FixFunction() : isVoid( false ) {
24 }
[51b73452]25
[0dd3a2f]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 }
[51b73452]31
[0dd3a2f]32 Type * FixFunction::mutate(VoidType *voidType) {
33 isVoid = true;
34 return voidType;
35 }
[51b73452]36
[0dd3a2f]37 Type * FixFunction::mutate(BasicType *basicType) {
38 return basicType;
39 }
[51b73452]40
[0dd3a2f]41 Type * FixFunction::mutate(PointerType *pointerType) {
42 return pointerType;
43 }
[51b73452]44
[0dd3a2f]45 Type * FixFunction::mutate(ArrayType *arrayType) {
[40e636a]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() );
[0dd3a2f]48 delete arrayType;
49 return pointerType;
50 }
[51b73452]51
[0dd3a2f]52 Type * FixFunction::mutate(StructInstType *aggregateUseType) {
53 return aggregateUseType;
54 }
[51b73452]55
[0dd3a2f]56 Type * FixFunction::mutate(UnionInstType *aggregateUseType) {
57 return aggregateUseType;
58 }
[51b73452]59
[0dd3a2f]60 Type * FixFunction::mutate(EnumInstType *aggregateUseType) {
61 return aggregateUseType;
62 }
[51b73452]63
[4040425]64 Type * FixFunction::mutate(TraitInstType *aggregateUseType) {
[0dd3a2f]65 return aggregateUseType;
66 }
[51b73452]67
[0dd3a2f]68 Type * FixFunction::mutate(TypeInstType *aggregateUseType) {
69 return aggregateUseType;
70 }
[51b73452]71
[0dd3a2f]72 Type * FixFunction::mutate(TupleType *tupleType) {
73 return tupleType;
74 }
[44b7088]75
76 Type * FixFunction::mutate(VarArgsType *varArgsType) {
77 return varArgsType;
78 }
[51b73452]79} // namespace SymTab
[0dd3a2f]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.