source: src/SymTab/ImplementationType.cc @ 7b13aeb

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 7b13aeb was 7e003011, checked in by Thierry Delisle <tdelisle@…>, 7 years ago

Some more unused argument removal, also removed some functions

  • Property mode set to 100644
File size: 4.5 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// ImplementationType.cc --
8//
9// Author           : Richard C. Bilson
10// Created On       : Sun May 17 21:32:01 2015
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Thu Mar 16 15:54:08 2017
13// Update Count     : 4
14//
15
16#include "ImplementationType.h"
17#include "SynTree/Type.h"
18#include "SynTree/Declaration.h"
19#include "SynTree/Visitor.h"
20#include "SymTab/Indexer.h"
21#include "Common/utility.h"
22
23
24namespace SymTab {
25        class ImplementationType : public Visitor {
26          public:
27                ImplementationType( const SymTab::Indexer &indexer );
28
29                Type *get_result() { return result; }
30          private:
31                virtual void visit(VoidType *voidType);
32                virtual void visit(BasicType *basicType);
33                virtual void visit(PointerType *pointerType);
34                virtual void visit(ArrayType *arrayType);
35                virtual void visit(FunctionType *functionType);
36                virtual void visit(StructInstType *aggregateUseType);
37                virtual void visit(UnionInstType *aggregateUseType);
38                virtual void visit(EnumInstType *aggregateUseType);
39                virtual void visit(TraitInstType *aggregateUseType);
40                virtual void visit(TypeInstType *aggregateUseType);
41                virtual void visit(TupleType *tupleType);
42                virtual void visit(VarArgsType *varArgsType);
43                virtual void visit(ZeroType *zeroType);
44                virtual void visit(OneType *oneType);
45
46                Type *result;                   // synthesized
47                const SymTab::Indexer &indexer;
48        };
49
50        Type * implementationType( Type *type, const SymTab::Indexer& indexer ) {
51                ImplementationType implementor( indexer );
52                type->accept( implementor );
53                if ( implementor.get_result() == 0 ) {
54                        return type->clone();
55                } else {
56                        return implementor.get_result();
57                } // if
58        }
59
60        ImplementationType::ImplementationType( const SymTab::Indexer &indexer ) : result( 0 ), indexer( indexer ) {
61        }
62
63        void ImplementationType::visit( __attribute__((unused)) VoidType *voidType ) {}
64        void ImplementationType::visit( __attribute__((unused)) BasicType *basicType ) {}
65
66        void ImplementationType::visit(PointerType *pointerType) {
67                PointerType *newType = pointerType->clone();
68                newType->set_base( implementationType( pointerType->get_base(), indexer ) );
69                result = newType;
70        }
71
72        void ImplementationType::visit(ArrayType *arrayType) {
73                ArrayType *newType = arrayType->clone();
74                newType->set_base( implementationType( arrayType->get_base(), indexer ) );
75                result = newType;
76        }
77
78        void ImplementationType::visit(FunctionType *functionType) {
79///   FunctionType *newType = functionType->clone();
80///   for ( std::list< DeclarationWithType* >::iterator i = newType->get_parameters().begin(); i != newType->get_parameters().end(); ++i ) {
81///     i->set_type( implementationType( i->get_type(), indexer ) );
82///   }
83///   for ( std::list< DeclarationWithType* >::iterator i = newType->get_parameters().begin(); i != newType->get_parameters().end(); ++i ) {
84///     i->set_type( implementationType( i->get_type(), indexer ) );
85///   }
86        }
87
88        void ImplementationType::visit( __attribute__((unused)) StructInstType * aggregateUseType ) {}
89        void ImplementationType::visit( __attribute__((unused)) UnionInstType * aggregateUseType ) {}
90        void ImplementationType::visit( __attribute__((unused)) EnumInstType * aggregateUseType ) {}
91        void ImplementationType::visit( __attribute__((unused)) TraitInstType * aggregateUseType ) {}
92
93        void ImplementationType::visit(TypeInstType *inst) {
94                NamedTypeDecl *typeDecl = indexer.lookupType( inst->get_name() );
95                if ( typeDecl && typeDecl->get_base() ) {
96                        Type *base = implementationType( typeDecl->get_base(), indexer );
97                        base->get_qualifiers() |= inst->get_qualifiers();
98                        result = base;
99                } // if
100        }
101
102        void ImplementationType::visit(TupleType *tupleType) {
103                TupleType *newType = new TupleType( Type::Qualifiers() );
104                for ( std::list< Type* >::iterator i = tupleType->get_types().begin(); i != tupleType->get_types().end(); ++i ) {
105                        Type *implType = implementationType( *i, indexer );
106                        implType->get_qualifiers() |= tupleType->get_qualifiers();
107                        newType->get_types().push_back( implType );
108                } // for
109                result = newType;
110        }
111
112        void ImplementationType::visit( __attribute__((unused)) VarArgsType *varArgsType ) {}
113        void ImplementationType::visit( __attribute__((unused)) ZeroType *zeroType ) {}
114        void ImplementationType::visit( __attribute__((unused)) OneType *oneType ) {}
115} // namespace SymTab
116
117// Local Variables: //
118// tab-width: 4 //
119// mode: c++ //
120// compile-command: "make install" //
121// End: //
Note: See TracBrowser for help on using the repository browser.