Changes in / [d06010a:85f0713]


Ignore:
Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    rd06010a r85f0713  
    1919#include <functional>
    2020#include <cassert>
    21 #include <unordered_map>
    22 #include <utility>
    23 #include <vector>
    2421
    2522#include "AlternativeFinder.h"
     
    411408        }
    412409
    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
     410        static const int recursionLimit = 10;
    418411
    419412        void addToIndexer( AssertionSet &assertSet, SymTab::Indexer &indexer ) {
     
    424417                }
    425418        }
    426        
     419
    427420        template< typename ForwardIterator, typename OutputIterator >
    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 ) {
     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 ) {
    430422                if ( begin == end ) {
    431423                        if ( newNeed.empty() ) {
     
    440432                                        printAssertionSet( newNeed, std::cerr, 8 );
    441433                                )
    442                                 inferRecursive( newNeed.begin(), newNeed.end(), newAlt, openVars, decls, newerNeed, needParents, level+1, indexer, out );
     434                                inferRecursive( newNeed.begin(), newNeed.end(), newAlt, openVars, decls, newerNeed, level+1, indexer, out );
    443435                                return;
    444436                        }
     
    447439                ForwardIterator cur = begin++;
    448440                if ( ! cur->second ) {
    449                         inferRecursive( begin, end, newAlt, openVars, decls, newNeed, needParents, level, indexer, out );
     441                        inferRecursive( begin, end, newAlt, openVars, decls, newNeed, level, indexer, out );
    450442                }
    451443                DeclarationWithType *curDecl = cur->first;
     
    464456                                std::cerr << std::endl;
    465457                        )
    466                        
    467458                        AssertionSet newHave, newerNeed( newNeed );
    468459                        TypeEnvironment newEnv( newAlt.env );
     
    487478                                newerAlt.env = newEnv;
    488479                                assert( (*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 );
     480                                Expression *varExpr = new VariableExpr( static_cast< DeclarationWithType* >( Declaration::declFromId( (*candidate)->get_uniqueId() ) ) );
    494481                                deleteAll( varExpr->get_results() );
    495482                                varExpr->get_results().clear();
     
    505492                                // XXX: this is a memory leak, but adjType can't be deleted because it might contain assertions
    506493                                appExpr->get_inferParams()[ curDecl->get_uniqueId() ] = ParamEntry( (*candidate)->get_uniqueId(), adjType->clone(), curDecl->get_type()->clone(), varExpr );
    507                                 inferRecursive( begin, end, newerAlt, newOpenVars, newDecls, newerNeed, newNeedParents, level, indexer, out );
     494                                inferRecursive( begin, end, newerAlt, newOpenVars, newDecls, newerNeed, level, indexer, out );
    508495                        } else {
    509496                                delete adjType;
     
    527514                addToIndexer( have, decls );
    528515                AssertionSet newNeed;
    529                 AssertionParentSet needParents;
    530                 inferRecursive( need.begin(), need.end(), newAlt, openVars, decls, newNeed, needParents, 0, indexer, out );
     516                inferRecursive( need.begin(), need.end(), newAlt, openVars, decls, newNeed, 0, indexer, out );
    531517//      PRINT(
    532518//          std::cerr << "declaration 14 is ";
  • src/ResolvExpr/RenameVars.cc

    rd06010a r85f0713  
    4545        void RenameVars::visit( PointerType *pointerType ) {
    4646                typeBefore( pointerType );
     47///   std::cout << "do pointer" << std::endl;
    4748                maybeAccept( pointerType->get_base(), *this );
     49///   std::cout << "done pointer" << std::endl;
    4850                typeAfter( pointerType );
    4951        }
     
    5860        void RenameVars::visit( FunctionType *functionType ) {
    5961                typeBefore( functionType );
     62///   std::cout << "return vals" << std::endl;
    6063                acceptAll( functionType->get_returnVals(), *this );
     64///   std::cout << functionType->get_parameters().size() << " parameters" << std::endl;
    6165                acceptAll( functionType->get_parameters(), *this );
     66///   std::cout << "done function" << std::endl;
    6267                typeAfter( functionType );
    6368        }
     
    9095        void RenameVars::visit( TypeInstType *instType ) {
    9196                typeBefore( instType );
     97///   std::cout << "instance of type " << instType->get_name() << std::endl;
    9298                std::map< std::string, std::string >::const_iterator i = mapStack.front().find( instType->get_name() );
    9399                if ( i != mapStack.front().end() ) {
     100///     std::cout << "found name " << i->second << std::endl;
    94101                        instType->set_name( i->second );
    95102                } else {
     103///     std::cout << "no name found" << std::endl;
    96104                } // if
    97105                acceptAll( instType->get_parameters(), *this );
     
    112120        void RenameVars::typeBefore( Type *type ) {
    113121                if ( ! type->get_forall().empty() ) {
     122///     std::cout << "type with forall: ";
     123///     type->print( std::cout );
     124///     std::cout << std::endl;
    114125                        // copies current name mapping into new mapping
    115126                        mapStack.push_front( mapStack.front() );
  • src/ResolvExpr/typeops.h

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

    rd06010a r85f0713  
    2121        return list
    2222
    23 def sh(cmd, dry_run = False, print2stdout = True):
     23def sh(cmd, dry_run):
    2424        if dry_run :
    2525                print("cmd: %s" % cmd)
    26                 return 0, None
     26                return 0
    2727        else :
    28                 proc = Popen(cmd, stdout=None if print2stdout else PIPE, stderr=STDOUT, shell=True)
    29                 out, err = proc.communicate()
    30                 return proc.returncode, out
     28                proc = Popen(cmd, stderr=STDOUT, shell=True)
     29                proc.communicate()
     30                return proc.returncode
    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
    7473
    7574        fix_MakeLevel(out_file)
     
    7776        if not generate :
    7877                # diff the output of the files
    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)
     78                retcode = sh("diff .expect/%s.txt .out/%s.log" % (test, test), dry_run)
    9479
    9580        # clean the executable
    9681        sh("rm -f %s > /dev/null 2>&1" % test, dry_run)
    9782
    98         return retcode, error
     83        return retcode
    9984
    10085def run_tests(tests, generate, dry_run) :
     
    10994                print("%20s  " % t, end="")
    11095                sys.stdout.flush()
    111                 test_failed, error = run_test_instance(t, generate, dry_run)
     96                test_failed = run_test_instance(t, generate, dry_run)
    11297                failed = test_failed or failed
    11398
    11499                if not generate :
    115100                        print("FAILED" if test_failed else "PASSED")
    116                         if error :
    117                                 print(error)
    118101                else :
    119102                        print( "Done" )
Note: See TracChangeset for help on using the changeset viewer.