Changeset 9236060 for src/Tuples


Ignore:
Timestamp:
Aug 14, 2017, 2:03:39 PM (7 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:
74b007ba
Parents:
fd344aa (diff), 54cd58b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into references

Location:
src/Tuples
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Tuples/Explode.h

    rfd344aa r9236060  
    99// Author           : Rob Schluntz
    1010// Created On       : Wed Nov 9 13:12:24 2016
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Nov 9 13:20:24 2016
    13 // Update Count     : 2
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sat Jul 22 09:55:16 2017
     13// Update Count     : 3
    1414//
    1515
    16 #ifndef _EXPLODE_H_
    17 #define _EXPLODE_H_
     16#pragma once
    1817
    1918#include "ResolvExpr/AlternativeFinder.h"
     
    8382} // namespace Tuples
    8483
    85 #endif // _TUPLE_ASSIGNMENT_H_
    86 
    8784// Local Variables: //
    8885// tab-width: 4 //
  • src/Tuples/TupleExpansion.cc

    rfd344aa r9236060  
    6666                };
    6767
    68                 class TupleTypeReplacer : public GenPoly::DeclMutator {
    69                   public:
    70                         typedef GenPoly::DeclMutator Parent;
    71                         using Parent::mutate;
    72 
    73                         virtual Type * mutate( TupleType * tupleType ) override;
    74 
    75                         virtual CompoundStmt * mutate( CompoundStmt * stmt ) override {
    76                                 typeMap.beginScope();
    77                                 stmt = Parent::mutate( stmt );
    78                                 typeMap.endScope();
    79                                 return stmt;
     68                struct TupleTypeReplacer : public WithDeclsToAdd, public WithGuards, public WithTypeSubstitution {
     69                        Type * postmutate( TupleType * tupleType );
     70
     71                        void premutate( CompoundStmt * ) {
     72                                GuardScope( typeMap );
    8073                        }
    8174                  private:
     
    111104                mutateAll( translationUnit, assnExpander );
    112105
    113                 TupleTypeReplacer replacer;
    114                 replacer.mutateDeclarationList( translationUnit );
     106                PassVisitor<TupleTypeReplacer> replacer;
     107                mutateAll( translationUnit, replacer );
    115108
    116109                PassVisitor<TupleIndexExpander> idxExpander;
     
    218211        }
    219212
    220         Type * TupleTypeReplacer::mutate( TupleType * tupleType ) {
    221                 tupleType = safe_dynamic_cast< TupleType * > ( Parent::mutate( tupleType ) );
     213        Type * TupleTypeReplacer::postmutate( TupleType * tupleType ) {
    222214                unsigned tupleSize = tupleType->size();
    223215                if ( ! typeMap.count( tupleSize ) ) {
     
    226218                        decl->set_body( true );
    227219                        for ( size_t i = 0; i < tupleSize; ++i ) {
    228                                 TypeDecl * tyParam = new TypeDecl( toString( "tuple_param_", i ), Type::StorageClasses(), nullptr, TypeDecl::Any );
     220                                TypeDecl * tyParam = new TypeDecl( toString( "tuple_param_", tupleSize, "_", i ), Type::StorageClasses(), nullptr, TypeDecl::Any );
    229221                                decl->get_members().push_back( new ObjectDecl( toString("field_", i ), Type::StorageClasses(), LinkageSpec::C, nullptr, new TypeInstType( Type::Qualifiers(), tyParam->get_name(), tyParam ), nullptr ) );
    230222                                decl->get_parameters().push_back( tyParam );
     
    235227                        }
    236228                        typeMap[tupleSize] = decl;
    237                         addDeclaration( decl );
     229                        declsToAddBefore.push_back( decl );
    238230                }
    239231                Type::Qualifiers qualifiers = tupleType->get_qualifiers();
     
    241233                StructDecl * decl = typeMap[tupleSize];
    242234                StructInstType * newType = new StructInstType( qualifiers, decl );
    243                 for ( Type * t : *tupleType ) {
     235                for ( auto p : group_iterate( tupleType->get_types(), decl->get_parameters() ) ) {
     236                        Type * t = std::get<0>(p);
     237                        TypeDecl * td = std::get<1>(p);
    244238                        newType->get_parameters().push_back( new TypeExpr( t->clone() ) );
     239                        if ( env ) {
     240                                // add bindings to the type environment.
     241                                // xxx - This may not be sufficient, it may be necessary to rename type variables on StructInstType?
     242                                env->add( td->get_name(), t->clone() );
     243                        }
    245244                }
    246245                delete tupleType;
  • src/Tuples/Tuples.h

    rfd344aa r9236060  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Nov 9 13:17:58 2016
    13 // Update Count     : 15
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sat Jul 22 09:55:00 2017
     13// Update Count     : 16
    1414//
    1515
    16 #ifndef _TUPLES_H_
    17 #define _TUPLES_H_
     16#pragma once
    1817
    1918#include <string>
     
    4948} // namespace Tuples
    5049
    51 #endif // _TUPLE_ASSIGNMENT_H_
    52 
    5350// Local Variables: //
    5451// tab-width: 4 //
Note: See TracChangeset for help on using the changeset viewer.