Changeset 3cd5fdd for src/ResolvExpr


Ignore:
Timestamp:
Jun 5, 2019, 6:07:41 PM (5 years ago)
Author:
Aaron Moss <a3moss@…>
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)
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    r99d4584 r3cd5fdd  
    2929#include "typeops.h"                     // for extractResultType
    3030#include "Unify.h"                       // for unify
     31#include "AST/Chain.hpp"
    3132#include "AST/Decl.hpp"
    3233#include "AST/Init.hpp"
     
    410411
    411412        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
    416417                // retained, so the type on the first analysis is preserved and used for selecting the RHS.
    417418                GuardValue( currentObject );
     
    450451
    451452        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
    453454                // later passes.
    454455                // xxx - it might be necessary to somehow keep the information from this environment, but I
     
    11181119        }
    11191120
    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,
    11231124          public ast::WithStmtsToAdd<> {
    1124        
     1125
    11251126                ast::ptr< ast::Type > functionReturn = nullptr;
    11261127                // ast::CurrentObject currentObject = nullptr;
    11271128                bool inEnumDecl = false;
    11281129
    1129         public: 
     1130        public:
    11301131                Resolver_new() = default;
    11311132                Resolver_new( const ast::SymbolTable & syms ) { symtab = syms; }
     
    11701171
    11711172        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
    11731174                // later passes.
    11741175                ast::ptr< ast::FunctionDecl > ret = functionDecl;
    11751176                for ( unsigned i = 0; i < functionDecl->type->params.size(); ++i ) {
    11761177                        const ast::ptr<ast::DeclWithType> & d = functionDecl->type->params[i];
    1177                        
     1178
    11781179                        if ( const ast::ObjectDecl * obj = d.as< ast::ObjectDecl >() ) {
    11791180                                if ( const ast::SingleInit * init = obj->init.as< ast::SingleInit >() ) {
    11801181                                        if ( init->value->env == nullptr ) continue;
    11811182                                        // 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 );
    11871191                                }
    11881192                        }
Note: See TracChangeset for help on using the changeset viewer.