本文整理汇总了C++中ParameterExpressionPtr类的典型用法代码示例。如果您正苦于以下问题:C++ ParameterExpressionPtr类的具体用法?C++ ParameterExpressionPtr怎么用?C++ ParameterExpressionPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ParameterExpressionPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cg_printf
void ClosureExpression::outputCPPImpl(CodeGenerator &cg,
AnalysisResultPtr ar) {
cg_printf("%sClosure((NEWOBJ(%sClosure)())->create(\"%s\", ",
Option::SmartPtrPrefix, Option::ClassPrefix,
m_func->getOriginalName().c_str());
if (m_vars && m_vars->getCount()) {
cg_printf("Array(ArrayInit(%d, false, true)", m_vars->getCount());
for (int i = 0; i < m_vars->getCount(); i++) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*m_vars)[i]);
ExpressionPtr value = (*m_values)[i];
cg_printf(".set%s(\"%s\", ",
param->isRef() ? "Ref" : "", param->getName().c_str());
value->outputCPP(cg, ar);
cg_printf(")");
}
cg_printf(".create())");
} else {
cg_printf("Array()");
}
cg_printf("))");
}
示例2: spc
bool AliasManager::optimize(AnalysisResultPtr ar, MethodStatementPtr m) {
m_arp = ar;
m_variables = ar->getScope()->getVariables();
if (!m_variables->isPseudoMainTable()) {
m_variables->clearUsed();
}
if (ExpressionListPtr pPtr = m->getParams()) {
ExpressionList ¶ms = *pPtr;
for (int i = params.getCount(); i--; ) {
ParameterExpressionPtr p = spc(ParameterExpression, params[i]);
AliasInfo &ai = m_aliasInfo[p->getName()];
if (p->isRef()) {
ai.setIsRefTo();
}
}
}
collectAliasInfoRecur(m->getStmts());
for (AliasInfoMap::iterator it = m_aliasInfo.begin(),
end = m_aliasInfo.end(); it != end; ++it) {
if (m_variables->isGlobal(it->first) ||
m_variables->isStatic(it->first)) {
it->second.setIsGlobal();
}
}
canonicalizeRecur(m->getStmts());
return m_changed;
}
示例3: onParse
void FunctionStatement::onParse(AnalysisResultConstPtr ar, FileScopePtr scope) {
// Correctness checks are normally done before adding function to scope.
if (m_params) {
for (int i = 0; i < m_params->getCount(); i++) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*m_params)[i]);
if (param->hasTypeHint() && param->defaultValue()) {
param->compatibleDefault();
}
}
}
// note it's important to add to scope, not a pushed FunctionContainer,
// as a function may be declared inside a class's method, yet this function
// is a global function, not a class method.
FunctionScopePtr fs = onInitialParse(ar, scope);
FunctionScope::RecordFunctionInfo(m_name, fs);
if (!scope->addFunction(ar, fs)) {
m_ignored = true;
return;
}
if (Option::PersistenceHook) {
fs->setPersistent(Option::PersistenceHook(fs, scope));
}
}
示例4: checkArgumentsToPromote
void InterfaceStatement::checkArgumentsToPromote(
FileScopeRawPtr scope, ExpressionListPtr promotedParams, int type) {
if (!m_stmt) {
return;
}
for (int i = 0; i < m_stmt->getCount(); i++) {
MethodStatementPtr meth =
dynamic_pointer_cast<MethodStatement>((*m_stmt)[i]);
if (meth && meth->isNamed("__construct")) {
ExpressionListPtr params = meth->getParams();
if (params) {
for (int i = 0; i < params->getCount(); i++) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*params)[i]);
if (param->getModifier() != 0) {
if (type == T_TRAIT || type == T_INTERFACE) {
param->parseTimeFatal(scope,
Compiler::InvalidAttribute,
"Constructor parameter promotion "
"not allowed on traits or interfaces");
}
if (promotedParams) {
promotedParams->addElement(param);
}
}
}
}
return; // nothing else to look at
}
}
}
示例5: Expression
ClosureExpression::ClosureExpression
(EXPRESSION_CONSTRUCTOR_PARAMETERS, FunctionStatementPtr func,
ExpressionListPtr vars)
: Expression(EXPRESSION_CONSTRUCTOR_PARAMETER_VALUES),
m_func(func), m_vars(vars) {
if (m_vars) {
m_values = ExpressionListPtr
(new ExpressionList(m_vars->getScope(), m_vars->getLocation(),
KindOfExpressionList));
for (int i = 0; i < m_vars->getCount(); i++) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*m_vars)[i]);
string name = param->getName();
SimpleVariablePtr var(new SimpleVariable(param->getScope(),
param->getLocation(),
KindOfSimpleVariable,
name));
if (param->isRef()) {
var->setContext(RefValue);
}
m_values->addElement(var);
}
}
}
示例6: assert
void FunctionScope::setParamCounts(AnalysisResultConstPtr ar, int minParam,
int numDeclParam) {
if (minParam >= 0) {
m_minParam = minParam;
m_numDeclParams = numDeclParam;
} else {
assert(numDeclParam == minParam);
}
assert(m_minParam >= 0 && m_numDeclParams >= m_minParam);
assert(IMPLIES(hasVariadicParam(), m_numDeclParams > 0));
if (m_numDeclParams > 0) {
m_paramNames.resize(m_numDeclParams);
m_refs.resize(m_numDeclParams);
if (m_stmt) {
MethodStatementPtr stmt = dynamic_pointer_cast<MethodStatement>(m_stmt);
ExpressionListPtr params = stmt->getParams();
for (int i = 0; i < m_numDeclParams; i++) {
if (stmt->isRef(i)) m_refs[i] = true;
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*params)[i]);
m_paramNames[i] = param->getName();
}
assert(m_paramNames.size() == m_numDeclParams);
}
}
}
示例7: assert
bool MethodStatement::isRef(int index /* = -1 */) const {
if (index == -1) return m_ref;
assert(index >= 0 && index < m_params->getCount());
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*m_params)[index]);
return param->isRef();
}
示例8: addParamRTTI
void MethodStatement::addParamRTTI(AnalysisResultPtr ar) {
FunctionScopePtr func =
dynamic_pointer_cast<FunctionScope>(ar->getScope());
VariableTablePtr variables = func->getVariables();
if (variables->getAttribute(VariableTable::ContainsDynamicVariable) ||
variables->getAttribute(VariableTable::ContainsExtract)) {
return;
}
for (int i = 0; i < m_params->getCount(); i++) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*m_params)[i]);
const string ¶mName = param->getName();
if (variables->isLvalParam(paramName)) continue;
TypePtr paramType = param->getActualType();
if ((paramType->is(Type::KindOfVariant) ||
paramType->is(Type::KindOfSome)) &&
!param->isRef()) {
param->setHasRTTI();
ClassScopePtr cls = ar->getClassScope();
ar->addParamRTTIEntry(cls, func, paramName);
const string funcId = ar->getFuncId(cls, func);
ar->addRTTIFunction(funcId);
}
}
}
示例9: ASSERT
void FunctionScope::setParamCounts(AnalysisResultPtr ar, int minParam,
int maxParam) {
m_minParam = minParam;
m_maxParam = maxParam;
ASSERT(m_minParam >= 0 && m_maxParam >= m_minParam);
if (m_maxParam > 0) {
m_paramNames.resize(m_maxParam);
m_paramTypes.resize(m_maxParam);
m_paramTypeSpecs.resize(m_maxParam);
m_refs.resize(m_maxParam);
if (m_stmt) {
MethodStatementPtr stmt = dynamic_pointer_cast<MethodStatement>(m_stmt);
ExpressionListPtr params = stmt->getParams();
for (int i = 0; i < m_maxParam; i++) {
if (stmt->isRef(i)) m_refs[i] = true;
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*params)[i]);
m_paramNames[i] = param->getName();
m_paramTypeSpecs[i] = param->getTypeSpec(ar);
}
}
}
}
示例10: assert
void Symbol::beginLocal(BlockScopeRawPtr scope) {
m_prevCoerced = m_coerced;
if (isClosureVar()) {
ExpressionListPtr useVars =
scope->getContainingFunction()->getClosureVars();
assert(useVars);
// linear scan for now, since most use var lists are
// fairly short
bool found = false;
for (int i = 0; i < useVars->getCount(); i++) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*useVars)[i]);
if (m_name == param->getName()) {
// bootstrap use var with parameter type
m_coerced = param->getType();
found = true;
break;
}
}
if (!found) assert(false);
assert(!isRefClosureVar() ||
(m_coerced && m_coerced->is(Type::KindOfVariant)));
} else {
m_coerced.reset();
}
}
示例11: getFunctionScope
void ClosureExpression::analyzeProgram(AnalysisResultPtr ar) {
m_func->analyzeProgram(ar);
if (m_vars) {
m_values->analyzeProgram(ar);
if (ar->getPhase() == AnalysisResult::AnalyzeAll) {
getFunctionScope()->addUse(m_func->getFunctionScope(),
BlockScope::UseKindClosure);
m_func->getFunctionScope()->setClosureVars(m_vars);
// closure function's variable table (not containing function's)
VariableTablePtr variables = m_func->getFunctionScope()->getVariables();
VariableTablePtr containing = getFunctionScope()->getVariables();
for (int i = 0; i < m_vars->getCount(); i++) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*m_vars)[i]);
const string &name = param->getName();
{
Symbol *containingSym = containing->addDeclaredSymbol(name, param);
containingSym->setPassClosureVar();
Symbol *sym = variables->addDeclaredSymbol(name, param);
sym->setClosureVar();
sym->setDeclaration(ConstructPtr());
if (param->isRef()) {
sym->setRefClosureVar();
sym->setUsed();
} else {
sym->clearRefClosureVar();
sym->clearUsed();
}
}
}
return;
}
if (ar->getPhase() == AnalysisResult::AnalyzeFinal) {
// closure function's variable table (not containing function's)
VariableTablePtr variables = m_func->getFunctionScope()->getVariables();
for (int i = 0; i < m_vars->getCount(); i++) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*m_vars)[i]);
const string &name = param->getName();
// so we can assign values to them, instead of seeing CVarRef
Symbol *sym = variables->getSymbol(name);
if (sym && sym->isParameter()) {
sym->setLvalParam();
}
}
}
}
FunctionScopeRawPtr container =
getFunctionScope()->getContainingNonClosureFunction();
if (container && container->isStatic()) {
m_func->getModifiers()->add(T_STATIC);
}
}
示例12: hasRefParam
bool MethodStatement::hasRefParam() {
for (int i = 0; i < m_params->getCount(); i++) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*m_params)[i]);
if (param->isRef()) return true;
}
return false;
}
示例13: fixupSelfAndParentTypehints
void MethodStatement::fixupSelfAndParentTypehints(ClassScopePtr scope) {
if (m_params) {
for (int i = 0; i < m_params->getCount(); i++) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*m_params)[i]);
param->fixupSelfAndParentTypehints(scope);
}
}
}
示例14: Expression
ClosureExpression::ClosureExpression
(EXPRESSION_CONSTRUCTOR_PARAMETERS, FunctionStatementPtr func,
ExpressionListPtr vars)
: Expression(EXPRESSION_CONSTRUCTOR_PARAMETER_VALUES(ClosureExpression)),
m_func(func) {
if (vars) {
m_vars = ExpressionListPtr
(new ExpressionList(vars->getScope(), vars->getLocation()));
// push the vars in reverse order, not retaining duplicates
std::set<string> seenBefore;
// Because PHP is insane you can have a use variable with the same
// name as a param name.
// In that case, params win (which is different than zend but much easier)
ExpressionListPtr bodyParams = m_func->getParams();
if (bodyParams) {
int nParams = bodyParams->getCount();
for (int i = 0; i < nParams; i++) {
ParameterExpressionPtr par(
static_pointer_cast<ParameterExpression>((*bodyParams)[i]));
seenBefore.insert(par->getName());
}
}
for (int i = vars->getCount() - 1; i >= 0; i--) {
ParameterExpressionPtr param(
dynamic_pointer_cast<ParameterExpression>((*vars)[i]));
assert(param);
if (seenBefore.find(param->getName().c_str()) == seenBefore.end()) {
seenBefore.insert(param->getName().c_str());
m_vars->insertElement(param);
}
}
if (m_vars) {
m_values = ExpressionListPtr
(new ExpressionList(m_vars->getScope(), m_vars->getLocation()));
for (int i = 0; i < m_vars->getCount(); i++) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*m_vars)[i]);
const string &name = param->getName();
SimpleVariablePtr var(new SimpleVariable(param->getScope(),
param->getLocation(),
name));
if (param->isRef()) {
var->setContext(RefValue);
}
m_values->addElement(var);
}
assert(m_vars->getCount() == m_values->getCount());
}
}
}
示例15: isUserFunction
void FunctionScope::outputCPPParamsCall(CodeGenerator &cg,
AnalysisResultPtr ar,
bool aggregateParams) {
if (isVariableArgument()) {
cg.printf("num_args, ");
}
bool userFunc = isUserFunction();
ExpressionListPtr params;
if (userFunc) {
MethodStatementPtr stmt = dynamic_pointer_cast<MethodStatement>(m_stmt);
params = stmt->getParams();
}
if (aggregateParams) {
cg.printf("Array(");
if (m_maxParam) {
// param arrays are always vectors
cg.printf("ArrayInit(%d, true).", m_maxParam);
}
}
for (int i = 0; i < m_maxParam; i++) {
if (i > 0) cg.printf(aggregateParams ? "." : ", ");
bool isRef;
if (userFunc) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*params)[i]);
isRef = param->isRef();
if (aggregateParams) {
cg.printf("set%s(%d, v_%s", isRef ? "Ref" : "", i,
param->getName().c_str());
} else {
cg.printf("%sv_%s%s",
isRef ? "ref(" : "", param->getName().c_str(),
isRef ? ")" : "");
}
} else {
isRef = isRefParam(i);
if (aggregateParams) {
cg.printf("set%s(%d, a%d", isRef ? "Ref" : "", i, i);
} else {
cg.printf("%sa%d%s",
isRef ? "ref(" : "", i, isRef ? ")" : "");
}
}
if (aggregateParams) cg.printf(")");
}
if (aggregateParams) {
if (m_maxParam) cg.printf(".create()");
cg.printf(")");
}
if (isVariableArgument()) {
if (aggregateParams || m_maxParam > 0) cg.printf(",");
cg.printf("args");
}
}