本文整理汇总了C++中ConstructPtr类的典型用法代码示例。如果您正苦于以下问题:C++ ConstructPtr类的具体用法?C++ ConstructPtr怎么用?C++ ConstructPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConstructPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkClassPresent
bool AnalysisResult::checkClassPresent(ConstructPtr cs,
const std::string &name) const {
if (name == "self" || name == "parent") return true;
std::string lowerName = toLower(name);
if (ClassScopePtr currentCls = cs->getClassScope()) {
if (lowerName == currentCls->getName() ||
currentCls->derivesFrom(shared_from_this(), lowerName,
true, false)) {
return true;
}
}
if (FileScopePtr currentFile = cs->getFileScope()) {
StatementList &stmts = *currentFile->getStmt();
for (int i = stmts.getCount(); i--; ) {
StatementPtr s = stmts[i];
if (s && s->is(Statement::KindOfClassStatement)) {
ClassScopePtr scope =
static_pointer_cast<ClassStatement>(s)->getClassScope();
if (lowerName == scope->getName()) {
return true;
}
if (scope->derivesFrom(shared_from_this(), lowerName,
true, false)) {
return true;
}
}
}
}
return false;
}
示例2: informClosuresAboutScopeClone
void ClassScope::informClosuresAboutScopeClone(
ConstructPtr root,
FunctionScopePtr outerScope,
AnalysisResultPtr ar) {
if (!root) {
return;
}
for (int i = 0; i < root->getKidCount(); i++) {
ConstructPtr cons = root->getNthKid(i);
ClosureExpressionPtr closure =
dynamic_pointer_cast<ClosureExpression>(cons);
if (!closure) {
informClosuresAboutScopeClone(cons, outerScope, ar);
continue;
}
FunctionStatementPtr func = closure->getClosureFunction();
HPHP::FunctionScopePtr funcScope = func->getFunctionScope();
assert(funcScope->isClosure());
funcScope->addClonedTraitOuterScope(outerScope);
// Don't need to recurse
}
}
示例3: analyzeProgram
void AnalysisResult::analyzeProgram(ConstructPtr c) const {
if (!c) return;
for (auto i = 0, n = c->getKidCount(); i < n; ++i) {
analyzeProgram(c->getNthKid(i));
}
c->analyzeProgram(AnalysisResultConstRawPtr{this});
}
示例4: addHphpNote
void Parser::addHphpNote(ConstructPtr c, const std::string ¬e) {
if (note[0] == '@') {
CodeError::ErrorType e;
if (CodeError::lookupErrorType(note.substr(1), e)) {
c->addSuppressError(e);
} else {
c->addHphpNote(note);
}
} else {
c->addHphpNote(note);
}
}
示例5: getNthKid
int Construct::getChildrenEffects() const {
int childrenEffects = NoEffect;
for (int i = getKidCount(); i--; ) {
ConstructPtr child = getNthKid(i);
if (child) {
childrenEffects |= child->getContainedEffects();
if ((childrenEffects & UnknownEffect) == UnknownEffect) {
break;
}
}
}
return childrenEffects;
}
示例6: VD4
bool TestDependGraph::TestFunctionCall() {
// functions
VD4(FunctionCall,
"<?php include $_SERVER['PHP_ROOT'].'f2';\n test();",
"<?php function test() {}",
"test", "test()");
VD4(FunctionCall,
"<?php test(); function test() {}", "", "test", "test()");
VD4(FunctionCall,
"<?php function test() {} test();", "", "test", "test()");
// methods
VD4(FunctionCall,
"<?php include $_SERVER['PHP_ROOT'].'f2';\n"
"function test() { $a = new C(); $a->test();}",
"<?php class C { public function test() {}}",
"c::test", "$a->test()");
VD4(FunctionCall,
"<?php function test() { $a = new C(); $a->test();} "
"class C { public function test() {}}",
"", "c::test", "$a->test()");
VD4(FunctionCall,
"<?php class C { public function test() {}} "
"function test() { $a = new C(); $a->test();}",
"", "c::test", "$a->test()");
#ifdef HPHP_NOTE
// making sure a "MasterCopy" marked function will always be used for
// dependency's parent
{
Option::IncludeRoots["$_SERVER['PHP_ROOT']"] = "";
AnalysisResultPtr ar(new AnalysisResult());
BuiltinSymbols::Load(ar);
Parser::ParseString("<?php function test() {}", ar, "f1");
Parser::ParseString("<?php /*|MasterCopy|*/ function test() {}", ar, "f2");
ar->analyzeProgram();
ar->inferTypes();
DependencyGraphPtr dg = ar->getDependencyGraph();
ConstructPtr parent = dg->getParent(DependencyGraph::KindOfFunctionCall,
"test");
if (!parent || strcmp(parent->getLocation()->file, "f2") != 0) {
printf("%s:%d: incorrect parent found at %s:%d\n", __FILE__, __LINE__,
parent ? parent->getLocation()->file : "",
parent ? parent->getLocation()->line0 : 0);
return false;
}
}
#endif
return true;
}
示例7: getNthKid
int Construct::getChildrenEffects() const {
int childrenEffects = NoEffect;
for (int i = getKidCount(); i--; ) {
ConstructPtr child = getNthKid(i);
if (child) {
if (FunctionWalker::SkipRecurse(child)) continue;
childrenEffects |= child->getContainedEffects();
if ((childrenEffects & UnknownEffect) == UnknownEffect) {
break;
}
}
}
return childrenEffects;
}
示例8: createNewLocalId
int CodeGenerator::createNewLocalId(ConstructPtr ar) {
if (m_wrappedExpression[m_curStream]) {
return m_localId[m_curStream]++;
}
FunctionScopePtr func = ar->getFunctionScope();
if (func) {
return func->nextInlineIndex();
}
FileScopePtr fs = ar->getFileScope();
if (fs) {
return createNewId(fs->getName());
}
return createNewId("");
}
示例9: createNewId
int CodeGenerator::createNewId(ConstructPtr cs) {
FileScopePtr fs = cs->getFileScope();
if (fs) {
return createNewId(fs->getName());
}
return createNewId("");
}
示例10: CheckInclude
string IncludeExpression::CheckInclude(ConstructPtr includeExp,
ExpressionPtr fileExp,
bool &documentRoot) {
string container = includeExp->getLocation()->file;
string var, lit;
parse_string_arg(fileExp, var, lit);
if (lit.empty()) return lit;
if (var == "__DIR__") {
var = "";
// get_include_file_path will check relative to the current file's dir
// as long as the first char isn't a /
if (lit[0] == '/') {
lit = lit.substr(1);
}
}
string included = get_include_file_path(container, var, lit, documentRoot);
if (!included.empty()) {
if (included == container) {
Compiler::Error(Compiler::BadPHPIncludeFile, includeExp);
}
included = Util::canonicalize(included);
if (!var.empty()) documentRoot = true;
}
return included;
}
示例11: switch
string DependencyGraph::add(KindOf kindOf, ConstructPtr childExp,
ExpressionPtr parentExp, CodeErrorPtr codeError,
bool documentRoot /* = false */) {
string child = childExp->getLocation()->file;
string parent;
switch (kindOf) {
case KindOfPHPInclude:
if (!checkInclude(childExp, parentExp, codeError,
documentRoot, child, parent)) {
return "";
}
break;
default:
if (!m_hookHandler ||
!m_hookHandler(this, kindOf, childExp, parentExp, codeError,
documentRoot, child, parent,
beforeDependencyGraphAdd)) {
return "";
}
break;
}
string program; // no program is associated
add(kindOf, program, child, childExp, parent, ConstructPtr(), codeError);
if (m_hookHandler) {
m_hookHandler(this, kindOf, childExp, parentExp, codeError,
documentRoot, child, parent, afterDependencyGraphAdd);
}
return parent;
}
示例12: GetValue
ExpressionPtr Option::GetValue(VariableTablePtr variables,
const char *varName) {
ConstructPtr decl = variables->getDeclaration(varName);
if (!decl) {
return ExpressionPtr();
}
AssignmentExpressionPtr assignment =
dynamic_pointer_cast<AssignmentExpression>(decl);
if (!assignment) {
Logger::Error("Line %d: Ignored option %s", decl->getLocation()->line1,
varName);
return ExpressionPtr();
}
return assignment->getValue();
}
示例13: Error
void Error(ErrorType error, ConstructPtr construct) {
if (hhvm) return;
ErrorInfoPtr errorInfo(new ErrorInfo());
errorInfo->m_error = error;
errorInfo->m_construct1 = construct;
errorInfo->m_data = construct->getText();
s_code_errors.record(errorInfo);
}
示例14: ASSERT
void ClassConstantExpression::outputCPPImpl(CodeGenerator &cg,
AnalysisResultPtr ar) {
const char *globals = "g";
if (cg.getContext() == CodeGenerator::CppParameterDefaultValueDecl ||
cg.getContext() == CodeGenerator::CppParameterDefaultValueImpl) {
globals = cg.getGlobals();
}
if (m_valid) {
ClassScopePtr foundCls;
string trueClassName;
for (ClassScopePtr cls = ar->findClass(m_className);
cls; cls = cls->getParentScope(ar)) {
if (cls->getConstants()->isPresent(m_varName)) {
foundCls = cls;
trueClassName = cls->getName();
break;
}
}
ASSERT(!trueClassName.empty());
ConstructPtr decl = foundCls->getConstants()->getValue(m_varName);
if (decl) {
decl->outputCPP(cg, ar);
if (cg.getContext() == CodeGenerator::CppImplementation ||
cg.getContext() == CodeGenerator::CppParameterDefaultValueImpl) {
cg.printf("(%s::%s)", m_className.c_str(), m_varName.c_str());
} else {
cg.printf("/* %s::%s */", m_className.c_str(), m_varName.c_str());
}
} else {
if (foundCls->getConstants()->isDynamic(m_varName)) {
cg.printf("%s%s::lazy_initializer(%s)->", Option::ClassPrefix,
trueClassName.c_str(), globals);
}
cg.printf("%s%s_%s", Option::ClassConstantPrefix, trueClassName.c_str(),
m_varName.c_str());
}
} else if (m_redeclared) {
cg.printf("%s->%s%s->os_constant(\"%s\")", globals,
Option::ClassStaticsObjectPrefix,
m_className.c_str(), m_varName.c_str());
} else {
cg.printf("throw_fatal(\"unknown class constant %s::%s\")",
m_className.c_str(), m_varName.c_str());
}
}
示例15: Error
void Error(ErrorType error, ConstructPtr construct1, ConstructPtr construct2) {
if (!Option::RecordErrors) return;
ErrorInfoPtr errorInfo(new ErrorInfo());
errorInfo->m_error = error;
errorInfo->m_construct1 = construct1;
errorInfo->m_construct2 = construct2;
errorInfo->m_data = construct1->getText();
s_code_errors.record(errorInfo);
}