ClassScopeRawPtr BlockScope::getContainingClass() { BlockScope *bs = this; if (bs->is(BlockScope::FunctionScope)) { bs = bs->m_outerScope.get(); } if (bs && !bs->is(BlockScope::ClassScope)) { bs = 0; } return ClassScopeRawPtr((HPHP::ClassScope*)bs); }
AnalysisResultRawPtr BlockScope::getContainingProgram() { BlockScope *bs = this; while (bs) { if (bs->is(BlockScope::ProgramScope)) { break; } bs = bs->getOuterScope().get(); } return AnalysisResultRawPtr((AnalysisResult*)bs); }
FileScopeRawPtr BlockScope::getContainingFile() { BlockScope *bs = this; while (bs) { if (bs->is(BlockScope::FileScope)) { break; } bs = bs->getOuterScope().get(); } return FileScopeRawPtr((HPHP::FileScope*)bs); }
FunctionScopeRawPtr BlockScope::getContainingNonClosureFunction() { BlockScope *bs = this; // walk out through all the closures while (bs && bs->is(BlockScope::FunctionScope)) { HPHP::FunctionScope *fs = static_cast<HPHP::FunctionScope*>(bs); if (!fs->isClosure()) { return FunctionScopeRawPtr(fs); } bs = bs->m_outerScope.get(); } return FunctionScopeRawPtr(); }
ClassScopeRawPtr BlockScope::getContainingClass() { BlockScope *bs = getContainingNonClosureFunction().get(); if (!bs) { bs = this; } if (bs && bs->is(BlockScope::FunctionScope)) { bs = bs->m_outerScope.get(); } if (!bs || !bs->is(BlockScope::ClassScope)) { return ClassScopeRawPtr(); } return ClassScopeRawPtr((HPHP::ClassScope*)bs); }