本文整理汇总了C++中ExpressionPtr::get方法的典型用法代码示例。如果您正苦于以下问题:C++ ExpressionPtr::get方法的具体用法?C++ ExpressionPtr::get怎么用?C++ ExpressionPtr::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExpressionPtr
的用法示例。
在下文中一共展示了ExpressionPtr::get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hasSubExpr
bool Expression::hasSubExpr(ExpressionPtr sub) const {
if (this == sub.get()) return true;
for (int i = getKidCount(); i--; ) {
ExpressionPtr kid = getNthExpr(i);
if (kid && kid->hasSubExpr(sub)) return true;
}
return false;
}
示例2: canonCompare
bool SimpleVariable::canonCompare(ExpressionPtr e) const {
return Expression::canonCompare(e) &&
getName() == static_cast<SimpleVariable*>(e.get())->getName();
}
示例3: canonCompare
bool BinaryOpExpression::canonCompare(ExpressionPtr e) const {
return Expression::canonCompare(e) &&
getOp() == static_cast<BinaryOpExpression*>(e.get())->getOp();
}
示例4: inliner
ExpressionPtr FunctionCall::inliner(AnalysisResultConstPtr ar,
ExpressionPtr obj, std::string localThis) {
FunctionScopePtr fs = getFunctionScope();
if (m_noInline || !fs || fs == m_funcScope || !m_funcScope->getStmt()) {
return ExpressionPtr();
}
BlockScope::s_jobStateMutex.lock();
if (m_funcScope->getMark() == BlockScope::MarkProcessing) {
fs->setForceRerun(true);
BlockScope::s_jobStateMutex.unlock();
return ExpressionPtr();
}
ReadLock lock(m_funcScope->getInlineMutex());
BlockScope::s_jobStateMutex.unlock();
if (!m_funcScope->getInlineAsExpr()) {
return ExpressionPtr();
}
if (m_funcScope->getInlineSameContext() &&
m_funcScope->getContainingClass() &&
m_funcScope->getContainingClass() != getClassScope()) {
/*
The function contains a context sensitive construct such as
call_user_func (context sensitive because it could call
array('parent', 'foo')) so its not safe to inline it
into a different context.
*/
return ExpressionPtr();
}
MethodStatementPtr m
(dynamic_pointer_cast<MethodStatement>(m_funcScope->getStmt()));
VariableTablePtr vt = fs->getVariables();
int nAct = m_params ? m_params->getCount() : 0;
int nMax = m_funcScope->getMaxParamCount();
if (nAct < m_funcScope->getMinParamCount() || !m->getStmts()) {
return ExpressionPtr();
}
InlineCloneInfo info(m_funcScope);
info.elist = ExpressionListPtr(new ExpressionList(
getScope(), getLocation(),
ExpressionList::ListKindWrapped));
std::ostringstream oss;
oss << fs->nextInlineIndex() << "_" << m_name << "_";
std::string prefix = oss.str();
if (obj) {
info.callWithThis = true;
if (!obj->isThis()) {
SimpleVariablePtr var
(new SimpleVariable(getScope(),
obj->getLocation(),
prefix + "this"));
var->updateSymbol(SimpleVariablePtr());
var->getSymbol()->setHidden();
var->getSymbol()->setUsed();
var->getSymbol()->setReferenced();
AssignmentExpressionPtr ae
(new AssignmentExpression(getScope(),
obj->getLocation(),
var, obj, false));
info.elist->addElement(ae);
info.sepm[var->getName()] = var;
info.localThis = var->getName();
}
} else {
if (m_classScope) {
if (!m_funcScope->isStatic()) {
ClassScopeRawPtr oCls = getOriginalClass();
FunctionScopeRawPtr oFunc = getOriginalFunction();
if (oCls && !oFunc->isStatic() &&
(oCls == m_classScope ||
oCls->derivesFrom(ar, m_className, true, false))) {
info.callWithThis = true;
info.localThis = localThis;
}
}
if (!isSelf() && !isParent() && !isStatic()) {
info.staticClass = m_className;
}
}
}
ExpressionListPtr plist = m->getParams();
int i;
for (i = 0; i < nMax || i < nAct; i++) {
ParameterExpressionPtr param
(i < nMax ?
dynamic_pointer_cast<ParameterExpression>((*plist)[i]) :
ParameterExpressionPtr());
ExpressionPtr arg = i < nAct ? (*m_params)[i] :
Clone(param->defaultValue(), getScope());
SimpleVariablePtr var
(new SimpleVariable(getScope(),
//.........这里部分代码省略.........
示例5: cloneForInlineRecur
static ExpressionPtr cloneForInlineRecur(InlineCloneInfo &info,
ExpressionPtr exp,
const std::string &prefix,
AnalysisResultConstPtr ar,
FunctionScopePtr scope) {
exp->getOriginalScope(); // make sure to cache the original scope
exp->setBlockScope(scope);
for (int i = 0, n = exp->getKidCount(); i < n; i++) {
if (ExpressionPtr k = exp->getNthExpr(i)) {
exp->setNthKid(i, cloneForInlineRecur(info, k, prefix, ar, scope));
}
}
StaticClassName *scn = dynamic_cast<StaticClassName*>(exp.get());
if (scn && scn->isStatic() && !info.staticClass.empty()) {
scn->resolveStatic(info.staticClass);
}
switch (exp->getKindOf()) {
case Expression::KindOfSimpleVariable:
{
SimpleVariablePtr sv(dynamic_pointer_cast<SimpleVariable>(exp));
if (sv->isSuperGlobal()) break;
string name;
if (sv->isThis()) {
if (!info.callWithThis) {
if (!sv->hasContext(Expression::ObjectContext)) {
exp = sv->makeConstant(ar, "null");
} else {
// This will produce the wrong error
// we really want a "throw_fatal" ast node.
exp = sv->makeConstant(ar, "null");
}
break;
}
if (info.localThis.empty()) break;
name = info.localThis;
} else {
name = prefix + sv->getName();
}
SimpleVariablePtr rep(new SimpleVariable(
exp->getScope(), exp->getLocation(), name));
rep->copyContext(sv);
rep->updateSymbol(SimpleVariablePtr());
rep->getSymbol()->setHidden();
// Conservatively set flags to prevent
// the alias manager from getting confused.
// On the next pass, it will correct the values,
// and optimize appropriately.
rep->getSymbol()->setUsed();
rep->getSymbol()->setReferenced();
if (exp->getContext() & (Expression::LValue|
Expression::RefValue|
Expression::RefParameter)) {
info.sepm[name] = rep;
}
exp = rep;
}
break;
case Expression::KindOfObjectMethodExpression:
{
FunctionCallPtr call(
static_pointer_cast<FunctionCall>(exp));
if (call->getFuncScope() == info.func) {
call->setNoInline();
}
break;
}
case Expression::KindOfSimpleFunctionCall:
{
SimpleFunctionCallPtr call(static_pointer_cast<SimpleFunctionCall>(exp));
call->addLateDependencies(ar);
call->setLocalThis(info.localThis);
if (call->getFuncScope() == info.func) {
call->setNoInline();
}
}
default:
break;
}
return exp;
}
示例6: dumpNode
void Construct::dumpNode(int spc, AnalysisResultPtr ar) {
int nkid = getKidCount();
std::string name;
int type = 0;
std::string scontext = "";
std::string value = "";
std::string type_info = "";
unsigned id = 0;
ExpressionPtr idPtr = ExpressionPtr();
int ef = 0;
if (Statement *s = dynamic_cast<Statement*>(this)) {
Statement::KindOf stype = s->getKindOf();
switch (stype) {
case Statement::KindOfFunctionStatement:
name="FunctionStatement";
break;
case Statement::KindOfClassStatement:
name="ClassStatement";
break;
case Statement::KindOfInterfaceStatement:
name="InterfaceStatement";
break;
case Statement::KindOfClassVariable:
name="ClassVariable";
break;
case Statement::KindOfClassConstant:
name="ClassConstant";
break;
case Statement::KindOfMethodStatement:
name="MethodStatement";
break;
case Statement::KindOfStatementList:
name="StatementList";
break;
case Statement::KindOfBlockStatement:
name="BlockStatement";
break;
case Statement::KindOfIfBranchStatement:
name="IfBranchStatement";
break;
case Statement::KindOfIfStatement:
name="IfStatement";
break;
case Statement::KindOfWhileStatement:
name="WhileStatement";
break;
case Statement::KindOfDoStatement:
name="DoStatement";
break;
case Statement::KindOfForStatement:
name="ForStatement";
break;
case Statement::KindOfSwitchStatement:
name="SwitchStatement";
break;
case Statement::KindOfCaseStatement:
name="CaseStatement";
break;
case Statement::KindOfBreakStatement:
name="BreakStatement";
break;
case Statement::KindOfContinueStatement:
name="ContinueStatement";
break;
case Statement::KindOfReturnStatement:
name="ReturnStatement";
break;
case Statement::KindOfGlobalStatement:
name="GlobalStatement";
break;
case Statement::KindOfStaticStatement:
name="StaticStatement";
break;
case Statement::KindOfEchoStatement:
name="EchoStatement";
break;
case Statement::KindOfUnsetStatement:
name="UnsetStatement";
break;
case Statement::KindOfExpStatement:
name="ExpStatement";
break;
case Statement::KindOfForEachStatement:
name="ForEachStatement";
break;
case Statement::KindOfCatchStatement:
name="CatchStatement";
break;
case Statement::KindOfTryStatement:
name="TryStatement";
break;
case Statement::KindOfThrowStatement:
name="ThrowStatement";
break;
case Statement::KindOfGotoStatement:
name="GotoStatement";
break;
case Statement::KindOfLabelStatement:
name="LabelStatement";
//.........这里部分代码省略.........
示例7: dumpNode
void Construct::dumpNode(int spc, AnalysisResultConstPtr ar) {
int nkid = getKidCount();
const char *name = 0;
int type = 0;
std::string scontext = "";
std::string value = "";
std::string type_info = "";
unsigned id = 0;
ExpressionPtr idPtr = ExpressionPtr();
int ef = 0;
if (Statement *s = dynamic_cast<Statement*>(this)) {
Statement::KindOf stype = s->getKindOf();
name = Statement::Names[stype];
value = s->getName();
type = (int)stype;
} else if (Expression *e = dynamic_cast<Expression*>(this)) {
id = e->getCanonID();
idPtr = e->getCanonLVal();
ef = e->getLocalEffects();
Expression::KindOf etype = e->getKindOf();
name = Expression::Names[etype];
switch (etype) {
case Expression::KindOfSimpleFunctionCall:
value = static_cast<SimpleFunctionCall*>(e)->getName();
break;
case Expression::KindOfSimpleVariable:
value = static_cast<SimpleVariable*>(e)->getName();
break;
case Expression::KindOfConstantExpression:
value = e->getText();
break;
case Expression::KindOfScalarExpression:
value = e->getText();
break;
default:
break;
}
int c = e->getContext();
if ((c & Expression::Declaration) == Expression::Declaration) {
scontext += "|Declaration";
} else if (c & Expression::LValue) {
scontext += "|LValue";
}
if (c & Expression::NoLValueWrapper) {
scontext += "|NoLValueWrapper";
}
if (c & Expression::RefValue) {
scontext += "|RefValue";
}
if (c & Expression::RefParameter) {
scontext += "|RefParameter";
}
if (c & Expression::DeepReference) {
scontext += "|DeepReference";
}
if (c & Expression::NoRefWrapper) {
scontext += "|NoRefWrapper";
}
if (c & Expression::ObjectContext) {
scontext += "|ObjectContext";
}
if (c & Expression::InParameterExpression) {
scontext += "|InParameterExpression";
}
if (c & Expression::ExistContext) {
scontext += "|ExistContext";
}
if (c & Expression::UnsetContext) {
scontext += "|UnsetContext";
}
if (c & Expression::AssignmentLHS) {
scontext += "|AssignmentLHS";
}
if (c & Expression::RefAssignmentLHS) {
scontext += "|RefAssignmentLHS";
}
if (c & Expression::DeepAssignmentLHS) {
scontext += "|DeepAssignmentLHS";
}
if (c & Expression::InvokeArgument) {
scontext += "|InvokeArgument";
}
if (c & Expression::OprLValue) {
scontext += "|OprLValue";
}
if (c & Expression::DeepOprLValue) {
scontext += "|DeepOprLValue";
}
if (c & Expression::AccessContext) {
scontext += "|AccessContext";
}
if (scontext != "") {
scontext = " (" + scontext.substr(1) + ")";
}
type = (int)etype;
//.........这里部分代码省略.........