Collections updates

Replace "collection" with "collections" in various file names since
we typically use the plural form in conversation and documentation.

Add set() and removeAt() methods needed for collection interfaces. Also
add the KeyedIterable and KeyedIterator interfaces.

Add __construct() methods for collections
Esse commit está contido em:
andrewparoski
2013-03-04 13:34:50 -08:00
commit de Sara Golemon
commit cc858b73db
33 arquivos alterados com 1373 adições e 718 exclusões
+7
Ver Arquivo
@@ -593,6 +593,9 @@ interface Iterator extends Traversable {
public function valid();
}
interface KeyedIterator extends Iterator {
}
// Do NOT modifiy this doc comment block generated by idl/sysdoc.php
/**
* ( excerpt from http://php.net/manual/en/class.seekableiterator.php )
@@ -1215,6 +1218,9 @@ interface IteratorAggregate extends Traversable {
interface Iterable extends IteratorAggregate {
}
interface KeyedIterable extends Iterable {
}
///////////////////////////////////////////////////////////////////////////////
// http://www.php.net/~helly/php/ext/spl/appenditerator_8inc-source.html
@@ -1356,6 +1362,7 @@ class AppendIterator implements OuterIterator {
}
}
// Do NOT modifiy this doc comment block generated by idl/sysdoc.php
/**
* ( excerpt from http://php.net/manual/en/class.splfileinfo.php )
@@ -88,8 +88,9 @@ CPP
BeginClass(
array(
'name' => "Vector",
'ifaces' => array('Iterable', 'Countable'),
'desc' => "A stack-style container.",
'ifaces' => array('KeyedIterable', 'Countable'),
'desc' => "An ordered collection where values are keyed using integers ".
"0 thru n-1 in order.",
'flags' => IsFinal | HasDocComment,
'footer' => <<<EOT
@@ -107,6 +108,13 @@ DefineFunction(
'return' => array(
'type' => null,
),
'args' => array(
array(
'name' => "iterable",
'type' => Variant,
'value' => "null",
),
),
));
DefineFunction(
@@ -163,6 +171,29 @@ DefineFunction(
),
));
DefineFunction(
array(
'name' => "set",
'flags' => HasDocComment,
'desc' => "Stores a value into the Vector with the specified key, ".
"overwriting any previous value that was associated with ".
"the key. If the key is outside the bounds of the Vector, ".
"an exception is thrown.",
'return' => array(
'type' => Object,
),
'args' => array(
array(
'name' => "key",
'type' => Variant,
),
array(
'name' => "value",
'type' => Variant,
),
),
));
DefineFunction(
array(
'name' => "put",
@@ -214,6 +245,23 @@ DefineFunction(
),
));
DefineFunction(
array(
'name' => "removeAt",
'flags' => HasDocComment,
'desc' => "Removes the element with the specified key from this ".
"Vector and renumbers the keys of all subsequent elements.",
'return' => array(
'type' => Object,
),
'args' => array(
array(
'name' => "key",
'type' => Variant,
),
),
));
DefineFunction(
array(
'name' => "append",
@@ -513,7 +561,7 @@ EndClass(
BeginClass(
array(
'name' => "VectorIterator",
'ifaces' => array('Iterator'),
'ifaces' => array('KeyedIterator'),
'desc' => "An iterator implementation for iterating over a Vector.",
'flags' => IsFinal | HasDocComment,
));
@@ -585,8 +633,8 @@ EndClass(
BeginClass(
array(
'name' => "Map",
'ifaces' => array('Iterable', 'Countable'),
'desc' => "An unordered dictionary-style container.",
'ifaces' => array('KeyedIterable', 'Countable'),
'desc' => "An unordered dictionary-style collection.",
'flags' => IsFinal | HasDocComment,
));
@@ -596,6 +644,13 @@ DefineFunction(
'return' => array(
'type' => null,
),
'args' => array(
array(
'name' => "iterable",
'type' => Variant,
'value' => "null",
),
),
));
DefineFunction(
@@ -652,6 +707,28 @@ DefineFunction(
),
));
DefineFunction(
array(
'name' => "set",
'flags' => HasDocComment,
'desc' => "Stores a value into the Map with the specified key, ".
"overwriting any previous value that was associated with ".
"the key.",
'return' => array(
'type' => Object,
),
'args' => array(
array(
'name' => "key",
'type' => Variant,
),
array(
'name' => "value",
'type' => Variant,
),
),
));
DefineFunction(
array(
'name' => "put",
@@ -717,6 +794,22 @@ DefineFunction(
),
));
DefineFunction(
array(
'name' => "removeAt",
'flags' => HasDocComment,
'desc' => "Removes the specified key from this Map.",
'return' => array(
'type' => Object,
),
'args' => array(
array(
'name' => "key",
'type' => Variant,
),
),
));
// This method is deprecated and will be removed soon
DefineFunction(
array(
@@ -961,7 +1054,7 @@ EndClass(
BeginClass(
array(
'name' => "MapIterator",
'ifaces' => array('Iterator'),
'ifaces' => array('KeyedIterator'),
'desc' => "An iterator implementation for iterating over a Map.",
'flags' => IsFinal | HasDocComment,
));
@@ -1033,8 +1126,8 @@ EndClass(
BeginClass(
array(
'name' => "StableMap",
'ifaces' => array('Iterable', 'Countable'),
'desc' => "An ordered dictionary-style container.",
'ifaces' => array('KeyedIterable', 'Countable'),
'desc' => "An ordered dictionary-style collection.",
'flags' => IsFinal | HasDocComment,
));
@@ -1044,6 +1137,13 @@ DefineFunction(
'return' => array(
'type' => null,
),
'args' => array(
array(
'name' => "iterable",
'type' => Variant,
'value' => "null",
),
),
));
DefineFunction(
@@ -1100,6 +1200,28 @@ DefineFunction(
),
));
DefineFunction(
array(
'name' => "set",
'flags' => HasDocComment,
'desc' => "Stores a value into the StableMap with the specified key, ".
"overwriting any previous value that was associated with ".
"the key.",
'return' => array(
'type' => Object,
),
'args' => array(
array(
'name' => "key",
'type' => Variant,
),
array(
'name' => "value",
'type' => Variant,
),
),
));
DefineFunction(
array(
'name' => "put",
@@ -1165,6 +1287,22 @@ DefineFunction(
),
));
DefineFunction(
array(
'name' => "removeAt",
'flags' => HasDocComment,
'desc' => "Removes the specified key from this StableMap.",
'return' => array(
'type' => Object,
),
'args' => array(
array(
'name' => "key",
'type' => Variant,
),
),
));
// This method is deprecated and will be removed soon
DefineFunction(
array(
@@ -1410,7 +1548,7 @@ EndClass(
BeginClass(
array(
'name' => "StableMapIterator",
'ifaces' => array('Iterator'),
'ifaces' => array('KeyedIterator'),
'desc' => "An iterator implementation for iterating over a StableMap.",
'flags' => IsFinal | HasDocComment,
));
+1 -19
Ver Arquivo
@@ -19,7 +19,7 @@
#include <runtime/base/array/hphp_array.h>
#include <runtime/base/complex_types.h>
#include <runtime/base/object_data.h>
#include <runtime/ext/ext_collection.h>
#include <runtime/ext/ext_collections.h>
namespace HPHP {
///////////////////////////////////////////////////////////////////////////////
@@ -76,24 +76,6 @@ void ArrayIter::reset() {
decRefObj(obj);
}
void ArrayIter::begin(CVarRef map, CStrRef context) {
try {
new (this) ArrayIter(map.begin(context));
} catch (...) {
m_data = nullptr;
throw;
}
}
void ArrayIter::begin(CArrRef map, CStrRef context) {
try {
new (this) ArrayIter(map.get());
} catch (...) {
m_data = nullptr;
throw;
}
}
template <bool incRef>
void ArrayIter::objInit(ObjectData *obj) {
assert(obj);
-2
Ver Arquivo
@@ -81,8 +81,6 @@ class ArrayIter {
m_pos = data->getIterBegin();
}
ArrayIter(CArrRef array);
void begin(CVarRef map, CStrRef);
void begin(CArrRef map, CStrRef);
void reset();
private:
+1 -1
Ver Arquivo
@@ -29,7 +29,7 @@
#include <runtime/ext/ext_class.h>
#include <runtime/ext/ext_function.h>
#include <runtime/ext/ext_file.h>
#include <runtime/ext/ext_collection.h>
#include <runtime/ext/ext_collections.h>
#include <util/logger.h>
#include <util/util.h>
#include <util/process.h>
+1 -1
Ver Arquivo
@@ -24,7 +24,7 @@
#include <runtime/base/class_info.h>
#include <runtime/ext/ext_closure.h>
#include <runtime/ext/ext_continuation.h>
#include <runtime/ext/ext_collection.h>
#include <runtime/ext/ext_collections.h>
#include <runtime/vm/class.h>
#include <system/lib/systemlib.h>
+1 -1
Ver Arquivo
@@ -20,7 +20,7 @@
#include <runtime/base/variable_serializer.h>
#include <runtime/base/array/array_iterator.h>
#include <runtime/base/strings.h>
#include <runtime/ext/ext_collection.h>
#include <runtime/ext/ext_collections.h>
#include <system/lib/systemlib.h>
+1 -1
Ver Arquivo
@@ -28,7 +28,7 @@
#include <runtime/vm/translator/translator-x64.h>
#include <runtime/vm/runtime.h>
#include <system/lib/systemlib.h>
#include <runtime/ext/ext_collection.h>
#include <runtime/ext/ext_collections.h>
#include <util/logger.h>
+1 -1
Ver Arquivo
@@ -27,7 +27,7 @@
#include <runtime/base/array/array_iterator.h>
#include <runtime/base/util/request_local.h>
#include <runtime/ext/ext_json.h>
#include <runtime/ext/ext_collection.h>
#include <runtime/ext/ext_collections.h>
namespace HPHP {
///////////////////////////////////////////////////////////////////////////////
+1 -1
Ver Arquivo
@@ -26,7 +26,7 @@
#include <runtime/ext/ext_bzip2.h>
#include <runtime/ext/ext_class.h>
#include <runtime/ext/ext_closure.h>
#include <runtime/ext/ext_collection.h>
#include <runtime/ext/ext_collections.h>
#include <runtime/ext/ext_continuation.h>
#include <runtime/ext/ext_ctype.h>
#include <runtime/ext/ext_curl.h>
+1 -1
Ver Arquivo
@@ -19,7 +19,7 @@
#include <runtime/ext/ext_iterator.h>
#include <runtime/ext/ext_function.h>
#include <runtime/ext/ext_continuation.h>
#include <runtime/ext/ext_collection.h>
#include <runtime/ext/ext_collections.h>
#include <runtime/base/util/request_local.h>
#include <runtime/base/zend/zend_collator.h>
#include <runtime/base/builtin_functions.h>
@@ -17,7 +17,7 @@
#include <runtime/base/variable_serializer.h>
#include <runtime/base/array/sort_helpers.h>
#include <runtime/ext/ext_collection.h>
#include <runtime/ext/ext_collections.h>
#include <runtime/ext/ext_array.h>
#include <runtime/ext/ext_math.h>
#include <runtime/ext/ext_intl.h>
@@ -60,6 +60,30 @@ static void throwStrOOB(StringData* key) {
throw e;
}
static inline ArrayIter getArrayIterHelper(CVarRef v, size_t& sz) {
if (v.isArray()) {
ArrayData* ad = v.getArrayData();
sz = ad->size();
return ArrayIter(ad);
}
if (v.isObject()) {
ObjectData* obj = v.getObjectData();
if (obj->isCollection()) {
sz = collectionSize(obj);
return ArrayIter(obj);
}
bool isIterable;
Object iterable = obj->iterableObject(isIterable);
if (isIterable) {
sz = 0;
return ArrayIter(iterable, ArrayIter::transferOwner);
}
}
Object e(SystemLib::AllocInvalidArgumentExceptionObject(
"Parameter must be an array or an instance of Traversable"));
throw e;
}
///////////////////////////////////////////////////////////////////////////////
c_Vector::c_Vector(VM::Class* cb) :
@@ -85,8 +109,24 @@ void c_Vector::freeData() {
m_data = NULL;
}
}
void c_Vector::t___construct() {
void c_Vector::t___construct(CVarRef iterable /* = null_variant */) {
if (!iterable.isInitialized()) {
return;
}
size_t sz;
ArrayIter iter = getArrayIterHelper(iterable, sz);
if (sz) {
reserve(sz);
}
for (; iter; ++iter) {
Variant v = iter.second();
TypedValue* tv = (TypedValue*)(&v);
if (UNLIKELY(tv->m_type == KindOfRef)) {
tv = tv->m_data.pref->tv();
}
add(tv);
}
}
Variant c_Vector::t___destruct() {
@@ -150,11 +190,11 @@ Array c_Vector::o_toArray() const {
ObjectData* c_Vector::clone() {
ObjectData* obj = ObjectData::clone();
auto vec = static_cast<c_Vector*>(obj);
auto target = static_cast<c_Vector*>(obj);
uint sz = m_size;
TypedValue* data;
vec->m_capacity = vec->m_size = sz;
vec->m_data = data = (TypedValue*)smart_malloc(sz * sizeof(TypedValue));
target->m_capacity = target->m_size = sz;
target->m_data = data = (TypedValue*)smart_malloc(sz * sizeof(TypedValue));
for (int i = 0; i < sz; ++i) {
tvDup(&m_data[i], &data[i]);
}
@@ -262,6 +302,25 @@ bool c_Vector::t_contains(CVarRef key) {
return false;
}
Object c_Vector::t_removeat(CVarRef key) {
if (!key.isInteger()) {
throwBadKeyType();
}
int64_t k = key.toInt64();
if (!contains(k)) {
return this;
}
uint64_t datum = m_data[k].m_data.num;
DataType t = m_data[k].m_type;
if (k+1 < m_size) {
memmove(&m_data[k], &m_data[k+1],
(m_size-(k+1)) * sizeof(TypedValue));
}
--m_size;
tvRefcountedDecRefHelper(t, datum);
return this;
}
Array c_Vector::t_toarray() {
return toArrayImpl();
}
@@ -401,7 +460,7 @@ Object c_Vector::t_getiterator() {
return it;
}
Object c_Vector::t_put(CVarRef key, CVarRef value) {
Object c_Vector::t_set(CVarRef key, CVarRef value) {
if (key.isInteger()) {
TypedValue* tv = (TypedValue*)(&value);
if (UNLIKELY(tv->m_type == KindOfRef)) {
@@ -414,6 +473,10 @@ Object c_Vector::t_put(CVarRef key, CVarRef value) {
return this;
}
Object c_Vector::t_put(CVarRef key, CVarRef value) {
return t_set(key, value);
}
Object c_Vector::ti_fromarray(const char* cls, CVarRef arr) {
if (!arr.isArray()) {
Object e(SystemLib::AllocInvalidArgumentExceptionObject(
@@ -793,7 +856,30 @@ void c_Map::deleteBuckets() {
}
}
void c_Map::t___construct() {
void c_Map::t___construct(CVarRef iterable /* = null_variant */) {
if (!iterable.isInitialized()) {
return;
}
size_t sz;
ArrayIter iter = getArrayIterHelper(iterable, sz);
if (sz) {
reserve(sz);
}
for (; iter; ++iter) {
Variant k = iter.first();
Variant v = iter.second();
TypedValue* tv = (TypedValue*)(&v);
if (UNLIKELY(tv->m_type == KindOfRef)) {
tv = tv->m_data.pref->tv();
}
if (k.isInteger()) {
update(k.toInt64(), tv);
} else if (k.isString()) {
update(k.getStringData(), tv);
} else {
throwBadKeyType();
}
}
}
Variant c_Map::t___destruct() {
@@ -894,7 +980,7 @@ Variant c_Map::t_get(CVarRef key) {
return null;
}
Object c_Map::t_put(CVarRef key, CVarRef value) {
Object c_Map::t_set(CVarRef key, CVarRef value) {
TypedValue* val = (TypedValue*)(&value);
if (UNLIKELY(val->m_type == KindOfRef)) {
val = val->m_data.pref->tv();
@@ -909,6 +995,10 @@ Object c_Map::t_put(CVarRef key, CVarRef value) {
return this;
}
Object c_Map::t_put(CVarRef key, CVarRef value) {
return t_set(key, value);
}
bool c_Map::t_contains(CVarRef key) {
DataType t = key.getType();
if (t == KindOfInt64) {
@@ -933,6 +1023,10 @@ Object c_Map::t_remove(CVarRef key) {
return this;
}
Object c_Map::t_removeat(CVarRef key) {
return t_remove(key);
}
Object c_Map::t_discard(CVarRef key) {
return t_remove(key);
}
@@ -1364,7 +1458,7 @@ void c_Map::reserve(int64_t sz) {
m_data = (Bucket*)smart_calloc(numSlots(), sizeof(Bucket));
return;
}
uint oldNumSlots = numSlots();
size_t oldNumSlots = numSlots();
m_nLastSlot = Util::roundUpToPowerOfTwo(sz << 1) - 1;
m_load = m_size;
Bucket* oldBuckets = m_data;
@@ -1672,7 +1766,30 @@ void c_StableMap::deleteBuckets() {
}
}
void c_StableMap::t___construct() {
void c_StableMap::t___construct(CVarRef iterable /* = null_variant */) {
if (!iterable.isInitialized()) {
return;
}
size_t sz;
ArrayIter iter = getArrayIterHelper(iterable, sz);
if (sz) {
reserve(sz);
}
for (; iter; ++iter) {
Variant k = iter.first();
Variant v = iter.second();
TypedValue* tv = (TypedValue*)(&v);
if (UNLIKELY(tv->m_type == KindOfRef)) {
tv = tv->m_data.pref->tv();
}
if (k.isInteger()) {
update(k.toInt64(), tv);
} else if (k.isString()) {
update(k.getStringData(), tv);
} else {
throwBadKeyType();
}
}
}
Variant c_StableMap::t___destruct() {
@@ -1790,7 +1907,7 @@ Variant c_StableMap::t_get(CVarRef key) {
return null;
}
Object c_StableMap::t_put(CVarRef key, CVarRef value) {
Object c_StableMap::t_set(CVarRef key, CVarRef value) {
TypedValue* val = (TypedValue*)(&value);
if (UNLIKELY(val->m_type == KindOfRef)) {
val = val->m_data.pref->tv();
@@ -1805,6 +1922,10 @@ Object c_StableMap::t_put(CVarRef key, CVarRef value) {
return this;
}
Object c_StableMap::t_put(CVarRef key, CVarRef value) {
return t_set(key, value);
}
bool c_StableMap::t_contains(CVarRef key) {
DataType t = key.getType();
if (t == KindOfInt64) {
@@ -1829,6 +1950,10 @@ Object c_StableMap::t_remove(CVarRef key) {
return this;
}
Object c_StableMap::t_removeat(CVarRef key) {
return t_remove(key);
}
Object c_StableMap::t_discard(CVarRef key) {
return t_remove(key);
}
@@ -35,13 +35,14 @@ HPHP::VM::Instance* new_Vector_Instance(HPHP::VM::Class* cls) {
IMPLEMENT_CLASS(Vector);
/*
void HPHP::c_Vector::t___construct()
_ZN4HPHP8c_Vector13t___constructEv
void HPHP::c_Vector::t___construct(HPHP::Variant const&)
_ZN4HPHP8c_Vector13t___constructERKNS_7VariantE
this_ => rdi
iterable => rsi
*/
void th_6Vector___construct(ObjectData* this_) asm("_ZN4HPHP8c_Vector13t___constructEv");
void th_6Vector___construct(ObjectData* this_, TypedValue* iterable) asm("_ZN4HPHP8c_Vector13t___constructERKNS_7VariantE");
TypedValue* tg_6Vector___construct(HPHP::VM::ActRec *ar) {
TypedValue rv;
@@ -49,22 +50,23 @@ TypedValue* tg_6Vector___construct(HPHP::VM::ActRec *ar) {
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
ObjectData* this_ = (ar->hasThis() ? ar->getThis() : NULL);
if (this_) {
if (count == 0LL) {
if (count <= 1LL) {
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
th_6Vector___construct((this_));
frame_free_locals_inl(ar, 0);
Variant defVal0;
th_6Vector___construct((this_), (count > 0) ? (args-0) : (TypedValue*)(&defVal0));
frame_free_locals_inl(ar, 1);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
} else {
throw_toomany_arguments_nr("Vector::__construct", 0, 1);
throw_toomany_arguments_nr("Vector::__construct", 1, 1);
}
} else {
throw_instance_method_fatal("Vector::__construct");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 0);
frame_free_locals_inl(ar, 1);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
return &ar->m_r;
@@ -218,6 +220,46 @@ TypedValue* tg_6Vector_get(HPHP::VM::ActRec *ar) {
return &ar->m_r;
}
/*
HPHP::Object HPHP::c_Vector::t_set(HPHP::Variant const&, HPHP::Variant const&)
_ZN4HPHP8c_Vector5t_setERKNS_7VariantES3_
(return value) => rax
_rv => rdi
this_ => rsi
key => rdx
value => rcx
*/
Value* th_6Vector_set(Value* _rv, ObjectData* this_, TypedValue* key, TypedValue* value) asm("_ZN4HPHP8c_Vector5t_setERKNS_7VariantES3_");
TypedValue* tg_6Vector_set(HPHP::VM::ActRec *ar) {
TypedValue rv;
int64_t count = ar->numArgs();
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
ObjectData* this_ = (ar->hasThis() ? ar->getThis() : NULL);
if (this_) {
if (count == 2LL) {
rv.m_type = KindOfObject;
th_6Vector_set((Value*)(&(rv)), (this_), (args-0), (args-1));
if (rv.m_data.num == 0LL) rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 2);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
} else {
throw_wrong_arguments_nr("Vector::set", count, 2, 2, 1);
}
} else {
throw_instance_method_fatal("Vector::set");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 2);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
return &ar->m_r;
}
/*
HPHP::Object HPHP::c_Vector::t_put(HPHP::Variant const&, HPHP::Variant const&)
_ZN4HPHP8c_Vector5t_putERKNS_7VariantES3_
@@ -333,6 +375,45 @@ TypedValue* tg_6Vector_contains(HPHP::VM::ActRec *ar) {
return &ar->m_r;
}
/*
HPHP::Object HPHP::c_Vector::t_removeat(HPHP::Variant const&)
_ZN4HPHP8c_Vector10t_removeatERKNS_7VariantE
(return value) => rax
_rv => rdi
this_ => rsi
key => rdx
*/
Value* th_6Vector_removeAt(Value* _rv, ObjectData* this_, TypedValue* key) asm("_ZN4HPHP8c_Vector10t_removeatERKNS_7VariantE");
TypedValue* tg_6Vector_removeAt(HPHP::VM::ActRec *ar) {
TypedValue rv;
int64_t count = ar->numArgs();
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
ObjectData* this_ = (ar->hasThis() ? ar->getThis() : NULL);
if (this_) {
if (count == 1LL) {
rv.m_type = KindOfObject;
th_6Vector_removeAt((Value*)(&(rv)), (this_), (args-0));
if (rv.m_data.num == 0LL) rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 1);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
} else {
throw_wrong_arguments_nr("Vector::removeAt", count, 1, 1, 1);
}
} else {
throw_instance_method_fatal("Vector::removeAt");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 1);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
return &ar->m_r;
}
/*
HPHP::Object HPHP::c_Vector::t_append(HPHP::Variant const&)
_ZN4HPHP8c_Vector8t_appendERKNS_7VariantE
@@ -1284,13 +1365,14 @@ HPHP::VM::Instance* new_Map_Instance(HPHP::VM::Class* cls) {
IMPLEMENT_CLASS(Map);
/*
void HPHP::c_Map::t___construct()
_ZN4HPHP5c_Map13t___constructEv
void HPHP::c_Map::t___construct(HPHP::Variant const&)
_ZN4HPHP5c_Map13t___constructERKNS_7VariantE
this_ => rdi
iterable => rsi
*/
void th_3Map___construct(ObjectData* this_) asm("_ZN4HPHP5c_Map13t___constructEv");
void th_3Map___construct(ObjectData* this_, TypedValue* iterable) asm("_ZN4HPHP5c_Map13t___constructERKNS_7VariantE");
TypedValue* tg_3Map___construct(HPHP::VM::ActRec *ar) {
TypedValue rv;
@@ -1298,22 +1380,23 @@ TypedValue* tg_3Map___construct(HPHP::VM::ActRec *ar) {
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
ObjectData* this_ = (ar->hasThis() ? ar->getThis() : NULL);
if (this_) {
if (count == 0LL) {
if (count <= 1LL) {
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
th_3Map___construct((this_));
frame_free_locals_inl(ar, 0);
Variant defVal0;
th_3Map___construct((this_), (count > 0) ? (args-0) : (TypedValue*)(&defVal0));
frame_free_locals_inl(ar, 1);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
} else {
throw_toomany_arguments_nr("Map::__construct", 0, 1);
throw_toomany_arguments_nr("Map::__construct", 1, 1);
}
} else {
throw_instance_method_fatal("Map::__construct");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 0);
frame_free_locals_inl(ar, 1);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
return &ar->m_r;
@@ -1467,6 +1550,46 @@ TypedValue* tg_3Map_get(HPHP::VM::ActRec *ar) {
return &ar->m_r;
}
/*
HPHP::Object HPHP::c_Map::t_set(HPHP::Variant const&, HPHP::Variant const&)
_ZN4HPHP5c_Map5t_setERKNS_7VariantES3_
(return value) => rax
_rv => rdi
this_ => rsi
key => rdx
value => rcx
*/
Value* th_3Map_set(Value* _rv, ObjectData* this_, TypedValue* key, TypedValue* value) asm("_ZN4HPHP5c_Map5t_setERKNS_7VariantES3_");
TypedValue* tg_3Map_set(HPHP::VM::ActRec *ar) {
TypedValue rv;
int64_t count = ar->numArgs();
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
ObjectData* this_ = (ar->hasThis() ? ar->getThis() : NULL);
if (this_) {
if (count == 2LL) {
rv.m_type = KindOfObject;
th_3Map_set((Value*)(&(rv)), (this_), (args-0), (args-1));
if (rv.m_data.num == 0LL) rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 2);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
} else {
throw_wrong_arguments_nr("Map::set", count, 2, 2, 1);
}
} else {
throw_instance_method_fatal("Map::set");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 2);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
return &ar->m_r;
}
/*
HPHP::Object HPHP::c_Map::t_put(HPHP::Variant const&, HPHP::Variant const&)
_ZN4HPHP5c_Map5t_putERKNS_7VariantES3_
@@ -1621,6 +1744,45 @@ TypedValue* tg_3Map_remove(HPHP::VM::ActRec *ar) {
return &ar->m_r;
}
/*
HPHP::Object HPHP::c_Map::t_removeat(HPHP::Variant const&)
_ZN4HPHP5c_Map10t_removeatERKNS_7VariantE
(return value) => rax
_rv => rdi
this_ => rsi
key => rdx
*/
Value* th_3Map_removeAt(Value* _rv, ObjectData* this_, TypedValue* key) asm("_ZN4HPHP5c_Map10t_removeatERKNS_7VariantE");
TypedValue* tg_3Map_removeAt(HPHP::VM::ActRec *ar) {
TypedValue rv;
int64_t count = ar->numArgs();
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
ObjectData* this_ = (ar->hasThis() ? ar->getThis() : NULL);
if (this_) {
if (count == 1LL) {
rv.m_type = KindOfObject;
th_3Map_removeAt((Value*)(&(rv)), (this_), (args-0));
if (rv.m_data.num == 0LL) rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 1);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
} else {
throw_wrong_arguments_nr("Map::removeAt", count, 1, 1, 1);
}
} else {
throw_instance_method_fatal("Map::removeAt");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 1);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
return &ar->m_r;
}
/*
HPHP::Object HPHP::c_Map::t_discard(HPHP::Variant const&)
_ZN4HPHP5c_Map9t_discardERKNS_7VariantE
@@ -2502,13 +2664,14 @@ HPHP::VM::Instance* new_StableMap_Instance(HPHP::VM::Class* cls) {
IMPLEMENT_CLASS(StableMap);
/*
void HPHP::c_StableMap::t___construct()
_ZN4HPHP11c_StableMap13t___constructEv
void HPHP::c_StableMap::t___construct(HPHP::Variant const&)
_ZN4HPHP11c_StableMap13t___constructERKNS_7VariantE
this_ => rdi
iterable => rsi
*/
void th_9StableMap___construct(ObjectData* this_) asm("_ZN4HPHP11c_StableMap13t___constructEv");
void th_9StableMap___construct(ObjectData* this_, TypedValue* iterable) asm("_ZN4HPHP11c_StableMap13t___constructERKNS_7VariantE");
TypedValue* tg_9StableMap___construct(HPHP::VM::ActRec *ar) {
TypedValue rv;
@@ -2516,22 +2679,23 @@ TypedValue* tg_9StableMap___construct(HPHP::VM::ActRec *ar) {
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
ObjectData* this_ = (ar->hasThis() ? ar->getThis() : NULL);
if (this_) {
if (count == 0LL) {
if (count <= 1LL) {
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
th_9StableMap___construct((this_));
frame_free_locals_inl(ar, 0);
Variant defVal0;
th_9StableMap___construct((this_), (count > 0) ? (args-0) : (TypedValue*)(&defVal0));
frame_free_locals_inl(ar, 1);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
} else {
throw_toomany_arguments_nr("StableMap::__construct", 0, 1);
throw_toomany_arguments_nr("StableMap::__construct", 1, 1);
}
} else {
throw_instance_method_fatal("StableMap::__construct");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 0);
frame_free_locals_inl(ar, 1);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
return &ar->m_r;
@@ -2685,6 +2849,46 @@ TypedValue* tg_9StableMap_get(HPHP::VM::ActRec *ar) {
return &ar->m_r;
}
/*
HPHP::Object HPHP::c_StableMap::t_set(HPHP::Variant const&, HPHP::Variant const&)
_ZN4HPHP11c_StableMap5t_setERKNS_7VariantES3_
(return value) => rax
_rv => rdi
this_ => rsi
key => rdx
value => rcx
*/
Value* th_9StableMap_set(Value* _rv, ObjectData* this_, TypedValue* key, TypedValue* value) asm("_ZN4HPHP11c_StableMap5t_setERKNS_7VariantES3_");
TypedValue* tg_9StableMap_set(HPHP::VM::ActRec *ar) {
TypedValue rv;
int64_t count = ar->numArgs();
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
ObjectData* this_ = (ar->hasThis() ? ar->getThis() : NULL);
if (this_) {
if (count == 2LL) {
rv.m_type = KindOfObject;
th_9StableMap_set((Value*)(&(rv)), (this_), (args-0), (args-1));
if (rv.m_data.num == 0LL) rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 2);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
} else {
throw_wrong_arguments_nr("StableMap::set", count, 2, 2, 1);
}
} else {
throw_instance_method_fatal("StableMap::set");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 2);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
return &ar->m_r;
}
/*
HPHP::Object HPHP::c_StableMap::t_put(HPHP::Variant const&, HPHP::Variant const&)
_ZN4HPHP11c_StableMap5t_putERKNS_7VariantES3_
@@ -2839,6 +3043,45 @@ TypedValue* tg_9StableMap_remove(HPHP::VM::ActRec *ar) {
return &ar->m_r;
}
/*
HPHP::Object HPHP::c_StableMap::t_removeat(HPHP::Variant const&)
_ZN4HPHP11c_StableMap10t_removeatERKNS_7VariantE
(return value) => rax
_rv => rdi
this_ => rsi
key => rdx
*/
Value* th_9StableMap_removeAt(Value* _rv, ObjectData* this_, TypedValue* key) asm("_ZN4HPHP11c_StableMap10t_removeatERKNS_7VariantE");
TypedValue* tg_9StableMap_removeAt(HPHP::VM::ActRec *ar) {
TypedValue rv;
int64_t count = ar->numArgs();
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
ObjectData* this_ = (ar->hasThis() ? ar->getThis() : NULL);
if (this_) {
if (count == 1LL) {
rv.m_type = KindOfObject;
th_9StableMap_removeAt((Value*)(&(rv)), (this_), (args-0));
if (rv.m_data.num == 0LL) rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 1);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
} else {
throw_wrong_arguments_nr("StableMap::removeAt", count, 1, 1, 1);
}
} else {
throw_instance_method_fatal("StableMap::removeAt");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 1);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
return &ar->m_r;
}
/*
HPHP::Object HPHP::c_StableMap::t_discard(HPHP::Variant const&)
_ZN4HPHP11c_StableMap9t_discardERKNS_7VariantE
@@ -45,7 +45,7 @@ class c_Vector : public ExtObjectDataFlags<ObjectData::VectorAttrInit|
public: c_Vector(VM::Class* cls = c_Vector::s_cls);
public: ~c_Vector();
public: void freeData();
public: void t___construct();
public: void t___construct(CVarRef iterable = null_variant);
public: Variant t___destruct();
public: Object t_add(CVarRef val);
public: Object t_append(CVarRef val);
@@ -56,8 +56,10 @@ class c_Vector : public ExtObjectDataFlags<ObjectData::VectorAttrInit|
public: int64_t t_count();
public: Variant t_at(CVarRef key);
public: Variant t_get(CVarRef key);
public: Object t_set(CVarRef key, CVarRef value);
public: Object t_put(CVarRef key, CVarRef value);
public: bool t_contains(CVarRef key);
public: Object t_removeat(CVarRef key);
public: Array t_toarray();
public: void t_sort(CVarRef col = null);
public: void t_reverse();
@@ -216,16 +218,18 @@ class c_Map : public ExtObjectDataFlags<ObjectData::MapAttrInit|
public: c_Map(VM::Class* cls = c_Map::s_cls);
public: ~c_Map();
public: void freeData();
public: void t___construct();
public: void t___construct(CVarRef iterable = null_variant);
public: Variant t___destruct();
public: Object t_clear();
public: bool t_isempty();
public: int64_t t_count();
public: Variant t_at(CVarRef key);
public: Variant t_get(CVarRef key);
public: Object t_set(CVarRef key, CVarRef value);
public: Object t_put(CVarRef key, CVarRef value);
public: bool t_contains(CVarRef key);
public: Object t_remove(CVarRef key);
public: Object t_removeat(CVarRef key);
public: Object t_discard(CVarRef key);
public: Array t_toarray();
public: Array t_copyasarray();
@@ -399,20 +403,20 @@ private:
uint m_nLastSlot;
int m_versionNumber;
uintptr_t numSlots() {
size_t numSlots() const {
return m_nLastSlot + 1;
}
// The maximum load factor is 75%.
uintptr_t computeMaxLoad() {
uintptr_t n = numSlots();
size_t computeMaxLoad() const {
size_t n = numSlots();
return (n - (n >> 2));
}
// When the map is not empty, the minimum allowed ratio
// of # elements / # slots is 18.75%.
uintptr_t computeMinElements() {
uintptr_t n = numSlots();
size_t computeMinElements() const {
size_t n = numSlots();
return ((n >> 3) + ((n+8) >> 4));
}
@@ -502,16 +506,18 @@ class c_StableMap : public ExtObjectDataFlags<ObjectData::StableMapAttrInit|
public: c_StableMap(VM::Class* cls = c_StableMap::s_cls);
public: ~c_StableMap();
public: void freeData();
public: void t___construct();
public: void t___construct(CVarRef iterable = null_variant);
public: Variant t___destruct();
public: Object t_clear();
public: bool t_isempty();
public: int64_t t_count();
public: Variant t_at(CVarRef key);
public: Variant t_get(CVarRef key);
public: Object t_set(CVarRef key, CVarRef value);
public: Object t_put(CVarRef key, CVarRef value);
public: bool t_contains(CVarRef key);
public: Object t_remove(CVarRef key);
public: Object t_removeat(CVarRef key);
public: Object t_discard(CVarRef key);
public: Array t_toarray();
public: Array t_copyasarray();
+15 -3
Ver Arquivo
@@ -2280,9 +2280,11 @@ TypedValue* tg_6Vector_isEmpty(VM::ActRec *ar);
TypedValue* tg_6Vector_count(VM::ActRec *ar);
TypedValue* tg_6Vector_at(VM::ActRec *ar);
TypedValue* tg_6Vector_get(VM::ActRec *ar);
TypedValue* tg_6Vector_set(VM::ActRec *ar);
TypedValue* tg_6Vector_put(VM::ActRec *ar);
TypedValue* tg_6Vector_clear(VM::ActRec *ar);
TypedValue* tg_6Vector_contains(VM::ActRec *ar);
TypedValue* tg_6Vector_removeAt(VM::ActRec *ar);
TypedValue* tg_6Vector_append(VM::ActRec *ar);
TypedValue* tg_6Vector_add(VM::ActRec *ar);
TypedValue* tg_6Vector_pop(VM::ActRec *ar);
@@ -2315,10 +2317,12 @@ TypedValue* tg_3Map_isEmpty(VM::ActRec *ar);
TypedValue* tg_3Map_count(VM::ActRec *ar);
TypedValue* tg_3Map_at(VM::ActRec *ar);
TypedValue* tg_3Map_get(VM::ActRec *ar);
TypedValue* tg_3Map_set(VM::ActRec *ar);
TypedValue* tg_3Map_put(VM::ActRec *ar);
TypedValue* tg_3Map_clear(VM::ActRec *ar);
TypedValue* tg_3Map_contains(VM::ActRec *ar);
TypedValue* tg_3Map_remove(VM::ActRec *ar);
TypedValue* tg_3Map_removeAt(VM::ActRec *ar);
TypedValue* tg_3Map_discard(VM::ActRec *ar);
TypedValue* tg_3Map_toArray(VM::ActRec *ar);
TypedValue* tg_3Map_copyAsArray(VM::ActRec *ar);
@@ -2349,10 +2353,12 @@ TypedValue* tg_9StableMap_isEmpty(VM::ActRec *ar);
TypedValue* tg_9StableMap_count(VM::ActRec *ar);
TypedValue* tg_9StableMap_at(VM::ActRec *ar);
TypedValue* tg_9StableMap_get(VM::ActRec *ar);
TypedValue* tg_9StableMap_set(VM::ActRec *ar);
TypedValue* tg_9StableMap_put(VM::ActRec *ar);
TypedValue* tg_9StableMap_clear(VM::ActRec *ar);
TypedValue* tg_9StableMap_contains(VM::ActRec *ar);
TypedValue* tg_9StableMap_remove(VM::ActRec *ar);
TypedValue* tg_9StableMap_removeAt(VM::ActRec *ar);
TypedValue* tg_9StableMap_discard(VM::ActRec *ar);
TypedValue* tg_9StableMap_toArray(VM::ActRec *ar);
TypedValue* tg_9StableMap_copyAsArray(VM::ActRec *ar);
@@ -5294,16 +5300,18 @@ static const HhbcExtMethodInfo hhbc_ext_methods_DummyClosure[] = {
{ "__construct", tg_12DummyClosure___construct }
};
static const long long hhbc_ext_method_count_Vector = 27;
static const long long hhbc_ext_method_count_Vector = 29;
static const HhbcExtMethodInfo hhbc_ext_methods_Vector[] = {
{ "__construct", tg_6Vector___construct },
{ "isEmpty", tg_6Vector_isEmpty },
{ "count", tg_6Vector_count },
{ "at", tg_6Vector_at },
{ "get", tg_6Vector_get },
{ "set", tg_6Vector_set },
{ "put", tg_6Vector_put },
{ "clear", tg_6Vector_clear },
{ "contains", tg_6Vector_contains },
{ "removeAt", tg_6Vector_removeAt },
{ "append", tg_6Vector_append },
{ "add", tg_6Vector_add },
{ "pop", tg_6Vector_pop },
@@ -5335,17 +5343,19 @@ static const HhbcExtMethodInfo hhbc_ext_methods_VectorIterator[] = {
{ "rewind", tg_14VectorIterator_rewind }
};
static const long long hhbc_ext_method_count_Map = 26;
static const long long hhbc_ext_method_count_Map = 28;
static const HhbcExtMethodInfo hhbc_ext_methods_Map[] = {
{ "__construct", tg_3Map___construct },
{ "isEmpty", tg_3Map_isEmpty },
{ "count", tg_3Map_count },
{ "at", tg_3Map_at },
{ "get", tg_3Map_get },
{ "set", tg_3Map_set },
{ "put", tg_3Map_put },
{ "clear", tg_3Map_clear },
{ "contains", tg_3Map_contains },
{ "remove", tg_3Map_remove },
{ "removeAt", tg_3Map_removeAt },
{ "discard", tg_3Map_discard },
{ "toArray", tg_3Map_toArray },
{ "copyAsArray", tg_3Map_copyAsArray },
@@ -5375,17 +5385,19 @@ static const HhbcExtMethodInfo hhbc_ext_methods_MapIterator[] = {
{ "rewind", tg_11MapIterator_rewind }
};
static const long long hhbc_ext_method_count_StableMap = 26;
static const long long hhbc_ext_method_count_StableMap = 28;
static const HhbcExtMethodInfo hhbc_ext_methods_StableMap[] = {
{ "__construct", tg_9StableMap___construct },
{ "isEmpty", tg_9StableMap_isEmpty },
{ "count", tg_9StableMap_count },
{ "at", tg_9StableMap_at },
{ "get", tg_9StableMap_get },
{ "set", tg_9StableMap_set },
{ "put", tg_9StableMap_put },
{ "clear", tg_9StableMap_clear },
{ "contains", tg_9StableMap_contains },
{ "remove", tg_9StableMap_remove },
{ "removeAt", tg_9StableMap_removeAt },
{ "discard", tg_9StableMap_discard },
{ "toArray", tg_9StableMap_toArray },
{ "copyAsArray", tg_9StableMap_copyAsArray },
+1 -1
Ver Arquivo
@@ -23,6 +23,7 @@
#include "../ext/ext_preg.ext_hhvm.h"
#include "../ext/ext_process.ext_hhvm.h"
#include "../ext/ext_openssl.ext_hhvm.h"
#include "../ext/ext_collections.ext_hhvm.h"
#include "../ext/ext_function.ext_hhvm.h"
#include "../ext/ext_closure.ext_hhvm.h"
#include "../ext/mailparse/mime.ext_hhvm.h"
@@ -59,7 +60,6 @@
#include "../ext/ext_debugger.ext_hhvm.h"
#include "../ext/ext_domdocument.ext_hhvm.h"
#include "../ext/ext_soap.ext_hhvm.h"
#include "../ext/ext_collection.ext_hhvm.h"
#include "../ext/ext_url.ext_hhvm.h"
#include "../ext/ext_hash.ext_hhvm.h"
#include "../ext/ext_ipc.ext_hhvm.h"
+1 -1
Ver Arquivo
@@ -63,7 +63,7 @@
#include <runtime/base/util/extended_logger.h>
#include <system/lib/systemlib.h>
#include <runtime/ext/ext_collection.h>
#include <runtime/ext/ext_collections.h>
#include "runtime/vm/name_value_table_wrapper.h"
#include "runtime/vm/request_arena.h"
+1 -1
Ver Arquivo
@@ -23,7 +23,7 @@
#include "runtime/vm/instance.h"
#include "runtime/vm/object_allocator_sizes.h"
#include "runtime/vm/translator/translator-inline.h"
#include "runtime/ext/ext_collection.h"
#include "runtime/ext/ext_collections.h"
#include "system/lib/systemlib.h"
namespace HPHP {
+1 -1
Ver Arquivo
@@ -15,7 +15,7 @@
*/
#include "runtime/vm/member_operations.h"
#include "runtime/ext/ext_collection.h"
#include "runtime/ext/ext_collections.h"
namespace HPHP {
namespace VM {
+1 -1
Ver Arquivo
@@ -23,7 +23,7 @@
#include "runtime/base/builtin_functions.h"
#include "runtime/vm/core_types.h"
#include "runtime/vm/runtime.h"
#include "runtime/ext/ext_collection.h"
#include "runtime/ext/ext_collections.h"
namespace HPHP {
namespace VM {
+1 -1
Ver Arquivo
@@ -19,7 +19,7 @@
#include "runtime/base/array/hphp_array.h"
#include "runtime/base/builtin_functions.h"
#include "runtime/ext/ext_continuation.h"
#include "runtime/ext/ext_collection.h"
#include "runtime/ext/ext_collections.h"
#include "runtime/vm/core_types.h"
#include "runtime/vm/bytecode.h"
#include "runtime/vm/repo.h"
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
+7
Ver Arquivo
@@ -167,6 +167,9 @@ interface Iterator extends Traversable {
public function valid();
}
interface KeyedIterator extends Iterator {
}
// Do NOT modifiy this doc comment block generated by idl/sysdoc.php
/**
* ( excerpt from http://php.net/manual/en/class.seekableiterator.php )
@@ -789,6 +792,9 @@ interface IteratorAggregate extends Traversable {
interface Iterable extends IteratorAggregate {
}
interface KeyedIterable extends Iterable {
}
///////////////////////////////////////////////////////////////////////////////
// http://www.php.net/~helly/php/ext/spl/appenditerator_8inc-source.html
@@ -929,3 +935,4 @@ class AppendIterator implements OuterIterator {
$params);
}
}
Diff do arquivo suprimido porque uma ou mais linhas são muito longas
Diff do arquivo suprimido porque uma ou mais linhas são muito longas
+1 -1
Ver Arquivo
@@ -10,7 +10,7 @@
#include "bzip2.inc"
#include "class.inc"
#include "closure.inc"
#include "collection.inc"
#include "collections.inc"
#include "continuation.inc"
#include "ctype.inc"
#include "curl.inc"
+111 -16
Ver Arquivo
@@ -9320,13 +9320,13 @@ bool TestCodeRun::TestCollectionClasses() {
"function f() {\n"
" var_dump(Vector {});\n"
" var_dump(Map {});\n"
" var_dump(Vector { 1, 2 });\n"
" var_dump(StableMap { 'a' => 1, 'b' => 2 });\n"
" var_dump(Vector {1, 2});\n"
" var_dump(StableMap {'a' => 1, 'b' => 2});\n"
"\n"
" var_dump(Vector<int> {});\n"
" var_dump(Map<string,int> {});\n"
" var_dump(Vector<int> { 1, 2 });\n"
" var_dump(StableMap<string,int> { 'a' => 1, 'b' => 2 });\n"
" var_dump(Vector<int> {1, 2});\n"
" var_dump(StableMap<string,int> {'a' => 1, 'b' => 2});\n"
"}\n"
"f();\n"
,
@@ -9366,10 +9366,10 @@ bool TestCodeRun::TestCollectionClasses() {
MVCRO("<?php\n"
"function f($x1, $x2, $x3, $x4) {\n"
" return Vector { $x1, $x2, $x3, $x4 };\n"
" return Vector {$x1, $x2, $x3, $x4};\n"
"}\n"
"function g($k1, $v1, $k2, $v2) {\n"
" $m = Map { $k1 => $v1, $k2 => $v2 };\n"
" $m = Map {$k1 => $v1, $k2 => $v2};\n"
" return $m;\n"
"}\n"
"var_dump(f(42, 123.456, 'blah', array(3, 5, 7)));\n"
@@ -9493,7 +9493,7 @@ bool TestCodeRun::TestCollectionClasses() {
MVCRO("<?php\n"
"function f() {\n"
" $x = StableMap { 'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4 };\n"
" $x = StableMap {'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4};\n"
" unset($x['a']);\n"
" unset($x['c']);\n"
" foreach ($x as $k => $v) {\n"
@@ -9507,8 +9507,8 @@ bool TestCodeRun::TestCollectionClasses() {
);
MVCRO("<?php\n"
"$v1 = Vector { 5 };\n"
"$v2 = Vector { 5 };\n"
"$v1 = Vector {5};\n"
"$v2 = Vector {5};\n"
"var_dump($v1 === $v2);\n"
"var_dump($v1 == $v2);\n"
"$v1[] = \"123\";\n"
@@ -9526,7 +9526,7 @@ bool TestCodeRun::TestCollectionClasses() {
"var_dump($v == 1);\n"
"var_dump($v == \"Vector\");\n"
"echo \"============\\n\";\n"
"$v = Vector { 7 };\n"
"$v = Vector {7};\n"
"var_dump($v == null);\n"
"var_dump($v == false);\n"
"var_dump($v == true);\n"
@@ -9564,10 +9564,10 @@ bool TestCodeRun::TestCollectionClasses() {
"$m1['c'] = 0;\n"
"var_dump($m1 == $m2);\n"
"echo \"============\\n\";\n"
"$m1 = Map { 'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4 };\n"
"$m1 = Map {'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4};\n"
"$m1->remove('a');\n"
"$m1->remove('c');\n"
"$m2 = Map { 'b' => 2, 'd' => 4 };\n"
"$m2 = Map {'b' => 2, 'd' => 4};\n"
"var_dump($m1 == $m2);\n"
"$m1->remove('d');\n"
"var_dump($m1 == $m2);\n"
@@ -9585,7 +9585,7 @@ bool TestCodeRun::TestCollectionClasses() {
"var_dump($m == 1);\n"
"var_dump($m == \"Map\");\n"
"echo \"============\\n\";\n"
"$m = Map { 'x' => 7 };\n"
"$m = Map {'x' => 7};\n"
"var_dump($m == null);\n"
"var_dump($m == false);\n"
"var_dump($m == true);\n"
@@ -9616,8 +9616,8 @@ bool TestCodeRun::TestCollectionClasses() {
);
MVCRO("<?php\n"
"$s1 = StableMap { 'a' => 1, 'b' => 2 };\n"
"$s2 = StableMap { 'b' => 2, 'a' => 1 };\n"
"$s1 = StableMap {'a' => 1, 'b' => 2};\n"
"$s2 = StableMap {'b' => 2, 'a' => 1};\n"
"var_dump($s1 == $s2);\n"
"$s2->remove('b');\n"
"$s2['b'] = 2;\n"
@@ -9634,7 +9634,7 @@ bool TestCodeRun::TestCollectionClasses() {
"var_dump($m == 1);\n"
"var_dump($m == \"StableMap\");\n"
"echo \"============\\n\";\n"
"$m = StableMap { 'x' => 7 };\n"
"$m = StableMap {'x' => 7};\n"
"var_dump($m == null);\n"
"var_dump($m == false);\n"
"var_dump($m == true);\n"
@@ -9658,6 +9658,101 @@ bool TestCodeRun::TestCollectionClasses() {
"bool(false)\n"
"bool(false)\n"
);
{
HipHopSyntax w1(this);
MVCRO("<?php\n"
"function f() {\n"
" $v = Vector {'a', 'b', 'c'};\n"
" $m = new Map($v);\n"
" var_dump($m);\n"
" $sm = new StableMap($m);\n"
" var_dump($sm);\n"
"}\n"
"function g() {\n"
" $m = Map {'a' => 1, 2 => 'b'};\n"
" $v = new Vector($m);\n"
" var_dump($v);\n"
"}\n"
"function h() {\n"
" $arr1 = array(11, 22, 33);\n"
" var_dump(new Vector($arr1));\n"
" var_dump(new Map($arr1));\n"
" $arr2 = array('a' => 1, 2 => 'b');\n"
" var_dump(new Vector($arr2));\n"
" var_dump(new StableMap($arr2));\n"
"}\n"
"function gen() {\n"
" yield 42;\n"
" yield 72;\n"
"}\n"
"function j() {\n"
" $v = new Vector(gen());\n"
" var_dump($v);\n"
"}\n"
"f();\n"
"g();\n"
"h();\n"
"j();\n"
,
"object(Map)#2 (3) {\n"
" [0]=>\n"
" string(1) \"a\"\n"
" [1]=>\n"
" string(1) \"b\"\n"
" [2]=>\n"
" string(1) \"c\"\n"
"}\n"
"object(StableMap)#3 (3) {\n"
" [0]=>\n"
" string(1) \"a\"\n"
" [1]=>\n"
" string(1) \"b\"\n"
" [2]=>\n"
" string(1) \"c\"\n"
"}\n"
"object(Vector)#2 (2) {\n"
" [0]=>\n"
" int(1)\n"
" [1]=>\n"
" string(1) \"b\"\n"
"}\n"
"object(Vector)#1 (3) {\n"
" [0]=>\n"
" int(11)\n"
" [1]=>\n"
" int(22)\n"
" [2]=>\n"
" int(33)\n"
"}\n"
"object(Map)#1 (3) {\n"
" [0]=>\n"
" int(11)\n"
" [1]=>\n"
" int(22)\n"
" [2]=>\n"
" int(33)\n"
"}\n"
"object(Vector)#1 (2) {\n"
" [0]=>\n"
" int(1)\n"
" [1]=>\n"
" string(1) \"b\"\n"
"}\n"
"object(StableMap)#1 (2) {\n"
" [\"a\"]=>\n"
" int(1)\n"
" [2]=>\n"
" string(1) \"b\"\n"
"}\n"
"object(Vector)#1 (2) {\n"
" [0]=>\n"
" int(42)\n"
" [1]=>\n"
" int(72)\n"
"}\n"
);
}
return true;
}
+1 -1
Ver Arquivo
@@ -25,7 +25,7 @@
#include <test/test_ext_bzip2.h>
#include <test/test_ext_class.h>
#include <test/test_ext_closure.h>
#include <test/test_ext_collection.h>
#include <test/test_ext_collections.h>
#include <test/test_ext_continuation.h>
#include <test/test_ext_ctype.h>
#include <test/test_ext_curl.h>
+1 -1
Ver Arquivo
@@ -10,7 +10,7 @@ RUN_TESTSUITE(TestExtBcmath);
RUN_TESTSUITE(TestExtBzip2);
RUN_TESTSUITE(TestExtClass);
RUN_TESTSUITE(TestExtClosure);
RUN_TESTSUITE(TestExtCollection);
RUN_TESTSUITE(TestExtCollections);
RUN_TESTSUITE(TestExtContinuation);
RUN_TESTSUITE(TestExtCtype);
RUN_TESTSUITE(TestExtCurl);
@@ -14,13 +14,13 @@
+----------------------------------------------------------------------+
*/
#include <test/test_ext_collection.h>
#include <runtime/ext/ext_collection.h>
#include <test/test_ext_collections.h>
#include <runtime/ext/ext_collections.h>
IMPLEMENT_SEP_EXTENSION_TEST(Collection);
///////////////////////////////////////////////////////////////////////////////
bool TestExtCollection::RunTests(const std::string &which) {
bool TestExtCollections::RunTests(const std::string &which) {
bool ret = true;
return ret;
@@ -23,7 +23,7 @@
///////////////////////////////////////////////////////////////////////////////
class TestExtCollection : public TestCppExt {
class TestExtCollections : public TestCppExt {
public:
virtual bool RunTests(const std::string &which);
};
+5 -5
Ver Arquivo
@@ -43,10 +43,10 @@ function main() {
class V {
public $x = array('a' => 1);
public $y = Map { 'a' => 1 };
public $y = Map {'a' => 1};
}
class W extends V {
public $x = Map { 'a' => 1 };
public $x = Map {'a' => 1};
public $y = array('a' => 1);
}
$obj1 = new W;
@@ -68,7 +68,7 @@ function main() {
echo "=========\n";
class X {
public $prop = array ( Map { 'a' => 1 } );
public $prop = array(Map {'a' => 1});
}
$obj1 = new X;
$obj2 = new X;
@@ -76,7 +76,7 @@ function main() {
var_dump($obj1->prop[0]['a']);
var_dump($obj2->prop[0]['a']);
class Y {
public $prop = Vector { array ( Map { 'a' => 1 } ) };
public $prop = Vector {array(Map {'a' => 1})};
}
$obj1 = new Y;
$obj2 = new Y;
@@ -91,7 +91,7 @@ function main() {
class Z {
const FOO = 456;
const BAR = "yo";
public $prop = StableMap { FOO => BAR, Z::FOO => Z::BAR };
public $prop = StableMap {FOO => BAR, Z::FOO => Z::BAR};
}
$obj1 = new Z;
var_dump($obj1->prop[FOO], $obj1->prop[Z::FOO], count($obj1->prop));