void Parser::onVariable(Token *out, Token *exprs, Token *var, Token *value, bool constant /* = false */) { ExpressionPtr expList; if (exprs) { expList = exprs->exp; } else { expList = NEW_EXP0(ExpressionList); } ExpressionPtr exp; if (constant) { exp = NEW_EXP(ConstantExpression, var->text()); } else { exp = NEW_EXP(SimpleVariable, var->text()); } if (value) { exp = NEW_EXP(AssignmentExpression, exp, value->exp, false); } else { // implicit null, #147156 static const std::string s_null ("null"); ExpressionPtr null_exp (NEW_EXP(ConstantExpression, s_null)); exp = NEW_EXP(AssignmentExpression, exp, null_exp, false); } expList->addElement(exp); out->exp = expList; }
void FunctionCall::optimizeArgArray(AnalysisResultPtr ar) { if (m_extraArg <= 0) return; int paramCount = m_params->getOutputCount(); int iMax = paramCount - m_extraArg; bool isScalar = true; for (int i = iMax; i < paramCount; i++) { ExpressionPtr param = (*m_params)[i]; if (!param->isScalar()) { isScalar = false; break; } } if (isScalar) { ExpressionPtr argArrayPairs = ExpressionListPtr(new ExpressionList(getLocation(), Expression::KindOfExpressionList)); for (int i = iMax; i < paramCount; i++) { ExpressionPtr param = (*m_params)[i]; argArrayPairs->addElement(ArrayPairExpressionPtr( new ArrayPairExpression(param->getLocation(), Expression::KindOfArrayPairExpression, ExpressionPtr(), param, false))); } m_argArrayId = ar->registerScalarArray(argArrayPairs); } }
void Parser::onGlobalVar(Token *out, Token *exprs, Token *expr) { ExpressionPtr expList; if (exprs && exprs->exp) { expList = exprs->exp; } else { expList = NEW_EXP0(ExpressionList); } switch (expr->num) { case 0: expList->addElement(NEW_EXP(SimpleVariable, expr->text())); break; case 1: expList->addElement(createDynamicVariable(expr->exp)); break; default: ASSERT(false); } out->exp = expList; }
void Parser::onInterfaceName(Token *out, Token *names, Token *name) { ExpressionPtr expList; if (names) { expList = names->exp; } else { expList = NEW_EXP0(ExpressionList); } expList->addElement(NEW_EXP(ScalarExpression, T_STRING, name->text())); out->exp = expList; }
void Parser::onExprListElem(Token *out, Token *exprs, Token *expr) { ExpressionPtr expList; if (exprs && exprs->exp) { expList = exprs->exp; } else { expList = NEW_EXP0(ExpressionList); } expList->addElement(expr->exp); out->exp = expList; }
void Parser::onArrayPair(Token *out, Token *pairs, Token *name, Token *value, bool ref) { ExpressionPtr expList; if (pairs) { expList = pairs->exp; } else { expList = NEW_EXP0(ExpressionList); } ExpressionPtr nameExp = name ? name->exp : ExpressionPtr(); expList->addElement(NEW_EXP(ArrayPairExpression, nameExp, value->exp, ref)); out->exp = expList; }
void Parser::onParam(Token *out, Token *params, Token *type, Token *var, bool ref, Token *defValue) { ExpressionPtr expList; if (params) { expList = params->exp; } else { expList = NEW_EXP0(ExpressionList); } expList->addElement(NEW_EXP(ParameterExpression, type->text(), var->text(), ref, defValue ? defValue->exp : ExpressionPtr())); out->exp = expList; }