Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    r62e5546 r5f5083e  
    1919#include "RenameVars.h"
    2020#include "ResolveTypeof.h"
     21#include "typeops.h"
    2122#include "SynTree/Statement.h"
    2223#include "SynTree/Type.h"
     
    6869          void resolveSingleAggrInit( Declaration *, InitIterator &, InitIterator & );
    6970          void fallbackInit( ConstructorInit * ctorInit );
    70                 std::list< Type * > functionReturn;
    71                 Type *initContext;
     71
     72                Type * functionReturn = nullptr;
     73                Type *initContext = nullptr;
    7274                bool inEnumDecl = false;
    7375        };
     
    157159                        const TypeEnvironment *newEnv = 0;
    158160                        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() ) ) {
     161                                if ( i->expr->get_result()->size() == 1 && isIntegralType( i->expr->get_result() ) ) {
    160162                                        if ( newExpr ) {
    161163                                                throw SemanticError( "Too many interpretations for case control expression", untyped );
     
    234236                Type *new_type = resolveTypeof( functionDecl->get_type(), *this );
    235237                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
     238                ValueGuard< Type * > oldFunctionReturn( functionReturn );
     239                functionReturn = ResolvExpr::extractResultType( functionDecl->get_functionType() );
    241240                SymTab::Indexer::visit( functionDecl );
    242                 functionReturn = oldFunctionReturn;
    243241        }
    244242
     
    338336        void Resolver::visit( ReturnStmt *returnStmt ) {
    339337                if ( returnStmt->get_expr() ) {
    340                         CastExpr *castExpr = new CastExpr( returnStmt->get_expr() );
    341                         cloneAll( functionReturn, castExpr->get_results() );
     338                        CastExpr *castExpr = new CastExpr( returnStmt->get_expr(), functionReturn->clone() );
    342339                        Expression *newExpr = findSingleExpression( castExpr, *this );
    343340                        delete castExpr;
     
    384381                                if ( isCharType( at->get_base() ) ) {
    385382                                        // check if the resolved type is char *
    386                                         if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_results().front() ) ) {
     383                                        if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_result() ) ) {
    387384                                                if ( isCharType( pt->get_base() ) ) {
    388385                                                        // strip cast if we're initializing a char[] with a char *, e.g.  char x[] = "hello";
     
    446443                                (*iter)->accept( *this );
    447444                        } // for
     445                } else if ( TupleType * tt = dynamic_cast< TupleType * > ( initContext ) ) {
     446                        for ( Type * t : *tt ) {
     447                                if ( iter == end ) break;
     448                                initContext = t;
     449                                (*iter++)->accept( *this );
     450                        }
    448451                } else if ( StructInstType * st = dynamic_cast< StructInstType * >( initContext ) ) {
    449452                        resolveAggrInit( st->get_baseStruct(), iter, end );
Note: See TracChangeset for help on using the changeset viewer.