Add map(), filter(), zip() APIs for collections

Esse commit está contido em:
andrewparoski
2013-04-03 21:28:13 -07:00
commit de Sara Golemon
commit ebeecdb417
20 arquivos alterados com 3144 adições e 206 exclusões
+397 -14
Ver Arquivo
@@ -2221,10 +2221,52 @@ interface Awaitable {
public function getWaitHandle();
}
class KeysIterator implements Iterator {
public $it;
public function __construct($it) {
trait IterableTrait {
public function view() {
return $this;
}
public function map($callback) {
return new MappedIterable($this, $callback);
}
public function filter($callback) {
return new FilteredIterable($this, $callback);
}
public function zip($iterable) {
return new ZippedIterable($this, $iterable);
}
}
trait KeyedIterableTrait {
public function view() {
return $this;
}
public function map($callback) {
return new MappedKeyedIterable($this, $callback);
}
public function filter($callback) {
return new FilteredKeyedIterable($this, $callback);
}
public function zip($iterable) {
return new ZippedKeyedIterable($this, $iterable);
}
public function keys() {
return new KeysIterable($this);
}
public function kvzip() {
return new KVZippedIterable($this);
}
}
class MappedIterator implements Iterator {
private $it;
private $fn;
public function __construct($it, $fn) {
$this->it = $it;
$this->fn = $fn;
}
public function __clone() {
$this->it = clone $this->it;
}
public function rewind() {
$this->it->rewind();
@@ -2237,7 +2279,294 @@ class KeysIterator implements Iterator {
}
public function key() {
throw new RuntimeException(
"Call to undefined method KeysIterator::keys()");
"Call to undefined method MappedIterator::key()");
}
public function current() {
return ($this->fn)($this->it->current());
}
}
class MappedIterable implements Iterable {
use IterableTrait;
private $iterable;
private $fn;
public function __construct($iterable, $fn) {
$this->iterable = $iterable;
$this->fn = $fn;
}
public function getIterator() {
return new MappedIterator($this->iterable->getIterator(), $this->fn);
}
}
class MappedKeyedIterator implements KeyedIterator {
private $it;
private $fn;
public function __construct($it, $fn) {
$this->it = $it;
$this->fn = $fn;
}
public function __clone() {
$this->it = clone $this->it;
}
public function rewind() {
$this->it->rewind();
}
public function valid() {
return $this->it->valid();
}
public function next() {
$this->it->next();
}
public function key() {
return $this->it->key();
}
public function current() {
return ($this->fn)($this->it->current());
}
}
class MappedKeyedIterable implements KeyedIterable {
use KeyedIterableTrait;
private $iterable;
private $fn;
public function __construct($iterable, $fn) {
$this->iterable = $iterable;
$this->fn = $fn;
}
public function getIterator() {
return new MappedKeyedIterator($this->iterable->getIterator(), $this->fn);
}
}
class FilteredIterator implements Iterator {
private $it;
private $fn;
public function __construct($it, $fn) {
$this->it = $it;
$this->fn = $fn;
}
public function __clone() {
$this->it = clone $this->it;
}
public function rewind() {
$it = $this->it;
$fn = $this->fn;
$it->rewind();
while ($it->valid() && !$fn($it->current())) {
$it->next();
}
}
public function valid() {
return $this->it->valid();
}
public function next() {
$it = $this->it;
$fn = $this->fn;
$it->next();
while ($it->valid() && !$fn($it->current())) {
$it->next();
}
}
public function key() {
throw new RuntimeException(
"Call to undefined method FilteredIterator::key()");
}
public function current() {
return $this->it->current();
}
}
class FilteredIterable implements Iterable {
use IterableTrait;
private $iterable;
private $fn;
public function __construct($iterable, $fn) {
$this->iterable = $iterable;
$this->fn = $fn;
}
public function getIterator() {
return new FilteredIterator($this->iterable->getIterator(), $this->fn);
}
}
class FilteredKeyedIterator implements KeyedIterator {
private $it;
private $fn;
public function __construct($it, $fn) {
$this->it = $it;
$this->fn = $fn;
}
public function __clone() {
$this->it = clone $this->it;
}
public function rewind() {
$it = $this->it;
$fn = $this->fn;
$it->rewind();
while ($it->valid() && !$fn($it->current())) {
$it->next();
}
}
public function valid() {
return $this->it->valid();
}
public function next() {
$it = $this->it;
$fn = $this->fn;
$it->next();
while ($it->valid() && !$fn($it->current())) {
$it->next();
}
}
public function key() {
return $this->it->key();
}
public function current() {
return $this->it->current();
}
}
class FilteredKeyedIterable implements KeyedIterable {
use KeyedIterableTrait;
private $iterable;
private $fn;
public function __construct($iterable, $fn) {
$this->iterable = $iterable;
$this->fn = $fn;
}
public function getIterator() {
return new FilteredKeyedIterator($this->iterable->getIterator(), $this->fn);
}
}
class ZippedIterator implements Iterator {
private $it1;
private $it2;
public function __construct($it1, $it2) {
$this->it1 = $it1;
$this->it2 = $it2;
}
public function __clone() {
$this->it1 = clone $this->it1;
$this->it2 = clone $this->it2;
}
public function rewind() {
$this->it1->rewind();
$this->it2->rewind();
}
public function valid() {
return ($this->it1->valid() && $this->it2->valid());
}
public function next() {
$this->it1->next();
$this->it2->next();
}
public function key() {
throw new RuntimeException(
"Call to undefined method ZippedIterator::key()");
}
public function current() {
return Pair {$this->it1->current(), $this->it2->current()};
}
}
class ZippedIterable implements Iterable {
use IterableTrait;
private $iterable1;
private $iterable2;
public function __construct($iterable1, $iterable2) {
$this->iterable1 = $iterable1;
$this->iterable2 = $iterable2;
}
public function getIterator() {
return new ZippedIterator($this->iterable1->getIterator(),
$this->iterable2->getIterator());
}
}
class ZippedKeyedIterator implements KeyedIterator {
private $it1;
private $it2;
public function __construct($it1, $it2) {
$this->it1 = $it1;
$this->it2 = $it2;
}
public function __clone() {
$this->it1 = clone $this->it1;
$this->it2 = clone $this->it2;
}
public function rewind() {
$this->it1->rewind();
$this->it2->rewind();
}
public function valid() {
return ($this->it1->valid() && $this->it2->valid());
}
public function next() {
$this->it1->next();
$this->it2->next();
}
public function key() {
return $this->it1->key();
}
public function current() {
return Pair {$this->it1->current(), $this->it2->current()};
}
}
class ZippedKeyedIterable implements KeyedIterable {
use KeyedIterableTrait;
private $iterable1;
private $iterable2;
public function __construct($iterable1, $iterable2) {
$this->iterable1 = $iterable1;
$this->iterable2 = $iterable2;
}
public function getIterator() {
return new ZippedKeyedIterator($this->iterable1->getIterator(),
$this->iterable2->getIterator());
}
}
class KeysIterator implements Iterator {
private $it;
public function __construct($it) {
$this->it = $it;
}
public function __clone() {
$this->it = clone $this->it;
}
public function rewind() {
$this->it->rewind();
}
public function valid() {
return $this->it->valid();
}
public function next() {
$this->it->next();
}
public function key() {
throw new RuntimeException(
"Call to undefined method KeysIterator::key()");
}
public function current() {
return $this->it->key();
@@ -2245,20 +2574,27 @@ class KeysIterator implements Iterator {
}
class KeysIterable implements Iterable {
public $it;
use IterableTrait;
private $iterable;
public function __construct($iterable) {
$this->it = new KeysIterator($iterable->getIterator());
$this->iterable = $iterable;
}
public function getIterator() {
return clone $this->it;
return new KeysIterator($this->iterable->getIterator());
}
}
class MapItemsIterator implements Iterator {
public $it;
class KVZippedIterator implements Iterator {
private $it;
public function __construct($it) {
$this->it = $it;
}
public function __clone() {
$this->it = clone $this->it;
}
public function rewind() {
$this->it->rewind();
}
@@ -2270,20 +2606,23 @@ class MapItemsIterator implements Iterator {
}
public function key() {
throw new RuntimeException(
"Call to undefined method MapItemsIterator::keys()");
"Call to undefined method KVZippedIterator::key()");
}
public function current() {
return Pair {$this->it->key(), $this->it->current()};
}
}
class MapItemsIterable implements Iterable {
public $it;
class KVZippedIterable implements Iterable {
use IterableTrait;
private $iterable;
public function __construct($iterable) {
$this->it = new MapItemsIterator($iterable->getIterator());
$this->iterable = $iterable;
}
public function getIterator() {
return clone $this->it;
return new KVZippedIterator($this->iterable->getIterator());
}
}
@@ -2362,6 +2701,50 @@ interface MutableSet extends ConstSet,
SetAccess {
}
class IterableView implements Iterable {
public $iterable;
public function __construct($iterable) { $this->iterable = $iterable; }
public function getIterator() { return $this->iterable->getIterator(); }
public function view() {
return $this;
}
public function map($callback) {
return new MappedIterable($this->iterable, $callback);
}
public function filter($callback) {
return new FilteredIterable($this->iterable, $callback);
}
public function zip($iterable) {
return new ZippedIterable($this->iterable, $iterable);
}
}
class KeyedIterableView implements KeyedIterable {
public $iterable;
public function __construct($iterable) { $this->iterable = $iterable; }
public function getIterator() { return $this->iterable->getIterator(); }
public function view() {
return $this;
}
public function map($callback) {
return new MappedKeyedIterable($this->iterable, $callback);
}
public function filter($callback) {
return new FilteredKeyedIterable($this->iterable, $callback);
}
public function zip($iterable) {
return new ZippedKeyedIterable($this->iterable, $iterable);
}
public function keys() {
return new KeysIterable($this->iterable);
}
public function kvzip() {
return new KVZippedIterable($this->iterable);
}
}
interface DebuggerCommand {
/**
+288
Ver Arquivo
@@ -161,6 +161,27 @@ DefineFunction(
),
));
DefineFunction(
array(
'name' => "view",
'flags' => HasDocComment,
'desc' => "Returns a lazy iterable view of this Vector.",
'return' => array(
'type' => Object,
),
));
DefineFunction(
array(
'name' => "kvzip",
'flags' => HasDocComment,
'desc' => "Returns an Iterable that produces the key/value pairs from ".
"this Vector.",
'return' => array(
'type' => Object,
),
));
DefineFunction(
array(
'name' => "at",
@@ -420,6 +441,57 @@ DefineFunction(
),
));
DefineFunction(
array(
'name' => "map",
'flags' => HasDocComment,
'desc' => "Returns a KeyedIterable of the values produced by applying ".
"the specified callback on the values of this Vector.",
'return' => array(
'type' => Object,
),
'args' => array(
array(
'name' => "callback",
'type' => Variant,
),
),
));
DefineFunction(
array(
'name' => "filter",
'flags' => HasDocComment,
'desc' => "Returns a KeyedIterable of all the values from this Vector ".
"for which the specified callback returns true.",
'return' => array(
'type' => Object,
),
'args' => array(
array(
'name' => "callback",
'type' => Variant,
),
),
));
DefineFunction(
array(
'name' => "zip",
'flags' => HasDocComment,
'desc' => "Returns a KeyedIterable produced by combined the specified ".
"Iterables pair-wise.",
'return' => array(
'type' => Object,
),
'args' => array(
array(
'name' => "iterable",
'type' => Variant,
),
),
));
DefineFunction(
array(
'name' => "sort",
@@ -793,6 +865,27 @@ DefineFunction(
),
));
DefineFunction(
array(
'name' => "view",
'flags' => HasDocComment,
'desc' => "Returns a lazy iterable view of this Map.",
'return' => array(
'type' => Object,
),
));
DefineFunction(
array(
'name' => "kvzip",
'flags' => HasDocComment,
'desc' => "Returns an Iterable that produces the key/value pairs from ".
"this Map.",
'return' => array(
'type' => Object,
),
));
DefineFunction(
array(
'name' => "at",
@@ -1129,6 +1222,57 @@ DefineFunction(
),
));
DefineFunction(
array(
'name' => "map",
'flags' => HasDocComment,
'desc' => "Returns a KeyedIterable of the values produced by applying ".
"the specified callback on the values of this Map.",
'return' => array(
'type' => Object,
),
'args' => array(
array(
'name' => "callback",
'type' => Variant,
),
),
));
DefineFunction(
array(
'name' => "filter",
'flags' => HasDocComment,
'desc' => "Returns a KeyedIterable of all the values from this Map ".
"for which the specified callback returns true.",
'return' => array(
'type' => Object,
),
'args' => array(
array(
'name' => "callback",
'type' => Variant,
),
),
));
DefineFunction(
array(
'name' => "zip",
'flags' => HasDocComment,
'desc' => "Returns a KeyedIterable produced by combined the specified ".
"Iterables pair-wise.",
'return' => array(
'type' => Object,
),
'args' => array(
array(
'name' => "iterable",
'type' => Variant,
),
),
));
DefineFunction(
array(
'name' => "__toString",
@@ -1395,6 +1539,27 @@ DefineFunction(
),
));
DefineFunction(
array(
'name' => "view",
'flags' => HasDocComment,
'desc' => "Returns a lazy iterable view of this StableMap.",
'return' => array(
'type' => Object,
),
));
DefineFunction(
array(
'name' => "kvzip",
'flags' => HasDocComment,
'desc' => "Returns an Iterable that produces the key/value pairs from ".
"this StableMap.",
'return' => array(
'type' => Object,
),
));
DefineFunction(
array(
'name' => "at",
@@ -1732,6 +1897,57 @@ DefineFunction(
),
));
DefineFunction(
array(
'name' => "map",
'flags' => HasDocComment,
'desc' => "Returns a KeyedIterable of the values produced by applying ".
"the specified callback on the values of this StableMap.",
'return' => array(
'type' => Object,
),
'args' => array(
array(
'name' => "callback",
'type' => Variant,
),
),
));
DefineFunction(
array(
'name' => "filter",
'flags' => HasDocComment,
'desc' => "Returns a KeyedIterable of all the values from this ".
"StableMap for which the specified callback returns true.",
'return' => array(
'type' => Object,
),
'args' => array(
array(
'name' => "callback",
'type' => Variant,
),
),
));
DefineFunction(
array(
'name' => "zip",
'flags' => HasDocComment,
'desc' => "Returns a KeyedIterable produced by combined the specified ".
"Iterables pair-wise.",
'return' => array(
'type' => Object,
),
'args' => array(
array(
'name' => "iterable",
'type' => Variant,
),
),
));
DefineFunction(
array(
'name' => "__get",
@@ -1994,6 +2210,27 @@ DefineFunction(
),
));
DefineFunction(
array(
'name' => "view",
'flags' => HasDocComment,
'desc' => "Returns a lazy iterable view of this Pair.",
'return' => array(
'type' => Object,
),
));
DefineFunction(
array(
'name' => "kvzip",
'flags' => HasDocComment,
'desc' => "Returns an Iterable that produces the key/value pairs from ".
"this Pair.",
'return' => array(
'type' => Object,
),
));
DefineFunction(
array(
'name' => "toArray",
@@ -2015,6 +2252,57 @@ DefineFunction(
),
));
DefineFunction(
array(
'name' => "map",
'flags' => HasDocComment,
'desc' => "Returns a KeyedIterable of the values produced by applying ".
"the specified callback on the values of this Pair.",
'return' => array(
'type' => Object,
),
'args' => array(
array(
'name' => "callback",
'type' => Variant,
),
),
));
DefineFunction(
array(
'name' => "filter",
'flags' => HasDocComment,
'desc' => "Returns a KeyedIterable of all the values from this Pair ".
"for which the specified callback returns true.",
'return' => array(
'type' => Object,
),
'args' => array(
array(
'name' => "callback",
'type' => Variant,
),
),
));
DefineFunction(
array(
'name' => "zip",
'flags' => HasDocComment,
'desc' => "Returns a KeyedIterable produced by combined the specified ".
"Iterables pair-wise.",
'return' => array(
'type' => Object,
),
'args' => array(
array(
'name' => "iterable",
'type' => Variant,
),
),
));
DefineFunction(
array(
'name' => "at",
+13 -13
Ver Arquivo
@@ -86,19 +86,19 @@ void ArrayIter::objInit(ObjectData *obj) {
switch (getCollectionType()) {
case Collection::VectorType: {
c_Vector* vec = getVector();
m_versionNumber = vec->getVersionNumber();
m_version = vec->getVersion();
m_pos = 0;
break;
}
case Collection::MapType: {
c_Map* mp = getMap();
m_versionNumber = mp->getVersionNumber();
m_version = mp->getVersion();
m_pos = mp->iter_begin();
break;
}
case Collection::StableMapType: {
c_StableMap* smp = getStableMap();
m_versionNumber = smp->getVersionNumber();
m_version = smp->getVersion();
m_pos = smp->iter_begin();
break;
}
@@ -179,7 +179,7 @@ void ArrayIter::nextHelper() {
case Collection::MapType: {
assert(m_pos != 0);
c_Map* mp = getMap();
if (UNLIKELY(m_versionNumber != mp->getVersionNumber())) {
if (UNLIKELY(m_version != mp->getVersion())) {
throw_collection_modified();
}
m_pos = mp->iter_next(m_pos);
@@ -188,7 +188,7 @@ void ArrayIter::nextHelper() {
case Collection::StableMapType: {
assert(m_pos != 0);
c_StableMap* smp = getStableMap();
if (UNLIKELY(m_versionNumber != smp->getVersionNumber())) {
if (UNLIKELY(m_version != smp->getVersion())) {
throw_collection_modified();
}
m_pos = smp->iter_next(m_pos);
@@ -212,7 +212,7 @@ Variant ArrayIter::firstHelper() {
case Collection::MapType: {
assert(m_pos != 0);
c_Map* mp = getMap();
if (UNLIKELY(m_versionNumber != mp->getVersionNumber())) {
if (UNLIKELY(m_version != mp->getVersion())) {
throw_collection_modified();
}
return mp->iter_key(m_pos);
@@ -220,7 +220,7 @@ Variant ArrayIter::firstHelper() {
case Collection::StableMapType: {
assert(m_pos != 0);
c_StableMap* smp = getStableMap();
if (UNLIKELY(m_versionNumber != smp->getVersionNumber())) {
if (UNLIKELY(m_version != smp->getVersion())) {
throw_collection_modified();
}
return smp->iter_key(m_pos);
@@ -246,21 +246,21 @@ Variant ArrayIter::second() {
switch (getCollectionType()) {
case Collection::VectorType: {
c_Vector* vec = getVector();
if (UNLIKELY(m_versionNumber != vec->getVersionNumber())) {
if (UNLIKELY(m_version != vec->getVersion())) {
throw_collection_modified();
}
return tvAsCVarRef(vec->at(m_pos));
}
case Collection::MapType: {
c_Map* mp = getMap();
if (UNLIKELY(m_versionNumber != mp->getVersionNumber())) {
if (UNLIKELY(m_version != mp->getVersion())) {
throw_collection_modified();
}
return mp->iter_value(m_pos);
}
case Collection::StableMapType: {
c_StableMap* smp = getStableMap();
if (UNLIKELY(m_versionNumber != smp->getVersionNumber())) {
if (UNLIKELY(m_version != smp->getVersion())) {
throw_collection_modified();
}
return smp->iter_value(m_pos);
@@ -279,7 +279,7 @@ void ArrayIter::secondHelper(Variant& v) {
switch (getCollectionType()) {
case Collection::VectorType: {
c_Vector* vec = getVector();
if (UNLIKELY(m_versionNumber != vec->getVersionNumber())) {
if (UNLIKELY(m_version != vec->getVersion())) {
throw_collection_modified();
}
v = tvAsCVarRef(vec->at(m_pos));
@@ -287,7 +287,7 @@ void ArrayIter::secondHelper(Variant& v) {
}
case Collection::MapType: {
c_Map* mp = getMap();
if (UNLIKELY(m_versionNumber != mp->getVersionNumber())) {
if (UNLIKELY(m_version != mp->getVersion())) {
throw_collection_modified();
}
v = mp->iter_value(m_pos);
@@ -295,7 +295,7 @@ void ArrayIter::secondHelper(Variant& v) {
}
case Collection::StableMapType: {
c_StableMap* smp = getStableMap();
if (UNLIKELY(m_versionNumber != smp->getVersionNumber())) {
if (UNLIKELY(m_version != smp->getVersion())) {
throw_collection_modified();
}
v = smp->iter_value(m_pos);
+1 -1
Ver Arquivo
@@ -232,7 +232,7 @@ class ArrayIter {
public:
ssize_t m_pos;
private:
int m_versionNumber;
int m_version;
Type m_itype;
friend struct VM::Iter;
+11
Ver Arquivo
@@ -371,6 +371,17 @@ vm_decode_function(CVarRef function,
HPHP::VM::Class*& cls,
StringData*& invName,
bool warn = true);
inline void
vm_decode_function(CVarRef function,
HPHP::VM::ActRec* ar,
bool forwarding,
HPHP::VM::CallCtx& ctx,
bool warn = true) {
ctx.func = vm_decode_function(function, ar, forwarding, ctx.this_, ctx.cls,
ctx.invName, warn);
}
HPHP::VM::ActRec* vm_get_previous_frame();
Variant vm_call_user_func(CVarRef function, CArrRef params,
bool forwarding = false);
+8
Ver Arquivo
@@ -704,6 +704,14 @@ public:
HPHP::VM::VarEnv* varEnv = nullptr,
StringData* invName = nullptr,
HPHP::VM::Unit* mergeUnit = nullptr);
void invokeFunc(TypedValue* retval,
HPHP::VM::CallCtx& ctx,
CArrRef params,
HPHP::VM::VarEnv* varEnv = nullptr,
HPHP::VM::Unit* toMerge = nullptr) {
invokeFunc(retval, ctx.func, params, ctx.this_, ctx.cls, varEnv,
ctx.invName, toMerge);
}
void invokeContFunc(const HPHP::VM::Func* f,
ObjectData* this_,
TypedValue* param = nullptr);
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
+772
Ver Arquivo
@@ -220,6 +220,82 @@ TypedValue* tg_6Vector_keys(HPHP::VM::ActRec *ar) {
return &ar->m_r;
}
/*
HPHP::Object HPHP::c_Vector::t_view()
_ZN4HPHP8c_Vector6t_viewEv
(return value) => rax
_rv => rdi
this_ => rsi
*/
Value* th_6Vector_view(Value* _rv, ObjectData* this_) asm("_ZN4HPHP8c_Vector6t_viewEv");
TypedValue* tg_6Vector_view(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 == 0LL) {
rv.m_type = KindOfObject;
th_6Vector_view((&rv.m_data), (this_));
if (rv.m_data.num == 0LL) rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 0);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
} else {
throw_toomany_arguments_nr("Vector::view", 0, 1);
}
} else {
throw_instance_method_fatal("Vector::view");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 0);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
return &ar->m_r;
}
/*
HPHP::Object HPHP::c_Vector::t_kvzip()
_ZN4HPHP8c_Vector7t_kvzipEv
(return value) => rax
_rv => rdi
this_ => rsi
*/
Value* th_6Vector_kvzip(Value* _rv, ObjectData* this_) asm("_ZN4HPHP8c_Vector7t_kvzipEv");
TypedValue* tg_6Vector_kvzip(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 == 0LL) {
rv.m_type = KindOfObject;
th_6Vector_kvzip((&rv.m_data), (this_));
if (rv.m_data.num == 0LL) rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 0);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
} else {
throw_toomany_arguments_nr("Vector::kvzip", 0, 1);
}
} else {
throw_instance_method_fatal("Vector::kvzip");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 0);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
return &ar->m_r;
}
/*
HPHP::Variant HPHP::c_Vector::t_at(HPHP::Variant const&)
_ZN4HPHP8c_Vector4t_atERKNS_7VariantE
@@ -834,6 +910,123 @@ TypedValue* tg_6Vector_getIterator(HPHP::VM::ActRec *ar) {
return &ar->m_r;
}
/*
HPHP::Object HPHP::c_Vector::t_map(HPHP::Variant const&)
_ZN4HPHP8c_Vector5t_mapERKNS_7VariantE
(return value) => rax
_rv => rdi
this_ => rsi
callback => rdx
*/
Value* th_6Vector_map(Value* _rv, ObjectData* this_, TypedValue* callback) asm("_ZN4HPHP8c_Vector5t_mapERKNS_7VariantE");
TypedValue* tg_6Vector_map(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_map((&rv.m_data), (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::map", count, 1, 1, 1);
}
} else {
throw_instance_method_fatal("Vector::map");
}
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_filter(HPHP::Variant const&)
_ZN4HPHP8c_Vector8t_filterERKNS_7VariantE
(return value) => rax
_rv => rdi
this_ => rsi
callback => rdx
*/
Value* th_6Vector_filter(Value* _rv, ObjectData* this_, TypedValue* callback) asm("_ZN4HPHP8c_Vector8t_filterERKNS_7VariantE");
TypedValue* tg_6Vector_filter(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_filter((&rv.m_data), (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::filter", count, 1, 1, 1);
}
} else {
throw_instance_method_fatal("Vector::filter");
}
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_zip(HPHP::Variant const&)
_ZN4HPHP8c_Vector5t_zipERKNS_7VariantE
(return value) => rax
_rv => rdi
this_ => rsi
iterable => rdx
*/
Value* th_6Vector_zip(Value* _rv, ObjectData* this_, TypedValue* iterable) asm("_ZN4HPHP8c_Vector5t_zipERKNS_7VariantE");
TypedValue* tg_6Vector_zip(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_zip((&rv.m_data), (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::zip", count, 1, 1, 1);
}
} else {
throw_instance_method_fatal("Vector::zip");
}
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;
}
/*
void HPHP::c_Vector::t_sort(HPHP::Variant const&)
_ZN4HPHP8c_Vector6t_sortERKNS_7VariantE
@@ -1775,6 +1968,82 @@ TypedValue* tg_3Map_keys(HPHP::VM::ActRec *ar) {
return &ar->m_r;
}
/*
HPHP::Object HPHP::c_Map::t_view()
_ZN4HPHP5c_Map6t_viewEv
(return value) => rax
_rv => rdi
this_ => rsi
*/
Value* th_3Map_view(Value* _rv, ObjectData* this_) asm("_ZN4HPHP5c_Map6t_viewEv");
TypedValue* tg_3Map_view(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 == 0LL) {
rv.m_type = KindOfObject;
th_3Map_view((&rv.m_data), (this_));
if (rv.m_data.num == 0LL) rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 0);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
} else {
throw_toomany_arguments_nr("Map::view", 0, 1);
}
} else {
throw_instance_method_fatal("Map::view");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 0);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
return &ar->m_r;
}
/*
HPHP::Object HPHP::c_Map::t_kvzip()
_ZN4HPHP5c_Map7t_kvzipEv
(return value) => rax
_rv => rdi
this_ => rsi
*/
Value* th_3Map_kvzip(Value* _rv, ObjectData* this_) asm("_ZN4HPHP5c_Map7t_kvzipEv");
TypedValue* tg_3Map_kvzip(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 == 0LL) {
rv.m_type = KindOfObject;
th_3Map_kvzip((&rv.m_data), (this_));
if (rv.m_data.num == 0LL) rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 0);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
} else {
throw_toomany_arguments_nr("Map::kvzip", 0, 1);
}
} else {
throw_instance_method_fatal("Map::kvzip");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 0);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
return &ar->m_r;
}
/*
HPHP::Variant HPHP::c_Map::t_at(HPHP::Variant const&)
_ZN4HPHP5c_Map4t_atERKNS_7VariantE
@@ -2622,6 +2891,123 @@ TypedValue* tg_3Map_getIterator(HPHP::VM::ActRec *ar) {
return &ar->m_r;
}
/*
HPHP::Object HPHP::c_Map::t_map(HPHP::Variant const&)
_ZN4HPHP5c_Map5t_mapERKNS_7VariantE
(return value) => rax
_rv => rdi
this_ => rsi
callback => rdx
*/
Value* th_3Map_map(Value* _rv, ObjectData* this_, TypedValue* callback) asm("_ZN4HPHP5c_Map5t_mapERKNS_7VariantE");
TypedValue* tg_3Map_map(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_map((&rv.m_data), (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::map", count, 1, 1, 1);
}
} else {
throw_instance_method_fatal("Map::map");
}
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_filter(HPHP::Variant const&)
_ZN4HPHP5c_Map8t_filterERKNS_7VariantE
(return value) => rax
_rv => rdi
this_ => rsi
callback => rdx
*/
Value* th_3Map_filter(Value* _rv, ObjectData* this_, TypedValue* callback) asm("_ZN4HPHP5c_Map8t_filterERKNS_7VariantE");
TypedValue* tg_3Map_filter(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_filter((&rv.m_data), (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::filter", count, 1, 1, 1);
}
} else {
throw_instance_method_fatal("Map::filter");
}
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_zip(HPHP::Variant const&)
_ZN4HPHP5c_Map5t_zipERKNS_7VariantE
(return value) => rax
_rv => rdi
this_ => rsi
iterable => rdx
*/
Value* th_3Map_zip(Value* _rv, ObjectData* this_, TypedValue* iterable) asm("_ZN4HPHP5c_Map5t_zipERKNS_7VariantE");
TypedValue* tg_3Map_zip(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_zip((&rv.m_data), (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::zip", count, 1, 1, 1);
}
} else {
throw_instance_method_fatal("Map::zip");
}
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::String HPHP::c_Map::t___tostring()
_ZN4HPHP5c_Map12t___tostringEv
@@ -3338,6 +3724,82 @@ TypedValue* tg_9StableMap_keys(HPHP::VM::ActRec *ar) {
return &ar->m_r;
}
/*
HPHP::Object HPHP::c_StableMap::t_view()
_ZN4HPHP11c_StableMap6t_viewEv
(return value) => rax
_rv => rdi
this_ => rsi
*/
Value* th_9StableMap_view(Value* _rv, ObjectData* this_) asm("_ZN4HPHP11c_StableMap6t_viewEv");
TypedValue* tg_9StableMap_view(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 == 0LL) {
rv.m_type = KindOfObject;
th_9StableMap_view((&rv.m_data), (this_));
if (rv.m_data.num == 0LL) rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 0);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
} else {
throw_toomany_arguments_nr("StableMap::view", 0, 1);
}
} else {
throw_instance_method_fatal("StableMap::view");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 0);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
return &ar->m_r;
}
/*
HPHP::Object HPHP::c_StableMap::t_kvzip()
_ZN4HPHP11c_StableMap7t_kvzipEv
(return value) => rax
_rv => rdi
this_ => rsi
*/
Value* th_9StableMap_kvzip(Value* _rv, ObjectData* this_) asm("_ZN4HPHP11c_StableMap7t_kvzipEv");
TypedValue* tg_9StableMap_kvzip(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 == 0LL) {
rv.m_type = KindOfObject;
th_9StableMap_kvzip((&rv.m_data), (this_));
if (rv.m_data.num == 0LL) rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 0);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
} else {
throw_toomany_arguments_nr("StableMap::kvzip", 0, 1);
}
} else {
throw_instance_method_fatal("StableMap::kvzip");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 0);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
return &ar->m_r;
}
/*
HPHP::Variant HPHP::c_StableMap::t_at(HPHP::Variant const&)
_ZN4HPHP11c_StableMap4t_atERKNS_7VariantE
@@ -4185,6 +4647,123 @@ TypedValue* tg_9StableMap_getIterator(HPHP::VM::ActRec *ar) {
return &ar->m_r;
}
/*
HPHP::Object HPHP::c_StableMap::t_map(HPHP::Variant const&)
_ZN4HPHP11c_StableMap5t_mapERKNS_7VariantE
(return value) => rax
_rv => rdi
this_ => rsi
callback => rdx
*/
Value* th_9StableMap_map(Value* _rv, ObjectData* this_, TypedValue* callback) asm("_ZN4HPHP11c_StableMap5t_mapERKNS_7VariantE");
TypedValue* tg_9StableMap_map(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_map((&rv.m_data), (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::map", count, 1, 1, 1);
}
} else {
throw_instance_method_fatal("StableMap::map");
}
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_filter(HPHP::Variant const&)
_ZN4HPHP11c_StableMap8t_filterERKNS_7VariantE
(return value) => rax
_rv => rdi
this_ => rsi
callback => rdx
*/
Value* th_9StableMap_filter(Value* _rv, ObjectData* this_, TypedValue* callback) asm("_ZN4HPHP11c_StableMap8t_filterERKNS_7VariantE");
TypedValue* tg_9StableMap_filter(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_filter((&rv.m_data), (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::filter", count, 1, 1, 1);
}
} else {
throw_instance_method_fatal("StableMap::filter");
}
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_zip(HPHP::Variant const&)
_ZN4HPHP11c_StableMap5t_zipERKNS_7VariantE
(return value) => rax
_rv => rdi
this_ => rsi
iterable => rdx
*/
Value* th_9StableMap_zip(Value* _rv, ObjectData* this_, TypedValue* iterable) asm("_ZN4HPHP11c_StableMap5t_zipERKNS_7VariantE");
TypedValue* tg_9StableMap_zip(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_zip((&rv.m_data), (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::zip", count, 1, 1, 1);
}
} else {
throw_instance_method_fatal("StableMap::zip");
}
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::Variant HPHP::c_StableMap::t___get(HPHP::Variant)
_ZN4HPHP11c_StableMap7t___getENS_7VariantE
@@ -4899,6 +5478,82 @@ TypedValue* tg_4Pair_keys(HPHP::VM::ActRec *ar) {
return &ar->m_r;
}
/*
HPHP::Object HPHP::c_Pair::t_view()
_ZN4HPHP6c_Pair6t_viewEv
(return value) => rax
_rv => rdi
this_ => rsi
*/
Value* th_4Pair_view(Value* _rv, ObjectData* this_) asm("_ZN4HPHP6c_Pair6t_viewEv");
TypedValue* tg_4Pair_view(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 == 0LL) {
rv.m_type = KindOfObject;
th_4Pair_view((&rv.m_data), (this_));
if (rv.m_data.num == 0LL) rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 0);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
} else {
throw_toomany_arguments_nr("Pair::view", 0, 1);
}
} else {
throw_instance_method_fatal("Pair::view");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 0);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
return &ar->m_r;
}
/*
HPHP::Object HPHP::c_Pair::t_kvzip()
_ZN4HPHP6c_Pair7t_kvzipEv
(return value) => rax
_rv => rdi
this_ => rsi
*/
Value* th_4Pair_kvzip(Value* _rv, ObjectData* this_) asm("_ZN4HPHP6c_Pair7t_kvzipEv");
TypedValue* tg_4Pair_kvzip(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 == 0LL) {
rv.m_type = KindOfObject;
th_4Pair_kvzip((&rv.m_data), (this_));
if (rv.m_data.num == 0LL) rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 0);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
} else {
throw_toomany_arguments_nr("Pair::kvzip", 0, 1);
}
} else {
throw_instance_method_fatal("Pair::kvzip");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
frame_free_locals_inl(ar, 0);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
return &ar->m_r;
}
/*
HPHP::Array HPHP::c_Pair::t_toarray()
_ZN4HPHP6c_Pair9t_toarrayEv
@@ -4975,6 +5630,123 @@ TypedValue* tg_4Pair_getIterator(HPHP::VM::ActRec *ar) {
return &ar->m_r;
}
/*
HPHP::Object HPHP::c_Pair::t_map(HPHP::Variant const&)
_ZN4HPHP6c_Pair5t_mapERKNS_7VariantE
(return value) => rax
_rv => rdi
this_ => rsi
callback => rdx
*/
Value* th_4Pair_map(Value* _rv, ObjectData* this_, TypedValue* callback) asm("_ZN4HPHP6c_Pair5t_mapERKNS_7VariantE");
TypedValue* tg_4Pair_map(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_4Pair_map((&rv.m_data), (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("Pair::map", count, 1, 1, 1);
}
} else {
throw_instance_method_fatal("Pair::map");
}
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_Pair::t_filter(HPHP::Variant const&)
_ZN4HPHP6c_Pair8t_filterERKNS_7VariantE
(return value) => rax
_rv => rdi
this_ => rsi
callback => rdx
*/
Value* th_4Pair_filter(Value* _rv, ObjectData* this_, TypedValue* callback) asm("_ZN4HPHP6c_Pair8t_filterERKNS_7VariantE");
TypedValue* tg_4Pair_filter(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_4Pair_filter((&rv.m_data), (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("Pair::filter", count, 1, 1, 1);
}
} else {
throw_instance_method_fatal("Pair::filter");
}
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_Pair::t_zip(HPHP::Variant const&)
_ZN4HPHP6c_Pair5t_zipERKNS_7VariantE
(return value) => rax
_rv => rdi
this_ => rsi
iterable => rdx
*/
Value* th_4Pair_zip(Value* _rv, ObjectData* this_, TypedValue* iterable) asm("_ZN4HPHP6c_Pair5t_zipERKNS_7VariantE");
TypedValue* tg_4Pair_zip(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_4Pair_zip((&rv.m_data), (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("Pair::zip", count, 1, 1, 1);
}
} else {
throw_instance_method_fatal("Pair::zip");
}
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::Variant HPHP::c_Pair::t_at(HPHP::Variant const&)
_ZN4HPHP6c_Pair4t_atERKNS_7VariantE
+49 -17
Ver Arquivo
@@ -38,6 +38,7 @@ class c_Vector : public ExtObjectDataFlags<ObjectData::VectorAttrInit|
friend class c_VectorIterator;
friend class c_Map;
friend class c_StableMap;
friend class c_Pair;
friend class ArrayIter;
enum SortFlavor { IntegerSort, StringSort, GenericSort };
@@ -56,6 +57,8 @@ class c_Vector : public ExtObjectDataFlags<ObjectData::VectorAttrInit|
public: int64_t t_count();
public: Object t_items();
public: Object t_keys();
public: Object t_view();
public: Object t_kvzip();
public: Variant t_at(CVarRef key);
public: Variant t_get(CVarRef key);
public: Object t_set(CVarRef key, CVarRef value);
@@ -72,6 +75,9 @@ class c_Vector : public ExtObjectDataFlags<ObjectData::VectorAttrInit|
public: int64_t t_linearsearch(CVarRef search_value);
public: void t_shuffle();
public: Object t_getiterator();
public: Object t_map(CVarRef callback);
public: Object t_filter(CVarRef callback);
public: Object t_zip(CVarRef iterable);
public: String t___tostring();
public: Variant t___get(Variant name);
public: Variant t___set(Variant name, Variant value);
@@ -127,7 +133,7 @@ class c_Vector : public ExtObjectDataFlags<ObjectData::VectorAttrInit|
}
public: void add(TypedValue* val) {
assert(val->m_type != KindOfRef);
++m_versionNumber;
++m_version;
if (m_capacity <= m_size) {
grow();
}
@@ -142,8 +148,8 @@ class c_Vector : public ExtObjectDataFlags<ObjectData::VectorAttrInit|
return ((uint64_t)key < (uint64_t)m_size);
}
public: void reserve(int64_t sz);
public: int getVersionNumber() {
return m_versionNumber;
public: int getVersion() {
return m_version;
}
public: Array toArrayImpl() const;
@@ -179,7 +185,7 @@ class c_Vector : public ExtObjectDataFlags<ObjectData::VectorAttrInit|
TypedValue* m_data;
uint m_size;
uint m_capacity;
int m_versionNumber;
int32_t m_version;
friend ObjectData* collectionDeepCopyVector(c_Vector* vec);
};
@@ -207,7 +213,7 @@ class c_VectorIterator : public ExtObjectData {
private:
SmartPtr<c_Vector> m_obj;
ssize_t m_pos;
int m_versionNumber;
int32_t m_version;
};
///////////////////////////////////////////////////////////////////////////////
@@ -239,6 +245,8 @@ class c_Map : public ExtObjectDataFlags<ObjectData::MapAttrInit|
public: int64_t t_count();
public: Object t_items();
public: Object t_keys();
public: Object t_view();
public: Object t_kvzip();
public: Variant t_at(CVarRef key);
public: Variant t_get(CVarRef key);
public: Object t_set(CVarRef key, CVarRef value);
@@ -258,6 +266,9 @@ class c_Map : public ExtObjectDataFlags<ObjectData::MapAttrInit|
public: Object t_updatefromiterable(CVarRef it);
public: Object t_differencebykey(CVarRef it);
public: Object t_getiterator();
public: Object t_map(CVarRef callback);
public: Object t_filter(CVarRef callback);
public: Object t_zip(CVarRef iterable);
public: String t___tostring();
public: Variant t___get(Variant name);
public: Variant t___set(Variant name, Variant value);
@@ -313,11 +324,11 @@ class c_Map : public ExtObjectDataFlags<ObjectData::MapAttrInit|
}
public: void add(TypedValue* val);
public: void remove(int64_t key) {
++m_versionNumber;
++m_version;
erase(find(key));
}
public: void remove(StringData* key) {
++m_versionNumber;
++m_version;
erase(find(key->data(), key->size(), key->hash()));
}
public: bool contains(int64_t key) {
@@ -331,8 +342,8 @@ class c_Map : public ExtObjectDataFlags<ObjectData::MapAttrInit|
growImpl(sz);
}
}
public: int getVersionNumber() {
return m_versionNumber;
public: int getVersion() {
return m_version;
}
public: Array toArrayImpl() const;
@@ -433,7 +444,7 @@ private:
uint m_size;
uint m_load;
uint m_nLastSlot;
int m_versionNumber;
int32_t m_version;
size_t numSlots() const {
return m_nLastSlot + 1;
@@ -526,7 +537,7 @@ class c_MapIterator : public ExtObjectData {
private:
SmartPtr<c_Map> m_obj;
ssize_t m_pos;
int m_versionNumber;
int32_t m_version;
};
///////////////////////////////////////////////////////////////////////////////
@@ -558,6 +569,8 @@ class c_StableMap : public ExtObjectDataFlags<ObjectData::StableMapAttrInit|
public: int64_t t_count();
public: Object t_items();
public: Object t_keys();
public: Object t_view();
public: Object t_kvzip();
public: Variant t_at(CVarRef key);
public: Variant t_get(CVarRef key);
public: Object t_set(CVarRef key, CVarRef value);
@@ -577,6 +590,9 @@ class c_StableMap : public ExtObjectDataFlags<ObjectData::StableMapAttrInit|
public: Object t_updatefromiterable(CVarRef it);
public: Object t_differencebykey(CVarRef it);
public: Object t_getiterator();
public: Object t_map(CVarRef callback);
public: Object t_filter(CVarRef callback);
public: Object t_zip(CVarRef iterable);
public: String t___tostring();
public: Variant t___get(Variant name);
public: Variant t___set(Variant name, Variant value);
@@ -630,11 +646,11 @@ class c_StableMap : public ExtObjectDataFlags<ObjectData::StableMapAttrInit|
}
public: void add(TypedValue* val);
public: void remove(int64_t key) {
++m_versionNumber;
++m_version;
erase(findForErase(key));
}
public: void remove(StringData* key) {
++m_versionNumber;
++m_version;
erase(findForErase(key->data(), key->size(), key->hash()));
}
public: bool contains(int64_t key) {
@@ -648,8 +664,8 @@ class c_StableMap : public ExtObjectDataFlags<ObjectData::StableMapAttrInit|
growImpl(sz);
}
}
public: int getVersionNumber() {
return m_versionNumber;
public: int getVersion() {
return m_version;
}
public: Array toArrayImpl() const;
@@ -742,7 +758,7 @@ private:
uint m_size;
uint m_nTableSize;
uint m_nTableMask;
int m_versionNumber;
int32_t m_version;
Bucket* m_pListHead;
Bucket* m_pListTail;
Bucket** m_arBuckets;
@@ -805,7 +821,7 @@ class c_StableMapIterator : public ExtObjectData {
private:
SmartPtr<c_StableMap> m_obj;
ssize_t m_pos;
int m_versionNumber;
int32_t m_version;
};
///////////////////////////////////////////////////////////////////////////////
@@ -833,11 +849,16 @@ class c_Pair : public ExtObjectDataFlags<ObjectData::PairAttrInit|
public: int64_t t_count();
public: Object t_items();
public: Object t_keys();
public: Object t_view();
public: Object t_kvzip();
public: Variant t_at(CVarRef key);
public: Variant t_get(CVarRef key);
public: bool t_containskey(CVarRef key);
public: Array t_toarray();
public: Object t_getiterator();
public: Object t_map(CVarRef callback);
public: Object t_filter(CVarRef callback);
public: Object t_zip(CVarRef iterable);
public: String t___tostring();
public: Variant t___get(Variant name);
public: Variant t___set(Variant name, Variant value);
@@ -872,6 +893,17 @@ class c_Pair : public ExtObjectDataFlags<ObjectData::PairAttrInit|
tv->m_type = val->m_type;
++m_size;
}
public: void addInt(int64_t val) {
if (m_size == 2) {
Object e(SystemLib::AllocRuntimeExceptionObject(
"Cannot add a new element to a Pair"));
throw e;
}
TypedValue* tv = &getElms()[m_size];
tv->m_data.num = val;
tv->m_type = KindOfInt64;
++m_size;
}
public: bool contains(int64_t key) {
return (uint64_t(key) < uint64_t(2));
}
+44 -4
Ver Arquivo
@@ -2278,6 +2278,8 @@ TypedValue* tg_6Vector_isEmpty(VM::ActRec *ar);
TypedValue* tg_6Vector_count(VM::ActRec *ar);
TypedValue* tg_6Vector_items(VM::ActRec *ar);
TypedValue* tg_6Vector_keys(VM::ActRec *ar);
TypedValue* tg_6Vector_view(VM::ActRec *ar);
TypedValue* tg_6Vector_kvzip(VM::ActRec *ar);
TypedValue* tg_6Vector_at(VM::ActRec *ar);
TypedValue* tg_6Vector_get(VM::ActRec *ar);
TypedValue* tg_6Vector_set(VM::ActRec *ar);
@@ -2294,6 +2296,9 @@ TypedValue* tg_6Vector_pop(VM::ActRec *ar);
TypedValue* tg_6Vector_resize(VM::ActRec *ar);
TypedValue* tg_6Vector_toArray(VM::ActRec *ar);
TypedValue* tg_6Vector_getIterator(VM::ActRec *ar);
TypedValue* tg_6Vector_map(VM::ActRec *ar);
TypedValue* tg_6Vector_filter(VM::ActRec *ar);
TypedValue* tg_6Vector_zip(VM::ActRec *ar);
TypedValue* tg_6Vector_sort(VM::ActRec *ar);
TypedValue* tg_6Vector_reverse(VM::ActRec *ar);
TypedValue* tg_6Vector_splice(VM::ActRec *ar);
@@ -2321,6 +2326,8 @@ TypedValue* tg_3Map_isEmpty(VM::ActRec *ar);
TypedValue* tg_3Map_count(VM::ActRec *ar);
TypedValue* tg_3Map_items(VM::ActRec *ar);
TypedValue* tg_3Map_keys(VM::ActRec *ar);
TypedValue* tg_3Map_view(VM::ActRec *ar);
TypedValue* tg_3Map_kvzip(VM::ActRec *ar);
TypedValue* tg_3Map_at(VM::ActRec *ar);
TypedValue* tg_3Map_get(VM::ActRec *ar);
TypedValue* tg_3Map_set(VM::ActRec *ar);
@@ -2343,6 +2350,9 @@ TypedValue* tg_3Map_updateFromArray(VM::ActRec *ar);
TypedValue* tg_3Map_updateFromIterable(VM::ActRec *ar);
TypedValue* tg_3Map_differenceByKey(VM::ActRec *ar);
TypedValue* tg_3Map_getIterator(VM::ActRec *ar);
TypedValue* tg_3Map_map(VM::ActRec *ar);
TypedValue* tg_3Map_filter(VM::ActRec *ar);
TypedValue* tg_3Map_zip(VM::ActRec *ar);
TypedValue* tg_3Map___toString(VM::ActRec *ar);
TypedValue* tg_3Map___get(VM::ActRec *ar);
TypedValue* tg_3Map___set(VM::ActRec *ar);
@@ -2364,6 +2374,8 @@ TypedValue* tg_9StableMap_isEmpty(VM::ActRec *ar);
TypedValue* tg_9StableMap_count(VM::ActRec *ar);
TypedValue* tg_9StableMap_items(VM::ActRec *ar);
TypedValue* tg_9StableMap_keys(VM::ActRec *ar);
TypedValue* tg_9StableMap_view(VM::ActRec *ar);
TypedValue* tg_9StableMap_kvzip(VM::ActRec *ar);
TypedValue* tg_9StableMap_at(VM::ActRec *ar);
TypedValue* tg_9StableMap_get(VM::ActRec *ar);
TypedValue* tg_9StableMap_set(VM::ActRec *ar);
@@ -2386,6 +2398,9 @@ TypedValue* tg_9StableMap_updateFromArray(VM::ActRec *ar);
TypedValue* tg_9StableMap_updateFromIterable(VM::ActRec *ar);
TypedValue* tg_9StableMap_differenceByKey(VM::ActRec *ar);
TypedValue* tg_9StableMap_getIterator(VM::ActRec *ar);
TypedValue* tg_9StableMap_map(VM::ActRec *ar);
TypedValue* tg_9StableMap_filter(VM::ActRec *ar);
TypedValue* tg_9StableMap_zip(VM::ActRec *ar);
TypedValue* tg_9StableMap___get(VM::ActRec *ar);
TypedValue* tg_9StableMap___set(VM::ActRec *ar);
TypedValue* tg_9StableMap___isset(VM::ActRec *ar);
@@ -2407,8 +2422,13 @@ TypedValue* tg_4Pair_isEmpty(VM::ActRec *ar);
TypedValue* tg_4Pair_count(VM::ActRec *ar);
TypedValue* tg_4Pair_items(VM::ActRec *ar);
TypedValue* tg_4Pair_keys(VM::ActRec *ar);
TypedValue* tg_4Pair_view(VM::ActRec *ar);
TypedValue* tg_4Pair_kvzip(VM::ActRec *ar);
TypedValue* tg_4Pair_toArray(VM::ActRec *ar);
TypedValue* tg_4Pair_getIterator(VM::ActRec *ar);
TypedValue* tg_4Pair_map(VM::ActRec *ar);
TypedValue* tg_4Pair_filter(VM::ActRec *ar);
TypedValue* tg_4Pair_zip(VM::ActRec *ar);
TypedValue* tg_4Pair_at(VM::ActRec *ar);
TypedValue* tg_4Pair_get(VM::ActRec *ar);
TypedValue* tg_4Pair_containsKey(VM::ActRec *ar);
@@ -5334,13 +5354,15 @@ static const HhbcExtMethodInfo hhbc_ext_methods_DummyClosure[] = {
{ "__construct", tg_12DummyClosure___construct }
};
static const long long hhbc_ext_method_count_Vector = 35;
static const long long hhbc_ext_method_count_Vector = 40;
static const HhbcExtMethodInfo hhbc_ext_methods_Vector[] = {
{ "__construct", tg_6Vector___construct },
{ "isEmpty", tg_6Vector_isEmpty },
{ "count", tg_6Vector_count },
{ "items", tg_6Vector_items },
{ "keys", tg_6Vector_keys },
{ "view", tg_6Vector_view },
{ "kvzip", tg_6Vector_kvzip },
{ "at", tg_6Vector_at },
{ "get", tg_6Vector_get },
{ "set", tg_6Vector_set },
@@ -5357,6 +5379,9 @@ static const HhbcExtMethodInfo hhbc_ext_methods_Vector[] = {
{ "resize", tg_6Vector_resize },
{ "toArray", tg_6Vector_toArray },
{ "getIterator", tg_6Vector_getIterator },
{ "map", tg_6Vector_map },
{ "filter", tg_6Vector_filter },
{ "zip", tg_6Vector_zip },
{ "sort", tg_6Vector_sort },
{ "reverse", tg_6Vector_reverse },
{ "splice", tg_6Vector_splice },
@@ -5383,13 +5408,15 @@ static const HhbcExtMethodInfo hhbc_ext_methods_VectorIterator[] = {
{ "rewind", tg_14VectorIterator_rewind }
};
static const long long hhbc_ext_method_count_Map = 35;
static const long long hhbc_ext_method_count_Map = 40;
static const HhbcExtMethodInfo hhbc_ext_methods_Map[] = {
{ "__construct", tg_3Map___construct },
{ "isEmpty", tg_3Map_isEmpty },
{ "count", tg_3Map_count },
{ "items", tg_3Map_items },
{ "keys", tg_3Map_keys },
{ "view", tg_3Map_view },
{ "kvzip", tg_3Map_kvzip },
{ "at", tg_3Map_at },
{ "get", tg_3Map_get },
{ "set", tg_3Map_set },
@@ -5412,6 +5439,9 @@ static const HhbcExtMethodInfo hhbc_ext_methods_Map[] = {
{ "updateFromIterable", tg_3Map_updateFromIterable },
{ "differenceByKey", tg_3Map_differenceByKey },
{ "getIterator", tg_3Map_getIterator },
{ "map", tg_3Map_map },
{ "filter", tg_3Map_filter },
{ "zip", tg_3Map_zip },
{ "__toString", tg_3Map___toString },
{ "__get", tg_3Map___get },
{ "__set", tg_3Map___set },
@@ -5432,13 +5462,15 @@ static const HhbcExtMethodInfo hhbc_ext_methods_MapIterator[] = {
{ "rewind", tg_11MapIterator_rewind }
};
static const long long hhbc_ext_method_count_StableMap = 35;
static const long long hhbc_ext_method_count_StableMap = 40;
static const HhbcExtMethodInfo hhbc_ext_methods_StableMap[] = {
{ "__construct", tg_9StableMap___construct },
{ "isEmpty", tg_9StableMap_isEmpty },
{ "count", tg_9StableMap_count },
{ "items", tg_9StableMap_items },
{ "keys", tg_9StableMap_keys },
{ "view", tg_9StableMap_view },
{ "kvzip", tg_9StableMap_kvzip },
{ "at", tg_9StableMap_at },
{ "get", tg_9StableMap_get },
{ "set", tg_9StableMap_set },
@@ -5461,6 +5493,9 @@ static const HhbcExtMethodInfo hhbc_ext_methods_StableMap[] = {
{ "updateFromIterable", tg_9StableMap_updateFromIterable },
{ "differenceByKey", tg_9StableMap_differenceByKey },
{ "getIterator", tg_9StableMap_getIterator },
{ "map", tg_9StableMap_map },
{ "filter", tg_9StableMap_filter },
{ "zip", tg_9StableMap_zip },
{ "__get", tg_9StableMap___get },
{ "__set", tg_9StableMap___set },
{ "__isset", tg_9StableMap___isset },
@@ -5481,15 +5516,20 @@ static const HhbcExtMethodInfo hhbc_ext_methods_StableMapIterator[] = {
{ "rewind", tg_17StableMapIterator_rewind }
};
static const long long hhbc_ext_method_count_Pair = 10;
static const long long hhbc_ext_method_count_Pair = 15;
static const HhbcExtMethodInfo hhbc_ext_methods_Pair[] = {
{ "__construct", tg_4Pair___construct },
{ "isEmpty", tg_4Pair_isEmpty },
{ "count", tg_4Pair_count },
{ "items", tg_4Pair_items },
{ "keys", tg_4Pair_keys },
{ "view", tg_4Pair_view },
{ "kvzip", tg_4Pair_kvzip },
{ "toArray", tg_4Pair_toArray },
{ "getIterator", tg_4Pair_getIterator },
{ "map", tg_4Pair_map },
{ "filter", tg_4Pair_filter },
{ "zip", tg_4Pair_zip },
{ "at", tg_4Pair_at },
{ "get", tg_4Pair_get },
{ "containsKey", tg_4Pair_containsKey }
+112
Ver Arquivo
@@ -22403,6 +22403,16 @@ const char *g_class_map[] = {
(const char *)0x40, NULL,
NULL,
NULL,
(const char *)0x10006040, "view", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/vector.view.php )\n *\n * Returns a lazy iterable view of this Vector.\n *\n * @return object\n */",
(const char *)0x40, NULL,
NULL,
NULL,
(const char *)0x10006040, "kvzip", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/vector.kvzip.php )\n *\n * Returns an Iterable that produces the key/value pairs from this Vector.\n *\n * @return object\n */",
(const char *)0x40, NULL,
NULL,
NULL,
(const char *)0x10006040, "at", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/vector.at.php )\n *\n * Returns the value at the specified key. If the key is not present, an\n * exception is thrown.\n *\n * @key mixed\n *\n * @return mixed\n */",
(const char *)0xffffffff, (const char *)0x2000, "key", "", (const char *)0xffffffff, "", "", NULL,
@@ -22498,6 +22508,24 @@ const char *g_class_map[] = {
(const char *)0x40, NULL,
NULL,
NULL,
(const char *)0x10006040, "map", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/vector.map.php )\n *\n * Returns a KeyedIterable of the values produced by applying the\n * specified callback on the values of this Vector.\n *\n * @callback mixed\n *\n * @return object\n */",
(const char *)0x40, (const char *)0x2000, "callback", "", (const char *)0xffffffff, "", "", NULL,
NULL,
NULL,
NULL,
(const char *)0x10006040, "filter", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/vector.filter.php )\n *\n * Returns a KeyedIterable of all the values from this Vector for which\n * the specified callback returns true.\n *\n * @callback mixed\n *\n * @return object\n */",
(const char *)0x40, (const char *)0x2000, "callback", "", (const char *)0xffffffff, "", "", NULL,
NULL,
NULL,
NULL,
(const char *)0x10006040, "zip", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/vector.zip.php )\n *\n * Returns a KeyedIterable produced by combined the specified Iterables\n * pair-wise.\n *\n * @iterable mixed\n *\n * @return object\n */",
(const char *)0x40, (const char *)0x2000, "iterable", "", (const char *)0xffffffff, "", "", NULL,
NULL,
NULL,
NULL,
(const char *)0x10006040, "sort", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/vector.sort.php )\n *\n * Uses the specified Collator to sort the Vector in place.\n *\n * @col mixed\n */",
(const char *)-1, (const char *)0x2000, "col", "", (const char *)0xffffffff, "N;", "null", NULL,
@@ -22654,6 +22682,16 @@ const char *g_class_map[] = {
(const char *)0x40, NULL,
NULL,
NULL,
(const char *)0x10006040, "view", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/map.view.php )\n *\n * Returns a lazy iterable view of this Map.\n *\n * @return object\n */",
(const char *)0x40, NULL,
NULL,
NULL,
(const char *)0x10006040, "kvzip", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/map.kvzip.php )\n *\n * Returns an Iterable that produces the key/value pairs from this Map.\n *\n * @return object\n */",
(const char *)0x40, NULL,
NULL,
NULL,
(const char *)0x10006040, "at", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/map.at.php )\n *\n * Returns the value at the specified key. If the key is not present, an\n * exception is thrown.\n *\n * @key mixed\n *\n * @return mixed\n */",
(const char *)0xffffffff, (const char *)0x2000, "key", "", (const char *)0xffffffff, "", "", NULL,
@@ -22781,6 +22819,24 @@ const char *g_class_map[] = {
(const char *)0x40, NULL,
NULL,
NULL,
(const char *)0x10006040, "map", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/map.map.php )\n *\n * Returns a KeyedIterable of the values produced by applying the\n * specified callback on the values of this Map.\n *\n * @callback mixed\n *\n * @return object\n */",
(const char *)0x40, (const char *)0x2000, "callback", "", (const char *)0xffffffff, "", "", NULL,
NULL,
NULL,
NULL,
(const char *)0x10006040, "filter", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/map.filter.php )\n *\n * Returns a KeyedIterable of all the values from this Map for which the\n * specified callback returns true.\n *\n * @callback mixed\n *\n * @return object\n */",
(const char *)0x40, (const char *)0x2000, "callback", "", (const char *)0xffffffff, "", "", NULL,
NULL,
NULL,
NULL,
(const char *)0x10006040, "zip", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/map.zip.php )\n *\n * Returns a KeyedIterable produced by combined the specified Iterables\n * pair-wise.\n *\n * @iterable mixed\n *\n * @return object\n */",
(const char *)0x40, (const char *)0x2000, "iterable", "", (const char *)0xffffffff, "", "", NULL,
NULL,
NULL,
NULL,
(const char *)0x10006040, "__toString", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/map.tostring.php )\n *\n *\n * @return string\n */",
(const char *)0x14, NULL,
@@ -22899,6 +22955,16 @@ const char *g_class_map[] = {
(const char *)0x40, NULL,
NULL,
NULL,
(const char *)0x10006040, "view", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/stablemap.view.php )\n *\n * Returns a lazy iterable view of this StableMap.\n *\n * @return object\n */",
(const char *)0x40, NULL,
NULL,
NULL,
(const char *)0x10006040, "kvzip", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/stablemap.kvzip.php )\n *\n * Returns an Iterable that produces the key/value pairs from this\n * StableMap.\n *\n * @return object\n */",
(const char *)0x40, NULL,
NULL,
NULL,
(const char *)0x10006040, "at", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/stablemap.at.php )\n *\n * Returns the value at the specified key. If the key is not present, an\n * exception is thrown.\n *\n * @key mixed\n *\n * @return mixed\n */",
(const char *)0xffffffff, (const char *)0x2000, "key", "", (const char *)0xffffffff, "", "", NULL,
@@ -23026,6 +23092,24 @@ const char *g_class_map[] = {
(const char *)0x40, NULL,
NULL,
NULL,
(const char *)0x10006040, "map", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/stablemap.map.php )\n *\n * Returns a KeyedIterable of the values produced by applying the\n * specified callback on the values of this StableMap.\n *\n * @callback mixed\n *\n * @return object\n */",
(const char *)0x40, (const char *)0x2000, "callback", "", (const char *)0xffffffff, "", "", NULL,
NULL,
NULL,
NULL,
(const char *)0x10006040, "filter", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/stablemap.filter.php )\n *\n * Returns a KeyedIterable of all the values from this StableMap for which\n * the specified callback returns true.\n *\n * @callback mixed\n *\n * @return object\n */",
(const char *)0x40, (const char *)0x2000, "callback", "", (const char *)0xffffffff, "", "", NULL,
NULL,
NULL,
NULL,
(const char *)0x10006040, "zip", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/stablemap.zip.php )\n *\n * Returns a KeyedIterable produced by combined the specified Iterables\n * pair-wise.\n *\n * @iterable mixed\n *\n * @return object\n */",
(const char *)0x40, (const char *)0x2000, "iterable", "", (const char *)0xffffffff, "", "", NULL,
NULL,
NULL,
NULL,
(const char *)0x10006040, "__get", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/stablemap.get.php )\n *\n *\n * @name mixed\n *\n * @return mixed\n */",
(const char *)0xffffffff, (const char *)0x2000, "name", "", (const char *)0xffffffff, "", "", NULL,
@@ -23143,6 +23227,16 @@ const char *g_class_map[] = {
(const char *)0x40, NULL,
NULL,
NULL,
(const char *)0x10006040, "view", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/pair.view.php )\n *\n * Returns a lazy iterable view of this Pair.\n *\n * @return object\n */",
(const char *)0x40, NULL,
NULL,
NULL,
(const char *)0x10006040, "kvzip", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/pair.kvzip.php )\n *\n * Returns an Iterable that produces the key/value pairs from this Pair.\n *\n * @return object\n */",
(const char *)0x40, NULL,
NULL,
NULL,
(const char *)0x10006040, "toArray", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/pair.toarray.php )\n *\n * Returns an array built from the values from this Pair.\n *\n * @return map\n */",
(const char *)0x20, NULL,
@@ -23153,6 +23247,24 @@ const char *g_class_map[] = {
(const char *)0x40, NULL,
NULL,
NULL,
(const char *)0x10006040, "map", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/pair.map.php )\n *\n * Returns a KeyedIterable of the values produced by applying the\n * specified callback on the values of this Pair.\n *\n * @callback mixed\n *\n * @return object\n */",
(const char *)0x40, (const char *)0x2000, "callback", "", (const char *)0xffffffff, "", "", NULL,
NULL,
NULL,
NULL,
(const char *)0x10006040, "filter", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/pair.filter.php )\n *\n * Returns a KeyedIterable of all the values from this Pair for which the\n * specified callback returns true.\n *\n * @callback mixed\n *\n * @return object\n */",
(const char *)0x40, (const char *)0x2000, "callback", "", (const char *)0xffffffff, "", "", NULL,
NULL,
NULL,
NULL,
(const char *)0x10006040, "zip", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/pair.zip.php )\n *\n * Returns a KeyedIterable produced by combined the specified Iterables\n * pair-wise.\n *\n * @iterable mixed\n *\n * @return object\n */",
(const char *)0x40, (const char *)0x2000, "iterable", "", (const char *)0xffffffff, "", "", NULL,
NULL,
NULL,
NULL,
(const char *)0x10006040, "at", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/pair.at.php )\n *\n * Returns the value at the specified key. If the key is not present, an\n * exception is thrown.\n *\n * @key mixed\n *\n * @return mixed\n */",
(const char *)0xffffffff, (const char *)0x2000, "key", "", (const char *)0xffffffff, "", "", NULL,
+397 -14
Ver Arquivo
@@ -1,9 +1,51 @@
<?php
class KeysIterator implements Iterator {
public $it;
public function __construct($it) {
trait IterableTrait {
public function view() {
return $this;
}
public function map($callback) {
return new MappedIterable($this, $callback);
}
public function filter($callback) {
return new FilteredIterable($this, $callback);
}
public function zip($iterable) {
return new ZippedIterable($this, $iterable);
}
}
trait KeyedIterableTrait {
public function view() {
return $this;
}
public function map($callback) {
return new MappedKeyedIterable($this, $callback);
}
public function filter($callback) {
return new FilteredKeyedIterable($this, $callback);
}
public function zip($iterable) {
return new ZippedKeyedIterable($this, $iterable);
}
public function keys() {
return new KeysIterable($this);
}
public function kvzip() {
return new KVZippedIterable($this);
}
}
class MappedIterator implements Iterator {
private $it;
private $fn;
public function __construct($it, $fn) {
$this->it = $it;
$this->fn = $fn;
}
public function __clone() {
$this->it = clone $this->it;
}
public function rewind() {
$this->it->rewind();
@@ -16,7 +58,294 @@ class KeysIterator implements Iterator {
}
public function key() {
throw new RuntimeException(
"Call to undefined method KeysIterator::keys()");
"Call to undefined method MappedIterator::key()");
}
public function current() {
return ($this->fn)($this->it->current());
}
}
class MappedIterable implements Iterable {
use IterableTrait;
private $iterable;
private $fn;
public function __construct($iterable, $fn) {
$this->iterable = $iterable;
$this->fn = $fn;
}
public function getIterator() {
return new MappedIterator($this->iterable->getIterator(), $this->fn);
}
}
class MappedKeyedIterator implements KeyedIterator {
private $it;
private $fn;
public function __construct($it, $fn) {
$this->it = $it;
$this->fn = $fn;
}
public function __clone() {
$this->it = clone $this->it;
}
public function rewind() {
$this->it->rewind();
}
public function valid() {
return $this->it->valid();
}
public function next() {
$this->it->next();
}
public function key() {
return $this->it->key();
}
public function current() {
return ($this->fn)($this->it->current());
}
}
class MappedKeyedIterable implements KeyedIterable {
use KeyedIterableTrait;
private $iterable;
private $fn;
public function __construct($iterable, $fn) {
$this->iterable = $iterable;
$this->fn = $fn;
}
public function getIterator() {
return new MappedKeyedIterator($this->iterable->getIterator(), $this->fn);
}
}
class FilteredIterator implements Iterator {
private $it;
private $fn;
public function __construct($it, $fn) {
$this->it = $it;
$this->fn = $fn;
}
public function __clone() {
$this->it = clone $this->it;
}
public function rewind() {
$it = $this->it;
$fn = $this->fn;
$it->rewind();
while ($it->valid() && !$fn($it->current())) {
$it->next();
}
}
public function valid() {
return $this->it->valid();
}
public function next() {
$it = $this->it;
$fn = $this->fn;
$it->next();
while ($it->valid() && !$fn($it->current())) {
$it->next();
}
}
public function key() {
throw new RuntimeException(
"Call to undefined method FilteredIterator::key()");
}
public function current() {
return $this->it->current();
}
}
class FilteredIterable implements Iterable {
use IterableTrait;
private $iterable;
private $fn;
public function __construct($iterable, $fn) {
$this->iterable = $iterable;
$this->fn = $fn;
}
public function getIterator() {
return new FilteredIterator($this->iterable->getIterator(), $this->fn);
}
}
class FilteredKeyedIterator implements KeyedIterator {
private $it;
private $fn;
public function __construct($it, $fn) {
$this->it = $it;
$this->fn = $fn;
}
public function __clone() {
$this->it = clone $this->it;
}
public function rewind() {
$it = $this->it;
$fn = $this->fn;
$it->rewind();
while ($it->valid() && !$fn($it->current())) {
$it->next();
}
}
public function valid() {
return $this->it->valid();
}
public function next() {
$it = $this->it;
$fn = $this->fn;
$it->next();
while ($it->valid() && !$fn($it->current())) {
$it->next();
}
}
public function key() {
return $this->it->key();
}
public function current() {
return $this->it->current();
}
}
class FilteredKeyedIterable implements KeyedIterable {
use KeyedIterableTrait;
private $iterable;
private $fn;
public function __construct($iterable, $fn) {
$this->iterable = $iterable;
$this->fn = $fn;
}
public function getIterator() {
return new FilteredKeyedIterator($this->iterable->getIterator(), $this->fn);
}
}
class ZippedIterator implements Iterator {
private $it1;
private $it2;
public function __construct($it1, $it2) {
$this->it1 = $it1;
$this->it2 = $it2;
}
public function __clone() {
$this->it1 = clone $this->it1;
$this->it2 = clone $this->it2;
}
public function rewind() {
$this->it1->rewind();
$this->it2->rewind();
}
public function valid() {
return ($this->it1->valid() && $this->it2->valid());
}
public function next() {
$this->it1->next();
$this->it2->next();
}
public function key() {
throw new RuntimeException(
"Call to undefined method ZippedIterator::key()");
}
public function current() {
return Pair {$this->it1->current(), $this->it2->current()};
}
}
class ZippedIterable implements Iterable {
use IterableTrait;
private $iterable1;
private $iterable2;
public function __construct($iterable1, $iterable2) {
$this->iterable1 = $iterable1;
$this->iterable2 = $iterable2;
}
public function getIterator() {
return new ZippedIterator($this->iterable1->getIterator(),
$this->iterable2->getIterator());
}
}
class ZippedKeyedIterator implements KeyedIterator {
private $it1;
private $it2;
public function __construct($it1, $it2) {
$this->it1 = $it1;
$this->it2 = $it2;
}
public function __clone() {
$this->it1 = clone $this->it1;
$this->it2 = clone $this->it2;
}
public function rewind() {
$this->it1->rewind();
$this->it2->rewind();
}
public function valid() {
return ($this->it1->valid() && $this->it2->valid());
}
public function next() {
$this->it1->next();
$this->it2->next();
}
public function key() {
return $this->it1->key();
}
public function current() {
return Pair {$this->it1->current(), $this->it2->current()};
}
}
class ZippedKeyedIterable implements KeyedIterable {
use KeyedIterableTrait;
private $iterable1;
private $iterable2;
public function __construct($iterable1, $iterable2) {
$this->iterable1 = $iterable1;
$this->iterable2 = $iterable2;
}
public function getIterator() {
return new ZippedKeyedIterator($this->iterable1->getIterator(),
$this->iterable2->getIterator());
}
}
class KeysIterator implements Iterator {
private $it;
public function __construct($it) {
$this->it = $it;
}
public function __clone() {
$this->it = clone $this->it;
}
public function rewind() {
$this->it->rewind();
}
public function valid() {
return $this->it->valid();
}
public function next() {
$this->it->next();
}
public function key() {
throw new RuntimeException(
"Call to undefined method KeysIterator::key()");
}
public function current() {
return $this->it->key();
@@ -24,20 +353,27 @@ class KeysIterator implements Iterator {
}
class KeysIterable implements Iterable {
public $it;
use IterableTrait;
private $iterable;
public function __construct($iterable) {
$this->it = new KeysIterator($iterable->getIterator());
$this->iterable = $iterable;
}
public function getIterator() {
return clone $this->it;
return new KeysIterator($this->iterable->getIterator());
}
}
class MapItemsIterator implements Iterator {
public $it;
class KVZippedIterator implements Iterator {
private $it;
public function __construct($it) {
$this->it = $it;
}
public function __clone() {
$this->it = clone $this->it;
}
public function rewind() {
$this->it->rewind();
}
@@ -49,20 +385,23 @@ class MapItemsIterator implements Iterator {
}
public function key() {
throw new RuntimeException(
"Call to undefined method MapItemsIterator::keys()");
"Call to undefined method KVZippedIterator::key()");
}
public function current() {
return Pair {$this->it->key(), $this->it->current()};
}
}
class MapItemsIterable implements Iterable {
public $it;
class KVZippedIterable implements Iterable {
use IterableTrait;
private $iterable;
public function __construct($iterable) {
$this->it = new MapItemsIterator($iterable->getIterator());
$this->iterable = $iterable;
}
public function getIterator() {
return clone $this->it;
return new KVZippedIterator($this->iterable->getIterator());
}
}
@@ -141,3 +480,47 @@ interface MutableSet extends ConstSet,
SetAccess {
}
class IterableView implements Iterable {
public $iterable;
public function __construct($iterable) { $this->iterable = $iterable; }
public function getIterator() { return $this->iterable->getIterator(); }
public function view() {
return $this;
}
public function map($callback) {
return new MappedIterable($this->iterable, $callback);
}
public function filter($callback) {
return new FilteredIterable($this->iterable, $callback);
}
public function zip($iterable) {
return new ZippedIterable($this->iterable, $iterable);
}
}
class KeyedIterableView implements KeyedIterable {
public $iterable;
public function __construct($iterable) { $this->iterable = $iterable; }
public function getIterator() { return $this->iterable->getIterator(); }
public function view() {
return $this;
}
public function map($callback) {
return new MappedKeyedIterable($this->iterable, $callback);
}
public function filter($callback) {
return new FilteredKeyedIterable($this->iterable, $callback);
}
public function zip($iterable) {
return new ZippedKeyedIterable($this->iterable, $iterable);
}
public function keys() {
return new KeysIterable($this->iterable);
}
public function kvzip() {
return new KVZippedIterable($this->iterable);
}
}
Diff do arquivo suprimido porque uma ou mais linhas são muito longas
+28 -2
Ver Arquivo
@@ -123,8 +123,34 @@ ObjectData* SystemLib::AllocKeysIterableObject(CVarRef mp) {
CREATE_AND_CONSTRUCT(KeysIterable, CREATE_VECTOR1(mp));
}
ObjectData* SystemLib::AllocMapItemsIterableObject(CVarRef mp) {
CREATE_AND_CONSTRUCT(MapItemsIterable, CREATE_VECTOR1(mp));
ObjectData* SystemLib::AllocKVZippedIterableObject(CVarRef mp) {
CREATE_AND_CONSTRUCT(KVZippedIterable, CREATE_VECTOR1(mp));
}
ObjectData* SystemLib::AllocMappedKeyedIterableObject(CVarRef iterable,
CVarRef callback) {
CREATE_AND_CONSTRUCT(MappedKeyedIterable, CREATE_VECTOR2(iterable,
callback));
}
ObjectData* SystemLib::AllocFilteredKeyedIterableObject(CVarRef iterable,
CVarRef callback) {
CREATE_AND_CONSTRUCT(FilteredKeyedIterable, CREATE_VECTOR2(iterable,
callback));
}
ObjectData* SystemLib::AllocZippedKeyedIterableObject(CVarRef iterable1,
CVarRef iterable2) {
CREATE_AND_CONSTRUCT(ZippedKeyedIterable, CREATE_VECTOR2(iterable1,
iterable2));
}
ObjectData* SystemLib::AllocIterableViewObject(CVarRef iterable) {
CREATE_AND_CONSTRUCT(IterableView, CREATE_VECTOR1(iterable));
}
ObjectData* SystemLib::AllocKeyedIterableViewObject(CVarRef iterable) {
CREATE_AND_CONSTRUCT(KeyedIterableView, CREATE_VECTOR1(iterable));
}
#undef CREATE_AND_CONSTRUCT
+16 -2
Ver Arquivo
@@ -60,7 +60,12 @@ namespace Eval {
x(Traversable) \
x(Countable) \
x(KeysIterable) \
x(MapItemsIterable) \
x(KVZippedIterable) \
x(MappedKeyedIterable) \
x(FilteredKeyedIterable) \
x(ZippedKeyedIterable) \
x(IterableView) \
x(KeyedIterableView) \
x(__PHP_Incomplete_Class) \
class SystemLib {
@@ -105,7 +110,16 @@ class SystemLib {
CVarRef name = null_variant,
CVarRef header = null_variant);
static ObjectData* AllocKeysIterableObject(CVarRef mp);
static ObjectData* AllocMapItemsIterableObject(CVarRef mp);
static ObjectData* AllocKVZippedIterableObject(CVarRef mp);
static ObjectData* AllocMappedKeyedIterableObject(CVarRef iterable,
CVarRef callback);
static ObjectData* AllocFilteredKeyedIterableObject(CVarRef iterable,
CVarRef callback);
static ObjectData* AllocZippedKeyedIterableObject(CVarRef iterable1,
CVarRef iterable2);
static ObjectData* AllocIterableViewObject(CVarRef iterable);
static ObjectData* AllocKeyedIterableViewObject(CVarRef iterable);
};
///////////////////////////////////////////////////////////////////////////////
+408 -21
Ver Arquivo
@@ -9904,7 +9904,7 @@ bool TestCodeRun::TestCollectionClasses() {
"string(1) \"a\"\n"
"int(2)\n"
"string(1) \"z\"\n"
"object(Vector)#7 (3) {\n"
"object(Vector)#3 (3) {\n"
" [0]=>\n"
" string(1) \"a\"\n"
" [1]=>\n"
@@ -9945,21 +9945,21 @@ bool TestCodeRun::TestCollectionClasses() {
"int(9)\n"
"object(Vector)#10 (3) {\n"
" [0]=>\n"
" object(Pair)#15 (2) {\n"
" object(Pair)#14 (2) {\n"
" [0]=>\n"
" string(1) \"a\"\n"
" [1]=>\n"
" int(1)\n"
" }\n"
" [1]=>\n"
" object(Pair)#16 (2) {\n"
" object(Pair)#15 (2) {\n"
" [0]=>\n"
" int(2)\n"
" [1]=>\n"
" string(1) \"b\"\n"
" }\n"
" [2]=>\n"
" object(Pair)#17 (2) {\n"
" object(Pair)#16 (2) {\n"
" [0]=>\n"
" string(1) \"z\"\n"
" [1]=>\n"
@@ -9967,30 +9967,30 @@ bool TestCodeRun::TestCollectionClasses() {
" }\n"
"}\n"
"==========\n"
"object(Vector)#21 (3) {\n"
"object(Vector)#19 (3) {\n"
" [0]=>\n"
" object(Pair)#22 (2) {\n"
" object(Pair)#20 (2) {\n"
" [0]=>\n"
" string(1) \"a\"\n"
" [1]=>\n"
" int(1)\n"
" }\n"
" [1]=>\n"
" object(Pair)#23 (2) {\n"
" object(Pair)#21 (2) {\n"
" [0]=>\n"
" int(2)\n"
" [1]=>\n"
" string(1) \"b\"\n"
" }\n"
" [2]=>\n"
" object(Pair)#24 (2) {\n"
" object(Pair)#22 (2) {\n"
" [0]=>\n"
" string(1) \"z\"\n"
" [1]=>\n"
" int(9)\n"
" }\n"
"}\n"
"object(StableMap)#29 (3) {\n"
"object(StableMap)#26 (3) {\n"
" [\"a\"]=>\n"
" int(1)\n"
" [2]=>\n"
@@ -9999,7 +9999,7 @@ bool TestCodeRun::TestCollectionClasses() {
" int(9)\n"
"}\n"
"==========\n"
"object(StableMap)#34 (3) {\n"
"object(StableMap)#31 (3) {\n"
" [\"a\"]=>\n"
" int(1)\n"
" [2]=>\n"
@@ -10117,6 +10117,333 @@ bool TestCodeRun::TestCollectionClasses() {
"int(44)\n"
);
MVCRO("<?php\n"
"$mapFn = function ($v) { return $v+1; };\n"
"$filtFn = function ($v) { return $v % 2 == 0; };\n"
"$vec = Vector {0, 3, 6, 9};\n"
"foreach ($vec->map($mapFn)->filter($filtFn) as $k => $v) {\n"
" var_dump($k, $v);\n"
"}\n"
"echo \"========\\n\";\n"
"$mp = Map {'a' => 0, 'b' => 3, 'c' => 6};\n"
"foreach ($mp->map($mapFn)->filter($filtFn) as $k => $v) {\n"
" var_dump($k, $v);\n"
"}\n"
"echo \"========\\n\";\n"
"$smp = StableMap {'a' => 0, 'b' => 3, 'c' => 6, 'd' => 9};\n"
"foreach ($smp->map($mapFn)->filter($filtFn) as $k => $v) {\n"
" var_dump($k, $v);\n"
"}\n"
"echo \"========\\n\";\n"
"$pair = Pair {0, 3};\n"
"foreach ($pair->map($mapFn)->filter($filtFn) as $k => $v) {\n"
" var_dump($k, $v);\n"
"}\n"
,
"int(0)\n"
"int(4)\n"
"int(1)\n"
"int(10)\n"
"========\n"
"string(1) \"b\"\n"
"int(4)\n"
"========\n"
"string(1) \"b\"\n"
"int(4)\n"
"string(1) \"d\"\n"
"int(10)\n"
"========\n"
"int(0)\n"
"int(4)\n"
);
MVCRO("<?php\n"
"$mapFn = function ($v) { return $v+1; };\n"
"$filtFn = function ($v) { return $v % 2 == 0; };\n"
"$vec = Vector {0, 3, 6, 9};\n"
"foreach ($vec->view()->map($mapFn)->filter($filtFn) as $k => $v) {\n"
" var_dump($k, $v);\n"
"}\n"
"echo \"========\\n\";\n"
"$mp = Map {'a' => 0, 'b' => 3, 'c' => 6};\n"
"foreach ($mp->view()->map($mapFn)->filter($filtFn) as $k => $v) {\n"
" var_dump($k, $v);\n"
"}\n"
"echo \"========\\n\";\n"
"$smp = StableMap {'a' => 0, 'b' => 3, 'c' => 6, 'd' => 9};\n"
"foreach ($smp->view()->map($mapFn)->filter($filtFn) as $k => $v) {\n"
" var_dump($k, $v);\n"
"}\n"
"echo \"========\\n\";\n"
"$pair = Pair {0, 3};\n"
"foreach ($pair->view()->map($mapFn)->filter($filtFn) as $k => $v) {\n"
" var_dump($k, $v);\n"
"}\n"
,
"int(1)\n"
"int(4)\n"
"int(3)\n"
"int(10)\n"
"========\n"
"string(1) \"b\"\n"
"int(4)\n"
"========\n"
"string(1) \"b\"\n"
"int(4)\n"
"string(1) \"d\"\n"
"int(10)\n"
"========\n"
"int(1)\n"
"int(4)\n"
);
MVCRO("<?php\n"
"$mapFn = function ($t) { return Pair {$t[0]*3+1, $t[1]}; };\n"
"$vec = Vector {'a', 'b', 'c', 'd'};\n"
"foreach ($vec->kvzip()->map($mapFn) as $t) {\n"
" var_dump($t[0], $t[1]);\n"
"}\n"
"echo \"========\\n\";\n"
"$mp = Map {2 => 'a'};\n"
"foreach ($mp->kvzip()->map($mapFn) as $t) {\n"
" var_dump($t[0], $t[1]);\n"
"}\n"
"echo \"========\\n\";\n"
"$smp = StableMap {2 => 'a', 4 => 'b', 6 => 'c', 8 => 'd'};\n"
"foreach ($smp->kvzip()->map($mapFn) as $t) {\n"
" var_dump($t[0], $t[1]);\n"
"}\n"
"echo \"========\\n\";\n"
"$pair = Pair {'a', 'b'};\n"
"foreach ($pair->kvzip()->map($mapFn) as $t) {\n"
" var_dump($t[0], $t[1]);\n"
"}\n"
,
"int(1)\n"
"string(1) \"a\"\n"
"int(4)\n"
"string(1) \"b\"\n"
"int(7)\n"
"string(1) \"c\"\n"
"int(10)\n"
"string(1) \"d\"\n"
"========\n"
"int(7)\n"
"string(1) \"a\"\n"
"========\n"
"int(7)\n"
"string(1) \"a\"\n"
"int(13)\n"
"string(1) \"b\"\n"
"int(19)\n"
"string(1) \"c\"\n"
"int(25)\n"
"string(1) \"d\"\n"
"========\n"
"int(1)\n"
"string(1) \"a\"\n"
"int(4)\n"
"string(1) \"b\"\n"
);
MVCRO("<?php\n"
"$mapFn = function ($x) { return $x*3+1; };\n"
"$vec = Vector {2, 4, 6, 8};\n"
"foreach ($vec->items()->map($mapFn) as $x) {\n"
" var_dump($x);\n"
"}\n"
"echo \"========\\n\";\n"
"$mapFn = function ($t) { return Pair {$t[0]*3+1, $t[1]}; };\n"
"$mp = Map {2 => 'a'};\n"
"foreach ($mp->items()->map($mapFn) as $t) {\n"
" var_dump($t[0], $t[1]);\n"
"}\n"
"echo \"========\\n\";\n"
"$smp = StableMap {2 => 'a', 4 => 'b', 6 => 'c', 8 => 'd'};\n"
"foreach ($smp->items()->map($mapFn) as $t) {\n"
" var_dump($t[0], $t[1]);\n"
"}\n"
,
"int(7)\n"
"int(13)\n"
"int(19)\n"
"int(25)\n"
"========\n"
"int(7)\n"
"string(1) \"a\"\n"
"========\n"
"int(7)\n"
"string(1) \"a\"\n"
"int(13)\n"
"string(1) \"b\"\n"
"int(19)\n"
"string(1) \"c\"\n"
"int(25)\n"
"string(1) \"d\"\n"
);
MVCRO("<?php\n"
"$mapFn = function ($v) { return $v+1; };\n"
"$filtFn = function ($v) { return $v % 2 == 0; };\n"
"$vec = Vector {0, 3, 6, 9};\n"
"foreach ($vec->keys()->map($mapFn)->filter($filtFn) as $x) {\n"
" var_dump($x);\n"
"}\n"
"echo \"========\\n\";\n"
"$mp = Map {0 => 'a', 3 => 'b', 6 => 'c'};\n"
"foreach ($mp->keys()->map($mapFn)->filter($filtFn) as $x) {\n"
" var_dump($x);\n"
"}\n"
"echo \"========\\n\";\n"
"$smp = StableMap {0 => 'a', 3 => 'b', 6 => 'c', 9 => 'd'};\n"
"foreach ($smp->keys()->map($mapFn)->filter($filtFn) as $x) {\n"
" var_dump($x);\n"
"}\n"
"echo \"========\\n\";\n"
"$v = Vector {0, 1, 2, 3, 4};\n"
"$iterable = $v->map(function ($x) { return $x+1; })\n"
" ->filter(function ($x) { return $x % 2 == 0; });\n"
"foreach ($iterable as $v1) {\n"
" foreach ($iterable as $v2) {\n"
" echo \"$v1 $v2\\n\";\n"
" }\n"
"}\n"
,
"int(2)\n"
"int(4)\n"
"========\n"
"int(4)\n"
"========\n"
"int(4)\n"
"int(10)\n"
"========\n"
"2 2\n"
"2 4\n"
"4 2\n"
"4 4\n"
);
MVCRO("<?php\n"
"$mapFn = function ($v) { return $v+1; };\n"
"$filtFn = function ($v) { return $v % 2 == 0; };\n"
"$vec = Vector {0, 3, 6, 9};\n"
"foreach ($vec->view()->keys()->map($mapFn)->filter($filtFn) as $x) {\n"
" var_dump($x);\n"
"}\n"
"echo \"========\\n\";\n"
"$mp = Map {0 => 'a', 3 => 'b', 6 => 'c'};\n"
"foreach ($mp->view()->keys()->map($mapFn)->filter($filtFn) as $x) {\n"
" var_dump($x);\n"
"}\n"
"echo \"========\\n\";\n"
"$smp = StableMap {0 => 'a', 3 => 'b', 6 => 'c', 9 => 'd'};\n"
"foreach ($smp->view()->keys()->map($mapFn)->filter($filtFn) as $x) {\n"
" var_dump($x);\n"
"}\n"
"echo \"========\\n\";\n"
"$v = Vector {0, 1, 2, 3, 4};\n"
"$iterable = $v->view()\n"
" ->map(function ($x) { return $x+1; })\n"
" ->filter(function ($x) { return $x % 2 == 0; });\n"
"foreach ($iterable as $v1) {\n"
" foreach ($iterable as $v2) {\n"
" echo \"$v1 $v2\\n\";\n"
" }\n"
"}\n"
,
"int(2)\n"
"int(4)\n"
"========\n"
"int(4)\n"
"========\n"
"int(4)\n"
"int(10)\n"
"========\n"
"2 2\n"
"2 4\n"
"4 2\n"
"4 4\n"
);
MVCRO("<?php\n"
"$c1 = StableMap {'a' => 0, 'b' => 3, 'c' => 6, 'd' => 9};\n"
"$c2 = Vector {1, 4, 7};\n"
"foreach ($c1->zip($c2) as $k => $v) {\n"
" var_dump($k, $v);\n"
"}\n"
"echo \"========\\n\";\n"
"$c1 = Vector {1, 4, 7, 10};\n"
"$c2 = StableMap {'a' => 0, 'b' => 3, 'c' => 6};\n"
"foreach ($c1->zip($c2) as $k => $v) {\n"
" var_dump($k, $v);\n"
"}\n"
"echo \"========\\n\";\n"
"$c1 = Pair {1, 4};\n"
"$c2 = StableMap {'a' => 0, 'b' => 3, 'c' => 6};\n"
"foreach ($c1->zip($c2) as $k => $v) {\n"
" var_dump($k, $v);\n"
"}\n"
,
"string(1) \"a\"\n"
"object(Pair)#4 (2) {\n"
" [0]=>\n"
" int(0)\n"
" [1]=>\n"
" int(1)\n"
"}\n"
"string(1) \"b\"\n"
"object(Pair)#5 (2) {\n"
" [0]=>\n"
" int(3)\n"
" [1]=>\n"
" int(4)\n"
"}\n"
"string(1) \"c\"\n"
"object(Pair)#6 (2) {\n"
" [0]=>\n"
" int(6)\n"
" [1]=>\n"
" int(7)\n"
"}\n"
"========\n"
"int(0)\n"
"object(Pair)#10 (2) {\n"
" [0]=>\n"
" int(1)\n"
" [1]=>\n"
" int(0)\n"
"}\n"
"int(1)\n"
"object(Pair)#11 (2) {\n"
" [0]=>\n"
" int(4)\n"
" [1]=>\n"
" int(3)\n"
"}\n"
"int(2)\n"
"object(Pair)#12 (2) {\n"
" [0]=>\n"
" int(7)\n"
" [1]=>\n"
" int(6)\n"
"}\n"
"========\n"
"int(0)\n"
"object(Pair)#16 (2) {\n"
" [0]=>\n"
" int(1)\n"
" [1]=>\n"
" int(0)\n"
"}\n"
"int(1)\n"
"object(Pair)#17 (2) {\n"
" [0]=>\n"
" int(4)\n"
" [1]=>\n"
" int(3)\n"
"}\n"
);
return true;
}
@@ -31254,6 +31581,16 @@ bool TestCodeRun::TestTraits() {
MVCRO(
"<?php\n"
"function get_declared_user_traits() {\n"
" $ret = array();\n"
" foreach (get_declared_traits() as $v) {\n"
" $lv = strtolower($v);\n"
" if ($lv !== 'iterabletrait' && $lv !== 'keyediterabletrait') {\n"
" $ret[] = $v;\n"
" }\n"
" }\n"
" return $ret;\n"
"}\n"
"class this_is_a_class { }\n"
"interface this_is_an_interface {\n"
" public function this_is_an_interface_method();\n"
@@ -31261,7 +31598,7 @@ bool TestCodeRun::TestTraits() {
"trait this_is_a_trait { }\n"
"abstract class this_is_an_abstract_class { }\n"
"final class this_is_a_final_class { }\n"
"var_dump(get_declared_traits());\n"
"var_dump(get_declared_user_traits());\n"
"?>\n"
,
"array(1) {\n"
@@ -31297,12 +31634,22 @@ bool TestCodeRun::TestTraits() {
MVCRO(
"<?php\n"
"namespace test {\n"
" function get_declared_user_traits() {\n"
" $ret = array();\n"
" foreach (get_declared_traits() as $v) {\n"
" $lv = strtolower($v);\n"
" if ($lv !== 'iterabletrait' && $lv !== 'keyediterabletrait') {\n"
" $ret[] = $v;\n"
" }\n"
" }\n"
" return $ret;\n"
" }\n"
" class a { }\n"
" interface b { }\n"
" trait c { }\n"
" abstract class d { }\n"
" final class e { }\n"
" var_dump(get_declared_traits());\n"
" var_dump(get_declared_user_traits());\n"
"}\n"
,
"array(1) {\n"
@@ -31314,12 +31661,22 @@ bool TestCodeRun::TestTraits() {
MVCRO(
"<?php\n"
"function get_declared_user_traits() {\n"
" $ret = array();\n"
" foreach (get_declared_traits() as $v) {\n"
" $lv = strtolower($v);\n"
" if ($lv !== 'iterabletrait' && $lv !== 'keyediterabletrait') {\n"
" $ret[] = $v;\n"
" }\n"
" }\n"
" return $ret;\n"
"}\n"
"class MY_CLASS { }\n"
"interface MY_INTERFACE { }\n"
"trait MY_TRAIT { }\n"
"abstract class MY_ABSTRCT_CLASS { }\n"
"final class MY_FINAL_CLASS { }\n"
"var_dump(get_declared_traits());\n"
"var_dump(get_declared_user_traits());\n"
"?>\n"
,
"array(1) {\n"
@@ -31445,15 +31802,25 @@ bool TestCodeRun::TestTraits() {
MVCRO(
"<?php\n"
"function get_declared_user_traits() {\n"
" $ret = array();\n"
" foreach (get_declared_traits() as $v) {\n"
" $lv = strtolower($v);\n"
" if ($lv !== 'iterabletrait' && $lv !== 'keyediterabletrait') {\n"
" $ret[] = $v;\n"
" }\n"
" }\n"
" return $ret;\n"
"}\n"
"/* Prototype : proto array get_declared_traits()\n"
" * Description: Returns an array of all declared traits.\n"
" * Source code: Zend/zend_builtin_functions.c\n"
" * Alias to functions:\n"
" */\n"
"$traits = get_declared_traits();\n"
"$traits = get_declared_user_traits();\n"
"var_dump($traits);\n"
"var_dump(in_array('T1', $traits));\n"
"var_dump(in_array('T1', get_declared_traits()));\n"
"var_dump(in_array('T1', get_declared_user_traits()));\n"
,
"array(0) {\n"
"}\n"
@@ -32205,6 +32572,16 @@ bool TestCodeRun::TestTraits() {
MVCRO(
"<?php\n"
"function get_declared_user_traits() {\n"
" $ret = array();\n"
" foreach (get_declared_traits() as $v) {\n"
" $lv = strtolower($v);\n"
" if ($lv !== 'iterabletrait' && $lv !== 'keyediterabletrait') {\n"
" $ret[] = $v;\n"
" }\n"
" }\n"
" return $ret;\n"
"}\n"
"/* Prototype : proto array get_declared_traits()\n"
" * Description: Returns an array of all declared traits. \n"
" * Source code: Zend/zend_builtin_functions.c\n"
@@ -32218,24 +32595,24 @@ bool TestCodeRun::TestTraits() {
"\n"
"// Zero arguments\n"
"echo \"\\n-- Testing get_declared_traits() function with Zero arguments --\\n\";\n"
"var_dump(get_declared_traits());\n"
"var_dump(get_declared_user_traits());\n"
"\n"
"foreach (get_declared_traits() as $trait) {\n"
"foreach (get_declared_user_traits() as $trait) {\n"
" if (!trait_exists($trait)) {\n"
" echo \"Error: $trait is not a valid trait.\\n\"; \n"
" }\n"
"}\n"
"\n"
"echo \"\\n-- Ensure trait is listed --\\n\";\n"
"var_dump(in_array('MyTrait', get_declared_traits()));\n"
"var_dump(in_array('MyTrait', get_declared_user_traits()));\n"
"\n"
"echo \"\\n-- Ensure userspace interfaces are not listed --\\n\";\n"
"interface I {}\n"
"var_dump(in_array( 'I', get_declared_traits()));\n"
"var_dump(in_array( 'I', get_declared_user_traits()));\n"
"\n"
"echo \"\\n-- Ensure userspace classes are not listed --\\n\";\n"
"class MyClass {}\n"
"var_dump(in_array( 'MyClass', get_declared_traits()));\n"
"var_dump(in_array( 'MyClass', get_declared_user_traits()));\n"
"\n"
"\n"
"echo \"Done\";\n"
@@ -32850,6 +33227,16 @@ bool TestCodeRun::TestTraits() {
MVCRO(
"<?php\n"
"function get_declared_user_traits() {\n"
" $ret = array();\n"
" foreach (get_declared_traits() as $v) {\n"
" $lv = strtolower($v);\n"
" if ($lv !== 'iterabletrait' && $lv !== 'keyediterabletrait') {\n"
" $ret[] = $v;\n"
" }\n"
" }\n"
" return $ret;\n"
"}\n"
"\n"
"class a { }\n"
"interface b { }\n"
@@ -32857,7 +33244,7 @@ bool TestCodeRun::TestTraits() {
"abstract class d { }\n"
"final class e { }\n"
"\n"
"var_dump(get_declared_traits());\n"
"var_dump(get_declared_user_traits());\n"
"\n"
"?>\n"
,