source: src/ResolvExpr/ResolveTypeof.cc @ 93fe7141

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 93fe7141 was d29fa5f, checked in by Rob Schluntz <rschlunt@…>, 6 years ago

Remove has_result

  • 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->result && ! newExpr->get_result()->isVoid() );
66                        Type *newType = newExpr->get_result();
67                        newExpr->set_result( nullptr );
68                        delete typeofType;
69                        delete newExpr;
70                        return newType;
71                } // if
72                return typeofType;
73        }
74} // namespace ResolvExpr
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.