source: src/ResolvExpr/ResolveTypeof.cc @ d104b02

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 d104b02 was c93bc28, checked in by Rob Schluntz <rschlunt@…>, 7 years ago

Minor cleanup, debug statements

  • Property mode set to 100644
File size: 1.9 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// ResolveTypeof.cc --
8//
9// Author           : Richard C. Bilson
10// Created On       : Sun May 17 12:12:20 2015
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Tue May 19 16:49:04 2015
13// Update Count     : 3
14//
15
16#include "ResolveTypeof.h"
17#include "Alternative.h"
18#include "AlternativeFinder.h"
19#include "Resolver.h"
20#include "TypeEnvironment.h"
21#include "SynTree/Expression.h"
22#include "SynTree/Type.h"
23
24namespace ResolvExpr {
25        namespace {
26#if 0
27                void
28                printAlts( const AltList &list, std::ostream &os, int indent = 0 )
29                {
30                        for ( AltList::const_iterator i = list.begin(); i != list.end(); ++i ) {
31                                i->print( os, indent );
32                                os << std::endl;
33                        }
34                }
35#endif
36        }
37
38        class ResolveTypeof : public Mutator {
39          public:
40                ResolveTypeof( const SymTab::Indexer &indexer ) : indexer( indexer ) {}
41                Type *mutate( TypeofType *typeofType );
42
43          private:
44                const SymTab::Indexer &indexer;
45        };
46
47        Type *resolveTypeof( Type *type, const SymTab::Indexer &indexer ) {
48                ResolveTypeof mutator( indexer );
49                return type->acceptMutator( mutator );
50        }
51
52        Type *ResolveTypeof::mutate( TypeofType *typeofType ) {
53#if 0
54                std::cout << "resolving typeof: ";
55                typeofType->print( std::cout );
56                std::cout << std::endl;
57#endif
58                if ( typeofType->get_expr() ) {
59                        Expression *newExpr = resolveInVoidContext( typeofType->get_expr(), indexer );
60                        assert( newExpr->has_result() && ! newExpr->get_result()->isVoid() );
61                        Type *newType = newExpr->get_result();
62                        newExpr->set_result( nullptr );
63                        delete typeofType;
64                        delete newExpr;
65                        return newType;
66                } // if
67                return typeofType;
68        }
69} // namespace ResolvExpr
70
71// Local Variables: //
72// tab-width: 4 //
73// mode: c++ //
74// compile-command: "make install" //
75// End: //
Note: See TracBrowser for help on using the repository browser.