source: translator/ResolvExpr/ResolveTypeof.cc@ c8ffe20b

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors ctor deferred_resn demangler enum forall-pointer-decay gc_noraii jacob/cs343-translation jenkins-sandbox memory new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new string with_gc
Last change on this file since c8ffe20b was 51b73452, checked in by Peter A. Buhr <pabuhr@…>, 11 years ago

initial commit

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 * This file is part of the Cforall project
3 *
4 * $Id: ResolveTypeof.cc,v 1.2 2005/08/29 20:14:16 rcbilson Exp $
5 *
6 */
7
8#include "ResolveTypeof.h"
9#include "Alternative.h"
10#include "AlternativeFinder.h"
11#include "Resolver.h"
12#include "TypeEnvironment.h"
13#include "SynTree/Expression.h"
14#include "SynTree/Type.h"
15
16namespace ResolvExpr {
17
18namespace {
19#if 0
20 void
21 printAlts( const AltList &list, std::ostream &os, int indent = 0 )
22 {
23 for( AltList::const_iterator i = list.begin(); i != list.end(); ++i ) {
24 i->print( os, indent );
25 os << std::endl;
26 }
27 }
28#endif
29}
30
31class ResolveTypeof : public Mutator
32{
33public:
34 ResolveTypeof( const SymTab::Indexer &indexer ) : indexer( indexer ) {}
35 Type *mutate( TypeofType *typeofType );
36
37private:
38 const SymTab::Indexer &indexer;
39};
40
41Type *
42resolveTypeof( Type *type, const SymTab::Indexer &indexer )
43{
44 ResolveTypeof mutator( indexer );
45 return type->acceptMutator( mutator );
46}
47
48Type *
49ResolveTypeof::mutate( TypeofType *typeofType )
50{
51/// std::cout << "resolving typeof: ";
52/// typeofType->print( std::cout );
53/// std::cout << std::endl;
54 if( typeofType->get_expr() ) {
55 Expression *newExpr = resolveInVoidContext( typeofType->get_expr(), indexer );
56 assert( newExpr->get_results().size() > 0 );
57 Type *newType;
58 if( newExpr->get_results().size() > 1 ) {
59 TupleType *tupleType = new TupleType( Type::Qualifiers() );
60 cloneAll( newExpr->get_results(), tupleType->get_types() );
61 newType = tupleType;
62 } else {
63 newType = newExpr->get_results().front()->clone();
64 }
65 delete typeofType;
66 return newType;
67 }
68 return typeofType;
69}
70
71} // namespace ResolvExpr
Note: See TracBrowser for help on using the repository browser.