Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    r89e6ffc r906e24d  
    1919#include "RenameVars.h"
    2020#include "ResolveTypeof.h"
     21#include "typeops.h"
    2122#include "SynTree/Statement.h"
    2223#include "SynTree/Type.h"
     
    6768          void resolveSingleAggrInit( Declaration *, InitIterator &, InitIterator & );
    6869          void fallbackInit( ConstructorInit * ctorInit );
    69                 std::list< Type * > functionReturn;
     70                Type * functionReturn;
    7071                Type *initContext;
    7172                Type *switchType;
     
    133134                        } else if ( BasicType *bt = dynamic_cast< BasicType * >( type ) ) {
    134135                                return bt->isInteger();
    135                         } else if ( dynamic_cast< ZeroType* >( type ) != nullptr || dynamic_cast< OneType* >( type ) != nullptr ) {
    136                                 return true;
    137136                        } else {
    138137                                return false;
     
    157156                        const TypeEnvironment *newEnv = 0;
    158157                        for ( AltList::const_iterator i = finder.get_alternatives().begin(); i != finder.get_alternatives().end(); ++i ) {
    159                                 if ( i->expr->get_results().size() == 1 && isIntegralType( i->expr->get_results().front() ) ) {
     158                                if ( i->expr->get_result()->size() == 1 && isIntegralType( i->expr->get_result() ) ) {
    160159                                        if ( newExpr ) {
    161160                                                throw SemanticError( "Too many interpretations for case control expression", untyped );
     
    234233                Type *new_type = resolveTypeof( functionDecl->get_type(), *this );
    235234                functionDecl->set_type( new_type );
    236                 std::list< Type * > oldFunctionReturn = functionReturn;
    237                 functionReturn.clear();
    238                 for ( std::list< DeclarationWithType * >::const_iterator i = functionDecl->get_functionType()->get_returnVals().begin(); i != functionDecl->get_functionType()->get_returnVals().end(); ++i ) {
    239                         functionReturn.push_back( (*i)->get_type() );
    240                 } // for
     235                ValueGuard< Type * > oldFunctionReturn( functionReturn );
     236                functionReturn = ResolvExpr::extractResultType( functionDecl->get_functionType() );
    241237                SymTab::Indexer::visit( functionDecl );
    242                 functionReturn = oldFunctionReturn;
    243238        }
    244239
     
    338333        void Resolver::visit( ReturnStmt *returnStmt ) {
    339334                if ( returnStmt->get_expr() ) {
    340                         CastExpr *castExpr = new CastExpr( returnStmt->get_expr() );
    341                         cloneAll( functionReturn, castExpr->get_results() );
     335                        CastExpr *castExpr = new CastExpr( returnStmt->get_expr(), functionReturn->clone() );
    342336                        Expression *newExpr = findSingleExpression( castExpr, *this );
    343337                        delete castExpr;
     
    384378                                if ( isCharType( at->get_base() ) ) {
    385379                                        // check if the resolved type is char *
    386                                         if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_results().front() ) ) {
     380                                        if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_result() ) ) {
    387381                                                if ( isCharType( pt->get_base() ) ) {
    388382                                                        // strip cast if we're initializing a char[] with a char *, e.g.  char x[] = "hello";
     
    461455                        }
    462456                } else {
    463                         assert( dynamic_cast< BasicType * >( initContext ) || dynamic_cast< PointerType * >( initContext )
    464                                 || dynamic_cast< ZeroType * >( initContext ) || dynamic_cast< OneType * >( initContext ) );
     457                        assert( dynamic_cast< BasicType * >( initContext ) || dynamic_cast< PointerType * >( initContext ) );
    465458                        // basic types are handled here
    466459                        Visitor::visit( listInit );
Note: See TracChangeset for help on using the changeset viewer.