本文整理汇总了C++中ParameterExpressionPtr::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ ParameterExpressionPtr::getName方法的具体用法?C++ ParameterExpressionPtr::getName怎么用?C++ ParameterExpressionPtr::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParameterExpressionPtr
的用法示例。
在下文中一共展示了ParameterExpressionPtr::getName方法的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: 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);
}
}
示例3: 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");
}
}
示例4: outputCPP
void FunctionScope::outputCPP(CodeGenerator &cg, AnalysisResultPtr ar) {
for (int i = 0; i < m_callTempCountMax; i++) {
cg_printf("Variant %s%d;\n", Option::EvalOrderTempPrefix, i);
}
ExpressionListPtr params =
dynamic_pointer_cast<MethodStatement>(getStmt())->getParams();
/* Typecheck parameters */
for (size_t i = 0; i < m_paramTypes.size(); i++) {
TypePtr specType = m_paramTypeSpecs[i];
if (!specType)
continue;
if (specType->is(Type::KindOfSome) || specType->is(Type::KindOfAny)
|| specType->is(Type::KindOfVariant))
continue;
/* If there's any possible runtime conflict, this will be turned into
* a Variant; if it hasn't been, then we don't need to worry */
if (!getParamType(i)->is(Type::KindOfVariant))
continue;
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*params)[i]);
/* Insert runtime checks. */
if (specType->is(Type::KindOfArray)) {
cg_printf("if(!%s%s.isArray())\n",
Option::VariablePrefix, param->getName().c_str());
cg_printf(" throw_unexpected_argument_type"
"(%d,\"%s\",\"array\",%s%s);\n",
i, m_name.c_str(),
Option::VariablePrefix, param->getName().c_str());
} else if (specType->is(Type::KindOfObject)) {
cg_printf("if(!%s%s.instanceof(\"%s\"))\n", Option::VariablePrefix,
param->getName().c_str(), specType->getName().c_str());
cg_printf(" throw_unexpected_argument_type(%d,\"%s\",\"%s\",%s%s);\n",
i, m_name.c_str(), specType->getName().c_str(),
Option::VariablePrefix, param->getName().c_str());
} else {
Logger::Error("parameter %d of %s: improper type hint %s",
i, m_name.c_str(), specType->toString().c_str());
return;
}
}
BlockScope::outputCPP(cg, ar);
}
示例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: setParamCounts
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);
}
}
}
}
示例7: beginLocal
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();
}
}
示例8: 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("))");
}
示例9: 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);
}
}
}
示例10: setParamCounts
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);
}
}
}
示例11: 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;
}
示例12: 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);
}
}
}
}
}
示例13: 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();
}
}
}
}
}
示例14: 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());
}
}
}
示例15: outputCPPStaticMethodWrapper
void MethodStatement::outputCPPStaticMethodWrapper(CodeGenerator &cg,
AnalysisResultPtr ar,
const char *cls) {
if (!m_modifiers->isStatic() || !m_stmt) return;
CodeGenerator::Context context = cg.getContext();
FunctionScopePtr funcScope = m_funcScope.lock();
bool isWrapper = context == CodeGenerator::CppTypedParamsWrapperDecl ||
context == CodeGenerator::CppTypedParamsWrapperImpl;
bool needsWrapper = isWrapper ||
(Option::HardTypeHints && funcScope->needsTypeCheckWrapper());
m_modifiers->outputCPP(cg, ar);
TypePtr type = funcScope->getReturnType();
if (type) {
type->outputCPPDecl(cg, ar);
} else {
cg_printf("void");
}
cg_printf(" %s%s(", needsWrapper && !isWrapper ?
Option::TypedMethodPrefix : Option::MethodPrefix,
cg.formatLabel(m_name).c_str());
if (!isWrapper) cg.setContext(CodeGenerator::CppStaticMethodWrapper);
funcScope->outputCPPParamsDecl(cg, ar, m_params, true);
cg_printf(") { %s%s%s(", type ? "return " : "",
needsWrapper && !isWrapper ?
Option::TypedMethodImplPrefix : Option::MethodImplPrefix,
cg.formatLabel(m_name).c_str());
cg_printf("%s%s::s_class_name", Option::ClassPrefix, cls);
cg.setContext(context);
if (funcScope->isVariableArgument()) {
cg_printf(", num_args");
}
if (m_params) {
for (int i = 0; i < m_params->getCount(); i++) {
ParameterExpressionPtr param =
dynamic_pointer_cast<ParameterExpression>((*m_params)[i]);
ASSERT(param);
cg_printf(", %s%s", Option::VariablePrefix, param->getName().c_str());
}
}
if (funcScope->isVariableArgument()) {
cg_printf(", args");
}
cg_printf("); }\n");
if (!isWrapper && needsWrapper) {
cg.setContext(CodeGenerator::CppTypedParamsWrapperDecl);
outputCPPStaticMethodWrapper(cg, ar, cls);
cg.setContext(context);
}
}