Changeset 4864a73 for src/ResolvExpr
- Timestamp:
- Jun 5, 2019, 4:28:28 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:
- 0ce063b
- Parents:
- 2a8f0c1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/Resolver.cc
r2a8f0c1 r4864a73 27 27 #include "typeops.h" // for extractResultType 28 28 #include "Unify.h" // for unify 29 #include "AST/Chain.hpp" 29 30 #include "AST/Decl.hpp" 30 31 #include "AST/Init.hpp" … … 407 408 408 409 void Resolver_old::previsit( ObjectDecl * objectDecl ) { 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 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 413 414 // retained, so the type on the first analysis is preserved and used for selecting the RHS. 414 415 GuardValue( currentObject ); … … 447 448 448 449 void Resolver_old::postvisit( FunctionDecl * functionDecl ) { 449 // default value expressions have an environment which shouldn't be there and trips up 450 // default value expressions have an environment which shouldn't be there and trips up 450 451 // later passes. 451 452 // xxx - it might be necessary to somehow keep the information from this environment, but I … … 939 940 /////////////////////////////////////////////////////////////////////////// 940 941 941 class Resolver_new final 942 : public ast::WithSymbolTable, public ast::WithGuards, 943 public ast::WithVisitorRef<Resolver_new>, public ast::WithShortCircuiting, 942 class Resolver_new final 943 : public ast::WithSymbolTable, public ast::WithGuards, 944 public ast::WithVisitorRef<Resolver_new>, public ast::WithShortCircuiting, 944 945 public ast::WithStmtsToAdd<> { 945 946 946 947 ast::ptr< ast::Type > functionReturn = nullptr; 947 948 // ast::CurrentObject currentObject = nullptr; 948 949 // bool inEnumDecl = false; 949 950 950 public: 951 public: 951 952 Resolver_new() = default; 952 953 Resolver_new( const ast::SymbolTable & syms ) { symtab = syms; } … … 991 992 992 993 const ast::FunctionDecl * Resolver_new::postvisit( const ast::FunctionDecl * functionDecl ) { 993 // default value expressions have an environment which shouldn't be there and trips up 994 // default value expressions have an environment which shouldn't be there and trips up 994 995 // later passes. 995 996 ast::ptr< ast::FunctionDecl > ret = functionDecl; 996 997 for ( unsigned i = 0; i < functionDecl->type->params.size(); ++i ) { 997 998 const ast::ptr<ast::DeclWithType> & d = functionDecl->type->params[i]; 998 999 999 1000 if ( const ast::ObjectDecl * obj = d.as< ast::ObjectDecl >() ) { 1000 1001 if ( const ast::SingleInit * init = obj->init.as< ast::SingleInit >() ) { 1001 1002 if ( init->value->env == nullptr ) continue; 1002 1003 // clone initializer minus the initializer environment 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; 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 ); 1008 1013 } 1009 1014 }
Note: See TracChangeset
for help on using the changeset viewer.