Remove hphp_get_iterator and related dead code

This code is no longer used, let's get rid of it.
Esse commit está contido em:
Drew Paroski
2013-04-29 23:28:49 -07:00
commit de Sara Golemon
commit a3620e7758
19 arquivos alterados com 10 adições e 502 exclusões
+9 -5
Ver Arquivo
@@ -6941,7 +6941,7 @@ static Unit* emitHHBCNativeFuncUnit(const HhbcExtFuncInfo* builtinFuncs,
BuiltinFunction nif = (BuiltinFunction)info->m_nativeFunc;
const ClassInfo::MethodInfo* mi = ClassInfo::FindFunction(name);
assert(mi &&
"MethodInfo not found; probably need to rebuild hphp/system");
"MethodInfo not found; may be a problem with the .idl.json files");
FuncEmitter* fe = ue->newFuncEmitter(name, /*top*/ true);
Offset base = ue->bcPos();
fe->setBuiltinFunc(mi, bif, nif, base);
@@ -7081,7 +7081,7 @@ static Unit* emitHHBCNativeClassUnit(const HhbcExtClassInfo* builtinClasses,
StringData* parentName
= StringData::GetStaticString(e.ci->getParentClass().get());
if (parentName->empty()) {
// If this class doesn't have a base class, it's classEntries to be
// If this class doesn't have a base class, it's eligible to be
// loaded now
classEntries.push_back(e);
} else {
@@ -7092,7 +7092,7 @@ static Unit* emitHHBCNativeClassUnit(const HhbcExtClassInfo* builtinClasses,
}
for (unsigned k = 0; k < classEntries.size(); ++k) {
Entry& e = classEntries[k];
// Any classes that derive from this class are now classEntries to be
// Any classes that derive from this class are now eligible to be
// loaded
PendingMap::iterator pendingIt = pending.find(e.name);
if (pendingIt != pending.end()) {
@@ -7111,7 +7111,8 @@ static Unit* emitHHBCNativeClassUnit(const HhbcExtClassInfo* builtinClasses,
StringData::GetStaticString(e.ci->getParentClass().get());
PreClassEmitter* pce = ue->newPreClassEmitter(e.name,
PreClass::AlwaysHoistable);
pce->init(0, 0, ue->bcPos(), AttrUnique | AttrPersistent, parentName, nullptr);
pce->init(0, 0, ue->bcPos(), AttrUnique|AttrPersistent, parentName,
nullptr);
pce->setBuiltinClassInfo(e.ci, e.info->m_InstanceCtor, e.info->m_sizeof);
{
ClassInfo::InterfaceVec intfVec = e.ci->getInterfacesVec();
@@ -7160,7 +7161,10 @@ static Unit* emitHHBCNativeClassUnit(const HhbcExtClassInfo* builtinClasses,
assert(false);
}
pce->addConstant(
cnsInfo->name.get(), nullptr, (TypedValue*)(&val), empty_string.get());
cnsInfo->name.get(),
nullptr,
(TypedValue*)(&val),
empty_string.get());
}
}
{
-57
Ver Arquivo
@@ -1069,26 +1069,6 @@
}
]
},
{
"name": "hphp_current_ref",
"desc": "Similar to current(), but hphp_current_ref() returns a reference to the current value in the array.",
"flags": [
"HasDocComment"
],
"return": {
"type": "Variant",
"desc": "Reference to the current value in the array.",
"ref": true
},
"args": [
{
"name": "array",
"type": "Variant",
"desc": "The array.",
"ref": true
}
]
},
{
"name": "next",
"desc": "next() behaves like current(), with one difference. It advances the internal array pointer one place forward before returning the element value. That means it returns the next array value and advances the internal array pointer by one.",
@@ -1200,43 +1180,6 @@
}
]
},
{
"name": "hphp_get_iterator",
"desc": "hphp_get_iterator() returns an iterator object for an array or an object.",
"flags": [
"HasDocComment"
],
"return": {
"type": "Variant",
"desc": "The hphp_get_iterator() function returns a non mutable iterator object for an array or an object."
},
"args": [
{
"name": "iterable",
"type": "Variant",
"desc": "The array or object to iterate on."
}
]
},
{
"name": "hphp_get_mutable_iterator",
"desc": "hphp_get_mutable_iterator() returns an iterator object for an array or an object.",
"flags": [
"HasDocComment"
],
"return": {
"type": "Variant",
"desc": "The hphp_get_mutable_iterator() function returns an iterator object for an array or an object. It could be mutable, but only for arrays and objects that are not instances of Iterator or IteratorAggregate."
},
"args": [
{
"name": "iterable",
"type": "Variant",
"desc": "The array or object to iterate on.",
"ref": true
}
]
},
{
"name": "in_array",
"desc": "Searches haystack for needle.",
+1 -83
Ver Arquivo
@@ -485,87 +485,5 @@
}
],
"classes": [
{
"name": "MutableArrayIterator",
"bases": [
"Sweepable"
],
"desc": "Data structure used by the runtime to deal with mutable iteration inside yield generators.",
"flags": [
"HasDocComment",
"NoDefaultSweep"
],
"footer": "\n public: union {\n char m_u[sizeof(MArrayIter)];\n TypedValue m_align;\n };\n public: bool m_valid;\n\n private: MArrayIter& marr() {\n return *(MArrayIter*)(m_u);\n }",
"funcs": [
{
"name": "__construct",
"return": {
"type": null
},
"args": [
{
"name": "array",
"type": "Variant",
"ref": true
}
],
"flags": [
]
},
{
"name": "currentRef",
"return": {
"type": "Variant",
"ref": true
},
"flags": [
],
"args": [
]
},
{
"name": "current",
"return": {
"type": "Variant"
},
"flags": [
],
"args": [
]
},
{
"name": "key",
"return": {
"type": "Variant"
},
"flags": [
],
"args": [
]
},
{
"name": "next",
"return": {
"type": null
},
"flags": [
],
"args": [
]
},
{
"name": "valid",
"return": {
"type": "Boolean"
},
"flags": [
],
"args": [
]
}
],
"consts": [
]
}
]
}
}
-66
Ver Arquivo
@@ -34,12 +34,6 @@
namespace HPHP {
///////////////////////////////////////////////////////////////////////////////
static StaticString s_Iterator("Iterator");
static StaticString s_IteratorAggregate("IteratorAggregate");
static StaticString s_ArrayIterator("ArrayIterator");
static StaticString s_MutableArrayIterator("MutableArrayIterator");
static StaticString s_getIterator("getIterator");
static StaticString s_count("count");
const int64_t k_UCOL_DEFAULT = UCOL_DEFAULT;
@@ -680,13 +674,6 @@ Variant f_each(VRefParam array) {
Variant f_current(VRefParam array) {
return array.array_iter_current();
}
Variant f_hphp_current_ref(VRefParam array) {
if (!array.isArray()) {
throw_bad_array_exception();
return false;
}
return strongBind(array.array_iter_current_ref());
}
Variant f_next(VRefParam array) {
return array.array_iter_next();
}
@@ -706,59 +693,6 @@ Variant f_key(VRefParam array) {
return array.array_iter_key();
}
static Variant f_hphp_get_iterator(VRefParam iterable, bool isMutable) {
if (iterable.isArray()) {
if (isMutable) {
return create_object(s_MutableArrayIterator,
CREATE_VECTOR1(ref(iterable)));
}
return create_object(s_ArrayIterator,
CREATE_VECTOR1(iterable));
}
if (iterable.isObject()) {
ObjectData *obj = iterable.getObjectData();
Variant iterator;
while (obj->instanceof(SystemLib::s_IteratorAggregateClass)) {
iterator = obj->o_invoke(s_getIterator, Array());
if (!iterator.isObject()) break;
obj = iterator.getObjectData();
}
VM::Class* ctx = g_vmContext->getContextClass();
CStrRef context = ctx ? ctx->nameRef() : empty_string;
if (isMutable) {
if (obj->instanceof(SystemLib::s_IteratorClass)) {
throw FatalErrorException("An iterator cannot be used for "
"iteration by reference");
}
Array properties = obj->o_toIterArray(context, true);
return create_object(s_MutableArrayIterator,
CREATE_VECTOR1(ref(properties)));
} else {
if (obj->instanceof(SystemLib::s_IteratorClass)) {
return obj;
}
return create_object(s_ArrayIterator,
CREATE_VECTOR1(obj->o_toIterArray(context)));
}
}
raise_warning("Invalid argument supplied for iteration");
if (isMutable) {
return create_object(s_MutableArrayIterator,
CREATE_VECTOR1(Array::Create()));
}
return create_object(s_ArrayIterator,
CREATE_VECTOR1(Array::Create()));
}
Variant f_hphp_get_iterator(CVarRef iterable) {
return f_hphp_get_iterator(directRef(iterable), false);
}
Variant f_hphp_get_mutable_iterator(VRefParam iterable) {
return f_hphp_get_iterator(iterable, true);
}
bool f_in_array(CVarRef needle, CVarRef haystack, bool strict /* = false */) {
getCheckedArrayRet(haystack, false);
return arr_haystack.valueExists(needle, strict);
-4
Ver Arquivo
@@ -113,7 +113,6 @@ int64_t f_count(CVarRef var, bool recursive = false);
int64_t f_sizeof(CVarRef var, bool recursive = false);
Variant f_each(VRefParam array);
Variant f_current(VRefParam array);
Variant f_hphp_current_ref(VRefParam array);
Variant f_next(VRefParam array);
Variant f_pos(VRefParam array);
Variant f_prev(VRefParam array);
@@ -121,9 +120,6 @@ Variant f_reset(VRefParam array);
Variant f_end(VRefParam array);
Variant f_key(VRefParam array);
Variant f_hphp_get_iterator(CVarRef iterable);
Variant f_hphp_get_mutable_iterator(VRefParam iterable);
bool f_in_array(CVarRef needle, CVarRef haystack, bool strict = false);
Variant f_range(CVarRef low, CVarRef high, CVarRef step = 1);
-91
Ver Arquivo
@@ -448,96 +448,5 @@ String f_hphp_recursivedirectoryiterator_getsubpathname(CObjRef obj) {
throw NotImplementedException(__func__);
}
c_MutableArrayIterator::c_MutableArrayIterator(VM::Class *cb)
: ExtObjectData(cb), m_valid(false) {
}
c_MutableArrayIterator::~c_MutableArrayIterator() {
c_MutableArrayIterator::sweep();
}
void c_MutableArrayIterator::sweep() {
if (m_valid) {
MArrayIter& mi = marr();
mi.~MArrayIter();
m_valid = false;
}
}
void c_MutableArrayIterator::t___construct(VRefParam array) {
if (m_valid) {
MArrayIter& mi = marr();
mi.~MArrayIter();
m_valid = false;
}
Variant var(strongBind(array));
TypedValue* tv = (TypedValue*)(&var);
assert(tv->m_type == KindOfRef);
TypedValue* rtv = tv->m_data.pref->tv();
if (rtv->m_type == KindOfArray) {
MArrayIter& mi = marr();
(void) new (&mi) MArrayIter(tv->m_data.pref);
m_valid = mi.advance();
if (!m_valid) mi.~MArrayIter();
} else if (rtv->m_type == KindOfObject) {
if (rtv->m_data.pobj->isCollection()) {
raise_error("Collection elements cannot be taken by reference");
}
bool isIterator;
Object obj = rtv->m_data.pobj->iterableObject(isIterator);
if (isIterator) {
raise_error("An iterator cannot be used with foreach by reference");
}
VM::Class* ctx = g_vmContext->getContextClass();
Array iterArray = obj->o_toIterArray(ctx ? ctx->nameRef() : empty_string,
true);
ArrayData* ad = iterArray.detach();
MArrayIter& mi = marr();
(void) new (&mi) MArrayIter(ad);
m_valid = mi.advance();
if (!m_valid) mi.~MArrayIter();
} else {
raise_warning("Invalid argument supplied for foreach()");
}
}
Variant c_MutableArrayIterator::t___destruct() {
return uninit_null();
}
Variant c_MutableArrayIterator::t_currentref() {
if (!m_valid) return uninit_null();
MArrayIter& mi = marr();
if (mi.end()) return uninit_null();
return strongBind(mi.val());
}
Variant c_MutableArrayIterator::t_current() {
if (!m_valid) return uninit_null();
MArrayIter& mi = marr();
if (mi.end()) return uninit_null();
return mi.val();
}
Variant c_MutableArrayIterator::t_key() {
if (!m_valid) return false;
MArrayIter& mi = marr();
if (mi.end()) return false;
return mi.key();
}
void c_MutableArrayIterator::t_next() {
if (!m_valid) return;
MArrayIter &mi = marr();
if (!mi.advance()) {
mi.~MArrayIter();
m_valid = false;
}
}
bool c_MutableArrayIterator::t_valid() {
return m_valid;
}
///////////////////////////////////////////////////////////////////////////////
}
-31
Ver Arquivo
@@ -123,37 +123,6 @@ Object f_hphp_recursivedirectoryiterator_getchildren(CObjRef obj);
String f_hphp_recursivedirectoryiterator_getsubpath(CObjRef obj);
String f_hphp_recursivedirectoryiterator_getsubpathname(CObjRef obj);
///////////////////////////////////////////////////////////////////////////////
// class MutableArrayIterator
FORWARD_DECLARE_CLASS_BUILTIN(MutableArrayIterator);
class c_MutableArrayIterator : public ExtObjectData, public Sweepable {
public:
DECLARE_CLASS(MutableArrayIterator, MutableArrayIterator, ObjectData)
// need to implement
public: c_MutableArrayIterator(VM::Class* cls = c_MutableArrayIterator::s_cls);
public: ~c_MutableArrayIterator();
public: void t___construct(VRefParam array);
public: Variant t_currentref();
public: Variant t_current();
public: Variant t_key();
public: void t_next();
public: bool t_valid();
public: Variant t___destruct();
public: union {
char m_u[sizeof(MArrayIter)];
TypedValue m_align;
};
public: bool m_valid;
private: MArrayIter& marr() {
return *(MArrayIter*)(m_u);
}
};
///////////////////////////////////////////////////////////////////////////////
}
-2
Ver Arquivo
@@ -2498,8 +2498,6 @@ const ClassInfo::MethodInfo* VMExecutionContext::findFunctionInfo(
if (it == m_functionInfos.end()) {
Func* func = Unit::loadFunc(name.get());
if (func == nullptr || func->builtinFuncPtr()) {
// Fall back to the logic in ClassInfo::FindFunction() logic to deal
// with builtin functions
return nullptr;
}
AtomicSmartPtr<MethodInfoVM> &m = m_functionInfos[name];
-56
Ver Arquivo
@@ -12927,12 +12927,6 @@ const char *g_class_map[] = {
NULL,
NULL,
NULL,
(const char *)0x10006040, "hphp_current_ref", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/function.hphp-current-ref.php )\n *\n * Similar to current(), but hphp_current_ref() returns a reference to the\n * current value in the array.\n *\n * @array mixed The array.\n *\n * @return mixed Reference to the current value in the array.\n */",
(const char *)0xffffffff /* KindOfUnknown: $t: Variant */, (const char *)0x2800, "array", "", (const char *)0xffffffff /* KindOfUnknown: $t: Variant */, "", (const char *)0, "", (const char *)0, NULL,
NULL,
NULL,
NULL,
(const char *)0x10006040, "next", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/function.next.php )\n *\n * next() behaves like current(), with one difference. It advances the\n * internal array pointer one place forward before returning the element\n * value. That means it returns the next array value and advances the\n * internal array pointer by one.\n *\n * @array mixed The array being affected.\n *\n * @return mixed Returns the array value in the next place that's\n * pointed to by the internal array pointer, or FALSE\n * if there are no more elements. WarningThis function\n * may return Boolean FALSE, but may also return a\n * non-Boolean value which evaluates to FALSE, such as\n * 0 or \"\". Please read the section on Booleans for\n * more information. Use the === operator for testing\n * the return value of this function.\n */",
(const char *)0xffffffff /* KindOfUnknown: $t: Variant */, (const char *)0x2800, "array", "", (const char *)0xffffffff /* KindOfUnknown: $t: Variant */, "", (const char *)0, "", (const char *)0, NULL,
@@ -12969,18 +12963,6 @@ const char *g_class_map[] = {
NULL,
NULL,
NULL,
(const char *)0x10006040, "hphp_get_iterator", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/function.hphp-get-iterator.php )\n *\n * hphp_get_iterator() returns an iterator object for an array or an\n * object.\n *\n * @iterable mixed The array or object to iterate on.\n *\n * @return mixed The hphp_get_iterator() function returns a non\n * mutable iterator object for an array or an object.\n */",
(const char *)0xffffffff /* KindOfUnknown: $t: Variant */, (const char *)0x2000, "iterable", "", (const char *)0xffffffff /* KindOfUnknown: $t: Variant */, "", (const char *)0, "", (const char *)0, NULL,
NULL,
NULL,
NULL,
(const char *)0x10006040, "hphp_get_mutable_iterator", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from\n * http://php.net/manual/en/function.hphp-get-mutable-iterator.php )\n *\n * hphp_get_mutable_iterator() returns an iterator object for an array or\n * an object.\n *\n * @iterable mixed The array or object to iterate on.\n *\n * @return mixed The hphp_get_mutable_iterator() function returns an\n * iterator object for an array or an object. It could\n * be mutable, but only for arrays and objects that are\n * not instances of Iterator or IteratorAggregate.\n */",
(const char *)0xffffffff /* KindOfUnknown: $t: Variant */, (const char *)0x2800, "iterable", "", (const char *)0xffffffff /* KindOfUnknown: $t: Variant */, "", (const char *)0, "", (const char *)0, NULL,
NULL,
NULL,
NULL,
(const char *)0x10106040, "in_array", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/function.in-array.php )\n *\n * Searches haystack for needle.\n *\n * @needle mixed The searched value.\n *\n * If needle is a string, the comparison is done in a\n * case-sensitive manner.\n * @haystack mixed The array.\n * @strict bool If the third parameter strict is set to TRUE then\n * the in_array() function will also check the types of\n * the needle in the haystack.\n *\n * @return bool Returns TRUE if needle is found in the array, FALSE\n * otherwise.\n */",
(const char *)0x9 /* KindOfBoolean */, (const char *)0x2000, "needle", "", (const char *)0xffffffff /* KindOfUnknown: $t: Variant */, "", (const char *)0, "", (const char *)0, NULL,
@@ -24718,44 +24700,6 @@ const char *g_class_map[] = {
NULL,
NULL,
NULL,
(const char *)0x18006000, "MutableArrayIterator", "", "", (const char *)0, (const char *)0,
"/**\n * ( excerpt from http://php.net/manual/en/class.mutablearrayiterator.php )\n *\n * Data structure used by the runtime to deal with mutable iteration\n * inside yield generators.\n *\n */",
NULL,
(const char *)0x10006040, "__construct", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from\n * http://php.net/manual/en/mutablearrayiterator.construct.php )\n *\n *\n * @array mixed\n */",
(const char *)0x8 /* KindOfNull */, (const char *)0x2800, "array", "", (const char *)0xffffffff /* KindOfUnknown: $t: Variant */, "", (const char *)0, "", (const char *)0, NULL,
NULL,
NULL,
NULL,
(const char *)0x10006040, "currentRef", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from\n * http://php.net/manual/en/mutablearrayiterator.currentref.php )\n *\n *\n * @return mixed\n */",
(const char *)0xffffffff /* KindOfUnknown: $t: Variant */, NULL,
NULL,
NULL,
(const char *)0x10006040, "current", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/mutablearrayiterator.current.php\n * )\n *\n *\n * @return mixed\n */",
(const char *)0xffffffff /* KindOfUnknown: $t: Variant */, NULL,
NULL,
NULL,
(const char *)0x10006040, "key", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/mutablearrayiterator.key.php )\n *\n *\n * @return mixed\n */",
(const char *)0xffffffff /* KindOfUnknown: $t: Variant */, NULL,
NULL,
NULL,
(const char *)0x10006040, "next", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/mutablearrayiterator.next.php )\n *\n *\n */",
(const char *)0x8 /* KindOfNull */, NULL,
NULL,
NULL,
(const char *)0x10006040, "valid", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/mutablearrayiterator.valid.php )\n *\n *\n * @return bool\n */",
(const char *)0x9 /* KindOfBoolean */, NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
(const char *)0x10006010, "WaitHandle", "", "", (const char *)0, (const char *)0,
"/**\n * ( excerpt from http://php.net/manual/en/class.waithandle.php )\n *\n * A wait handle representing asynchronous operation\n *\n */",
"awaitable", NULL,
-8
Ver Arquivo
@@ -1,8 +0,0 @@
<?php
$a = array(50);
// This function is the easiest way to get hold of an ObjectData that isn't an
// Instance; this exercises getting and setting properties on these.
$it = hphp_get_iterator($a);
$it->blah = 2000;
var_dump($it->blah);
-1
Ver Arquivo
@@ -1 +0,0 @@
int(2000)
-3
Ver Arquivo
@@ -1,3 +0,0 @@
<?php
class A { public function __call($method, $args) { for ($o = new MutableArrayIterator($args); $o->valid(); $o->next()) { $v = &$o->currentRef(); var_dump($v); var_dump($v); } var_dump(array_key_exists('foo', $args)); var_dump(array_unshift($args, 4)); var_dump(array_pop($args)); if (isset($args['foo'])) {} var_dump(each($args)); var_dump(array_shift($args)); }}$obj = new A;$obj->foo(1, 2, 3);
-20
Ver Arquivo
@@ -1,20 +0,0 @@
int(1)
int(1)
int(2)
int(2)
int(3)
int(3)
bool(false)
int(4)
int(3)
array(4) {
[1]=>
int(4)
["value"]=>
int(4)
[0]=>
int(0)
["key"]=>
int(0)
}
int(4)
-13
Ver Arquivo
@@ -1,13 +0,0 @@
<?php
$a = array(1, 2, 3);
foreach ($a as $k1 => &$v1) { $v1 += $k1; }
var_dump($a);
$a = array(1, 2, 3);
for ($o = new MutableArrayIterator($a); $o->valid(); $o->next()) {
$k2 = $o->key();
$v2 = &$o->currentRef();
$v2 += $k2;
}
var_dump($a);
-16
Ver Arquivo
@@ -1,16 +0,0 @@
array(3) {
[0]=>
int(1)
[1]=>
int(3)
[2]=>
&int(5)
}
array(3) {
[0]=>
int(1)
[1]=>
int(3)
[2]=>
&int(5)
}
-17
Ver Arquivo
@@ -1,17 +0,0 @@
<?php
function gen() {
$a = array(1, 2, 3);
foreach ($a as $k1 => &$v1) { $v1 += $k1; }
var_dump($a);
$a = array(1, 2, 3);
for ($o = new MutableArrayIterator($a); $o->valid(); $o->next()) {
$k2 = $o->key();
$v2 = &$o->currentRef();
$v2 += $k2;
}
var_dump($a);
yield null;
}
foreach (gen() as $_) {}
-16
Ver Arquivo
@@ -1,16 +0,0 @@
array(3) {
[0]=>
int(1)
[1]=>
int(3)
[2]=>
&int(5)
}
array(3) {
[0]=>
int(1)
[1]=>
int(3)
[2]=>
&int(5)
}
-10
Ver Arquivo
@@ -1,10 +0,0 @@
<?php
function f() {
$var = hphp_get_iterator(null);
var_dump(is_null($var));
var_dump(is_object($var));
var_dump(get_class($var));
}
f();
-3
Ver Arquivo
@@ -1,3 +0,0 @@
bool(false)
bool(true)
string(13) "ArrayIterator"