source: translator/CodeGen/OperatorTable.cc @ df23c8f

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since df23c8f was 51b7345, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

initial commit

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/*
2 * This file is part of the Cforall project
3 *
4 * $Id: OperatorTable.cc,v 1.6 2003/01/19 04:19:31 rcbilson Exp $
5 *
6 */
7
8#include <map>
9
10#include "OperatorTable.h"
11
12namespace CodeGen {
13
14namespace {
15
16const OperatorInfo tableValues[] = {
17{       "?[?]",         "",             "_operator_index",              OT_INDEX                },
18{       "?()",          "",             "_operator_call",               OT_CALL                 },
19{       "?++",          "++",           "_operator_postincr",           OT_POSTFIXASSIGN        },
20{       "?--",          "--",           "_operator_postdecr",           OT_POSTFIXASSIGN        },
21{       "*?",           "*",            "_operator_deref",              OT_PREFIX               },
22{       "+?",           "+",            "_operator_unaryplus",          OT_PREFIX               },
23{       "-?",           "-",            "_operator_unaryminus",         OT_PREFIX               },
24{       "~?",           "~",            "_operator_bitnot",             OT_PREFIX               },
25{       "!?",           "!",            "_operator_lognot",             OT_PREFIX               },
26{       "++?",          "++",           "_operator_preincr",            OT_PREFIXASSIGN         },
27{       "--?",          "--",           "_operator_predecr",            OT_PREFIXASSIGN         },
28{       "?*?",          "*",            "_operator_multiply",           OT_INFIX                },
29{       "?/?",          "/",            "_operator_divide",             OT_INFIX                },
30{       "?%?",          "%",            "_operator_modulus",            OT_INFIX                },
31{       "?+?",          "+",            "_operator_add",                OT_INFIX                },
32{       "?-?",          "-",            "_operator_subtract",           OT_INFIX                },
33{       "?<<?",         "<<",           "_operator_shiftleft",          OT_INFIX                },
34{       "?>>?",         ">>",           "_operator_shiftright",         OT_INFIX                },
35{       "?<?",          "<",            "_operator_less",               OT_INFIX                },
36{       "?>?",          ">",            "_operator_greater",            OT_INFIX                },
37{       "?<=?",         "<=",           "_operator_lessequal",          OT_INFIX                },
38{       "?>=?",         ">=",           "_operator_greaterequal",       OT_INFIX                },
39{       "?==?",         "==",           "_operator_equal",              OT_INFIX                },
40{       "?!=?",         "!=",           "_operator_notequal",           OT_INFIX                },
41{       "?&?",          "&",            "_operator_bitand",             OT_INFIX                },
42{       "?^?",          "^",            "_operator_bitxor",             OT_INFIX                },
43{       "?|?",          "|",            "_operator_bitor",              OT_INFIX                },
44{       "?=?",          "=",            "_operator_assign",             OT_INFIXASSIGN          },
45{       "?*=?",         "*=",           "_operator_multassign",         OT_INFIXASSIGN          },
46{       "?/=?",         "/=",           "_operator_divassign",          OT_INFIXASSIGN          },
47{       "?%=?",         "%=",           "_operator_modassign",          OT_INFIXASSIGN          },
48{       "?+=?",         "+=",           "_operator_addassign",          OT_INFIXASSIGN          },
49{       "?-=?",         "-=",           "_operator_subassign",          OT_INFIXASSIGN          },
50{       "?<<=?",        "<<=",          "_operator_shiftleftassign",    OT_INFIXASSIGN          },
51{       "?>>=?",        ">>=",          "_operator_shiftrightassign",   OT_INFIXASSIGN          },
52{       "?&=?",         "&=",           "_operator_bitandassign",       OT_INFIXASSIGN          },
53{       "?^=?",         "^=",           "_operator_bitxorassign",       OT_INFIXASSIGN          },
54{       "?|=?",         "|=",           "_operator_bitorassign",        OT_INFIXASSIGN          },
55{       "0",            "0",            "_constant_zero",               OT_CONSTANT             },
56{       "1",            "1",            "_constant_one",                        OT_CONSTANT             }
57};
58
59const int numOps = sizeof( tableValues ) / sizeof( OperatorInfo );
60
61std::map< std::string, OperatorInfo > table;
62
63void
64initialize()
65{
66  for( int i = 0; i < numOps; ++i ) {
67    table[ tableValues[i].inputName ] = tableValues[i];
68  }
69}
70
71} // namespace
72
73bool
74operatorLookup( std::string funcName, OperatorInfo &info )
75{
76  static bool init = false;
77  if( !init ) {
78    initialize();
79  }
80  std::map< std::string, OperatorInfo >::const_iterator i = table.find( funcName );
81  if( i == table.end() ) {
82    return false;
83  } else {
84    info = i->second;
85    return true;
86  }
87}
88
89} // namespace CodeGen
Note: See TracBrowser for help on using the repository browser.