Changeset 3cd5fdd for src/ResolvExpr
- Timestamp:
- Jun 5, 2019, 6:07:41 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- c6a1e8a, d3b2c32a, dd857bb
- Parents:
- 99d4584 (diff), 8568319 (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. - git-author:
- Aaron Moss <a3moss@…> (06/05/19 18:02:23)
- git-committer:
- Aaron Moss <a3moss@…> (06/05/19 18:07:41)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/Resolver.cc
r99d4584 r3cd5fdd 29 29 #include "typeops.h" // for extractResultType 30 30 #include "Unify.h" // for unify 31 #include "AST/Chain.hpp" 31 32 #include "AST/Decl.hpp" 32 33 #include "AST/Init.hpp" … … 410 411 411 412 void Resolver_old::previsit( ObjectDecl * objectDecl ) { 412 // To handle initialization of routine pointers, e.g., int (*fp)(int) = foo(), means that 413 // class-variable initContext is changed multiple time because the LHS is analysed twice. 414 // The second analysis changes initContext because of a function type can contain object 415 // declarations in the return and parameter types. So each value of initContext is 413 // To handle initialization of routine pointers, e.g., int (*fp)(int) = foo(), means that 414 // class-variable initContext is changed multiple time because the LHS is analysed twice. 415 // The second analysis changes initContext because of a function type can contain object 416 // declarations in the return and parameter types. So each value of initContext is 416 417 // retained, so the type on the first analysis is preserved and used for selecting the RHS. 417 418 GuardValue( currentObject ); … … 450 451 451 452 void Resolver_old::postvisit( FunctionDecl * functionDecl ) { 452 // default value expressions have an environment which shouldn't be there and trips up 453 // default value expressions have an environment which shouldn't be there and trips up 453 454 // later passes. 454 455 // xxx - it might be necessary to somehow keep the information from this environment, but I … … 1118 1119 } 1119 1120 1120 class Resolver_new final 1121 : public ast::WithSymbolTable, public ast::WithGuards, 1122 public ast::WithVisitorRef<Resolver_new>, public ast::WithShortCircuiting, 1121 class Resolver_new final 1122 : public ast::WithSymbolTable, public ast::WithGuards, 1123 public ast::WithVisitorRef<Resolver_new>, public ast::WithShortCircuiting, 1123 1124 public ast::WithStmtsToAdd<> { 1124 1125 1125 1126 ast::ptr< ast::Type > functionReturn = nullptr; 1126 1127 // ast::CurrentObject currentObject = nullptr; 1127 1128 bool inEnumDecl = false; 1128 1129 1129 public: 1130 public: 1130 1131 Resolver_new() = default; 1131 1132 Resolver_new( const ast::SymbolTable & syms ) { symtab = syms; } … … 1170 1171 1171 1172 const ast::FunctionDecl * Resolver_new::postvisit( const ast::FunctionDecl * functionDecl ) { 1172 // default value expressions have an environment which shouldn't be there and trips up 1173 // default value expressions have an environment which shouldn't be there and trips up 1173 1174 // later passes. 1174 1175 ast::ptr< ast::FunctionDecl > ret = functionDecl; 1175 1176 for ( unsigned i = 0; i < functionDecl->type->params.size(); ++i ) { 1176 1177 const ast::ptr<ast::DeclWithType> & d = functionDecl->type->params[i]; 1177 1178 1178 1179 if ( const ast::ObjectDecl * obj = d.as< ast::ObjectDecl >() ) { 1179 1180 if ( const ast::SingleInit * init = obj->init.as< ast::SingleInit >() ) { 1180 1181 if ( init->value->env == nullptr ) continue; 1181 1182 // clone initializer minus the initializer environment 1182 strict_dynamic_cast< ast::SingleInit * >( 1183 strict_dynamic_cast< ast::ObjectDecl * >( 1184 ret.get_and_mutate()->type.get_and_mutate()->params[i].get_and_mutate() 1185 )->init.get_and_mutate() 1186 )->value.get_and_mutate()->env = nullptr; 1183 ast::chain_mutate( ret ) 1184 ( &ast::FunctionDecl::type ) 1185 ( &ast::FunctionType::params )[i] 1186 ( &ast::ObjectDecl::init ) 1187 ( &ast::SingleInit::value )->env = nullptr; 1188 1189 assert( functionDecl != ret.get() || functionDecl->unique() ); 1190 assert( ! ret->type->params[i].strict_as< ast::ObjectDecl >()->init.strict_as< ast::SingleInit >()->value->env ); 1187 1191 } 1188 1192 }
Note: See TracChangeset
for help on using the changeset viewer.