本文整理汇总了C++中ParameterExpressionPtr::isRef方法的典型用法代码示例。如果您正苦于以下问题:C++ ParameterExpressionPtr::isRef方法的具体用法?C++ ParameterExpressionPtr::isRef怎么用?C++ ParameterExpressionPtr::isRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParameterExpressionPtr
的用法示例。
在下文中一共展示了ParameterExpressionPtr::isRef方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: inferTypes
TypePtr ClosureExpression::inferTypes(AnalysisResultPtr ar, TypePtr type,
bool coerce) {
if (m_vars) {
assert(m_values && m_values->getCount() == m_vars->getCount());
// containing function's variable table (not closure function's)
VariableTablePtr variables = getScope()->getVariables();
// closure function's variable table
VariableTablePtr cvariables = m_func->getFunctionScope()->getVariables();
// force all reference use vars into variant for this function scope
for (int i = 0; i < m_vars->getCount(); i++) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*m_vars)[i]);
const string &name = param->getName();
if (param->isRef()) {
variables->forceVariant(ar, name, VariableTable::AnyVars);
}
}
// infer the types of the values
m_values->inferAndCheck(ar, Type::Some, false);
// coerce the types inferred from m_values into m_vars
for (int i = 0; i < m_vars->getCount(); i++) {
ExpressionPtr value = (*m_values)[i];
ParameterExpressionPtr var =
dynamic_pointer_cast<ParameterExpression>((*m_vars)[i]);
assert(!var->getExpectedType());
assert(!var->getImplementedType());
if (var->isRef()) {
var->setActualType(Type::Variant);
} else {
TypePtr origVarType(var->getActualType() ?
var->getActualType() : Type::Some);
var->setActualType(Type::Coerce(ar, origVarType, value->getType()));
}
}
{
// this lock isn't technically needed for thread-safety, since
// the dependencies are all set up. however, the lock assertions
// will fail if we don't acquire it.
GET_LOCK(m_func->getFunctionScope());
// bootstrap the closure function's variable table with
// the types from m_vars
for (int i = 0; i < m_vars->getCount(); i++) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*m_vars)[i]);
const string &name = param->getName();
cvariables->addParamLike(name, param->getType(), ar,
shared_from_this(),
getScope()->isFirstPass());
}
}
}
return s_ClosureType;
}
示例2: var
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);
}
}
}
示例3: optimize
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;
}
示例4: isRef
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();
}
示例5: 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);
}
}
}
示例6: outputCPPImpl
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("))");
}
示例7: analyzeProgram
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);
}
}
示例8: 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;
}
示例9: par
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());
}
}
}
示例10: outputCPPParamsCall
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");
}
}
示例11: outputCPPArgInjections
void MethodStatement::outputCPPArgInjections(CodeGenerator &cg,
AnalysisResultPtr ar,
const char *name,
ClassScopePtr cls,
FunctionScopePtr funcScope) {
if (cg.getOutput() != CodeGenerator::SystemCPP) {
if (m_params) {
int n = m_params->getCount();
cg_printf("INTERCEPT_INJECTION(\"%s\", ", name);
if (Option::GenArrayCreate && !hasRefParam()) {
ar->m_arrayIntegerKeySizes.insert(n);
outputParamArrayCreate(cg, true);
cg_printf(", %s);\n", funcScope->isRefReturn() ? "ref(r)" : "r");
} else {
cg_printf("(Array(ArrayInit(%d, true)", n);
for (int i = 0; i < n; i++) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*m_params)[i]);
const string ¶mName = param->getName();
cg_printf(".set%s(%d, %s%s)", param->isRef() ? "Ref" : "",
i, Option::VariablePrefix, paramName.c_str());
}
cg_printf(".create())), %s);\n",
funcScope->isRefReturn() ? "ref(r)" : "r");
}
} else {
cg_printf("INTERCEPT_INJECTION(\"%s\", null_array, %s);\n",
name, funcScope->isRefReturn() ? "ref(r)" : "r");
}
}
if (Option::GenRTTIProfileData && m_params) {
for (int i = 0; i < m_params->getCount(); i++) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*m_params)[i]);
if (param->hasRTTI()) {
const string ¶mName = param->getName();
int id = ar->getParamRTTIEntryId(cls, funcScope, paramName);
if (id != -1) {
cg_printf("RTTI_INJECTION(%s%s, %d);\n",
Option::VariablePrefix, paramName.c_str(), id);
}
}
}
}
}
示例12: param
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;
for (int i = vars->getCount() - 1; i >= 0; i--) {
ParameterExpressionPtr param(
dynamic_pointer_cast<ParameterExpression>((*vars)[i]));
assert(param);
if (param->getName() == "this") {
// "this" is automatically included.
// Once we get rid of all the callsites, make this an error
continue;
}
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());
}
}
}
示例13: inferTypes
TypePtr ClosureExpression::inferTypes(AnalysisResultPtr ar, TypePtr type,
bool coerce) {
m_func->inferTypes(ar);
if (m_values) m_values->inferAndCheck(ar, Type::Some, false);
if (m_vars) {
// containing function's variable table (not closure function's)
VariableTablePtr variables = getScope()->getVariables();
for (int i = 0; i < m_vars->getCount(); i++) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*m_vars)[i]);
string name = param->getName();
if (param->isRef()) {
variables->forceVariant(ar, name, VariableTable::AnyVars);
}
}
}
return Type::CreateObjectType("Closure");
}
示例14: analyzeProgram
void ClosureExpression::analyzeProgram(AnalysisResultPtr ar) {
m_func->analyzeProgram(ar);
if (m_vars) {
m_values->analyzeProgram(ar);
if (ar->getPhase() == AnalysisResult::AnalyzeAll) {
m_func->getFunctionScope()->setClosureVars(m_vars);
// 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]);
string name = param->getName();
{
Symbol *sym = variables->addSymbol(name);
sym->setClosureVar();
if (param->isRef()) {
sym->setRefClosureVar();
} else {
sym->clearRefClosureVar();
}
}
}
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]);
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();
}
}
}
}
}
示例15: param
ClosureExpression::ClosureExpression
(EXPRESSION_CONSTRUCTOR_PARAMETERS, FunctionStatementPtr func,
ExpressionListPtr vars)
: Expression(EXPRESSION_CONSTRUCTOR_PARAMETER_VALUES),
m_func(func) {
if (vars) {
m_vars = ExpressionListPtr
(new ExpressionList(vars->getScope(), vars->getLocation(),
KindOfExpressionList));
// push the vars in reverse order, not retaining duplicates
set<string> seenBefore;
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(),
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);
}
}
}
}