source: src/ResolvExpr/ResolveTypeof.cc @ ea6332d

aaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerresolv-newwith_gc
Last change on this file since ea6332d was ea6332d, checked in by Thierry Delisle <tdelisle@…>, 4 years ago

Big header cleaning pass - commit 3

  • Property mode set to 100644
File size: 2.0 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
18#include <cassert>               // for assert
19
20#include "Resolver.h"            // for resolveInVoidContext
21#include "SynTree/Expression.h"  // for Expression
22#include "SynTree/Mutator.h"     // for Mutator
23#include "SynTree/Type.h"        // for TypeofType, Type
24
25namespace SymTab {
26class Indexer;
27}  // namespace SymTab
28
29namespace ResolvExpr {
30        namespace {
31#if 0
32                void
33                printAlts( const AltList &list, std::ostream &os, int indent = 0 )
34                {
35                        for ( AltList::const_iterator i = list.begin(); i != list.end(); ++i ) {
36                                i->print( os, indent );
37                                os << std::endl;
38                        }
39                }
40#endif
41        }
42
43        class ResolveTypeof : public Mutator {
44          public:
45                ResolveTypeof( const SymTab::Indexer &indexer ) : indexer( indexer ) {}
46                Type *mutate( TypeofType *typeofType );
47
48          private:
49                const SymTab::Indexer &indexer;
50        };
51
52        Type *resolveTypeof( Type *type, const SymTab::Indexer &indexer ) {
53                ResolveTypeof mutator( indexer );
54                return type->acceptMutator( mutator );
55        }
56
57        Type *ResolveTypeof::mutate( TypeofType *typeofType ) {
58#if 0
59                std::cout << "resolving typeof: ";
60                typeofType->print( std::cout );
61                std::cout << std::endl;
62#endif
63                if ( typeofType->get_expr() ) {
64                        Expression *newExpr = resolveInVoidContext( typeofType->get_expr(), indexer );
65                        assert( newExpr->has_result() && ! newExpr->get_result()->isVoid() );
66                        Type *newType = newExpr->get_result();
67                        delete typeofType;
68                        return newType;
69                } // if
70                return typeofType;
71        }
72} // namespace ResolvExpr
73
74// Local Variables: //
75// tab-width: 4 //
76// mode: c++ //
77// compile-command: "make install" //
78// End: //
Note: See TracBrowser for help on using the repository browser.