本文整理汇总了C++中ExpressionPtr::isLiteralString方法的典型用法代码示例。如果您正苦于以下问题:C++ ExpressionPtr::isLiteralString方法的具体用法?C++ ExpressionPtr::isLiteralString怎么用?C++ ExpressionPtr::isLiteralString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExpressionPtr
的用法示例。
在下文中一共展示了ExpressionPtr::isLiteralString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse_string_arg
static void parse_string_arg(ExpressionPtr exp, string &var, string &lit) {
if (exp->is(Expression::KindOfUnaryOpExpression)) {
UnaryOpExpressionPtr u(static_pointer_cast<UnaryOpExpression>(exp));
if (u->getOp() == '(') {
parse_string_arg(u->getExpression(), var, lit);
return;
}
} else if (exp->is(Expression::KindOfBinaryOpExpression)) {
BinaryOpExpressionPtr b(static_pointer_cast<BinaryOpExpression>(exp));
if (b->getOp() == '.') {
string v, l;
parse_string_arg(b->getExp2(), v, l);
if (v.empty()) {
parse_string_arg(b->getExp1(), var, lit);
lit += l;
return;
}
}
}
if (exp->isLiteralString()) {
var = "";
lit = exp->getLiteralString();
return;
}
var = exp->getText();
lit = "";
return;
}
示例2: if
bool
ExpressionList::flattenLiteralStrings(vector<ExpressionPtr> &literals) const {
for (unsigned i = 0; i < m_exps.size(); i++) {
ExpressionPtr e = m_exps[i];
if (e->is(Expression::KindOfArrayPairExpression)) {
ArrayPairExpressionPtr ap = dynamic_pointer_cast<ArrayPairExpression>(e);
if (ap->getName()) return false;
e = ap->getValue();
}
if (e->is(Expression::KindOfUnaryOpExpression)) {
UnaryOpExpressionPtr unary = dynamic_pointer_cast<UnaryOpExpression>(e);
if (unary->getOp() == T_ARRAY) {
ExpressionListPtr el =
dynamic_pointer_cast<ExpressionList>(unary->getExpression());
if (!el->flattenLiteralStrings(literals)) {
return false;
}
}
}
else if (e->isLiteralString()) {
literals.push_back(e);
} else {
return false;
}
}
return true;
}
示例3: outputCPPImpl
void QOpExpression::outputCPPImpl(CodeGenerator &cg, AnalysisResultPtr ar) {
if (!m_cppValue.empty()) {
cg_printf("%s", m_cppValue.c_str());
} else {
ExpressionPtr expYes = m_expYes ? m_expYes : m_condition;
bool wrapped = !isUnused();
if (wrapped) {
cg_printf("(");
}
wrapBoolean(cg, ar, m_condition);
if (isUnused()) {
cg_printf(" ? ");
outputUnneededExpr(cg, ar, expYes);
cg_printf(" : ");
outputUnneededExpr(cg, ar, m_expNo);
} else {
TypePtr typeYes = expYes->getActualType();
TypePtr typeNo = m_expNo->getActualType();
const char *castType =
typeYes && typeNo && Type::SameType(typeYes, typeNo) &&
!typeYes->is(Type::KindOfVariant) &&
expYes->isLiteralString() == m_expNo->isLiteralString()
? "" : "(Variant)";
cg_printf(" ? (%s(", castType);
expYes->outputCPP(cg, ar);
cg_printf(")) : (%s(", castType);
m_expNo->outputCPP(cg, ar);
cg_printf("))");
}
if (wrapped) {
cg_printf(")");
}
}
}
示例4: getConcatList
int BinaryOpExpression::getConcatList(ExpressionPtrVec &ev, ExpressionPtr exp,
bool &hasVoid, bool &hasLitStr) {
if (!exp->hasCPPTemp()) {
if (exp->is(Expression::KindOfUnaryOpExpression)) {
UnaryOpExpressionPtr u = static_pointer_cast<UnaryOpExpression>(exp);
if (u->getOp() == '(') {
return getConcatList(ev, u->getExpression(), hasVoid, hasLitStr);
}
} else if (exp->is(Expression::KindOfBinaryOpExpression)) {
BinaryOpExpressionPtr b = static_pointer_cast<BinaryOpExpression>(exp);
if (b->getOp() == '.') {
return getConcatList(ev, b->getExp1(), hasVoid, hasLitStr) +
getConcatList(ev, b->getExp2(), hasVoid, hasLitStr);
}
} else if (exp->is(Expression::KindOfEncapsListExpression)) {
EncapsListExpressionPtr e =
static_pointer_cast<EncapsListExpression>(exp);
if (e->getType() != '`') {
ExpressionListPtr el = e->getExpressions();
int num = 0;
for (int i = 0, s = el->getCount(); i < s; i++) {
ExpressionPtr exp = (*el)[i];
num += getConcatList(ev, exp, hasVoid, hasLitStr);
}
return num;
}
}
}
ev.push_back(exp);
bool isVoid = !exp->getActualType();
hasVoid |= isVoid;
hasLitStr |= exp->isLiteralString();
return isVoid ? 0 : 1;
}
示例5: outputStringExpr
static void outputStringExpr(CodeGenerator &cg, AnalysisResultPtr ar,
ExpressionPtr exp, bool asLitStr) {
if (asLitStr && exp->isLiteralString()) {
const std::string &s = exp->getLiteralString();
std::string enc = string_cplus_escape(s.c_str(), s.size());
cg_printf("\"%s\", %d", enc.c_str(), (int)s.size());
return;
}
TypePtr et(exp->getExpectedType());
exp->setExpectedType(Type::String);
exp->outputCPP(cg, ar);
exp->setExpectedType(et);
}
示例6: outputStringExpr
static void outputStringExpr(CodeGenerator &cg, AnalysisResultPtr ar,
ExpressionPtr exp, bool asLitStr) {
if (asLitStr && exp->isLiteralString()) {
const std::string &s = exp->getLiteralString();
char *enc = string_cplus_escape(s.c_str(), s.size());
cg_printf("\"%s\", %d", enc, s.size());
free(enc);
return;
}
bool close = false;
if ((exp->hasContext(Expression::LValue) &&
(!exp->getActualType()->is(Type::KindOfString) ||
(exp->getImplementedType() &&
!exp->getImplementedType()->is(Type::KindOfString))))
||
!exp->getType()->is(Type::KindOfString)) {
cg_printf("toString(");
close = true;
}
exp->outputCPP(cg, ar);
if (close) cg_printf(")");
}