Ignore:
Timestamp:
Sep 15, 2016, 10:17:16 AM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
aa8f9df
Parents:
96a10cd
git-author:
Rob Schluntz <rschlunt@…> (09/14/16 22:32:34)
git-committer:
Rob Schluntz <rschlunt@…> (09/15/16 10:17:16)
Message:

replace results list on Expressions with a single Type field

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    r96a10cd 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;
     
    155156                        const TypeEnvironment *newEnv = 0;
    156157                        for ( AltList::const_iterator i = finder.get_alternatives().begin(); i != finder.get_alternatives().end(); ++i ) {
    157                                 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() ) ) {
    158159                                        if ( newExpr ) {
    159160                                                throw SemanticError( "Too many interpretations for case control expression", untyped );
     
    232233                Type *new_type = resolveTypeof( functionDecl->get_type(), *this );
    233234                functionDecl->set_type( new_type );
    234                 std::list< Type * > oldFunctionReturn = functionReturn;
    235                 functionReturn.clear();
    236                 for ( std::list< DeclarationWithType * >::const_iterator i = functionDecl->get_functionType()->get_returnVals().begin(); i != functionDecl->get_functionType()->get_returnVals().end(); ++i ) {
    237                         functionReturn.push_back( (*i)->get_type() );
    238                 } // for
     235                ValueGuard< Type * > oldFunctionReturn( functionReturn );
     236                functionReturn = ResolvExpr::extractResultType( functionDecl->get_functionType() );
    239237                SymTab::Indexer::visit( functionDecl );
    240                 functionReturn = oldFunctionReturn;
    241238        }
    242239
     
    336333        void Resolver::visit( ReturnStmt *returnStmt ) {
    337334                if ( returnStmt->get_expr() ) {
    338                         CastExpr *castExpr = new CastExpr( returnStmt->get_expr() );
    339                         cloneAll( functionReturn, castExpr->get_results() );
     335                        CastExpr *castExpr = new CastExpr( returnStmt->get_expr(), functionReturn->clone() );
    340336                        Expression *newExpr = findSingleExpression( castExpr, *this );
    341337                        delete castExpr;
     
    382378                                if ( isCharType( at->get_base() ) ) {
    383379                                        // check if the resolved type is char *
    384                                         if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_results().front() ) ) {
     380                                        if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_result() ) ) {
    385381                                                if ( isCharType( pt->get_base() ) ) {
    386382                                                        // strip cast if we're initializing a char[] with a char *, e.g.  char x[] = "hello";
Note: See TracChangeset for help on using the changeset viewer.