Changeset 01aeade for translator/Common


Ignore:
Timestamp:
May 19, 2015, 7:57:09 AM (11 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:
a08ba92
Parents:
51587aa
Message:

licencing: fifth groups of files

Location:
translator/Common
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • translator/Common/CompilerError.h

    r51587aa r01aeade  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // XXX.cc --
     7// CompilerError.h --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By :
    12 // Last Modified On :
    13 // Update Count     : 0
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue May 19 07:20:37 2015
     13// Update Count     : 2
    1414//
     15
    1516#ifndef COMPILER_ERROR_H
    1617#define COMPILER_ERROR_H
     
    1920//#include "../config.h"
    2021
    21 class CompilerError : public std::exception
    22 {
    23 public:
    24   CompilerError();
    25   CompilerError( std::string what ) : what( what ) {}
    26   ~CompilerError() throw () {}
     22class CompilerError : public std::exception {
     23  public:
     24        CompilerError();
     25        CompilerError( std::string what ) : what( what ) {}
     26        ~CompilerError() throw () {}
    2727
    28   std::string get_what() const { return what; }
    29   void set_what( std::string newValue ) { what = newValue; }
    30 
    31 private:
    32   std::string what;
     28        std::string get_what() const { return what; }
     29        void set_what( std::string newValue ) { what = newValue; }
     30  private:
     31        std::string what;
    3332};
    3433
    35 #endif /* COMPILER_ERROR_H */
     34#endif // COMPILER_ERROR_H
    3635
    37 /*
    38   Local Variables:
    39   mode: c++
    40   End:
    41 */
    4236// Local Variables: //
    4337// tab-width: 4 //
  • translator/Common/SemanticError.cc

    r51587aa r01aeade  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // XXX.cc --
     7// SemanticError.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By :
    12 // Last Modified On :
    13 // Update Count     : 0
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue May 19 07:21:25 2015
     13// Update Count     : 1
    1414//
    15 /*
    16  * This file is part of the Cforall project
    17  *
    18  * $Id: SemanticError.cc,v 1.1 2002/04/27 19:57:10 rcbilson Exp $
    19  *
    20  */
    2115
    2216#include <iostream>
     
    2822#include "SemanticError.h"
    2923
    30 SemanticError::SemanticError()
    31 {
     24SemanticError::SemanticError() {
    3225}
    3326
    34 SemanticError::SemanticError( std::string error )
    35 {
    36   errors.push_back( std::string( "Error: " ) + error );
     27SemanticError::SemanticError( std::string error ) {
     28        errors.push_back( std::string( "Error: " ) + error );
    3729}
    3830
    39 void
    40 SemanticError::append( SemanticError &other )
    41 {
    42   errors.splice( errors.end(), other.errors );
     31void SemanticError::append( SemanticError &other ) {
     32        errors.splice( errors.end(), other.errors );
    4333}
    4434
    45 bool
    46 SemanticError::isEmpty() const
    47 {
    48   return errors.empty();
     35bool SemanticError::isEmpty() const {
     36        return errors.empty();
    4937}
    5038
    51 void
    52 SemanticError::print( std::ostream &os )
    53 {
    54   std::copy( errors.begin(), errors.end(), std::ostream_iterator< std::string >( os, "\n" ) );
     39void SemanticError::print( std::ostream &os ) {
     40        std::copy( errors.begin(), errors.end(), std::ostream_iterator< std::string >( os, "\n" ) );
    5541}
     42
    5643// Local Variables: //
    5744// tab-width: 4 //
  • translator/Common/SemanticError.h

    r51587aa r01aeade  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // XXX.cc --
     7// SemanticError.h --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By :
    12 // Last Modified On :
    13 // Update Count     : 0
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue May 19 07:22:23 2015
     13// Update Count     : 1
    1414//
    15 /*
    16  * This file is part of the Cforall project
    17  *
    18  * $Id: SemanticError.h,v 1.1 2002/04/27 19:57:10 rcbilson Exp $
    19  *
    20  */
    2115
    2216#ifndef SEMANTICERROR_H
     
    2923#include <iostream>
    3024
    31 class SemanticError : public std::exception
    32 {
    33 public:
    34   SemanticError();
    35   SemanticError( std::string error );
    36   template< typename T > SemanticError( const std::string &error, const T *obj );
    37   ~SemanticError() throw() {}
     25class SemanticError : public std::exception {
     26  public:
     27        SemanticError();
     28        SemanticError( std::string error );
     29        template< typename T > SemanticError( const std::string &error, const T *obj );
     30        ~SemanticError() throw() {}
    3831
    39   void append( SemanticError &other );
    40   bool isEmpty() const;
    41   void print( std::ostream &os );
     32        void append( SemanticError &other );
     33        bool isEmpty() const;
     34        void print( std::ostream &os );
    4235
    43   // constructs an exception using the given message and the printed
    44   // representation of the obj (T must have a print method)
    45 
    46 private:
    47   std::list< std::string > errors;
     36        // constructs an exception using the given message and the printed
     37        // representation of the obj (T must have a print method)
     38  private:
     39        std::list< std::string > errors;
    4840};
    4941
    5042template< typename T >
    51 SemanticError::SemanticError( const std::string &error, const T *obj )
    52 {
    53   std::ostrstream os;
    54   os << "Error: " << error;
    55   obj->print( os );
    56   errors.push_back( std::string( os.str(), os.pcount() ) );
     43SemanticError::SemanticError( const std::string &error, const T *obj ) {
     44        std::ostrstream os;
     45        os << "Error: " << error;
     46        obj->print( os );
     47        errors.push_back( std::string( os.str(), os.pcount() ) );
    5748}
    5849
    59 #endif /* SEMANTICERROR_H */
     50#endif // SEMANTICERROR_H
     51
    6052// Local Variables: //
    6153// tab-width: 4 //
  • translator/Common/UnimplementedError.h

    r51587aa r01aeade  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // XXX.cc --
     7// UnimplementedError.h --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By :
    12 // Last Modified On :
    13 // Update Count     : 0
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue May 19 07:23:08 2015
     13// Update Count     : 1
    1414//
    15 /*
    16  * This file is part of the Cforall project
    17  *
    18  * $Id: UnimplementedError.h,v 1.1 2002/09/02 20:31:53 rcbilson Exp $
    19  *
    20  */
    2115
    22 #ifndef COMMON_UNIMPLEMENTEDERROR_H
    23 #define COMMON_UNIMPLEMENTEDERROR_H
     16#ifndef _UNIMPLEMENTEDERROR_H
     17#define _UNIMPLEMENTEDERROR_H
    2418
    2519#include <string>
    2620
    27 class UnimplementedError : public std::exception
    28 {
    29 public:
    30   UnimplementedError();
    31   UnimplementedError( std::string what ) : what( what ) {}
    32   ~UnimplementedError() throw () {}
     21class UnimplementedError : public std::exception {
     22  public:
     23        UnimplementedError();
     24        UnimplementedError( std::string what ) : what( what ) {}
     25        ~UnimplementedError() throw () {}
    3326 
    34   std::string get_what() const { return what; }
    35   void set_what( std::string newValue ) { what = newValue; }
    36  
    37 private:
    38   std::string what;
     27        std::string get_what() const { return what; }
     28        void set_what( std::string newValue ) { what = newValue; }
     29  private:
     30        std::string what;
    3931};
    4032
    41 #endif /* #ifndef COMMON_UNIMPLEMENTEDERROR_H */
     33#endif // _UNIMPLEMENTEDERROR_H
     34
    4235// Local Variables: //
    4336// tab-width: 4 //
  • translator/Common/UniqueName.cc

    r51587aa r01aeade  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // XXX.cc --
     7// UniqueName.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By :
    12 // Last Modified On :
    13 // Update Count     : 0
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue May 19 07:23:41 2015
     13// Update Count     : 1
    1414//
    15 /*
    16  * This file is part of the Cforall project
    17  *
    18  * $Id: UniqueName.cc,v 1.1 2002/04/30 03:30:14 rcbilson Exp $
    19  *
    20  */
    2115
    2216#include <string>
     
    2519#include "UniqueName.h"
    2620
    27 UniqueName::UniqueName( const std::string &base )
    28   : base( base ), count( 0 )
    29 {
     21UniqueName::UniqueName( const std::string &base ) : base( base ), count( 0 ) {
    3022}
    3123
    32 std::string
    33 UniqueName::newName( const std::string &additional )
    34 {
    35   std::ostrstream os;
    36   os << base << additional << count++;
    37   return std::string( os.str(), os.pcount() );
     24std::string UniqueName::newName( const std::string &additional ) {
     25        std::ostrstream os;
     26        os << base << additional << count++;
     27        return std::string( os.str(), os.pcount() );
    3828}
    3929
  • translator/Common/UniqueName.h

    r51587aa r01aeade  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // XXX.cc --
     7// UniqueName.h --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By :
    12 // Last Modified On :
    13 // Update Count     : 0
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue May 19 07:24:20 2015
     13// Update Count     : 1
    1414//
    15 /*
    16  * This file is part of the Cforall project
    17  *
    18  * $Id: UniqueName.h,v 1.1 2002/04/30 03:30:14 rcbilson Exp $
    19  *
    20  */
    2115
    2216#ifndef UNIQUENAME_H
     
    2519#include <string>
    2620
    27 class UniqueName
    28 {
    29 public:
    30   UniqueName( const std::string &base = "" );
    31 
    32   std::string newName( const std::string &additional = "" );
    33 
    34 private:
    35   std::string base;
    36   int count;
     21class UniqueName {
     22  public:
     23        UniqueName( const std::string &base = "" );
     24        std::string newName( const std::string &additional = "" );
     25  private:
     26        std::string base;
     27        int count;
    3728};
    3829
    39 #endif /* #ifndef UNIQUENAME_H */
     30#endif // UNIQUENAME_H
     31
    4032// Local Variables: //
    4133// tab-width: 4 //
  • translator/Common/utility.h

    r51587aa r01aeade  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // XXX.cc --
     7// utility.h --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By :
    12 // Last Modified On :
    13 // Update Count     : 0
    14 //
    15 /*
    16  * This file is part of the Cforall project
    17  *
    18  * Some useful template utility functions
    19  *
    20  * $Id: utility.h,v 1.17 2003/11/26 18:05:21 rgesteve Exp $
    21  *
    22  */
    23 
    24 #ifndef COMMON_UTILITY_H
    25 #define COMMON_UTILITY_H
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue May 19 07:27:38 2015
     13// Update Count     : 2
     14//
     15
     16#ifndef _UTILITY_H
     17#define _UTILITY_H
    2618
    2719#include <iostream>
     
    3325
    3426template< typename T >
    35 static inline T*
    36 maybeClone( const T *orig )
    37 {
    38   if ( orig ) {
    39     return orig->clone();
    40   } else {
    41     return 0;
    42   }
     27static inline T * maybeClone( const T *orig ) {
     28        if ( orig ) {
     29                return orig->clone();
     30        } else {
     31                return 0;
     32        } // if
    4333}
    4434
    4535template< typename T, typename U >
    46 static inline T*
    47 maybeBuild( const U *orig )
    48 {
    49   if ( orig ) {
    50     return orig->build();
    51   } else {
    52     return 0;
    53   }
     36static inline T * maybeBuild( const U *orig ) {
     37        if ( orig ) {
     38                return orig->build();
     39        } else {
     40                return 0;
     41        } // if
    5442}
    5543
    5644template< typename Input_iterator >
    57 void
    58 printEnums( Input_iterator begin, Input_iterator end, const char * const *name_array, std::ostream &os )
    59 {
    60   for ( Input_iterator i = begin; i != end; ++i ) {
    61     os << name_array[ *i ] << ' ';
    62   }
     45void printEnums( Input_iterator begin, Input_iterator end, const char * const *name_array, std::ostream &os ) {
     46        for ( Input_iterator i = begin; i != end; ++i ) {
     47                os << name_array[ *i ] << ' ';
     48        } // for
    6349}
    6450
    6551template< typename Container >
    66 void
    67 deleteAll( Container &container )
    68 {
    69   for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
    70     delete *i;
    71   }
     52void deleteAll( Container &container ) {
     53        for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
     54                delete *i;
     55        } // for
    7256}
    7357
    7458template< typename Container >
    75 void
    76 printAll( const Container &container, std::ostream &os, int indent = 0 )
    77 {
    78   for ( typename Container::const_iterator i = container.begin(); i != container.end(); ++i ) {
    79     if ( *i ) {
    80       os << std::string(indent,  ' ');
    81       (*i)->print( os, indent + 2 );
    82       os << std::endl;
    83     }
    84   }
     59void printAll( const Container &container, std::ostream &os, int indent = 0 ) {
     60        for ( typename Container::const_iterator i = container.begin(); i != container.end(); ++i ) {
     61                if ( *i ) {
     62                        os << std::string(indent,  ' ');
     63                        (*i)->print( os, indent + 2 );
     64                        os << std::endl;
     65                } // if
     66        } // for
    8567}
    8668
    8769template< typename SrcContainer, typename DestContainer >
    88 void
    89 cloneAll( const SrcContainer &src, DestContainer &dest )
    90 {
    91   typename SrcContainer::const_iterator in = src.begin();
    92   std::back_insert_iterator< DestContainer > out( dest );
    93   while ( in != src.end() ) {
    94     *out++ = (*in++)->clone();
    95   }
     70void cloneAll( const SrcContainer &src, DestContainer &dest ) {
     71        typename SrcContainer::const_iterator in = src.begin();
     72        std::back_insert_iterator< DestContainer > out( dest );
     73        while ( in != src.end() ) {
     74                *out++ = (*in++)->clone();
     75        } // while
    9676}
    9777
    9878template< typename Container >
    99 void
    100 assertAll( const Container &container )
    101 {
    102   int count = 0;
    103   for ( typename Container::const_iterator i = container.begin(); i != container.end(); ++i ) {
    104     if ( !(*i) ) {
    105       std::cerr << count << " is null" << std::endl;
    106     }
    107   }
    108 }
    109 
    110 static inline std::string
    111 assign_strptr( std::string *str )
    112 {
    113   if ( str == 0 ) {
    114     return "";
    115   } else {
    116     std::string tmp;
    117     tmp = *str;
    118     delete str;
    119     return tmp;
    120   }
     79void assertAll( const Container &container ) {
     80        int count = 0;
     81        for ( typename Container::const_iterator i = container.begin(); i != container.end(); ++i ) {
     82                if ( !(*i) ) {
     83                        std::cerr << count << " is null" << std::endl;
     84                } // if
     85        } // for
     86}
     87
     88static inline std::string assign_strptr( std::string *str ) {
     89        if ( str == 0 ) {
     90                return "";
     91        } else {
     92                std::string tmp;
     93                tmp = *str;
     94                delete str;
     95                return tmp;
     96        } // if
    12197}
    12298
    12399template< class T, typename ResultType, ResultType (T::* memfunc)() >
    124 ResultType dispatch(T *pT){
    125   return (pT->*memfunc)();
     100ResultType dispatch( T *pT ) {
     101        return (pT->*memfunc)();
    126102}
    127103
    128104template < typename T >
    129 std::list<T> tail( std::list<T> l )
    130 {
    131   if (! l.empty()){
    132     std::list<T> ret(++(l.begin()), l.end());
    133     return ret;
    134   }
     105std::list<T> tail( std::list<T> l ) {
     106        if ( ! l.empty() ) {
     107                std::list<T> ret(++(l.begin()), l.end());
     108                return ret;
     109        } // if
    135110}
    136111
    137112template < typename T >
    138113std::list<T> flatten( std::list < std::list<T> > l) {
    139   typedef std::list <T> Ts;
    140 
    141   Ts ret;
    142 
    143   switch ( l.size() ){
    144   case 0:
    145     return ret;
    146   case 1:
    147     return l.front();
    148   default:
    149     ret = flatten(tail(l));
    150     ret.insert(ret.begin(), l.front().begin(), l.front().end());
    151     return ret;
    152   }
     114        typedef std::list <T> Ts;
     115
     116        Ts ret;
     117
     118        switch ( l.size() ){
     119          case 0:
     120                return ret;
     121          case 1:
     122                return l.front();
     123          default:
     124                ret = flatten(tail(l));
     125                ret.insert(ret.begin(), l.front().begin(), l.front().end());
     126                return ret;
     127        } // switch
    153128}
    154129
    155130template < typename T >
    156131std::string toString ( T value ) {
    157   std::ostrstream os;
     132        std::ostrstream os;
    158133 
    159   os << value; // << std::ends;
    160   os.freeze( false );
    161 
    162   return std::string(os.str(), os.pcount());
     134        os << value; // << std::ends;
     135        os.freeze( false );
     136
     137        return std::string(os.str(), os.pcount());
    163138}
    164139
    165140template< class Constructed, typename Arg >
    166141Constructed *ctor( Arg arg ) {
    167   Constructed *c = new Constructed( arg );
    168   return c;
     142        Constructed *c = new Constructed( arg );
     143        return c;
    169144}
    170145
    171146template< class Constructed, typename Arg >
    172147Constructed ctor_noptr( Arg arg ) {
    173   return Constructed( arg );
     148        return Constructed( arg );
    174149}
    175150
    176151template< typename T >
    177152void replace( std::list< T > &org, typename std::list< T >::iterator pos, std::list< T > &with ) {
    178   // TIter should secretly be a typename std::list< T >::iterator
    179   //   ( g++ 3.2 issues a 'is implicitly a typename' warning if I make this explicit )
    180    typename std::list< T >::iterator next = pos; advance( next, 1 );
    181 
    182    //if ( next != org.end() ) {
     153        // TIter should secretly be a typename std::list< T >::iterator
     154        //   ( g++ 3.2 issues a 'is implicitly a typename' warning if I make this explicit )
     155        typename std::list< T >::iterator next = pos; advance( next, 1 );
     156
     157        //if ( next != org.end() ) {
    183158    org.erase( pos );
    184159    org.splice( next, with );
    185160    //}
    186161
    187   return;
     162        return;
    188163}
    189164
    190165template< typename T1, typename T2 >
    191166T2 *cast_ptr( T1 *from ) {
    192   return dynamic_cast< T2 * >( from );
     167        return dynamic_cast< T2 * >( from );
    193168}
    194169
    195170template< class Exception, typename Arg >
    196171void inline assert_throw( bool pred, Arg arg ) {
    197   if (pred) throw Exception( arg );
     172        if (pred) throw Exception( arg );
    198173}
    199174
    200175template< typename T >
    201176struct is_null_pointer {
    202   bool operator()( const T *ptr ){ return ( ptr == 0 ); }
     177        bool operator()( const T *ptr ){ return ( ptr == 0 ); }
    203178};
    204179
    205180template< class InputIterator, class OutputIterator, class Predicate >
    206 void filter(InputIterator begin, InputIterator end, OutputIterator out, Predicate pred)
    207 {
    208   while ( begin++ != end )
    209     if ( pred(*begin) ) *out++ = *begin;
    210 
    211   return;
     181void filter(InputIterator begin, InputIterator end, OutputIterator out, Predicate pred) {
     182        while ( begin++ != end )
     183                if ( pred(*begin) ) *out++ = *begin;
     184
     185        return;
    212186}
    213187
    214188template< class InputIterator1, class InputIterator2, class OutputIterator >
    215189void zip( InputIterator1 b1, InputIterator1 e1, InputIterator2 b2, InputIterator2 e2, OutputIterator out ) {
    216   while ( b1 != e1 && b2 != e2 )
    217     *out++ = std::pair<typename InputIterator1::value_type, typename InputIterator2::value_type>(*b1++, *b2++);
     190        while ( b1 != e1 && b2 != e2 )
     191                *out++ = std::pair<typename InputIterator1::value_type, typename InputIterator2::value_type>(*b1++, *b2++);
    218192}
    219193
    220194template< class InputIterator1, class InputIterator2, class OutputIterator, class BinFunction >
    221195void zipWith( InputIterator1 b1, InputIterator1 e1, InputIterator2 b2, InputIterator2 e2, OutputIterator out, BinFunction func ) {
    222   while ( b1 != e1 && b2 != e2 )
    223     *out++ = func(*b1++, *b2++);
    224 }
    225 
    226 #endif /* #ifndef COMMON_UTILITY_H */
    227 
    228 /*
    229   Local Variables:
    230   mode: c++
    231   End:
    232 */
     196        while ( b1 != e1 && b2 != e2 )
     197                *out++ = func(*b1++, *b2++);
     198}
     199
     200#endif // _UTILITY_H
     201
    233202// Local Variables: //
    234203// tab-width: 4 //
Note: See TracChangeset for help on using the changeset viewer.