This machine mirrors various open-source projects.
20 Gbit/s uplink.
If there are any issues or you want another project mirrored, please contact
mirror-service -=AT=- netcologne DOT de !
00001 //===-- basic/PrimitiveOps.cpp -------------------------------- -*- C++ -*-===// 00002 // 00003 // This file is distributed under the MIT license. See LICENSE.txt for details. 00004 // 00005 // Copyright (C) 2010, Stephen Wilson 00006 // 00007 //===----------------------------------------------------------------------===// 00008 00009 #include "comma/basic/IdentifierInfo.h" 00010 #include "comma/basic/PrimitiveOps.h" 00011 00012 using namespace comma::primitive_ops; 00013 00014 bool comma::primitive_ops::denotesBinaryOp(const llvm::StringRef &string) 00015 { 00016 const char* name = string.data(); 00017 size_t length = string.size(); 00018 00019 if (length == 1) { 00020 switch (*name) { 00021 default: 00022 return false; 00023 case '=': 00024 case '+': 00025 case '*': 00026 case '-': 00027 case '>': 00028 case '<': 00029 case '/': 00030 return true; 00031 } 00032 } 00033 else if (length == 2) { 00034 switch (*name) { 00035 default: 00036 return false; 00037 case '/': 00038 case '<': 00039 case '>': 00040 return name[1] == '='; 00041 00042 case '*': 00043 return name[1] == '*'; 00044 00045 case 'o': 00046 return name[1] == 'r'; 00047 } 00048 } 00049 else if (length == 3) { 00050 return (string.compare("and") == 0 || 00051 string.compare("not") == 0 || 00052 string.compare("xor") == 0 || 00053 string.compare("mod") == 0 || 00054 string.compare("rem") == 0); 00055 } 00056 return false; 00057 } 00058 00059 bool comma::primitive_ops::denotesUnaryOp(const llvm::StringRef &string) 00060 { 00061 const char *name = string.data(); 00062 size_t length = string.size(); 00063 00064 if (length == 1) { 00065 switch (*name) { 00066 default: 00067 return false; 00068 case '+': 00069 case '-': 00070 return true; 00071 } 00072 } 00073 else 00074 return string.compare("not") == 0; 00075 } 00076 00077 bool comma::primitive_ops::denotesOperator(const llvm::StringRef &string) 00078 { 00079 return denotesBinaryOp(string) || denotesUnaryOp(string); 00080 } 00081 00082 bool 00083 comma::primitive_ops::denotesBinaryOp(const comma::IdentifierInfo *idInfo) 00084 { 00085 return denotesBinaryOp(idInfo->getString()); 00086 } 00087 00088 bool 00089 comma::primitive_ops::denotesUnaryOp(const comma::IdentifierInfo *idInfo) 00090 { 00091 return denotesUnaryOp(idInfo->getString()); 00092 } 00093 00094 bool 00095 comma::primitive_ops::denotesOperator(const comma::IdentifierInfo *idInfo) 00096 { 00097 llvm::StringRef name(idInfo->getString()); 00098 return denotesBinaryOp(name) || denotesUnaryOp(name); 00099 } 00100