source: src/ResolvExpr/ResolveTypeof.cc @ fbcb354

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

Merge branch 'master' into references

  • Property mode set to 100644
File size: 2.0 KB
RevLine 
[a32b204]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//
[906e24d]7// ResolveTypeof.cc --
[a32b204]8//
9// Author           : Richard C. Bilson
10// Created On       : Sun May 17 12:12:20 2015
11// Last Modified By : Peter A. Buhr
[a08ba92]12// Last Modified On : Tue May 19 16:49:04 2015
13// Update Count     : 3
[a32b204]14//
15
[51b7345]16#include "ResolveTypeof.h"
[ea6332d]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
[51b7345]28
29namespace ResolvExpr {
[a08ba92]30        namespace {
[51b7345]31#if 0
[a32b204]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                }
[51b7345]40#endif
[a08ba92]41        }
[51b7345]42
[a08ba92]43        class ResolveTypeof : public Mutator {
44          public:
[a32b204]45                ResolveTypeof( const SymTab::Indexer &indexer ) : indexer( indexer ) {}
46                Type *mutate( TypeofType *typeofType );
[51b7345]47
[a08ba92]48          private:
[a32b204]49                const SymTab::Indexer &indexer;
[a08ba92]50        };
[51b7345]51
[a08ba92]52        Type *resolveTypeof( Type *type, const SymTab::Indexer &indexer ) {
[a32b204]53                ResolveTypeof mutator( indexer );
54                return type->acceptMutator( mutator );
[a08ba92]55        }
[51b7345]56
[a08ba92]57        Type *ResolveTypeof::mutate( TypeofType *typeofType ) {
[d9a0e76]58#if 0
[a32b204]59                std::cout << "resolving typeof: ";
60                typeofType->print( std::cout );
61                std::cout << std::endl;
[d9a0e76]62#endif
[a32b204]63                if ( typeofType->get_expr() ) {
64                        Expression *newExpr = resolveInVoidContext( typeofType->get_expr(), indexer );
[906e24d]65                        assert( newExpr->has_result() && ! newExpr->get_result()->isVoid() );
66                        Type *newType = newExpr->get_result();
[c93bc28]67                        newExpr->set_result( nullptr );
[a32b204]68                        delete typeofType;
[c93bc28]69                        delete newExpr;
[a32b204]70                        return newType;
71                } // if
72                return typeofType;
[a08ba92]73        }
[51b7345]74} // namespace ResolvExpr
[a32b204]75
76// Local Variables: //
77// tab-width: 4 //
78// mode: c++ //
79// compile-command: "make install" //
80// End: //
Note: See TracBrowser for help on using the repository browser.