Ignore:
Timestamp:
Sep 20, 2016, 7:14:15 PM (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:
65660bd
Parents:
23b6643f
Message:

copy construct tuple function arguments, and destruct tuple function results

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Tuples/TupleExpansion.cc

    r23b6643f r1132b62  
    2727#include "SymTab/Mangler.h"
    2828#include "Common/ScopedMap.h"
     29#include "ResolvExpr/typeops.h"
    2930
    3031namespace Tuples {
     
    4849
    4950                        virtual Type * mutate( TupleType * tupleType );
     51                        virtual Type * mutate( FunctionType * ftype );
    5052
    5153                        virtual CompoundStmt * mutate( CompoundStmt * stmt ) {
     
    119121        }
    120122
     123        Type * TupleTypeReplacer::mutate( FunctionType * ftype ) {
     124                // replace multiple-returning functions with functions which return a tuple
     125                if ( ftype->get_returnVals().size() > 1 ) {
     126                        TupleType * tupleType = safe_dynamic_cast<TupleType *>( ResolvExpr::extractResultType( ftype ) );
     127                        ObjectDecl * retVal = new ObjectDecl( "__tuple_ret", DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, tupleType, nullptr );
     128                        // xxx - replace all uses of return vals with appropriate tuple index expr
     129                        deleteAll( ftype->get_returnVals() );
     130                        ftype->get_returnVals().clear();
     131                        ftype->get_returnVals().push_back( retVal );
     132                }
     133                return Parent::mutate( ftype );
     134        }
     135
    121136        Type * TupleTypeReplacer::mutate( TupleType * tupleType ) {
    122137                std::string mangleName = SymTab::Mangler::mangleType( tupleType );
Note: See TracChangeset for help on using the changeset viewer.