Changeset 13d326ec
- Timestamp:
- Jul 26, 2022, 4:45:07 PM (14 months ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation
- Children:
- 2af1943
- Parents:
- 1b97cc87
- Location:
- src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/SpecializeNew.cpp
r1b97cc87 r13d326ec 230 230 if ( auto tuple = type.as<ast::TupleType>() ) { 231 231 std::vector<ast::ptr<ast::Expr>> exprs; 232 for ( const ast:: Type *t : *tuple ) {232 for ( const ast::ptr<ast::Type> & t : *tuple ) { 233 233 exprs.push_back( structureArg( location, t, begin, end ) ); 234 234 } … … 248 248 if (typeMap.count(typeInst->base)) { 249 249 ast::TypeInstType * newInst = mutate(typeInst); 250 newInst->expr_id = typeMap[typeInst->base].first; 251 newInst->formal_usage = typeMap[typeInst->base].second; 250 auto const & pair = typeMap[typeInst->base]; 251 newInst->expr_id = pair.first; 252 newInst->formal_usage = pair.second; 252 253 return newInst; 253 254 } … … 462 463 if ( specialized != expr->arg ) { 463 464 // Assume that the specialization incorporates the cast. 464 // std::cerr << expr <<std::endl;465 465 return specialized; 466 466 } else { -
src/InitTweak/InitTweak.cc
r1b97cc87 r13d326ec 27 27 #include "AST/Stmt.hpp" 28 28 #include "AST/Type.hpp" 29 #include "CodeGen/OperatorTable.h" // for isConstructor, isDestructor, isCto... 29 30 #include "Common/PassVisitor.h" 30 31 #include "Common/SemanticError.h" // for SemanticError … … 770 771 std::list< Expression * > callExprs; 771 772 collectCtorDtorCalls( stmt, callExprs ); 772 // if ( callExprs.empty() ) return false; // xxx - do I still need this check?773 773 return std::all_of( callExprs.begin(), callExprs.end(), pred); 774 774 } … … 901 901 } else if ( VariableExpr * varExpr = dynamic_cast< VariableExpr * >( func ) ) { 902 902 return varExpr->get_var()->get_name(); 903 } 903 } else if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( func ) ) { 904 904 return funcName( castExpr->get_arg() ); 905 905 } else if ( MemberExpr * memberExpr = dynamic_cast< MemberExpr * >( func ) ) { … … 923 923 } else if ( const ast::VariableExpr * varExpr = dynamic_cast< const ast::VariableExpr * >( func ) ) { 924 924 return varExpr->var->name; 925 } 925 } else if ( const ast::CastExpr * castExpr = dynamic_cast< const ast::CastExpr * >( func ) ) { 926 926 return funcName( castExpr->arg ); 927 927 } else if ( const ast::MemberExpr * memberExpr = dynamic_cast< const ast::MemberExpr * >( func ) ) { … … 991 991 992 992 Type * isPointerType( Type * type ) { 993 if ( getPointerBase( type ) ) return type; 994 else return nullptr; 993 return getPointerBase( type ) ? type : nullptr; 995 994 } 996 995 … … 1014 1013 src = new AddressExpr( src ); 1015 1014 } 1016 // src = new CastExpr( src, new ReferenceType( noQualifiers, src->result->stripReferences()->clone() ) );1017 1015 } 1018 1016 return new ApplicationExpr( VariableExpr::functionPointer( assign ), { dst, src } ); … … 1167 1165 } 1168 1166 1169 bool isConstructor( const std::string & str ) { return str == "?{}"; }1170 bool isDestructor( const std::string & str ) { return str == "^?{}"; }1171 bool isAssignment( const std::string & str ) { return str == "?=?"; }1172 bool isCtorDtor( const std::string & str ) { return isConstructor( str ) || isDestructor( str ); }1173 bool isCtorDtorAssign( const std::string & str ) { return isCtorDtor( str ) || isAssignment( str ); }1174 1175 1167 const FunctionDecl * isCopyFunction( const Declaration * decl, const std::string & fname ) { 1176 1168 const FunctionDecl * function = dynamic_cast< const FunctionDecl * >( decl ); … … 1192 1184 1193 1185 bool isAssignment( const ast::FunctionDecl * decl ) { 1194 return isAssignment( decl->name ) && isCopyFunction( decl );1186 return CodeGen::isAssignment( decl->name ) && isCopyFunction( decl ); 1195 1187 } 1196 1188 1197 1189 bool isDestructor( const ast::FunctionDecl * decl ) { 1198 return isDestructor( decl->name );1190 return CodeGen::isDestructor( decl->name ); 1199 1191 } 1200 1192 1201 1193 bool isDefaultConstructor( const ast::FunctionDecl * decl ) { 1202 return isConstructor( decl->name ) && 1 == decl->params.size();1194 return CodeGen::isConstructor( decl->name ) && 1 == decl->params.size(); 1203 1195 } 1204 1196 1205 1197 bool isCopyConstructor( const ast::FunctionDecl * decl ) { 1206 return isConstructor( decl->name ) && 2 == decl->params.size();1198 return CodeGen::isConstructor( decl->name ) && 2 == decl->params.size(); 1207 1199 } 1208 1200 … … 1222 1214 } 1223 1215 const FunctionDecl * isDestructor( const Declaration * decl ) { 1224 if ( isDestructor( decl->name ) ) {1216 if ( CodeGen::isDestructor( decl->name ) ) { 1225 1217 return dynamic_cast< const FunctionDecl * >( decl ); 1226 1218 } … … 1228 1220 } 1229 1221 const FunctionDecl * isDefaultConstructor( const Declaration * decl ) { 1230 if ( isConstructor( decl->name ) ) {1222 if ( CodeGen::isConstructor( decl->name ) ) { 1231 1223 if ( const FunctionDecl * func = dynamic_cast< const FunctionDecl * >( decl ) ) { 1232 1224 if ( func->type->parameters.size() == 1 ) {
Note: See TracChangeset
for help on using the changeset viewer.