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