本文整理汇总了C++中SgType::isFloatType方法的典型用法代码示例。如果您正苦于以下问题:C++ SgType::isFloatType方法的具体用法?C++ SgType::isFloatType怎么用?C++ SgType::isFloatType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgType
的用法示例。
在下文中一共展示了SgType::isFloatType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
std::string writeSgBinaryOpZ3(SgBinaryOp* op, SgExpression* lhs, SgExpression* rhs) {
std::stringstream ss;
std::string opStr;
bool compAssign = false;
if (isSgCompoundAssignOp(op)) {
compAssign = true;
opStr = getSgCompoundAssignOp(isSgCompoundAssignOp(op));
}
else {
opStr = getSgBinaryOp(op);
}
ROSE_ASSERT(opStr != "unknown");
std::string rhsstring;
std::string lhsstring;
lhsstring = getSgExpressionString(lhs);
SgType* lhstyp;
SgType* rhstyp;
if (isSgArrayType(lhs->get_type())) {
lhstyp = isSgArrayType(lhs->get_type())->get_base_type();
}
else {
lhstyp = lhs->get_type();
}
if (isSgArrayType(rhs->get_type())) {
rhstyp = isSgArrayType(rhs->get_type())->get_base_type();
}
else {
rhstyp = rhs->get_type();
}
if (isSgEnumType(lhs->get_type())) {
}
else {
ROSE_ASSERT(lhstyp == rhstyp);
}
if (isSgValueExp(rhs)) {
rhsstring = getSgValueExp(isSgValueExp(rhs));
}
else if (isSgUnaryOp(rhs)) {
rhsstring = getSgUnaryOp(isSgUnaryOp(rhs));
}
else {
rhsstring = getSgExpressionString(rhs);
}
if (opStr == "/" && lhstyp->isIntegerType()) {
opStr = "cdiv";
}
if (opStr == "assign" || compAssign) {
if (isSgVarRefExp(lhs)) {
SgVarRefExp* lhsSgVarRefExp = isSgVarRefExp(lhs);
int instances = SymbolToInstances[lhsSgVarRefExp->get_symbol()];
std::stringstream instanceName;
SymbolToInstances[lhsSgVarRefExp->get_symbol()] = instances + 1;
std::string lhsname = SymbolToZ3[lhsSgVarRefExp->get_symbol()];
instanceName << lhsname << "_" << (instances+1);
SgType* varType = lhsSgVarRefExp->get_type();
std::string typeZ3;
if (varType->isFloatType()) {
typeZ3 = "Real";
}
else if (varType->isIntegerType()) {
typeZ3 = "Int";
}
else if (isSgEnumType(varType)) {
typeZ3 = isSgEnumType(varType)->get_name().getString();
}
else {
typeZ3 = "Unknown";
}
ss << "(declare-fun " << instanceName.str() << " () " << typeZ3 << ")\n";
if (!compAssign) {
ss << "(assert (= " << instanceName.str() << " " << rhsstring << "))";
}
else {
std::stringstream oldInstanceName;
oldInstanceName << lhsname << "_" << instances;
ss << "(assert (= " << instanceName.str() << " (" << opStr << " " << oldInstanceName.str() << " " << rhsstring << ")))";
}
}
else {
ROSE_ASSERT(isSgPntrArrRefExp(lhs));
std::string u_type;
SgPntrArrRefExp* lhspntr = isSgPntrArrRefExp(lhs);
SgVarRefExp* varlhspntr = isSgVarRefExp(lhspntr->get_lhs_operand());
SgArrayType* arrTy = isSgArrayType(varlhspntr->get_type());
if (arrTy->get_base_type()->isIntegerType()) {
u_type = "Int";
}
else if (arrTy->get_base_type()->isFloatType()) {
u_type = "Real";
}
else {
std::cout << "unknown base type for array" << std::endl;
ROSE_ASSERT(false);
}
std::stringstream oldInstanceName;
SgVarRefExp* varexp = isSgVarRefExp((isSgPntrArrRefExp(lhs))->get_lhs_operand());
//.........这里部分代码省略.........
示例2: initializeVariable
std::string initializeVariable(SgInitializedName* initName) {
//if array type we need to get the index expression
std::string index_expression_string;
std::stringstream nameStringStream;
SgName initNameName = initName->get_qualified_name();
SgSymbol* initNameSym = initName->search_for_symbol_from_symbol_table();
if (variablesOfNameX.find(initNameName.getString()) == variablesOfNameX.end()) {
nameStringStream << initNameName.getString() << "_0";
variablesOfNameX[initNameName.getString()] = 1;
}
else {
int occurrence = variablesOfNameX[initNameName.getString()];
nameStringStream << initNameName.getString() << "_" << occurrence;
variablesOfNameX[initNameName.getString()] = occurrence+1;
}
SymbolToZ3[initNameSym] = nameStringStream.str();
SymbolToInstances[initNameSym] = 0;
SgType* initNameType = initName->get_type();
std::string typeZ3;
if (initNameType->isIntegerType()) {
typeZ3 = "Int";
}
else if (initNameType->isFloatType()) {
typeZ3 = "Real";
}
else if (isSgArrayType(initNameType)) {
SgArrayType* arrTyp = isSgArrayType(initNameType);
ROSE_ASSERT(arrTyp != NULL);
SgType* underlying_type = arrTyp->get_base_type();
std::string array_typeZ3;
if (underlying_type->isIntegerType()) {
array_typeZ3 = "Int";
}
else if (underlying_type->isFloatType()) {
array_typeZ3 = "Real";
}
else {
std::cout << "unknown underlying type of array!" << std::endl;
std::cout << underlying_type->class_name() << std::endl;
ROSE_ASSERT(false);
}
SgExpression* ind = arrTyp->get_index();
std::stringstream arrStr;
index_expression_string = getSgExpressionString(ind);
typeZ3 = "(Array Int " + array_typeZ3 + ")";
}
else if (isSgClassType(initNameType)) {
std::cout << "structs are not yet implemented" << std::endl;
ROSE_ASSERT(false);
}
else if (isSgPointerType(initNameType)) {
std::cout << "pointers are not yet implemented" << std::endl;
ROSE_ASSERT(false);
}
else if (isSgEnumType(initNameType)) {
SgEnumType* et = isSgEnumType(initNameType);
SgEnumDeclaration* enum_d = isSgEnumDeclaration(et->getAssociatedDeclaration());
getSgDeclarationStatement(enum_d);
typeZ3 = et->get_name().getString();
}
else {
std::cout << "unknown type: " << initNameType->class_name() << std::endl;
ROSE_ASSERT(false);
}
std::string name = nameStringStream.str() + "_0";
std::stringstream streamZ3;
if (isSgArrayType(initNameType)) {
streamZ3 << "(declare-const " << name << " " << typeZ3 << ")";
streamZ3 << "\n(declare-fun " << name << "_len () Int)";
streamZ3 << "\n(assert (= " << name << "_len " << index_expression_string << "))";
#ifdef ARRAY_TEST
std::cout << "arrStream: " << streamZ3.str() << std::endl;
#endif
}
else if (isSgEnumType(initNameType)) {
streamZ3 << "(declare-const " << name << " " << typeZ3 << ")";
}
else {
streamZ3 << "(declare-fun " << name << " () " << typeZ3 << ")";
}
return streamZ3.str();
}