Changeset 8135d4c for src/GenPoly


Ignore:
Timestamp:
Aug 22, 2017, 7:31:52 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:
9aaac6e9
Parents:
fc56cdbf (diff), b3d413b (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/GenPoly
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    rfc56cdbf r8135d4c  
    1414//
    1515
    16 #include <algorithm>
    17 #include <iterator>
    18 #include <list>
    19 #include <map>
    20 #include <set>
    21 #include <stack>
    22 #include <string>
    23 #include <utility>
    24 #include <vector>
    25 #include <cassert>
     16#include <algorithm>                     // for mismatch
     17#include <cassert>                       // for assert, safe_dynamic_cast
     18#include <iostream>                      // for operator<<, stringstream
     19#include <list>                          // for list, list<>::iterator, _Lis...
     20#include <map>                           // for _Rb_tree_const_iterator, map
     21#include <memory>                        // for auto_ptr
     22#include <set>                           // for set
     23#include <string>                        // for string, allocator, basic_string
     24#include <utility>                       // for pair
    2625
    2726#include "Box.h"
    28 #include "DeclMutator.h"
    29 #include "Lvalue.h"
    30 #include "FindFunction.h"
    31 #include "PolyMutator.h"
    32 #include "ScopedSet.h"
    33 #include "ScrubTyVars.h"
    34 
    35 #include "Parser/ParseNode.h"
    36 
    37 #include "SynTree/Attribute.h"
    38 #include "SynTree/Constant.h"
    39 #include "SynTree/Declaration.h"
    40 #include "SynTree/Expression.h"
    41 #include "SynTree/Initializer.h"
    42 #include "SynTree/Mutator.h"
    43 #include "SynTree/Statement.h"
    44 #include "SynTree/Type.h"
    45 #include "SynTree/TypeSubstitution.h"
    46 
    47 #include "ResolvExpr/TypeEnvironment.h"
    48 #include "ResolvExpr/TypeMap.h"
    49 #include "ResolvExpr/typeops.h"
    50 
    51 #include "SymTab/Indexer.h"
    52 #include "SymTab/Mangler.h"
    53 
    54 #include "Common/ScopedMap.h"
    55 #include "Common/SemanticError.h"
    56 #include "Common/UniqueName.h"
    57 #include "Common/utility.h"
    5827
    5928#include "CodeGen/OperatorTable.h"
    60 
    61 #include "InitTweak/InitTweak.h"
    62 
    63 #include <ext/functional> // temporary
     29#include "Common/ScopedMap.h"            // for ScopedMap, ScopedMap<>::iter...
     30#include "Common/SemanticError.h"        // for SemanticError
     31#include "Common/UniqueName.h"           // for UniqueName
     32#include "Common/utility.h"              // for toString
     33#include "DeclMutator.h"                 // for DeclMutator
     34#include "FindFunction.h"                // for findFunction, findAndReplace...
     35#include "GenPoly/ErasableScopedMap.h"   // for ErasableScopedMap<>::const_i...
     36#include "GenPoly/GenPoly.h"             // for TyVarMap, isPolyType, mangle...
     37#include "InitTweak/InitTweak.h"         // for getFunctionName, isAssignment
     38#include "Lvalue.h"                      // for generalizedLvalue
     39#include "Parser/LinkageSpec.h"          // for C, Spec, Cforall, Intrinsic
     40#include "PolyMutator.h"                 // for PolyMutator
     41#include "ResolvExpr/TypeEnvironment.h"  // for EqvClass
     42#include "ResolvExpr/typeops.h"          // for typesCompatible
     43#include "ScopedSet.h"                   // for ScopedSet, ScopedSet<>::iter...
     44#include "ScrubTyVars.h"                 // for ScrubTyVars
     45#include "SymTab/Indexer.h"              // for Indexer
     46#include "SymTab/Mangler.h"              // for Mangler
     47#include "SynTree/Attribute.h"           // for Attribute
     48#include "SynTree/Constant.h"            // for Constant
     49#include "SynTree/Declaration.h"         // for DeclarationWithType, ObjectDecl
     50#include "SynTree/Expression.h"          // for ApplicationExpr, UntypedExpr
     51#include "SynTree/Initializer.h"         // for SingleInit, Initializer, Lis...
     52#include "SynTree/Label.h"               // for Label, noLabels
     53#include "SynTree/Mutator.h"             // for maybeMutate, Mutator, mutateAll
     54#include "SynTree/Statement.h"           // for ExprStmt, DeclStmt, ReturnStmt
     55#include "SynTree/SynTree.h"             // for UniqueId
     56#include "SynTree/Type.h"                // for Type, FunctionType, PointerType
     57#include "SynTree/TypeSubstitution.h"    // for TypeSubstitution, operator<<
    6458
    6559namespace GenPoly {
  • src/GenPoly/Box.h

    rfc56cdbf r8135d4c  
    1616#pragma once
    1717
    18 #include <list>
    19 #include "SynTree/SynTree.h"
     18#include <list>  // for list
     19
     20class Declaration;
    2021
    2122namespace GenPoly {
  • src/GenPoly/CopyParams.cc

    rfc56cdbf r8135d4c  
    1414//
    1515
    16 #include <set>
    17 #include <map>
    18 #include <cassert>
     16#include <cassert>                 // for assert
     17#include <list>                    // for list, _List_iterator, _List_const_...
     18#include <map>                     // for map, _Rb_tree_const_iterator, map<...
     19#include <set>                     // for set, set<>::const_iterator
     20#include <string>                  // for string, operator==
     21#include <utility>                 // for pair
    1922
    20 #include "SynTree/Declaration.h"
    21 #include "SynTree/Type.h"
    22 #include "SynTree/Expression.h"
    23 #include "SynTree/Statement.h"
    24 #include "SynTree/Visitor.h"
    25 #include "Common/UniqueName.h"
     23#include "Common/SemanticError.h"  // for SemanticError
     24#include "Common/UniqueName.h"     // for UniqueName
     25#include "SynTree/Declaration.h"   // for DeclarationWithType, TypeDecl, Fun...
     26#include "SynTree/Expression.h"    // for VariableExpr, ApplicationExpr, Add...
     27#include "SynTree/Label.h"         // for Label, noLabels
     28#include "SynTree/Statement.h"     // for CompoundStmt, DeclStmt, ExprStmt
     29#include "SynTree/SynTree.h"       // for UniqueId
     30#include "SynTree/Type.h"          // for FunctionType, TypeInstType, Type
     31#include "SynTree/Visitor.h"       // for acceptAll, Visitor
    2632
    2733namespace GenPoly {
  • src/GenPoly/DeclMutator.cc

    rfc56cdbf r8135d4c  
    1616#include "DeclMutator.h"
    1717
    18 #include "SynTree/Expression.h"
    19 #include "SynTree/Statement.h"
     18#include <memory>                  // for allocator_traits<>::value_type
     19
     20#include "Common/SemanticError.h"  // for SemanticError
     21#include "SynTree/Declaration.h"   // for Declaration
     22#include "SynTree/Expression.h"    // for Expression
     23#include "SynTree/Label.h"         // for Label, noLabels
     24#include "SynTree/Statement.h"     // for CatchStmt, Statement, CompoundStmt
    2025
    2126namespace GenPoly {
  • src/GenPoly/DeclMutator.h

    rfc56cdbf r8135d4c  
    1616#pragma once
    1717
    18 #include <list>
    19 #include <vector>
     18#include <list>               // for list
     19#include <vector>             // for vector
    2020
    21 #include "SynTree/SynTree.h"
    22 #include "SynTree/Declaration.h"
    23 #include "SynTree/Mutator.h"
     21#include "SynTree/Mutator.h"  // for Mutator
     22#include "SynTree/SynTree.h"  // for Visitor Nodes
    2423
    2524namespace GenPoly {
  • src/GenPoly/FindFunction.cc

    rfc56cdbf r8135d4c  
    1515
    1616#include "FindFunction.h"
    17 #include "SynTree/Type.h"
    18 #include "SynTree/Declaration.h"
    19 #include "SynTree/Visitor.h"
    2017
    21 #include "ScrubTyVars.h"
     18#include <utility>                      // for pair
     19
     20#include "Common/SemanticError.h"       // for SemanticError
     21#include "GenPoly/ErasableScopedMap.h"  // for ErasableScopedMap<>::iterator
     22#include "GenPoly/GenPoly.h"            // for TyVarMap
     23#include "ScrubTyVars.h"                // for ScrubTyVars
     24#include "SynTree/Declaration.h"        // for DeclarationWithType, TypeDecl
     25#include "SynTree/Mutator.h"            // for Mutator, mutateAll
     26#include "SynTree/Type.h"               // for FunctionType, Type, Type::For...
    2227
    2328namespace GenPoly {
  • src/GenPoly/FindFunction.h

    rfc56cdbf r8135d4c  
    1616#pragma once
    1717
    18 #include "SynTree/SynTree.h"
    19 #include "GenPoly.h"
     18#include <list>       // for list
     19
     20#include "GenPoly.h"  // for TyVarMap
     21
     22class FunctionType;
     23class Type;
    2024
    2125namespace GenPoly {
  • src/GenPoly/GenPoly.cc

    rfc56cdbf r8135d4c  
    1515
    1616#include "GenPoly.h"
    17 #include "assert.h"
    18 
    19 #include "SynTree/Expression.h"
    20 #include "SynTree/Type.h"
    21 #include "ResolvExpr/typeops.h"
    22 
    23 #include <iostream>
    24 #include <iterator>
    25 #include <list>
    26 #include <typeindex>
    27 #include <typeinfo>
    28 #include <vector>
     17
     18#include <cassert>                      // for assertf, assert
     19#include <iostream>                     // for operator<<, ostream, basic_os...
     20#include <iterator>                     // for back_insert_iterator, back_in...
     21#include <list>                         // for list, _List_iterator, list<>:...
     22#include <typeindex>                    // for type_index
     23#include <utility>                      // for pair
     24#include <vector>                       // for vector
     25
     26#include "GenPoly/ErasableScopedMap.h"  // for ErasableScopedMap<>::const_it...
     27#include "ResolvExpr/typeops.h"         // for flatten
     28#include "SynTree/Constant.h"           // for Constant
     29#include "SynTree/Expression.h"         // for Expression, TypeExpr, Constan...
     30#include "SynTree/Type.h"               // for Type, StructInstType, UnionIn...
     31#include "SynTree/TypeSubstitution.h"   // for TypeSubstitution
     32
    2933using namespace std;
    3034
  • src/GenPoly/GenPoly.h

    rfc56cdbf r8135d4c  
    1616#pragma once
    1717
    18 #include <string>
    19 #include <iostream>
    20 #include <utility>
     18#include <iostream>               // for ostream
     19#include <string>                 // for string, allocator, operator+, basic...
    2120
    22 #include "ErasableScopedMap.h"
    23 
    24 #include "SymTab/Mangler.h"
    25 
    26 #include "SynTree/Declaration.h"
    27 #include "SynTree/Type.h"
    28 #include "SynTree/TypeSubstitution.h"
     21#include "ErasableScopedMap.h"    // for ErasableScopedMap
     22#include "SymTab/Mangler.h"       // for Mangler
     23#include "SynTree/Declaration.h"  // for TypeDecl::Data, AggregateDecl, Type...
     24#include "SynTree/SynTree.h"      // for Visitor Nodes
    2925
    3026namespace GenPoly {
     
    6662        Type *hasPolyBase( Type *type, const TyVarMap &tyVars, int *levels = 0, const TypeSubstitution *env = 0 );
    6763
    68         /// true iff this type or some base of this type after dereferencing pointers is either polymorphic or a generic type with at least one 
     64        /// true iff this type or some base of this type after dereferencing pointers is either polymorphic or a generic type with at least one
    6965        /// polymorphic parameter; will look up substitution in env if provided.
    7066        bool includesPolyType( Type *type, const TypeSubstitution *env = 0 );
    7167
    72         /// true iff this type or some base of this type after dereferencing pointers is either polymorphic in tyVars, or a generic type with 
     68        /// true iff this type or some base of this type after dereferencing pointers is either polymorphic in tyVars, or a generic type with
    7369        /// at least one polymorphic parameter in tyVars; will look up substitution in env if provided.
    7470        bool includesPolyType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env = 0 );
  • src/GenPoly/InstantiateGeneric.cc

    rfc56cdbf r8135d4c  
    1313// Update Count     : 1
    1414//
    15 
    16 #include <cassert>
    17 #include <list>
    18 #include <unordered_map>
    19 #include <utility>
    20 #include <vector>
    21 
    2215#include "InstantiateGeneric.h"
    2316
    24 #include "GenPoly.h"
    25 #include "ScopedSet.h"
    26 #include "ScrubTyVars.h"
    27 
    28 #include "Common/PassVisitor.h"
    29 #include "Common/ScopedMap.h"
    30 #include "Common/UniqueName.h"
    31 #include "Common/utility.h"
    32 
    33 #include "ResolvExpr/typeops.h"
    34 
    35 #include "SynTree/Declaration.h"
    36 #include "SynTree/Expression.h"
    37 #include "SynTree/Type.h"
    38 
    39 
    40 #include "InitTweak/InitTweak.h"
     17#include <cassert>                     // for assertf, assert
     18#include <iterator>                    // for back_inserter, inserter
     19#include <list>                        // for list, _List_const_iterator
     20#include <utility>                     // for move, pair
     21#include <vector>                      // for vector
     22
     23#include "Common/PassVisitor.h"        // for PassVisitor, WithDeclsToAdd
     24#include "Common/ScopedMap.h"          // for ScopedMap
     25#include "Common/SemanticError.h"      // for SemanticError
     26#include "Common/UniqueName.h"         // for UniqueName
     27#include "Common/utility.h"            // for deleteAll, cloneAll
     28#include "GenPoly.h"                   // for isPolyType, typesPolyCompatible
     29#include "ScopedSet.h"                 // for ScopedSet, ScopedSet<>::iterator
     30#include "ScrubTyVars.h"               // for ScrubTyVars
     31#include "SynTree/Declaration.h"       // for StructDecl, UnionDecl, TypeDecl
     32#include "SynTree/Expression.h"        // for TypeExpr, Expression
     33#include "SynTree/Mutator.h"           // for mutateAll
     34#include "SynTree/Type.h"              // for StructInstType, UnionInstType
     35#include "SynTree/TypeSubstitution.h"  // for TypeSubstitution
     36#include "SynTree/Visitor.h"           // for acceptAll
    4137
    4238
  • src/GenPoly/InstantiateGeneric.h

    rfc56cdbf r8135d4c  
    1616#pragma once
    1717
    18 #include "SynTree/SynTree.h"
     18#include <list>  // for list
     19
     20class Declaration;
    1921
    2022namespace GenPoly {
  • src/GenPoly/Lvalue.cc

    rfc56cdbf r8135d4c  
    1414//
    1515
    16 #include <cassert>
    17 
     16#include <cassert>                       // for safe_dynamic_cast
     17#include <string>                        // for string
     18
     19#include "Common/PassVisitor.h"
     20#include "Common/SemanticError.h"        // for SemanticError
     21#include "GenPoly.h"                     // for isPolyType
    1822#include "Lvalue.h"
    1923
    20 #include "GenPoly.h"
    21 
    22 #include "SynTree/Declaration.h"
    23 #include "SynTree/Type.h"
    24 #include "SynTree/Expression.h"
    25 #include "SynTree/Statement.h"
    26 #include "SynTree/Visitor.h"
    27 #include "SynTree/Mutator.h"
    28 #include "SymTab/Indexer.h"
     24#include "Parser/LinkageSpec.h"          // for Spec, isBuiltin, Intrinsic
     25#include "ResolvExpr/TypeEnvironment.h"  // for AssertionSet, OpenVarSet
     26#include "ResolvExpr/Unify.h"            // for unify
     27#include "ResolvExpr/typeops.h"
    2928#include "SymTab/Autogen.h"
    30 
    31 #include "ResolvExpr/Resolver.h"
    32 #include "ResolvExpr/TypeEnvironment.h"
    33 #include "ResolvExpr/typeops.h"
    34 #include "ResolvExpr/Unify.h"
    35 
    36 #include "Common/UniqueName.h"
    37 #include "Common/utility.h"
    38 #include "Common/PassVisitor.h"
    39 
    40 #include "InitTweak/InitTweak.h"
     29#include "SymTab/Indexer.h"              // for Indexer
     30#include "SynTree/Declaration.h"         // for Declaration, FunctionDecl
     31#include "SynTree/Expression.h"          // for Expression, ConditionalExpr
     32#include "SynTree/Mutator.h"             // for mutateAll, Mutator
     33#include "SynTree/Statement.h"           // for ReturnStmt, Statement (ptr o...
     34#include "SynTree/Type.h"                // for PointerType, Type, FunctionType
     35#include "SynTree/Visitor.h"             // for Visitor, acceptAll
    4136
    4237#if 0
     
    223218                // at inner &, record depth D of reference type
    224219                // at outer &, add D derefs.
    225                 void AddrRef::premutate( Expression * expr ) {
     220                void AddrRef::premutate( Expression * ) {
    226221                        GuardValue( current );
    227222                        GuardValue( first );
     
    230225                }
    231226
    232                 void AddrRef::premutate( AddressExpr * addrExpr ) {
     227                void AddrRef::premutate( AddressExpr * ) {
    233228                        GuardValue( current );
    234229                        GuardValue( first );
  • src/GenPoly/Lvalue.h

    rfc56cdbf r8135d4c  
    1616#pragma once
    1717
    18 #include <list>
     18#include <list>  // for list
    1919
    20 #include "SynTree/SynTree.h"
     20class Declaration;
     21class Expression;
    2122
    2223namespace GenPoly {
  • src/GenPoly/PolyMutator.cc

    rfc56cdbf r8135d4c  
    1515
    1616#include "PolyMutator.h"
    17 #include "SynTree/Declaration.h"
    18 #include "SynTree/Type.h"
    19 #include "SynTree/Expression.h"
    20 #include "SynTree/Statement.h"
    21 #include "SynTree/Mutator.h"
    22 #include "SynTree/Initializer.h"
     17
     18#include "Common/SemanticError.h"  // for SemanticError
     19#include "Common/utility.h"        // for ValueGuard
     20#include "SynTree/Declaration.h"   // for Declaration, TypeDecl, TypeDecl::Data
     21#include "SynTree/Expression.h"    // for Expression, UntypedExpr, StmtExpr ...
     22#include "SynTree/Initializer.h"   // for SingleInit, Initializer (ptr only)
     23#include "SynTree/Label.h"         // for Label, noLabels
     24#include "SynTree/Mutator.h"       // for maybeMutate, mutateAll
     25#include "SynTree/Statement.h"     // for CatchStmt, CompoundStmt, ForStmt
     26
     27class TypeSubstitution;
    2328
    2429namespace GenPoly {
  • src/GenPoly/PolyMutator.h

    rfc56cdbf r8135d4c  
    1616#pragma once
    1717
    18 #include <map>
    19 #include <string>
    20 #include <list>
     18#include <list>               // for list
    2119
    22 #include "GenPoly.h"
    23 
    24 #include "SynTree/SynTree.h"
    25 #include "SynTree/Declaration.h"
    26 #include "SynTree/Mutator.h"
     20#include "GenPoly.h"          // for TyVarMap
     21#include "SynTree/Mutator.h"  // for Mutator
     22#include "SynTree/SynTree.h"  // for Visitor Nodes
    2723
    2824namespace GenPoly {
  • src/GenPoly/ScrubTyVars.cc

    rfc56cdbf r8135d4c  
    1414//
    1515
    16 #include <sstream>
    17 #include <string>
     16#include <utility>                      // for pair
    1817
    19 #include "GenPoly.h"
     18#include "GenPoly.h"                    // for mangleType, TyVarMap, alignof...
     19#include "GenPoly/ErasableScopedMap.h"  // for ErasableScopedMap<>::const_it...
    2020#include "ScrubTyVars.h"
    21 
    22 #include "SynTree/Mutator.h"
    23 #include "SynTree/Type.h"
    24 #include "SynTree/Expression.h"
     21#include "SynTree/Declaration.h"        // for TypeDecl, TypeDecl::Data, Typ...
     22#include "SynTree/Expression.h"         // for Expression (ptr only), NameExpr
     23#include "SynTree/Mutator.h"            // for Mutator
     24#include "SynTree/Type.h"               // for PointerType, TypeInstType, Type
    2525
    2626namespace GenPoly {
  • src/GenPoly/ScrubTyVars.h

    rfc56cdbf r8135d4c  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // ScrubTyVars.h -- 
     7// ScrubTyVars.h --
    88//
    99// Author           : Richard C. Bilson
     
    1616#pragma once
    1717
    18 #include <string>
     18#include <cassert>            // for assert
    1919
    20 #include "GenPoly.h"
     20#include "GenPoly.h"          // for TyVarMap, isPolyType, isDynType
     21#include "SynTree/Mutator.h"  // for Mutator
     22#include "SynTree/Type.h"     // for Type (ptr only), PointerType (ptr only)
    2123
    22 #include "SynTree/SynTree.h"
    23 #include "SynTree/Mutator.h"
     24class AlignofExpr;
     25class Expression;
     26class SizeofExpr;
    2427
    2528namespace GenPoly {
     
    6669                        // return dynamicOnly ? isDynType( ty, tyVars ) : isPolyType( ty, tyVars );
    6770                }
    68                
     71
    6972                /// Mutates (possibly generic) aggregate types appropriately
    7073                Type* mutateAggregateType( Type *ty );
    71                
     74
    7275                const TyVarMap *tyVars;  ///< Type variables to scrub
    7376                ScrubMode mode;          ///< which type variables to scrub? [FromMap]
  • src/GenPoly/Specialize.cc

    rfc56cdbf r8135d4c  
    1414//
    1515
    16 #include <cassert>
    17 
     16#include <cassert>                       // for assert, assertf
     17#include <iterator>                      // for back_insert_iterator, back_i...
     18#include <map>                           // for _Rb_tree_iterator, _Rb_tree_...
     19#include <memory>                        // for unique_ptr
     20#include <string>                        // for string
     21#include <tuple>                         // for get
     22#include <utility>                       // for pair
     23
     24#include "Common/SemanticError.h"        // for SemanticError
     25#include "Common/UniqueName.h"           // for UniqueName
     26#include "Common/utility.h"              // for group_iterate
     27#include "GenPoly.h"                     // for getFunctionType
     28#include "InitTweak/InitTweak.h"         // for isIntrinsicCallExpr
     29#include "Parser/LinkageSpec.h"          // for C
     30#include "PolyMutator.h"                 // for PolyMutator
     31#include "ResolvExpr/FindOpenVars.h"     // for findOpenVars
     32#include "ResolvExpr/TypeEnvironment.h"  // for OpenVarSet, AssertionSet
    1833#include "Specialize.h"
    19 #include "GenPoly.h"
    20 #include "PolyMutator.h"
    21 
    22 #include "Parser/ParseNode.h"
    23 
    24 #include "SynTree/Expression.h"
    25 #include "SynTree/Statement.h"
    26 #include "SynTree/Type.h"
    27 #include "SynTree/Attribute.h"
    28 #include "SynTree/TypeSubstitution.h"
    29 #include "SynTree/Mutator.h"
    30 #include "ResolvExpr/FindOpenVars.h"
    31 #include "Common/UniqueName.h"
    32 #include "Common/utility.h"
    33 #include "InitTweak/InitTweak.h"
    34 #include "Tuples/Tuples.h"
     34#include "SynTree/Attribute.h"           // for Attribute
     35#include "SynTree/Declaration.h"         // for FunctionDecl, DeclarationWit...
     36#include "SynTree/Expression.h"          // for ApplicationExpr, Expression
     37#include "SynTree/Label.h"               // for Label, noLabels
     38#include "SynTree/Mutator.h"             // for mutateAll
     39#include "SynTree/Statement.h"           // for CompoundStmt, DeclStmt, Expr...
     40#include "SynTree/Type.h"                // for FunctionType, TupleType, Type
     41#include "SynTree/TypeSubstitution.h"    // for TypeSubstitution
     42#include "SynTree/Visitor.h"             // for Visitor
    3543
    3644namespace GenPoly {
     
    93101        }
    94102
     103        // walk into tuple type and find the number of components
     104        size_t singleParameterSize( Type * type ) {
     105                if ( TupleType * tt = dynamic_cast< TupleType * >( type ) ) {
     106                        size_t sz = 0;
     107                        for ( Type * t : *tt ) {
     108                                sz += singleParameterSize( t );
     109                        }
     110                        return sz;
     111                } else {
     112                        return 1;
     113                }
     114        }
     115
     116        // find the total number of components in a parameter list
     117        size_t functionParameterSize( FunctionType * ftype ) {
     118                size_t sz = 0;
     119                for ( DeclarationWithType * p : ftype->get_parameters() ) {
     120                        sz += singleParameterSize( p->get_type() );
     121                }
     122                return sz;
     123        }
     124
    95125        bool needsTupleSpecialization( Type *formalType, Type *actualType ) {
    96126                // Needs tuple specialization if the structure of the formal type and actual type do not match.
     
    103133                        FunctionType * aftype = getFunctionType( actualType->stripReferences() );
    104134                        assertf( aftype, "formal type is a function type, but actual type is not: %s", toString( actualType ).c_str() );
     135                        // Can't tuple specialize if parameter sizes deeply-differ.
     136                        if ( functionParameterSize( fftype ) != functionParameterSize( aftype ) ) return false;
     137                        // tuple-parameter sizes are the same, but actual parameter sizes differ - must tuple specialize
    105138                        if ( fftype->get_parameters().size() != aftype->get_parameters().size() ) return true;
     139                        // total parameter size can be the same, while individual parameters can have different structure
    106140                        for ( auto params : group_iterate( fftype->get_parameters(), aftype->get_parameters() ) ) {
    107141                                DeclarationWithType * formal = std::get<0>(params);
  • src/GenPoly/Specialize.h

    rfc56cdbf r8135d4c  
    1616#pragma once
    1717
    18 #include <list>
     18#include <list>  // for list
    1919
    20 #include "SynTree/SynTree.h"
     20class Declaration;
    2121
    2222namespace GenPoly {
Note: See TracChangeset for help on using the changeset viewer.