Fix getContextClassName and getParentContextClassName
They both returned the late static bound class, not the context
class. This meant that eg "constant('self::FOO')" was actually
returning what "constant('static::FOO')" should have done.
In addition, we often want the Class*, not its name, so
change them to return Class*. The remaining places that then
read the name from the Class* should be fixed to use the Class*
directly (in a later diff).
Finally, noticed that while "defined()" was recently fixed to
support "static::", "constant()" was not. Pulled out a common
function to find the correct Class*.
Esse commit está contido em:
@@ -1426,46 +1426,22 @@ ObjectData* VMExecutionContext::getThis() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CStrRef VMExecutionContext::getContextClassName() {
|
||||
Class* VMExecutionContext::getContextClass() {
|
||||
VMRegAnchor _;
|
||||
ActRec* ar = getFP();
|
||||
assert(ar != nullptr);
|
||||
if (ar->skipFrame()) {
|
||||
ar = getPrevVMState(ar);
|
||||
if (!ar) return empty_string;
|
||||
}
|
||||
if (ar->hasThis()) {
|
||||
return ar->getThis()->o_getClassName();
|
||||
} else if (ar->hasClass()) {
|
||||
return ar->getClass()->nameRef();
|
||||
} else {
|
||||
return empty_string;
|
||||
if (!ar) return nullptr;
|
||||
}
|
||||
return ar->m_func->cls();
|
||||
}
|
||||
|
||||
CStrRef VMExecutionContext::getParentContextClassName() {
|
||||
VMRegAnchor _;
|
||||
ActRec* ar = getFP();
|
||||
assert(ar != nullptr);
|
||||
if (ar->skipFrame()) {
|
||||
ar = getPrevVMState(ar);
|
||||
if (!ar) return empty_string;
|
||||
}
|
||||
if (ar->hasThis()) {
|
||||
const Class* cls = ar->getThis()->getVMClass();
|
||||
if (cls->parent() == nullptr) {
|
||||
return empty_string;
|
||||
}
|
||||
return cls->parent()->nameRef();
|
||||
} else if (ar->hasClass()) {
|
||||
const Class* cls = ar->getClass();
|
||||
if (cls->parent() == nullptr) {
|
||||
return empty_string;
|
||||
}
|
||||
return cls->parent()->nameRef();
|
||||
} else {
|
||||
return empty_string;
|
||||
Class* VMExecutionContext::getParentContextClass() {
|
||||
if (Class* ctx = getContextClass()) {
|
||||
return ctx->parent();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CStrRef VMExecutionContext::getContainingFileName() {
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário