source: src/ResolvExpr/ResolveTypeof.cc @ fd344aa

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 fd344aa was 906e24d, checked in by Rob Schluntz <rschlunt@…>, 8 years ago

replace results list on Expressions with a single Type field

  • Property mode set to 100644
File size: 1.8 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                        delete typeofType;
63                        return newType;
64                } // if
65                return typeofType;
66        }
67} // namespace ResolvExpr
68
69// Local Variables: //
70// tab-width: 4 //
71// mode: c++ //
72// compile-command: "make install" //
73// End: //
Note: See TracBrowser for help on using the repository browser.