Changes in / [45161b4d:b11fac4]
- Location:
- src/GenPoly
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
r45161b4d rb11fac4 292 292 /// adds type parameters to the layout call; will generate the appropriate parameters if needed 293 293 void addOtypeParamsToLayoutCall( UntypedExpr *layoutCall, const std::list< Type* > &otypeParams ); 294 295 /// Enters a new scope for type-variables, adding the type variables from ty 296 void beginTypeScope( Type *ty ); 297 /// Exits the type-variable scope 298 void endTypeScope(); 294 299 295 300 ScopedSet< std::string > knownLayouts; ///< Set of generic type layouts known in the current scope, indexed by sizeofName … … 1821 1826 ////////////////////////////////////////// PolyGenericCalculator //////////////////////////////////////////////////// 1822 1827 1828 void PolyGenericCalculator::beginTypeScope( Type *ty ) { 1829 scopeTyVars.beginScope(); 1830 makeTyVarMap( ty, scopeTyVars ); 1831 } 1832 1833 void PolyGenericCalculator::endTypeScope() { 1834 scopeTyVars.endScope(); 1835 } 1836 1823 1837 template< typename DeclClass > 1824 1838 DeclClass * PolyGenericCalculator::handleDecl( DeclClass *decl, Type *type ) { 1825 scopeTyVars.beginScope(); 1826 makeTyVarMap( type, scopeTyVars ); 1839 beginTypeScope( type ); 1840 knownLayouts.beginScope(); 1841 knownOffsets.beginScope(); 1827 1842 1828 1843 DeclClass *ret = static_cast< DeclClass *>( Mutator::mutate( decl ) ); 1829 1844 1830 scopeTyVars.endScope(); 1845 knownOffsets.endScope(); 1846 knownLayouts.endScope(); 1847 endTypeScope(); 1831 1848 return ret; 1832 1849 } … … 1850 1867 1851 1868 Type * PolyGenericCalculator::mutate( PointerType *pointerType ) { 1852 scopeTyVars.beginScope(); 1853 makeTyVarMap( pointerType, scopeTyVars ); 1869 beginTypeScope( pointerType ); 1854 1870 1855 1871 Type *ret = Mutator::mutate( pointerType ); 1856 1872 1857 scopeTyVars.endScope();1873 endTypeScope(); 1858 1874 return ret; 1859 1875 } 1860 1876 1861 1877 Type * PolyGenericCalculator::mutate( FunctionType *funcType ) { 1862 scopeTyVars.beginScope(); 1863 makeTyVarMap( funcType, scopeTyVars ); 1878 beginTypeScope( funcType ); 1864 1879 1865 1880 // make sure that any type information passed into the function is accounted for … … 1874 1889 Type *ret = Mutator::mutate( funcType ); 1875 1890 1876 scopeTyVars.endScope();1891 endTypeScope(); 1877 1892 return ret; 1878 1893 } -
src/GenPoly/Lvalue.cc
r45161b4d rb11fac4 17 17 18 18 #include "Lvalue.h" 19 20 #include "GenPoly.h" 19 21 20 22 #include "SynTree/Declaration.h" … … 63 65 64 66 namespace { 65 bool isLvalueRet( FunctionType *function ) { 66 if ( ! function->get_returnVals().empty() ) { 67 return function->get_returnVals().front()->get_type()->get_isLvalue(); 68 } else { 69 return false; 70 } // if 67 Type* isLvalueRet( FunctionType *function ) { 68 if ( function->get_returnVals().empty() ) return 0; 69 Type *ty = function->get_returnVals().front()->get_type(); 70 return ty->get_isLvalue() ? ty : 0; 71 71 } 72 72 … … 107 107 assert( function ); 108 108 109 std::string typeName; 110 if ( isLvalueRet( function ) && ! isIntrinsicApp( appExpr ) ) { 109 Type *funType = isLvalueRet( function ); 110 if ( funType && ! isIntrinsicApp( appExpr ) ) { 111 Expression *expr = appExpr; 112 Type *appType = appExpr->get_results().front(); 113 if ( isPolyType( funType ) ) { 114 // make sure cast for polymorphic type is inside dereference 115 expr = new CastExpr( appExpr, new PointerType( Type::Qualifiers(), appType->clone() ) ); 116 } 111 117 UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) ); 112 deref->get_results().push_back( app Expr->get_results().front() );113 appExpr->get_results().front() = new PointerType( Type::Qualifiers(), deref->get_results().front()->clone());114 deref->get_args().push_back( appExpr );118 deref->get_results().push_back( appType->clone() ); 119 appExpr->get_results().front() = new PointerType( Type::Qualifiers(), appType ); 120 deref->get_args().push_back( expr ); 115 121 return deref; 116 122 } else {
Note: See TracChangeset
for help on using the changeset viewer.