source: src/ResolvExpr/ResolveTypeof.cc @ dc12481

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since dc12481 was 843054c2, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

licencing: seventh groups of files

  • 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//
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
[a08ba92]12// Last Modified On : Tue May 19 16:49:04 2015
13// Update Count     : 3
[a32b204]14//
15
[51b7345]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 {
[a08ba92]25        namespace {
[51b7345]26#if 0
[a32b204]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                }
[51b7345]35#endif
[a08ba92]36        }
[51b7345]37
[a08ba92]38        class ResolveTypeof : public Mutator {
39          public:
[a32b204]40                ResolveTypeof( const SymTab::Indexer &indexer ) : indexer( indexer ) {}
41                Type *mutate( TypeofType *typeofType );
[51b7345]42
[a08ba92]43          private:
[a32b204]44                const SymTab::Indexer &indexer;
[a08ba92]45        };
[51b7345]46
[a08ba92]47        Type *resolveTypeof( Type *type, const SymTab::Indexer &indexer ) {
[a32b204]48                ResolveTypeof mutator( indexer );
49                return type->acceptMutator( mutator );
[a08ba92]50        }
[51b7345]51
[a08ba92]52        Type *ResolveTypeof::mutate( TypeofType *typeofType ) {
[d9a0e76]53#if 0
[a32b204]54                std::cout << "resolving typeof: ";
55                typeofType->print( std::cout );
56                std::cout << std::endl;
[d9a0e76]57#endif
[a32b204]58                if ( typeofType->get_expr() ) {
59                        Expression *newExpr = resolveInVoidContext( typeofType->get_expr(), indexer );
60                        assert( newExpr->get_results().size() > 0 );
61                        Type *newType;
62                        if ( newExpr->get_results().size() > 1 ) {
63                                TupleType *tupleType = new TupleType( Type::Qualifiers() );
64                                cloneAll( newExpr->get_results(), tupleType->get_types() );
65                                newType = tupleType;
66                        } else {
67                                newType = newExpr->get_results().front()->clone();
68                        } // if
69                        delete typeofType;
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.