source: src/ResolvExpr/ResolveTypeof.cc @ 6d53e779

new-env
Last change on this file since 6d53e779 was 68f9c43, checked in by Aaron Moss <a3moss@…>, 6 years ago

First pass at delete removal

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