Ignore:
Timestamp:
May 17, 2015, 1:19:35 PM (9 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, 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, string, with_gc
Children:
0dd3a2f
Parents:
b87a5ed
Message:

licencing: second groups of files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • translator/ResolvExpr/FindOpenVars.cc

    rb87a5ed ra32b204  
    1 /*
    2  * This file is part of the Cforall project
    3  *
    4  * $Id: FindOpenVars.cc,v 1.4 2005/08/29 20:14:16 rcbilson Exp $
    5  *
    6  */
     1//
     2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
     3//
     4// The contents of this file are covered under the licence agreement in the
     5// file "LICENCE" distributed with Cforall.
     6//
     7// FindOpenVars.cc --
     8//
     9// Author           : Richard C. Bilson
     10// Created On       : Sun May 17 09:42:48 2015
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sun May 17 09:45:25 2015
     13// Update Count     : 3
     14//
    715
    816#include "FindOpenVars.h"
     
    1018#include "SynTree/Visitor.h"
    1119
     20namespace ResolvExpr {
     21        class FindOpenVars : public Visitor {
     22          public:
     23                FindOpenVars( OpenVarSet &openVars, OpenVarSet &closedVars, AssertionSet &needAssertions, AssertionSet &haveAssertions, bool firstIsOpen );
    1224
    13 namespace ResolvExpr {
     25          private:
     26                virtual void visit(PointerType *pointerType);
     27                virtual void visit(ArrayType *arrayType);
     28                virtual void visit(FunctionType *functionType);
     29                virtual void visit(TupleType *tupleType);
    1430
    15 class FindOpenVars : public Visitor
    16 {
    17 public:
    18   FindOpenVars( OpenVarSet &openVars, OpenVarSet &closedVars, AssertionSet &needAssertions, AssertionSet &haveAssertions, bool firstIsOpen );
    19  
    20 private:
    21   virtual void visit(PointerType *pointerType);
    22   virtual void visit(ArrayType *arrayType);
    23   virtual void visit(FunctionType *functionType);
    24   virtual void visit(TupleType *tupleType);
    25  
    26   void common_action( Type *type );
    27  
    28   OpenVarSet &openVars, &closedVars;
    29   AssertionSet &needAssertions, &haveAssertions;
    30   bool nextIsOpen;
    31 };
     31                void common_action( Type *type );
    3232
    33 void
    34 findOpenVars( Type *type, OpenVarSet &openVars, OpenVarSet &closedVars, AssertionSet &needAssertions, AssertionSet &haveAssertions, bool firstIsOpen )
    35 {
    36   FindOpenVars finder( openVars, closedVars, needAssertions, haveAssertions, firstIsOpen );
    37   type->accept( finder );
    38 }
     33                OpenVarSet &openVars, &closedVars;
     34                AssertionSet &needAssertions, &haveAssertions;
     35                bool nextIsOpen;
     36        };
    3937
    40 FindOpenVars::FindOpenVars( OpenVarSet &openVars, OpenVarSet &closedVars, AssertionSet &needAssertions, AssertionSet &haveAssertions, bool firstIsOpen )
    41   : openVars( openVars ), closedVars( closedVars ), needAssertions( needAssertions ), haveAssertions( haveAssertions ), nextIsOpen( firstIsOpen )
    42 {
    43 }
     38        void findOpenVars( Type *type, OpenVarSet &openVars, OpenVarSet &closedVars, AssertionSet &needAssertions, AssertionSet &haveAssertions, bool firstIsOpen ) {
     39                FindOpenVars finder( openVars, closedVars, needAssertions, haveAssertions, firstIsOpen );
     40                type->accept( finder );
     41        }
    4442
    45 void
    46 FindOpenVars::common_action( Type *type )
    47 {
    48   if( nextIsOpen ) {
    49     for( std::list< TypeDecl* >::const_iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {
    50       openVars[ (*i)->get_name() ] = (*i)->get_kind();
    51       for( std::list< DeclarationWithType* >::const_iterator assert = (*i)->get_assertions().begin(); assert != (*i)->get_assertions().end(); ++assert ) {
    52         needAssertions[ *assert ] = false;
    53       }
     43        FindOpenVars::FindOpenVars( OpenVarSet &openVars, OpenVarSet &closedVars, AssertionSet &needAssertions, AssertionSet &haveAssertions, bool firstIsOpen )
     44                : openVars( openVars ), closedVars( closedVars ), needAssertions( needAssertions ), haveAssertions( haveAssertions ), nextIsOpen( firstIsOpen ) {
     45        }
     46
     47        void FindOpenVars::common_action( Type *type ) {
     48                if ( nextIsOpen ) {
     49                        for ( std::list< TypeDecl* >::const_iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {
     50                                openVars[ (*i)->get_name() ] = (*i)->get_kind();
     51                                for ( std::list< DeclarationWithType* >::const_iterator assert = (*i)->get_assertions().begin(); assert != (*i)->get_assertions().end(); ++assert ) {
     52                                        needAssertions[ *assert ] = false;
     53                                }
    5454///       cloneAll( (*i)->get_assertions(), needAssertions );
    5555///       needAssertions.insert( needAssertions.end(), (*i)->get_assertions().begin(), (*i)->get_assertions().end() );
    56     }
    57   } else {
    58     for( std::list< TypeDecl* >::const_iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {
    59       closedVars[ (*i)->get_name() ] = (*i)->get_kind();
    60       for( std::list< DeclarationWithType* >::const_iterator assert = (*i)->get_assertions().begin(); assert != (*i)->get_assertions().end(); ++assert ) {
    61         haveAssertions[ *assert ] = false;
    62       }
     56                        }
     57                } else {
     58                        for ( std::list< TypeDecl* >::const_iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {
     59                                closedVars[ (*i)->get_name() ] = (*i)->get_kind();
     60                                for ( std::list< DeclarationWithType* >::const_iterator assert = (*i)->get_assertions().begin(); assert != (*i)->get_assertions().end(); ++assert ) {
     61                                        haveAssertions[ *assert ] = false;
     62                                }
    6363///       cloneAll( (*i)->get_assertions(), haveAssertions );
    6464///       haveAssertions.insert( haveAssertions.end(), (*i)->get_assertions().begin(), (*i)->get_assertions().end() );
    65     }
    66   }
     65                        } // for
     66                } // if
    6767///   std::cout << "type is ";
    6868///   type->print( std::cout );
     
    7171///   std::cout << std::endl << "have is" << std::endl;
    7272///   printAssertionSet( haveAssertions, std::cout );
    73 }
     73        }
    7474
    75 void
    76 FindOpenVars::visit(PointerType *pointerType)
    77 {
    78   common_action( pointerType );
    79   Visitor::visit( pointerType );
    80 }
     75        void FindOpenVars::visit(PointerType *pointerType) {
     76                common_action( pointerType );
     77                Visitor::visit( pointerType );
     78        }
    8179
    82 void
    83 FindOpenVars::visit(ArrayType *arrayType)
    84 {
    85   common_action( arrayType );
    86   Visitor::visit( arrayType );
    87 }
     80        void FindOpenVars::visit(ArrayType *arrayType) {
     81                common_action( arrayType );
     82                Visitor::visit( arrayType );
     83        }
    8884
    89 void
    90 FindOpenVars::visit(FunctionType *functionType)
    91 {
    92   common_action( functionType );
    93   nextIsOpen = !nextIsOpen;
    94   Visitor::visit( functionType );
    95   nextIsOpen = !nextIsOpen;
    96 }
     85        void FindOpenVars::visit(FunctionType *functionType) {
     86                common_action( functionType );
     87                nextIsOpen = ! nextIsOpen;
     88                Visitor::visit( functionType );
     89                nextIsOpen = ! nextIsOpen;
     90        }
    9791
    98 void
    99 FindOpenVars::visit(TupleType *tupleType)
    100 {
    101   common_action( tupleType );
    102   Visitor::visit( tupleType );
    103 }
     92        void FindOpenVars::visit(TupleType *tupleType) {
     93                common_action( tupleType );
     94                Visitor::visit( tupleType );
     95        }
     96} // namespace ResolvExpr
    10497
    105 } // namespace ResolvExpr
     98// Local Variables: //
     99// tab-width: 4 //
     100// mode: c++ //
     101// compile-command: "make install" //
     102// End: //
Note: See TracChangeset for help on using the changeset viewer.