Changes in src/ResolvExpr/Resolver.cc [4864a73:2a8f0c1]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/Resolver.cc
r4864a73 r2a8f0c1 27 27 #include "typeops.h" // for extractResultType 28 28 #include "Unify.h" // for unify 29 #include "AST/Chain.hpp"30 29 #include "AST/Decl.hpp" 31 30 #include "AST/Init.hpp" … … 408 407 409 408 void Resolver_old::previsit( ObjectDecl * objectDecl ) { 410 // To handle initialization of routine pointers, e.g., int (*fp)(int) = foo(), means that 411 // class-variable initContext is changed multiple time because the LHS is analysed twice. 412 // The second analysis changes initContext because of a function type can contain object 413 // declarations in the return and parameter types. So each value of initContext is 409 // To handle initialization of routine pointers, e.g., int (*fp)(int) = foo(), means that 410 // class-variable initContext is changed multiple time because the LHS is analysed twice. 411 // The second analysis changes initContext because of a function type can contain object 412 // declarations in the return and parameter types. So each value of initContext is 414 413 // retained, so the type on the first analysis is preserved and used for selecting the RHS. 415 414 GuardValue( currentObject ); … … 448 447 449 448 void Resolver_old::postvisit( FunctionDecl * functionDecl ) { 450 // default value expressions have an environment which shouldn't be there and trips up 449 // default value expressions have an environment which shouldn't be there and trips up 451 450 // later passes. 452 451 // xxx - it might be necessary to somehow keep the information from this environment, but I … … 940 939 /////////////////////////////////////////////////////////////////////////// 941 940 942 class Resolver_new final 943 : public ast::WithSymbolTable, public ast::WithGuards, 944 public ast::WithVisitorRef<Resolver_new>, public ast::WithShortCircuiting, 941 class Resolver_new final 942 : public ast::WithSymbolTable, public ast::WithGuards, 943 public ast::WithVisitorRef<Resolver_new>, public ast::WithShortCircuiting, 945 944 public ast::WithStmtsToAdd<> { 946 945 947 946 ast::ptr< ast::Type > functionReturn = nullptr; 948 947 // ast::CurrentObject currentObject = nullptr; 949 948 // bool inEnumDecl = false; 950 949 951 public: 950 public: 952 951 Resolver_new() = default; 953 952 Resolver_new( const ast::SymbolTable & syms ) { symtab = syms; } … … 992 991 993 992 const ast::FunctionDecl * Resolver_new::postvisit( const ast::FunctionDecl * functionDecl ) { 994 // default value expressions have an environment which shouldn't be there and trips up 993 // default value expressions have an environment which shouldn't be there and trips up 995 994 // later passes. 996 995 ast::ptr< ast::FunctionDecl > ret = functionDecl; 997 996 for ( unsigned i = 0; i < functionDecl->type->params.size(); ++i ) { 998 997 const ast::ptr<ast::DeclWithType> & d = functionDecl->type->params[i]; 999 998 1000 999 if ( const ast::ObjectDecl * obj = d.as< ast::ObjectDecl >() ) { 1001 1000 if ( const ast::SingleInit * init = obj->init.as< ast::SingleInit >() ) { 1002 1001 if ( init->value->env == nullptr ) continue; 1003 1002 // clone initializer minus the initializer environment 1004 ast::chain_mutate( ret ) 1005 ( &ast::FunctionDecl::type ) 1006 ( &ast::FunctionType::params ) 1007 [i] 1008 ( &ast::ObjectDecl::init ) 1009 ( &ast::SingleInit::value )->env = nullptr; 1010 1011 assert( functionDecl != ret.get() || functionDecl->unique() ); 1012 assert( ! ret->type->params[i].strict_as< ast::ObjectDecl >()->init.strict_as< ast::SingleInit >()->value->env ); 1003 strict_dynamic_cast< ast::SingleInit * >( 1004 strict_dynamic_cast< ast::ObjectDecl * >( 1005 ret.get_and_mutate()->type.get_and_mutate()->params[i].get_and_mutate() 1006 )->init.get_and_mutate() 1007 )->value.get_and_mutate()->env = nullptr; 1013 1008 } 1014 1009 }
Note: See TracChangeset
for help on using the changeset viewer.