Ignore:
Timestamp:
Dec 16, 2014, 9:41:50 PM (10 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
17cd4eb
Parents:
3848e0e
Message:

remove Parser.old, add -XCFA to driver, copy ptrdiff_t from stddef.h in preclude, remove casts from initialization constants, adjust formatting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • translator/ResolvExpr/ResolveTypeof.cc

    r3848e0e rd9a0e76  
    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 
    81#include "ResolveTypeof.h"
    92#include "Alternative.h"
     
    158
    169namespace 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    }
    1722
    18 namespace {
     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 ) {
    1938#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;
     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;
    2658    }
    27   }
    28 #endif
    29 }
    30 
    31 class ResolveTypeof : public Mutator
    32 {
    33 public:
    34   ResolveTypeof( const SymTab::Indexer &indexer ) : indexer( indexer ) {}
    35   Type *mutate( TypeofType *typeofType );
    36 
    37 private:
    38   const SymTab::Indexer &indexer;
    39 };
    40 
    41 Type *
    42 resolveTypeof( Type *type, const SymTab::Indexer &indexer )
    43 {
    44   ResolveTypeof mutator( indexer );
    45   return type->acceptMutator( mutator );
    46 }
    47 
    48 Type *
    49 ResolveTypeof::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 }
    7059
    7160} // namespace ResolvExpr
Note: See TracChangeset for help on using the changeset viewer.