Ignore:
Timestamp:
Aug 25, 2017, 12:11:53 PM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
bf7b9da7
Parents:
135b431 (diff), f676b84 (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' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/OperatorTable.cc

    r135b431 r6b224a52  
    1414//
    1515
    16 #include <map>      // for map, _Rb_tree_const_iterator, map<>::const_iterator
    17 #include <utility>  // for pair
     16#include <algorithm>  // for any_of
     17#include <map>        // for map, _Rb_tree_const_iterator, map<>::const_iterator
     18#include <utility>    // for pair
    1819
    1920#include "OperatorTable.h"
     
    9394                } // if
    9495        }
     96
     97        /// determines if a given function name is one of the operator types between [begin, end)
     98        template<typename Iterator>
     99        bool isOperatorType( const std::string & funcName, Iterator begin, Iterator end ) {
     100                OperatorInfo info;
     101                if ( operatorLookup( funcName, info ) ) {
     102                        return std::find( begin, end, info.type ) != end;
     103                }
     104                return false;
     105        }
     106
     107        bool isConstructor( const std::string & funcName ) {
     108                static OperatorType types[] = { OT_CTOR };
     109                return isOperatorType( funcName, std::begin(types), std::end(types) );
     110        }
     111
     112        bool isDestructor( const std::string & funcName ) {
     113                static OperatorType types[] = { OT_DTOR };
     114                return isOperatorType( funcName, std::begin(types), std::end(types) );
     115        }
     116
     117        bool isAssignment( const std::string & funcName ) {
     118                static OperatorType types[] = { OT_PREFIXASSIGN, OT_POSTFIXASSIGN, OT_INFIXASSIGN };
     119                return isOperatorType( funcName, std::begin(types), std::end(types) );
     120        }
     121
     122        bool isCtorDtor( const std::string & funcName ) {
     123                static OperatorType types[] = { OT_CTOR, OT_DTOR };
     124                return isOperatorType( funcName, std::begin(types), std::end(types) );
     125        }
     126
     127        bool isCtorDtorAssign( const std::string & funcName ) {
     128                static OperatorType types[] = { OT_CTOR, OT_DTOR, OT_PREFIXASSIGN, OT_POSTFIXASSIGN, OT_INFIXASSIGN };
     129                return isOperatorType( funcName, std::begin(types), std::end(types) );
     130        }
    95131} // namespace CodeGen
    96132
Note: See TracChangeset for help on using the changeset viewer.