Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/OperatorTable.h

    r49ae2bc r60a8062  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Nov  3 14:53:00 2023
    13 // Update Count     : 27
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sun Feb 16 08:13:34 2020
     13// Update Count     : 26
    1414//
    1515
     
    1717
    1818#include <string>
     19#include <map>
    1920
    2021namespace CodeGen {
     22        enum OperatorType {
     23                OT_CTOR,
     24                OT_DTOR,
     25                OT_CONSTRUCTOR = OT_DTOR,
     26                OT_PREFIXASSIGN,
     27                OT_POSTFIXASSIGN,
     28                OT_INFIXASSIGN,
     29                OT_ASSIGNMENT = OT_INFIXASSIGN,
     30                OT_CALL,
     31                OT_PREFIX,
     32                OT_INFIX,
     33                OT_POSTFIX,
     34                OT_INDEX,
     35                OT_LABELADDRESS,
     36                OT_CONSTANT
     37        };
    2138
    22 enum OperatorType {
    23         OT_CTOR,
    24         OT_DTOR,
    25         OT_CONSTRUCTOR = OT_DTOR,
    26         OT_PREFIXASSIGN,
    27         OT_POSTFIXASSIGN,
    28         OT_INFIXASSIGN,
    29         OT_ASSIGNMENT = OT_INFIXASSIGN,
    30         OT_CALL,
    31         OT_PREFIX,
    32         OT_INFIX,
    33         OT_POSTFIX,
    34         OT_INDEX,
    35         OT_LABELADDRESS,
    36         OT_CONSTANT
    37 };
     39        struct OperatorInfo {
     40                std::string inputName;
     41                std::string symbol;
     42                std::string outputName;
     43                std::string friendlyName;
     44                OperatorType type;
     45        };
    3846
    39 struct OperatorInfo {
    40         // The Cforall special function name.
    41         std::string inputName;
    42         // The string used when the operator is used as an operator.
    43         std::string symbol;
    44         // The base name used in the mangled name.
    45         std::string outputName;
    46         // Human-readable name of the operator.
    47         std::string friendlyName;
    48         // The type of operator shows how it is used as an operator.
    49         OperatorType type;
    50 };
     47        class CodeGen {
     48                friend const OperatorInfo * operatorLookup( const std::string & funcName );
    5149
    52 // Look up the operator (by inputName), return nullptr if no such operator.
    53 const OperatorInfo * operatorLookup( const std::string & inputName );
    54 // Is there an operator with this name?
    55 bool isOperator( const std::string & inputName );
    56 // Get the friendlyName of the operator with the inputName
    57 std::string operatorFriendlyName( const std::string & inputName );
    58 // Get the OperatorInfo with the given outputName, if one exists.
    59 const OperatorInfo * operatorLookupByOutput( const std::string & outputName );
     50                static const OperatorInfo tableValues[];
     51                static std::map< std::string, OperatorInfo > table;
     52          public:
     53                CodeGen();
     54        }; // CodeGen
    6055
    61 // Is the operator a constructor, destructor or any form of assignment.
    62 // (Last two are "or" combinations of the first three.)
    63 bool isConstructor( const std::string & );
    64 bool isDestructor( const std::string & );
    65 bool isAssignment( const std::string & );
    66 bool isCtorDtor( const std::string & );
    67 bool isCtorDtorAssign( const std::string & );
     56        bool isOperator( const std::string & funcName );
     57        const OperatorInfo * operatorLookup( const std::string & funcName );
     58        std::string operatorFriendlyName( const std::string & funcName );
    6859
     60        bool isConstructor( const std::string & );
     61        bool isDestructor( const std::string & );
     62        bool isAssignment( const std::string & );
     63        bool isCtorDtor( const std::string & );
     64        bool isCtorDtorAssign( const std::string & );
    6965} // namespace CodeGen
    7066
Note: See TracChangeset for help on using the changeset viewer.