/* * This file is part of the Cforall project * * $Id: OperatorTable.cc,v 1.6 2003/01/19 04:19:31 rcbilson Exp $ * */ #include #include "OperatorTable.h" namespace CodeGen { namespace { const OperatorInfo tableValues[] = { { "?[?]", "", "_operator_index", OT_INDEX }, { "?()", "", "_operator_call", OT_CALL }, { "?++", "++", "_operator_postincr", OT_POSTFIXASSIGN }, { "?--", "--", "_operator_postdecr", OT_POSTFIXASSIGN }, { "*?", "*", "_operator_deref", OT_PREFIX }, { "+?", "+", "_operator_unaryplus", OT_PREFIX }, { "-?", "-", "_operator_unaryminus", OT_PREFIX }, { "~?", "~", "_operator_bitnot", OT_PREFIX }, { "!?", "!", "_operator_lognot", OT_PREFIX }, { "++?", "++", "_operator_preincr", OT_PREFIXASSIGN }, { "--?", "--", "_operator_predecr", OT_PREFIXASSIGN }, { "?*?", "*", "_operator_multiply", OT_INFIX }, { "?/?", "/", "_operator_divide", OT_INFIX }, { "?%?", "%", "_operator_modulus", OT_INFIX }, { "?+?", "+", "_operator_add", OT_INFIX }, { "?-?", "-", "_operator_subtract", OT_INFIX }, { "?<>?", ">>", "_operator_shiftright", OT_INFIX }, { "??", ">", "_operator_greater", OT_INFIX }, { "?<=?", "<=", "_operator_lessequal", OT_INFIX }, { "?>=?", ">=", "_operator_greaterequal", OT_INFIX }, { "?==?", "==", "_operator_equal", OT_INFIX }, { "?!=?", "!=", "_operator_notequal", OT_INFIX }, { "?&?", "&", "_operator_bitand", OT_INFIX }, { "?^?", "^", "_operator_bitxor", OT_INFIX }, { "?|?", "|", "_operator_bitor", OT_INFIX }, { "?=?", "=", "_operator_assign", OT_INFIXASSIGN }, { "?*=?", "*=", "_operator_multassign", OT_INFIXASSIGN }, { "?/=?", "/=", "_operator_divassign", OT_INFIXASSIGN }, { "?%=?", "%=", "_operator_modassign", OT_INFIXASSIGN }, { "?+=?", "+=", "_operator_addassign", OT_INFIXASSIGN }, { "?-=?", "-=", "_operator_subassign", OT_INFIXASSIGN }, { "?<<=?", "<<=", "_operator_shiftleftassign", OT_INFIXASSIGN }, { "?>>=?", ">>=", "_operator_shiftrightassign", OT_INFIXASSIGN }, { "?&=?", "&=", "_operator_bitandassign", OT_INFIXASSIGN }, { "?^=?", "^=", "_operator_bitxorassign", OT_INFIXASSIGN }, { "?|=?", "|=", "_operator_bitorassign", OT_INFIXASSIGN }, { "0", "0", "_constant_zero", OT_CONSTANT }, { "1", "1", "_constant_one", OT_CONSTANT } }; const int numOps = sizeof( tableValues ) / sizeof( OperatorInfo ); std::map< std::string, OperatorInfo > table; void initialize() { for( int i = 0; i < numOps; ++i ) { table[ tableValues[i].inputName ] = tableValues[i]; } } } // namespace bool operatorLookup( std::string funcName, OperatorInfo &info ) { static bool init = false; if( !init ) { initialize(); } std::map< std::string, OperatorInfo >::const_iterator i = table.find( funcName ); if( i == table.end() ) { return false; } else { info = i->second; return true; } } } // namespace CodeGen