source: src/ResolvExpr/ResolveTypeof.cc@ ea6332d

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new stuck-waitfor-destruct with_gc
Last change on this file since ea6332d was ea6332d, checked in by Thierry Delisle <tdelisle@…>, 9 years ago

Big header cleaning pass - commit 3

  • 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
[51b73452]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
[51b73452]28
29namespace ResolvExpr {
[a08ba92]30 namespace {
[51b73452]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 }
[51b73452]40#endif
[a08ba92]41 }
[51b73452]42
[a08ba92]43 class ResolveTypeof : public Mutator {
44 public:
[a32b204]45 ResolveTypeof( const SymTab::Indexer &indexer ) : indexer( indexer ) {}
46 Type *mutate( TypeofType *typeofType );
[51b73452]47
[a08ba92]48 private:
[a32b204]49 const SymTab::Indexer &indexer;
[a08ba92]50 };
[51b73452]51
[a08ba92]52 Type *resolveTypeof( Type *type, const SymTab::Indexer &indexer ) {
[a32b204]53 ResolveTypeof mutator( indexer );
54 return type->acceptMutator( mutator );
[a08ba92]55 }
[51b73452]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();
[a32b204]67 delete typeofType;
68 return newType;
69 } // if
70 return typeofType;
[a08ba92]71 }
[51b73452]72} // namespace ResolvExpr
[a32b204]73
74// Local Variables: //
75// tab-width: 4 //
76// mode: c++ //
77// compile-command: "make install" //
78// End: //
Note: See TracBrowser for help on using the repository browser.