use a flag instead of isdigit
Instead of doing name-based checks, using a flag in the runtime seems better. I tried to have a flag on the FuncEmitter that was set when you made these weird functions, but there was a few situations that needed to do name-based checks * .hhas files have no control over anything but the name * the parser would have to pass the info through the AST to the emitter Instead I opted for the simpler approach for now until we want to solve those.
Esse commit está contido em:
@@ -819,10 +819,7 @@ Array f_hphp_get_class_info(CVarRef name) {
|
||||
size_t const numMethods = cls->preClass()->numMethods();
|
||||
for (Slot i = 0; i < numMethods; ++i) {
|
||||
const Func* m = methods[i];
|
||||
if (isdigit(m->name()->data()[0]) ||
|
||||
ParserBase::IsClosureOrContinuationName(m->name()->toCPPString())) {
|
||||
continue;
|
||||
}
|
||||
if (m->isGenerated()) continue;
|
||||
Array info = Array::Create();
|
||||
set_method_info(info, m);
|
||||
arr.set(StringUtil::ToLower(m->nameRef()), VarNR(info));
|
||||
@@ -833,10 +830,7 @@ Array f_hphp_get_class_info(CVarRef name) {
|
||||
i < cls->traitsEndIdx();
|
||||
++i) {
|
||||
const Func* m = clsMethods[i];
|
||||
if (isdigit(m->name()->data()[0]) ||
|
||||
ParserBase::IsClosureOrContinuationName(m->name()->toCPPString())) {
|
||||
continue;
|
||||
}
|
||||
if (m->isGenerated()) continue;
|
||||
Array info = Array::Create();
|
||||
set_method_info(info, m);
|
||||
arr.set(StringUtil::ToLower(m->nameRef()), VarNR(info));
|
||||
|
||||
@@ -1565,7 +1565,7 @@ void Class::importTraitMethods(MethodMap::Builder& builder) {
|
||||
|
||||
void Class::methodOverrideCheck(const Func* parentMethod, const Func* method) {
|
||||
// Skip special methods
|
||||
if (isdigit((uchar)method->name()->data()[0])) return;
|
||||
if (method->isGenerated()) return;
|
||||
|
||||
if ((parentMethod->attrs() & AttrFinal)) {
|
||||
static StringData* sd___MockClass =
|
||||
@@ -2368,10 +2368,7 @@ void Class::getMethodNames(const Class* ctx, HphpArray* methods) const {
|
||||
Func* const* pcMethods = m_preClass->methods();
|
||||
for (size_t i = 0, sz = m_preClass->numMethods(); i < sz; i++) {
|
||||
Func* func = pcMethods[i];
|
||||
if (isdigit(func->name()->data()[0]) ||
|
||||
ParserBase::IsClosureOrContinuationName(func->name()->toCPPString())) {
|
||||
continue;
|
||||
}
|
||||
if (func->isGenerated()) continue;
|
||||
if (!(func->attrs() & AttrPublic)) {
|
||||
if (!ctx) continue;
|
||||
if (ctx != this) {
|
||||
@@ -2459,10 +2456,14 @@ void Class::getClassInfo(ClassInfoVM* ci) {
|
||||
|
||||
// Methods: in source order (from our PreClass), then traits.
|
||||
for (size_t i = 0; i < m_preClass->numMethods(); ++i) {
|
||||
const StringData* name = m_preClass->methods()[i]->name();
|
||||
// Filter out special methods
|
||||
if (isdigit(name->data()[0])) continue;
|
||||
Func* func = lookupMethod(m_preClass->methods()[i]->name());
|
||||
// Filter out special methods
|
||||
if (!func) {
|
||||
DEBUG_ONLY const StringData* name = m_preClass->methods()[i]->name();
|
||||
assert(!strcmp(name->data(), "86ctor"));
|
||||
continue;
|
||||
}
|
||||
if (func->isGenerated()) continue;
|
||||
assert(func);
|
||||
assert(declaredMethod(func));
|
||||
SET_FUNCINFO_BODY;
|
||||
@@ -2471,7 +2472,7 @@ void Class::getClassInfo(ClassInfoVM* ci) {
|
||||
for (Slot i = m_traitsBeginIdx; i < m_traitsEndIdx; ++i) {
|
||||
Func* func = m_methods[i];
|
||||
assert(func);
|
||||
if (!isdigit(func->name()->data()[0])) {
|
||||
if (!func->isGenerated()) {
|
||||
SET_FUNCINFO_BODY;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "hphp/runtime/vm/func_inline.h"
|
||||
#include "hphp/system/systemlib.h"
|
||||
#include "hphp/runtime/vm/bytecode.h"
|
||||
#include "hphp/util/parser/parser.h"
|
||||
|
||||
namespace HPHP {
|
||||
|
||||
@@ -642,7 +643,8 @@ Func::SharedData::SharedData(PreClass* preClass, Id id,
|
||||
m_info(nullptr), m_refBitPtr(0), m_builtinFuncPtr(nullptr),
|
||||
m_docComment(docComment), m_top(top), m_isClosureBody(false),
|
||||
m_isGenerator(false), m_isGeneratorFromClosure(false),
|
||||
m_hasGeneratorAsBody(false), m_originalFilename(nullptr) {
|
||||
m_hasGeneratorAsBody(false), m_isGenerated(false),
|
||||
m_originalFilename(nullptr) {
|
||||
}
|
||||
|
||||
Func::SharedData::~SharedData() {
|
||||
@@ -905,10 +907,12 @@ void FuncEmitter::commit(RepoTxn& txn) const {
|
||||
}
|
||||
|
||||
Func* FuncEmitter::create(Unit& unit, PreClass* preClass /* = NULL */) const {
|
||||
bool isGenerated = isdigit(m_name->data()[0]) ||
|
||||
ParserBase::IsClosureOrContinuationName(m_name->toCPPString());
|
||||
|
||||
Attr attrs = m_attrs;
|
||||
if (attrs & AttrPersistent &&
|
||||
((RuntimeOption::EvalJitEnableRenameFunction &&
|
||||
!isdigit(m_name->data()[0])) ||
|
||||
((RuntimeOption::EvalJitEnableRenameFunction && !isGenerated) ||
|
||||
(!RuntimeOption::RepoAuthoritative && SystemLib::s_inited))) {
|
||||
attrs = Attr(attrs & ~AttrPersistent);
|
||||
}
|
||||
@@ -970,6 +974,7 @@ Func* FuncEmitter::create(Unit& unit, PreClass* preClass /* = NULL */) const {
|
||||
f->shared()->m_nativeFuncPtr = m_nativeFuncPtr;
|
||||
f->shared()->m_retTypeConstraint = m_retTypeConstraint;
|
||||
f->shared()->m_originalFilename = m_originalFilename;
|
||||
f->shared()->m_isGenerated = isGenerated;
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
@@ -351,6 +351,10 @@ struct Func {
|
||||
*/
|
||||
bool hasGeneratorAsBody() const { return shared()->m_hasGeneratorAsBody; }
|
||||
const Func* getGeneratorBody(const StringData* name) const;
|
||||
/**
|
||||
* Was this generated specially by the compiler to aide the runtime?
|
||||
*/
|
||||
bool isGenerated() const { return shared()->m_isGenerated; }
|
||||
bool hasStaticLocals() const { return !shared()->m_staticVars.empty(); }
|
||||
int numStaticLocals() const { return shared()->m_staticVars.size(); }
|
||||
const ClassInfo::MethodInfo* info() const { return shared()->m_info; }
|
||||
@@ -470,6 +474,7 @@ private:
|
||||
bool m_isGenerator : 1;
|
||||
bool m_isGeneratorFromClosure : 1;
|
||||
bool m_hasGeneratorAsBody : 1;
|
||||
bool m_isGenerated : 1;
|
||||
UserAttributeMap m_userAttributes;
|
||||
const StringData* m_retTypeConstraint;
|
||||
// per-func filepath for traits flattened during repo construction
|
||||
|
||||
@@ -185,10 +185,7 @@ Array Unit::getUserFunctions() {
|
||||
for (NamedEntityMap::const_iterator it = s_namedDataMap->begin();
|
||||
it != s_namedDataMap->end(); ++it) {
|
||||
Func* func_ = it->second.getCachedFunc();
|
||||
if (!func_ || func_->isBuiltin() ||
|
||||
isdigit(func_->name()->data()[0]) ||
|
||||
ParserBase::IsClosureOrContinuationName(
|
||||
func_->name()->toCPPString())) {
|
||||
if (!func_ || func_->isBuiltin() || func_->isGenerated()) {
|
||||
continue;
|
||||
}
|
||||
a.append(func_->nameRef());
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário