Changeset ad861ef for src/GenPoly
- Timestamp:
- Jan 20, 2023, 1:25:37 PM (3 years ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 79a6b17, cd5eb4b
- Parents:
- 466787a (diff), a0d1f1c (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. - Location:
- src/GenPoly
- Files:
-
- 4 edited
-
Box.cc (modified) (4 diffs)
-
GenPoly.cc (modified) (2 diffs)
-
InstantiateGeneric.cc (modified) (1 diff)
-
InstantiateGenericNew.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
r466787a rad861ef 14 14 // 15 15 16 #include "Box.h" 17 16 18 #include <algorithm> // for mismatch 17 19 #include <cassert> // for assert, strict_dynamic_cast … … 23 25 #include <string> // for string, allocator, basic_string 24 26 #include <utility> // for pair 25 26 #include "Box.h"27 27 28 28 #include "CodeGen/OperatorTable.h" … … 37 37 #include "InitTweak/InitTweak.h" // for getFunctionName, isAssignment 38 38 #include "Lvalue.h" // for generalizedLvalue 39 #include "ResolvExpr/ typeops.h"// for typesCompatible39 #include "ResolvExpr/Unify.h" // for typesCompatible 40 40 #include "ScopedSet.h" // for ScopedSet, ScopedSet<>::iter... 41 41 #include "ScrubTyVars.h" // for ScrubTyVars … … 911 911 912 912 for ( FunctionType const * const funType : functions ) { 913 FunctionType *originalFunction = funType->clone(); 914 FunctionType *realFunction = funType->clone(); 915 std::string mangleName = SymTab::Mangler::mangle( realFunction ); 913 std::string mangleName = SymTab::Mangler::mangle( funType ); 916 914 917 915 // only attempt to create an adapter or pass one as a parameter if we haven't already done so for this 918 916 // pre-substitution parameter function type. 919 917 // The second part of the insert result is "is the value new". 920 if ( adaptersDone.insert( mangleName ).second ) { 921 922 // apply substitution to type variables to figure out what the adapter's type should look like 923 assert( env ); 924 env->apply( realFunction ); 925 mangleName = SymTab::Mangler::mangle( realFunction ); 926 mangleName += makePolyMonoSuffix( originalFunction, exprTyVars ); 927 928 typedef ScopedMap< std::string, DeclarationWithType* >::iterator AdapterIter; 929 AdapterIter adapter = adapters.find( mangleName ); 930 if ( adapter == adapters.end() ) { 931 // adapter has not been created yet in the current scope, so define it 932 FunctionDecl *newAdapter = makeAdapter( funType, realFunction, mangleName, exprTyVars ); 933 std::pair< AdapterIter, bool > answer = adapters.insert( std::pair< std::string, DeclarationWithType *>( mangleName, newAdapter ) ); 934 adapter = answer.first; 935 stmtsToAddBefore.push_back( new DeclStmt( newAdapter ) ); 936 } // if 937 assert( adapter != adapters.end() ); 938 939 // add the appropriate adapter as a parameter 940 appExpr->get_args().push_front( new VariableExpr( adapter->second ) ); 918 if ( !adaptersDone.insert( mangleName ).second ) continue; 919 920 // Apply substitution to type variables to figure out what the adapter's type should look like. 921 assert( env ); 922 FunctionType *realType = funType->clone(); 923 env->apply( realType ); 924 mangleName = SymTab::Mangler::mangle( realType ); 925 mangleName += makePolyMonoSuffix( funType, exprTyVars ); 926 927 typedef ScopedMap< std::string, DeclarationWithType* >::iterator AdapterIter; 928 AdapterIter adapter = adapters.find( mangleName ); 929 if ( adapter == adapters.end() ) { 930 // Adapter has not been created yet in the current scope, so define it. 931 FunctionDecl *newAdapter = makeAdapter( funType, realType, mangleName, exprTyVars ); 932 std::pair< AdapterIter, bool > answer = adapters.insert( mangleName, newAdapter ); 933 adapter = answer.first; 934 stmtsToAddBefore.push_back( new DeclStmt( newAdapter ) ); 941 935 } // if 936 assert( adapter != adapters.end() ); 937 938 // Add the appropriate adapter as a parameter. 939 appExpr->args.push_front( new VariableExpr( adapter->second ) ); 942 940 } // for 943 941 } // passAdapters -
src/GenPoly/GenPoly.cc
r466787a rad861ef 24 24 #include <vector> // for vector 25 25 26 #include "AST/Expr.hpp" 26 27 #include "AST/Type.hpp" 28 #include "AST/TypeSubstitution.hpp" 27 29 #include "GenPoly/ErasableScopedMap.h" // for ErasableScopedMap<>::const_it... 28 30 #include "ResolvExpr/typeops.h" // for flatten … … 490 492 } 491 493 494 /// Flattens a list of types. 495 // There is another flattenList in Unify. 492 496 void flattenList( vector<ast::ptr<ast::Type>> const & src, 493 497 vector<ast::ptr<ast::Type>> & out ) { -
src/GenPoly/InstantiateGeneric.cc
r466787a rad861ef 28 28 #include "GenPoly.h" // for isPolyType, typesPolyCompatible 29 29 #include "InitTweak/InitTweak.h" 30 #include "ResolvExpr/typeops.h" 30 #include "ResolvExpr/AdjustExprType.hpp" // for adjustExprType 31 #include "ResolvExpr/Unify.h" // for typesCompatible 31 32 #include "ScopedSet.h" // for ScopedSet, ScopedSet<>::iterator 32 33 #include "ScrubTyVars.h" // for ScrubTyVars -
src/GenPoly/InstantiateGenericNew.cpp
r466787a rad861ef 32 32 #include "GenPoly/GenPoly.h" // for isPolyType, typesPolyCompatible 33 33 #include "GenPoly/ScrubTyVars.h" // for scrubAll 34 #include "ResolvExpr/typeops.h" // for typesCompatible 34 #include "ResolvExpr/AdjustExprType.hpp" // for adjustExprType 35 #include "ResolvExpr/Unify.h" // for typesCompatible 35 36 36 37 namespace GenPoly {
Note:
See TracChangeset
for help on using the changeset viewer.