MCPcopy Create free account
hub / github.com/Samsung/UTopia / getData

Method getData

lib/constantanalysis/ASTValue.cpp:53–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51ASTValue::ASTValue(const ASTValue &Rhs) : IsArray(false) { *this = Rhs; }
52
53std::pair<bool, std::vector<ASTValueData>>
54ASTValue::getData(const Expr &E, const ASTContext &Ctx) const {
55
56 std::pair<bool, std::vector<ASTValueData>> Result =
57 std::make_pair(false, std::vector<ASTValueData>());
58
59 auto QTy = E.getType();
60 if (QTy.isNull()) {
61 return Result;
62 }
63
64 if (QTy->isIntegerType() || QTy->isEnumeralType()) {
65 auto Value = getValueAsReal(E, Ctx);
66 if (!Value.empty()) {
67 Result.second.emplace_back(ASTValueData::VType_INT, Value);
68 }
69 return Result;
70 }
71
72 if (QTy->isRealFloatingType()) {
73 auto Value = getValueAsReal(E, Ctx);
74 if (!Value.empty()) {
75 Result.second.emplace_back(ASTValueData::VType_FLOAT, Value);
76 }
77 return Result;
78 }
79
80 if (QTy->isAnyPointerType()) {
81 auto PointeeQTy = QTy->getPointeeType();
82 if (!PointeeQTy.getTypePtrOrNull() || !PointeeQTy->isAnyCharacterType()) {
83 return Result;
84 }
85
86 auto Value = getValueAsString(E, Ctx);
87 if (!Value.empty()) {
88 Result.second.emplace_back(ASTValueData::VType_STRING, Value);
89 }
90 return Result;
91 }
92
93 if (QTy->isArrayType()) {
94 Result.first = true;
95 Result.second = getDataForArray(E, Ctx);
96 }
97
98 return Result;
99}
100
101bool ASTValue::fromJson(Json::Value Json) {
102

Callers

nothing calls this directly

Calls 5

isNullMethod · 0.80
isIntegerTypeMethod · 0.80
emptyMethod · 0.80
getPointeeTypeMethod · 0.80
getTypeMethod · 0.45

Tested by

no test coverage detected