Changeset d06010a


Ignore:
Timestamp:
Jun 29, 2016, 1:57:32 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
2fb2ad5
Parents:
85f0713 (diff), 66999e7 (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.
Message:

Merge branch 'master' into ctor

Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    r85f0713 rd06010a  
    1919#include <functional>
    2020#include <cassert>
     21#include <unordered_map>
     22#include <utility>
     23#include <vector>
    2124
    2225#include "AlternativeFinder.h"
     
    408411        }
    409412
    410         static const int recursionLimit = 10;
     413        /// Map of declaration uniqueIds (intended to be the assertions in an AssertionSet) to their parents and the number of times they've been included
     414        typedef std::unordered_map< UniqueId, std::unordered_map< UniqueId, unsigned > > AssertionParentSet;
     415       
     416        static const int recursionLimit = 10;  ///< Limit to depth of recursion satisfaction
     417        static const unsigned recursionParentLimit = 1;  ///< Limit to the number of times an assertion can recursively use itself
    411418
    412419        void addToIndexer( AssertionSet &assertSet, SymTab::Indexer &indexer ) {
     
    417424                }
    418425        }
    419 
     426       
    420427        template< typename ForwardIterator, typename OutputIterator >
    421         void inferRecursive( ForwardIterator begin, ForwardIterator end, const Alternative &newAlt, OpenVarSet &openVars, const SymTab::Indexer &decls, const AssertionSet &newNeed, int level, const SymTab::Indexer &indexer, OutputIterator out ) {
     428        void inferRecursive( ForwardIterator begin, ForwardIterator end, const Alternative &newAlt, OpenVarSet &openVars, const SymTab::Indexer &decls, const AssertionSet &newNeed, const AssertionParentSet &needParents,
     429                                                 int level, const SymTab::Indexer &indexer, OutputIterator out ) {
    422430                if ( begin == end ) {
    423431                        if ( newNeed.empty() ) {
     
    432440                                        printAssertionSet( newNeed, std::cerr, 8 );
    433441                                )
    434                                 inferRecursive( newNeed.begin(), newNeed.end(), newAlt, openVars, decls, newerNeed, level+1, indexer, out );
     442                                inferRecursive( newNeed.begin(), newNeed.end(), newAlt, openVars, decls, newerNeed, needParents, level+1, indexer, out );
    435443                                return;
    436444                        }
     
    439447                ForwardIterator cur = begin++;
    440448                if ( ! cur->second ) {
    441                         inferRecursive( begin, end, newAlt, openVars, decls, newNeed, level, indexer, out );
     449                        inferRecursive( begin, end, newAlt, openVars, decls, newNeed, needParents, level, indexer, out );
    442450                }
    443451                DeclarationWithType *curDecl = cur->first;
     
    456464                                std::cerr << std::endl;
    457465                        )
     466                       
    458467                        AssertionSet newHave, newerNeed( newNeed );
    459468                        TypeEnvironment newEnv( newAlt.env );
     
    478487                                newerAlt.env = newEnv;
    479488                                assert( (*candidate)->get_uniqueId() );
    480                                 Expression *varExpr = new VariableExpr( static_cast< DeclarationWithType* >( Declaration::declFromId( (*candidate)->get_uniqueId() ) ) );
     489                                DeclarationWithType *candDecl = static_cast< DeclarationWithType* >( Declaration::declFromId( (*candidate)->get_uniqueId() ) );
     490                                AssertionParentSet newNeedParents( needParents );
     491                                // skip repeatingly-self-recursive assertion satisfaction
     492                                if ( newNeedParents[ curDecl->get_uniqueId() ][ candDecl->get_uniqueId() ]++ > recursionParentLimit ) continue;
     493                                Expression *varExpr = new VariableExpr( candDecl );
    481494                                deleteAll( varExpr->get_results() );
    482495                                varExpr->get_results().clear();
     
    492505                                // XXX: this is a memory leak, but adjType can't be deleted because it might contain assertions
    493506                                appExpr->get_inferParams()[ curDecl->get_uniqueId() ] = ParamEntry( (*candidate)->get_uniqueId(), adjType->clone(), curDecl->get_type()->clone(), varExpr );
    494                                 inferRecursive( begin, end, newerAlt, newOpenVars, newDecls, newerNeed, level, indexer, out );
     507                                inferRecursive( begin, end, newerAlt, newOpenVars, newDecls, newerNeed, newNeedParents, level, indexer, out );
    495508                        } else {
    496509                                delete adjType;
     
    514527                addToIndexer( have, decls );
    515528                AssertionSet newNeed;
    516                 inferRecursive( need.begin(), need.end(), newAlt, openVars, decls, newNeed, 0, indexer, out );
     529                AssertionParentSet needParents;
     530                inferRecursive( need.begin(), need.end(), newAlt, openVars, decls, newNeed, needParents, 0, indexer, out );
    517531//      PRINT(
    518532//          std::cerr << "declaration 14 is ";
  • src/ResolvExpr/RenameVars.cc

    r85f0713 rd06010a  
    4545        void RenameVars::visit( PointerType *pointerType ) {
    4646                typeBefore( pointerType );
    47 ///   std::cout << "do pointer" << std::endl;
    4847                maybeAccept( pointerType->get_base(), *this );
    49 ///   std::cout << "done pointer" << std::endl;
    5048                typeAfter( pointerType );
    5149        }
     
    6058        void RenameVars::visit( FunctionType *functionType ) {
    6159                typeBefore( functionType );
    62 ///   std::cout << "return vals" << std::endl;
    6360                acceptAll( functionType->get_returnVals(), *this );
    64 ///   std::cout << functionType->get_parameters().size() << " parameters" << std::endl;
    6561                acceptAll( functionType->get_parameters(), *this );
    66 ///   std::cout << "done function" << std::endl;
    6762                typeAfter( functionType );
    6863        }
     
    9590        void RenameVars::visit( TypeInstType *instType ) {
    9691                typeBefore( instType );
    97 ///   std::cout << "instance of type " << instType->get_name() << std::endl;
    9892                std::map< std::string, std::string >::const_iterator i = mapStack.front().find( instType->get_name() );
    9993                if ( i != mapStack.front().end() ) {
    100 ///     std::cout << "found name " << i->second << std::endl;
    10194                        instType->set_name( i->second );
    10295                } else {
    103 ///     std::cout << "no name found" << std::endl;
    10496                } // if
    10597                acceptAll( instType->get_parameters(), *this );
     
    120112        void RenameVars::typeBefore( Type *type ) {
    121113                if ( ! type->get_forall().empty() ) {
    122 ///     std::cout << "type with forall: ";
    123 ///     type->print( std::cout );
    124 ///     std::cout << std::endl;
    125114                        // copies current name mapping into new mapping
    126115                        mapStack.push_front( mapStack.front() );
  • src/ResolvExpr/typeops.h

    r85f0713 rd06010a  
    5454 
    5555        // in AdjustExprType.cc
     56        /// Replaces array types with the equivalent pointer, and function types with a pointer-to-function
    5657        void adjustExprType( Type *&type, const TypeEnvironment &env, const SymTab::Indexer &indexer );
    5758
  • src/tests/test.py

    r85f0713 rd06010a  
    2121        return list
    2222
    23 def sh(cmd, dry_run):
     23def sh(cmd, dry_run = False, print2stdout = True):
    2424        if dry_run :
    2525                print("cmd: %s" % cmd)
    26                 return 0
     26                return 0, None
    2727        else :
    28                 proc = Popen(cmd, stderr=STDOUT, shell=True)
    29                 proc.communicate()
    30                 return proc.returncode
     28                proc = Popen(cmd, stdout=None if print2stdout else PIPE, stderr=STDOUT, shell=True)
     29                out, err = proc.communicate()
     30                return proc.returncode, out
    3131
    3232def file_replace(fname, pat, s_after):
     
    6161
    6262        # build, skipping to next test on error
    63         make_ret = sh("%s %s 2> %s 1> /dev/null" % (make_cmd, test, out_file), dry_run)
     63        make_ret, _ = sh("%s %s 2> %s 1> /dev/null" % (make_cmd, test, out_file), dry_run)
    6464
    6565        if make_ret == 0 :
     
    7171
    7272        retcode = 0
     73        error = None
    7374
    7475        fix_MakeLevel(out_file)
     
    7677        if not generate :
    7778                # diff the output of the files
    78                 retcode = sh("diff .expect/%s.txt .out/%s.log" % (test, test), dry_run)
     79                diff_cmd = ("diff --old-group-format='\t\tmissing lines :\n"
     80                                        "%%<' \\\n"
     81                                        "--new-group-format='\t\tnew lines :\n"
     82                                        "%%>' \\\n"
     83                                        "--unchanged-group-format='%%=' \\"
     84                                        "--changed-group-format='\t\texpected :\n"
     85                                        "%%<\n"
     86                                        "\t\tgot :\n"
     87                                        "%%>' \\\n"
     88                                        "--new-line-format='\t\t%%dn\t%%L' \\\n"
     89                                        "--old-line-format='\t\t%%dn\t%%L' \\\n"
     90                                        "--unchanged-line-format='' \\\n"
     91                                        ".expect/%s.txt .out/%s.log")
     92
     93                retcode, error = sh(diff_cmd % (test, test), dry_run, False)
    7994
    8095        # clean the executable
    8196        sh("rm -f %s > /dev/null 2>&1" % test, dry_run)
    8297
    83         return retcode
     98        return retcode, error
    8499
    85100def run_tests(tests, generate, dry_run) :
     
    94109                print("%20s  " % t, end="")
    95110                sys.stdout.flush()
    96                 test_failed = run_test_instance(t, generate, dry_run)
     111                test_failed, error = run_test_instance(t, generate, dry_run)
    97112                failed = test_failed or failed
    98113
    99114                if not generate :
    100115                        print("FAILED" if test_failed else "PASSED")
     116                        if error :
     117                                print(error)
    101118                else :
    102119                        print( "Done" )
Note: See TracChangeset for help on using the changeset viewer.