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 643a2e1 was d9a0e76, checked in by Peter A. Buhr <pabuhr@…>, 11 years ago |
remove Parser.old, add -XCFA to driver, copy ptrdiff_t from stddef.h in preclude, remove casts from initialization constants, adjust formatting
|
-
Property mode
set to
100644
|
File size:
1.5 KB
|
Line | |
---|
1 | #include "ResolveTypeof.h"
|
---|
2 | #include "Alternative.h"
|
---|
3 | #include "AlternativeFinder.h"
|
---|
4 | #include "Resolver.h"
|
---|
5 | #include "TypeEnvironment.h"
|
---|
6 | #include "SynTree/Expression.h"
|
---|
7 | #include "SynTree/Type.h"
|
---|
8 |
|
---|
9 | namespace ResolvExpr {
|
---|
10 | namespace {
|
---|
11 | #if 0
|
---|
12 | void
|
---|
13 | printAlts( const AltList &list, std::ostream &os, int indent = 0 )
|
---|
14 | {
|
---|
15 | for( AltList::const_iterator i = list.begin(); i != list.end(); ++i ) {
|
---|
16 | i->print( os, indent );
|
---|
17 | os << std::endl;
|
---|
18 | }
|
---|
19 | }
|
---|
20 | #endif
|
---|
21 | }
|
---|
22 |
|
---|
23 | class ResolveTypeof : public Mutator {
|
---|
24 | public:
|
---|
25 | ResolveTypeof( const SymTab::Indexer &indexer ) : indexer( indexer ) {}
|
---|
26 | Type *mutate( TypeofType *typeofType );
|
---|
27 |
|
---|
28 | private:
|
---|
29 | const SymTab::Indexer &indexer;
|
---|
30 | };
|
---|
31 |
|
---|
32 | Type *resolveTypeof( Type *type, const SymTab::Indexer &indexer ) {
|
---|
33 | ResolveTypeof mutator( indexer );
|
---|
34 | return type->acceptMutator( mutator );
|
---|
35 | }
|
---|
36 |
|
---|
37 | Type *ResolveTypeof::mutate( TypeofType *typeofType ) {
|
---|
38 | #if 0
|
---|
39 | std::cout << "resolving typeof: ";
|
---|
40 | typeofType->print( std::cout );
|
---|
41 | std::cout << std::endl;
|
---|
42 | #endif
|
---|
43 | if ( typeofType->get_expr() ) {
|
---|
44 | Expression *newExpr = resolveInVoidContext( typeofType->get_expr(), indexer );
|
---|
45 | assert( newExpr->get_results().size() > 0 );
|
---|
46 | Type *newType;
|
---|
47 | if ( newExpr->get_results().size() > 1 ) {
|
---|
48 | TupleType *tupleType = new TupleType( Type::Qualifiers() );
|
---|
49 | cloneAll( newExpr->get_results(), tupleType->get_types() );
|
---|
50 | newType = tupleType;
|
---|
51 | } else {
|
---|
52 | newType = newExpr->get_results().front()->clone();
|
---|
53 | }
|
---|
54 | delete typeofType;
|
---|
55 | return newType;
|
---|
56 | }
|
---|
57 | return typeofType;
|
---|
58 | }
|
---|
59 |
|
---|
60 | } // namespace ResolvExpr
|
---|
Note:
See
TracBrowser
for help on using the repository browser.