source: src/SymTab/ImplementationType.cc@ 7527e63

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 7527e63 was 4040425, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

change keyword type to otype and context to trait

  • Property mode set to 100644
File size: 4.1 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 : Wed Mar 2 17:31:20 2016
13// Update Count : 3
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
44 Type *result; // synthesized
45 const SymTab::Indexer &indexer;
46 };
47
48 Type * implementationType( Type *type, const SymTab::Indexer& indexer ) {
49 ImplementationType implementor( indexer );
50 type->accept( implementor );
51 if ( implementor.get_result() == 0 ) {
52 return type->clone();
53 } else {
54 return implementor.get_result();
55 } // if
56 }
57
58 ImplementationType::ImplementationType( const SymTab::Indexer &indexer ) : result( 0 ), indexer( indexer ) {
59 }
60
61 void ImplementationType::visit(VoidType *voidType) {
62 }
63
64 void ImplementationType::visit(BasicType *basicType) {
65 }
66
67 void ImplementationType::visit(PointerType *pointerType) {
68 PointerType *newType = pointerType->clone();
69 newType->set_base( implementationType( pointerType->get_base(), indexer ) );
70 result = newType;
71 }
72
73 void ImplementationType::visit(ArrayType *arrayType) {
74 ArrayType *newType = arrayType->clone();
75 newType->set_base( implementationType( arrayType->get_base(), indexer ) );
76 result = newType;
77 }
78
79 void ImplementationType::visit(FunctionType *functionType) {
80/// FunctionType *newType = functionType->clone();
81/// for ( std::list< DeclarationWithType* >::iterator i = newType->get_parameters().begin(); i != newType->get_parameters().end(); ++i ) {
82/// i->set_type( implementationType( i->get_type(), indexer ) );
83/// }
84/// for ( std::list< DeclarationWithType* >::iterator i = newType->get_parameters().begin(); i != newType->get_parameters().end(); ++i ) {
85/// i->set_type( implementationType( i->get_type(), indexer ) );
86/// }
87 }
88
89 void ImplementationType::visit(StructInstType *aggregateUseType) {
90 }
91
92 void ImplementationType::visit(UnionInstType *aggregateUseType) {
93 }
94
95 void ImplementationType::visit(EnumInstType *aggregateUseType) {
96 }
97
98 void ImplementationType::visit(TraitInstType *aggregateUseType) {
99 }
100
101 void ImplementationType::visit(TypeInstType *inst) {
102 NamedTypeDecl *typeDecl = indexer.lookupType( inst->get_name() );
103 if ( typeDecl && typeDecl->get_base() ) {
104 Type *base = implementationType( typeDecl->get_base(), indexer );
105 base->get_qualifiers() += inst->get_qualifiers();
106 result = base;
107 } // if
108 }
109
110 void ImplementationType::visit(TupleType *tupleType) {
111 TupleType *newType = new TupleType( Type::Qualifiers() );
112 for ( std::list< Type* >::iterator i = tupleType->get_types().begin(); i != tupleType->get_types().end(); ++i ) {
113 Type *implType = implementationType( *i, indexer );
114 implType->get_qualifiers() += tupleType->get_qualifiers();
115 newType->get_types().push_back( implType );
116 } // for
117 result = newType;
118 }
119
120 void ImplementationType::visit(VarArgsType *varArgsType) {
121 }
122} // namespace SymTab
123
124// Local Variables: //
125// tab-width: 4 //
126// mode: c++ //
127// compile-command: "make install" //
128// End: //
Note: See TracBrowser for help on using the repository browser.