Rename Tuple to Pair, restrict them to having exactly 2 elements

Esse commit está contido em:
andrewparoski
2013-04-03 15:46:10 -07:00
commit de Sara Golemon
commit d0321ec5aa
24 arquivos alterados com 502 adições e 570 exclusões
+1 -1
Ver Arquivo
@@ -2273,7 +2273,7 @@ class MapItemsIterator implements Iterator {
"Call to undefined method MapItemsIterator::keys()");
}
public function current() {
return Tuple {$this->it->key(), $this->it->current()};
return Pair {$this->it->key(), $this->it->current()};
}
}
+16 -13
Ver Arquivo
@@ -2858,6 +2858,12 @@ bool EmitterVisitor::visitImpl(ConstructPtr node) {
if (op == T_COLLECTION) {
ScalarExpressionPtr cls =
static_pointer_cast<ScalarExpression>(b->getExp1());
int nElms = 0;
ExpressionListPtr el;
if (b->getExp2()) {
el = static_pointer_cast<ExpressionList>(b->getExp2());
nElms = el->getCount();
}
const std::string* clsName = nullptr;
cls->getString(clsName);
int cType = 0;
@@ -2867,24 +2873,21 @@ bool EmitterVisitor::visitImpl(ConstructPtr node) {
cType = Collection::MapType;
} else if (!strcasecmp(clsName->c_str(), "stablemap")) {
cType = Collection::StableMapType;
} else if (!strcasecmp(clsName->c_str(), "tuple")) {
cType = Collection::TupleType;
} else if (!strcasecmp(clsName->c_str(), "pair")) {
cType = Collection::PairType;
if (nElms != 2) {
throw IncludeTimeFatalException(b,
"Pair objects must have exactly 2 elements");
}
} else {
throw IncludeTimeFatalException(b,
"Cannot use collection initialization for "
"non-collection class");
"Cannot use collection initialization for non-collection class");
}
bool kvPairs = (cType == Collection::MapType ||
cType == Collection::StableMapType);
int nElems = 0;
ExpressionListPtr el;
if (b->getExp2()) {
el = static_pointer_cast<ExpressionList>(b->getExp2());
nElems = el->getCount();
}
e.NewCol(cType, nElems);
e.NewCol(cType, nElms);
if (kvPairs) {
for (int i = 0; i < nElems; i++) {
for (int i = 0; i < nElms; i++) {
ArrayPairExpressionPtr ap(
static_pointer_cast<ArrayPairExpression>((*el)[i]));
ExpressionPtr key = ap->getName();
@@ -2900,7 +2903,7 @@ bool EmitterVisitor::visitImpl(ConstructPtr node) {
e.ColAddElemC();
}
} else {
for (int i = 0; i < nElems; i++) {
for (int i = 0; i < nElms; i++) {
ArrayPairExpressionPtr ap(
static_pointer_cast<ArrayPairExpression>((*el)[i]));
ExpressionPtr key = ap->getName();
@@ -71,8 +71,8 @@ BinaryOpExpression::BinaryOpExpression
cType = Collection::MapType;
} else if (strcasecmp(s.c_str(), "stablemap") == 0) {
cType = Collection::StableMapType;
} else if (strcasecmp(s.c_str(), "tuple") == 0) {
cType = Collection::TupleType;
} else if (strcasecmp(s.c_str(), "pair") == 0) {
cType = Collection::PairType;
}
ExpressionListPtr el = static_pointer_cast<ExpressionList>(m_exp2);
el->setCollectionType(cType);
+7 -6
Ver Arquivo
@@ -1599,7 +1599,7 @@ static const yytype_uint16 yyrline[] =
2220, 2221, 2222, 2223, 2224, 2225, 2226, 2230, 2231, 2235,
2244, 2245, 2251, 2252, 2260, 2263, 2267, 2268, 2272, 2273,
2274, 2275, 2279, 2280, 2284, 2285, 2286, 2288, 2296, 2297,
2298, 2309, 2310, 2313, 2316, 2317, 2320, 2324, 2325
2298, 2309, 2310, 2313, 2316, 2317, 2320, 2325, 2326
};
#endif
@@ -10115,27 +10115,28 @@ yyreduce:
/* Line 1455 of yacc.c */
#line 2320 "../../../hphp/util/parser/hphp.y"
{ only_in_strict_mode(_p); (yyval).reset(); ;}
{ only_in_strict_mode(_p);
(yyval).setText("array"); ;}
break;
case 677:
/* Line 1455 of yacc.c */
#line 2324 "../../../hphp/util/parser/hphp.y"
#line 2325 "../../../hphp/util/parser/hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]); ;}
break;
case 678:
/* Line 1455 of yacc.c */
#line 2325 "../../../hphp/util/parser/hphp.y"
#line 2326 "../../../hphp/util/parser/hphp.y"
{ (yyval).reset(); ;}
break;
/* Line 1455 of yacc.c */
#line 10138 "hphp.tab.cpp"
#line 10139 "hphp.tab.cpp"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -10355,7 +10356,7 @@ yyreturn:
/* Line 1675 of yacc.c */
#line 2328 "../../../hphp/util/parser/hphp.y"
#line 2329 "../../../hphp/util/parser/hphp.y"
bool Parser::parseImpl() {
return yyparse(this) == 0;
+20 -20
Ver Arquivo
@@ -776,8 +776,8 @@ DefineFunction(
array(
'name' => "items",
'flags' => HasDocComment,
'desc' => "Returns an Iterable that produces the key/value pairs as ".
"Tuples from this Map.",
'desc' => "Returns an Iterable that produces the key/value Pairs ".
"from this Map.",
'return' => array(
'type' => Object,
),
@@ -986,7 +986,7 @@ DefineFunction(
array(
'name' => "add",
'flags' => HasDocComment,
'desc' => "Adds the specified key/value Tuple to this Map. If an ".
'desc' => "Adds the specified key/value Pair to this Map. If an ".
"element with the same key is already present, an exception ".
"is thrown.",
'return' => array(
@@ -1004,7 +1004,7 @@ DefineFunction(
array(
'name' => "addAll",
'flags' => HasDocComment,
'desc' => "Adds the key/value Tuples produced by the specified ".
'desc' => "Adds the key/value Pairs produced by the specified ".
"Iterable to this Map.",
'return' => array(
'type' => Object,
@@ -1205,7 +1205,7 @@ DefineFunction(
array(
'name' => "fromItems",
'flags' => IsStatic | HasDocComment,
'desc' => "Returns a Map built from the key/value Tuples produced by ".
'desc' => "Returns a Map built from the key/value Pairs produced by ".
"the specified Iterable.",
'return' => array(
'type' => Object,
@@ -1377,8 +1377,8 @@ DefineFunction(
array(
'name' => "items",
'flags' => HasDocComment,
'desc' => "Returns an Iterable that produces the key/value pairs as ".
"Tuples from this StableMap.",
'desc' => "Returns an Iterable that produces the key/value Pairs ".
"from this StableMap.",
'return' => array(
'type' => Object,
),
@@ -1588,7 +1588,7 @@ DefineFunction(
array(
'name' => "add",
'flags' => HasDocComment,
'desc' => "Adds the specified key/value Tuple to this StableMap. If an ".
'desc' => "Adds the specified key/value Pair to this StableMap. If an ".
"element with the same key is already present, an exception ".
"is thrown.",
'return' => array(
@@ -1606,7 +1606,7 @@ DefineFunction(
array(
'name' => "addAll",
'flags' => HasDocComment,
'desc' => "Adds the key/value Tuples produced by the specified ".
'desc' => "Adds the key/value Pairs produced by the specified ".
"Iterable to the end of this StableMap.",
'return' => array(
'type' => Object,
@@ -1800,7 +1800,7 @@ DefineFunction(
array(
'name' => "fromItems",
'flags' => IsStatic | HasDocComment,
'desc' => "Returns a StableMap built from the key/value Tuples produced ".
'desc' => "Returns a StableMap built from the key/value Pairs produced ".
"by the specified Iterable.",
'return' => array(
'type' => Object,
@@ -1932,7 +1932,7 @@ EndClass(
BeginClass(
array(
'name' => "Tuple",
'name' => "Pair",
'ifaces' => array('ConstVector'),
'desc' => "An ordered fixed-sized container.",
'flags' => IsFinal | HasDocComment,
@@ -1957,7 +1957,7 @@ DefineFunction(
array(
'name' => "isEmpty",
'flags' => HasDocComment,
'desc' => "Returns true if this Tuple is empty, false otherwise.",
'desc' => "Returns true if this Pair is empty, false otherwise.",
'return' => array(
'type' => Boolean,
),
@@ -1967,7 +1967,7 @@ DefineFunction(
array(
'name' => "count",
'flags' => HasDocComment,
'desc' => "Returns the number of values in the Tuple.",
'desc' => "Returns the number of values in the Pair.",
'return' => array(
'type' => Int64,
),
@@ -1978,7 +1978,7 @@ DefineFunction(
'name' => "items",
'flags' => HasDocComment,
'desc' => "Returns an Iterable that produces the values from this ".
"Tuple.",
"Pair.",
'return' => array(
'type' => Object,
),
@@ -1988,7 +1988,7 @@ DefineFunction(
array(
'name' => "keys",
'flags' => HasDocComment,
'desc' => "Returns an Iterable that produces the keys from this Tuple.",
'desc' => "Returns an Iterable that produces the keys from this Pair.",
'return' => array(
'type' => Object,
),
@@ -1998,7 +1998,7 @@ DefineFunction(
array(
'name' => "toArray",
'flags' => HasDocComment,
'desc' => "Returns an array built from the values from this Tuple.",
'desc' => "Returns an array built from the values from this Pair.",
'return' => array(
'type' => VariantMap,
),
@@ -2009,7 +2009,7 @@ DefineFunction(
'name' => "getIterator",
'flags' => HasDocComment,
'desc' => "Returns an iterator that points to beginning of this ".
"Tuple.",
"Pair.",
'return' => array(
'type' => Object,
),
@@ -2053,7 +2053,7 @@ DefineFunction(
array(
'name' => "containsKey",
'flags' => HasDocComment,
'desc' => "Returns true if the specified key is present in the Tuple, ".
'desc' => "Returns true if the specified key is present in the Pair, ".
"returns false otherwise.",
'return' => array(
'type' => Boolean,
@@ -2071,9 +2071,9 @@ EndClass(
BeginClass(
array(
'name' => "TupleIterator",
'name' => "PairIterator",
'ifaces' => array('KeyedIterator'),
'desc' => "An iterator implementation for iterating over a Tuple.",
'desc' => "An iterator implementation for iterating over a Pair.",
'flags' => IsFinal | HasDocComment,
));
+10 -10
Ver Arquivo
@@ -102,7 +102,7 @@ void ArrayIter::objInit(ObjectData *obj) {
m_pos = smp->iter_begin();
break;
}
case Collection::TupleType: {
case Collection::PairType: {
m_pos = 0;
break;
}
@@ -159,9 +159,9 @@ bool ArrayIter::endHelper() {
case Collection::StableMapType: {
return m_pos == 0;
}
case Collection::TupleType: {
c_Tuple* tup = getTuple();
return m_pos >= tup->t_count();
case Collection::PairType: {
c_Pair* pair = getPair();
return m_pos >= pair->t_count();
}
default: {
ObjectData* obj = getIteratorObj();
@@ -194,7 +194,7 @@ void ArrayIter::nextHelper() {
m_pos = smp->iter_next(m_pos);
return;
}
case Collection::TupleType: {
case Collection::PairType: {
m_pos++;
return;
}
@@ -225,7 +225,7 @@ Variant ArrayIter::firstHelper() {
}
return smp->iter_key(m_pos);
}
case Collection::TupleType: {
case Collection::PairType: {
return m_pos;
}
default: {
@@ -265,8 +265,8 @@ Variant ArrayIter::second() {
}
return smp->iter_value(m_pos);
}
case Collection::TupleType: {
return tvAsCVarRef(getTuple()->at(m_pos));
case Collection::PairType: {
return tvAsCVarRef(getPair()->at(m_pos));
}
default: {
ObjectData* obj = getIteratorObj();
@@ -301,8 +301,8 @@ void ArrayIter::secondHelper(Variant& v) {
v = smp->iter_value(m_pos);
break;
}
case Collection::TupleType: {
v = tvAsCVarRef(getTuple()->at(m_pos));
case Collection::PairType: {
v = tvAsCVarRef(getPair()->at(m_pos));
break;
}
default: {
+4 -4
Ver Arquivo
@@ -30,7 +30,7 @@ struct TypedValue;
class c_Vector;
class c_Map;
class c_StableMap;
class c_Tuple;
class c_Pair;
namespace VM {
struct Iter;
}
@@ -194,9 +194,9 @@ class ArrayIter {
assert(hasCollection() && getCollectionType() == Collection::StableMapType);
return (c_StableMap*)((intptr_t)m_obj & ~1);
}
c_Tuple* getTuple() {
assert(hasCollection() && getCollectionType() == Collection::TupleType);
return (c_Tuple*)((intptr_t)m_obj & ~1);
c_Pair* getPair() {
assert(hasCollection() && getCollectionType() == Collection::PairType);
return (c_Pair*)((intptr_t)m_obj & ~1);
}
ObjectData* getObject() {
assert(!hasArrayData());
+1 -1
Ver Arquivo
@@ -68,7 +68,7 @@ class ObjectData : public CountableNF {
VectorAttrInit = (Collection::VectorType << 13),
MapAttrInit = (Collection::MapType << 13),
StableMapAttrInit = (Collection::StableMapType << 13),
TupleAttrInit = (Collection::TupleType << 13),
PairAttrInit = (Collection::PairType << 13),
};
enum {
+3 -4
Ver Arquivo
@@ -3149,10 +3149,9 @@ void Variant::unserialize(VariableUnserializer *uns,
VM::Class* cls = VM::Unit::loadClass(clsName.get());
Object obj;
if (cls) {
if (LIKELY(cls != c_Tuple::s_cls)) {
obj = VM::Instance::newInstance(cls);
} else {
obj = c_Tuple::alloc(size);
obj = VM::Instance::newInstance(cls);
if (UNLIKELY(cls == c_Pair::s_cls && size != 2)) {
throw Exception("Pair objects must have exactly 2 elements");
}
} else {
obj = VM::Instance::newInstance(
+1 -1
Ver Arquivo
@@ -309,7 +309,7 @@ enum Type {
VectorType = 1,
MapType = 2,
StableMapType = 3,
TupleType = 4,
PairType = 4,
MaxNumTypes = 5
};
}
+117 -152
Ver Arquivo
@@ -1295,19 +1295,14 @@ Object c_Map::ti_fromitems(const char* cls, CVarRef iterable) {
Variant v = iter.second();
TypedValue* tv = tvToCell(v.asTypedValue());
if (UNLIKELY(tv->m_type != KindOfObject ||
!tv->m_data.pobj->instanceof(c_Tuple::s_cls))) {
!tv->m_data.pobj->instanceof(c_Pair::s_cls))) {
Object e(SystemLib::AllocInvalidArgumentExceptionObject(
"Parameter must be an instance of Iterable<Tuple>"));
"Parameter must be an instance of Iterable<Pair>"));
throw e;
}
auto tup = static_cast<c_Tuple*>(tv->m_data.pobj);
if (UNLIKELY(tup->t_count() != 2)) {
Object e(SystemLib::AllocInvalidArgumentExceptionObject(
"Expected Tuples containing exactly two elements"));
throw e;
}
TypedValue* tvKey = &tup->getData()[0];
TypedValue* tvValue = &tup->getData()[1];
auto pair = static_cast<c_Pair*>(tv->m_data.pobj);
TypedValue* tvKey = &pair->elm0;
TypedValue* tvValue = &pair->elm1;
assert(tvKey->m_type != KindOfRef);
assert(tvValue->m_type != KindOfRef);
if (tvKey->m_type == KindOfInt64) {
@@ -1382,19 +1377,14 @@ void c_Map::throwOOB(StringData* key) {
void c_Map::add(TypedValue* val) {
if (UNLIKELY(val->m_type != KindOfObject ||
!val->m_data.pobj->instanceof(c_Tuple::s_cls))) {
!val->m_data.pobj->instanceof(c_Pair::s_cls))) {
Object e(SystemLib::AllocInvalidArgumentExceptionObject(
"Parameter must be an instance of Tuple"));
"Parameter must be an instance of Pair"));
throw e;
}
auto tup = static_cast<c_Tuple*>(val->m_data.pobj);
if (UNLIKELY(tup->t_count() != 2)) {
Object e(SystemLib::AllocInvalidArgumentExceptionObject(
"Expected Tuple containing exactly two elements"));
throw e;
}
TypedValue* tvKey = &tup->getData()[0];
TypedValue* tvValue = &tup->getData()[1];
auto pair = static_cast<c_Pair*>(val->m_data.pobj);
TypedValue* tvKey = &pair->elm0;
TypedValue* tvValue = &pair->elm1;
assert(tvKey->m_type != KindOfRef);
assert(tvValue->m_type != KindOfRef);
if (tvKey->m_type == KindOfInt64) {
@@ -2346,19 +2336,14 @@ Object c_StableMap::ti_fromitems(const char* cls, CVarRef iterable) {
Variant v = iter.second();
TypedValue* tv = cvarToCell(&v);
if (UNLIKELY(tv->m_type != KindOfObject ||
!tv->m_data.pobj->instanceof(c_Tuple::s_cls))) {
!tv->m_data.pobj->instanceof(c_Pair::s_cls))) {
Object e(SystemLib::AllocInvalidArgumentExceptionObject(
"Parameter must be an instance of Iterable<Tuple>"));
"Parameter must be an instance of Iterable<Pair>"));
throw e;
}
auto tup = static_cast<c_Tuple*>(tv->m_data.pobj);
if (UNLIKELY(tup->t_count() != 2)) {
Object e(SystemLib::AllocInvalidArgumentExceptionObject(
"Expected Tuples containing exactly two elements"));
throw e;
}
TypedValue* tvKey = &tup->getData()[0];
TypedValue* tvValue = &tup->getData()[1];
auto pair = static_cast<c_Pair*>(tv->m_data.pobj);
TypedValue* tvKey = &pair->elm0;
TypedValue* tvValue = &pair->elm1;
assert(tvKey->m_type != KindOfRef);
assert(tvValue->m_type != KindOfRef);
if (tvKey->m_type == KindOfInt64) {
@@ -2434,19 +2419,14 @@ void c_StableMap::throwOOB(StringData* key) {
void c_StableMap::add(TypedValue* val) {
if (UNLIKELY(val->m_type != KindOfObject ||
!val->m_data.pobj->instanceof(c_Tuple::s_cls))) {
!val->m_data.pobj->instanceof(c_Pair::s_cls))) {
Object e(SystemLib::AllocInvalidArgumentExceptionObject(
"Parameter must be an instance of Tuple"));
"Parameter must be an instance of Pair"));
throw e;
}
auto tup = static_cast<c_Tuple*>(val->m_data.pobj);
if (UNLIKELY(tup->t_count() != 2)) {
Object e(SystemLib::AllocInvalidArgumentExceptionObject(
"Expected Tuple containing exactly two elements"));
throw e;
}
TypedValue* tvKey = &tup->getData()[0];
TypedValue* tvValue = &tup->getData()[1];
auto pair = static_cast<c_Pair*>(val->m_data.pobj);
TypedValue* tvKey = &pair->elm0;
TypedValue* tvValue = &pair->elm1;
assert(tvKey->m_type != KindOfRef);
assert(tvValue->m_type != KindOfRef);
if (tvKey->m_type == KindOfInt64) {
@@ -3060,71 +3040,70 @@ void c_StableMapIterator::t_rewind() {
///////////////////////////////////////////////////////////////////////////////
c_Tuple::c_Tuple(VM::Class* cb) :
ExtObjectDataFlags<ObjectData::TupleAttrInit|
c_Pair::c_Pair(VM::Class* cb) :
ExtObjectDataFlags<ObjectData::PairAttrInit|
ObjectData::UseGet|
ObjectData::UseSet|
ObjectData::UseIsset|
ObjectData::UseUnset>(cb),
m_size(0), m_capacity(0) {
m_size(0) {
}
c_Tuple::~c_Tuple() {
uint sz = m_size;
for (uint i = 0; i < sz; ++i) {
tvRefcountedDecRef(&getData()[i]);
c_Pair::~c_Pair() {
if (LIKELY(m_size == 2)) {
tvRefcountedDecRef(&elm0);
tvRefcountedDecRef(&elm1);
return;
}
if (m_size == 1) {
tvRefcountedDecRef(&elm0);
}
}
void c_Tuple::t___construct() {
void c_Pair::t___construct() {
Object e(SystemLib::AllocRuntimeExceptionObject(
"Tuples cannot be created using the new operator"));
"Pairs cannot be created using the new operator"));
throw e;
}
Array c_Tuple::toArrayImpl() const {
ArrayInit ai(m_size, ArrayInit::vectorInit);
uint sz = m_size;
for (uint i = 0; i < sz; ++i) {
ai.set(tvAsCVarRef(&getData()[i]));
}
Array c_Pair::toArrayImpl() const {
ArrayInit ai(2, ArrayInit::vectorInit);
ai.set(tvAsCVarRef(&elm0));
ai.set(tvAsCVarRef(&elm1));
return ai.create();
}
Array c_Tuple::o_toArray() const {
Array c_Pair::o_toArray() const {
check_collection_cast_to_array();
return toArrayImpl();
}
ObjectData* c_Tuple::clone() {
auto tup = c_Tuple::alloc(m_size);
tup->incRefCount();
uint sz = tup->m_size = m_size;
TypedValue* src = getData();
TypedValue* dst = tup->getData();
for (int i = 0; i < sz; ++i) {
tvDup(&src[i], &dst[i]);
}
return tup;
ObjectData* c_Pair::clone() {
auto pair = NEWOBJ(c_Pair)();
pair->incRefCount();
pair->m_size = 2;
tvDup(&elm0, &pair->elm0);
tvDup(&elm1, &pair->elm1);
return pair;
}
bool c_Tuple::t_isempty() {
return (m_size == 0);
bool c_Pair::t_isempty() {
return false;
}
int64_t c_Tuple::t_count() {
return m_size;
int64_t c_Pair::t_count() {
return 2;
}
Object c_Tuple::t_items() {
Object c_Pair::t_items() {
return this;
}
Object c_Tuple::t_keys() {
Object c_Pair::t_keys() {
return SystemLib::AllocKeysIterableObject(this);
}
Variant c_Tuple::t_at(CVarRef key) {
Variant c_Pair::t_at(CVarRef key) {
if (key.isInteger()) {
return tvAsCVarRef(at(key.toInt64()));
}
@@ -3132,7 +3111,7 @@ Variant c_Tuple::t_at(CVarRef key) {
return init_null_variant;
}
Variant c_Tuple::t_get(CVarRef key) {
Variant c_Pair::t_get(CVarRef key) {
if (key.isInteger()) {
TypedValue* tv = get(key.toInt64());
if (tv) {
@@ -3145,7 +3124,7 @@ Variant c_Tuple::t_get(CVarRef key) {
return init_null_variant;
}
bool c_Tuple::t_containskey(CVarRef key) {
bool c_Pair::t_containskey(CVarRef key) {
if (key.isInteger()) {
return contains(key.toInt64());
}
@@ -3153,49 +3132,49 @@ bool c_Tuple::t_containskey(CVarRef key) {
return false;
}
Array c_Tuple::t_toarray() {
Array c_Pair::t_toarray() {
return toArrayImpl();
}
Object c_Tuple::t_getiterator() {
c_TupleIterator* it = NEWOBJ(c_TupleIterator)();
Object c_Pair::t_getiterator() {
c_PairIterator* it = NEWOBJ(c_PairIterator)();
it->m_obj = this;
it->m_pos = 0;
return it;
}
void c_Tuple::throwOOB(int64_t key) {
void c_Pair::throwOOB(int64_t key) {
throwIntOOB(key, true);
}
void c_Tuple::throwBadKeyType() {
void c_Pair::throwBadKeyType() {
Object e(SystemLib::AllocInvalidArgumentExceptionObject(
"Only integer keys may be used with Tuples"));
"Only integer keys may be used with Pairs"));
throw e;
}
TypedValue* c_Tuple::OffsetGet(ObjectData* obj, TypedValue* key) {
TypedValue* c_Pair::OffsetGet(ObjectData* obj, TypedValue* key) {
assert(key->m_type != KindOfRef);
auto tup = static_cast<c_Tuple*>(obj);
auto pair = static_cast<c_Pair*>(obj);
if (key->m_type == KindOfInt64) {
return tup->at(key->m_data.num);
return pair->at(key->m_data.num);
}
throwBadKeyType();
return NULL;
}
void c_Tuple::OffsetSet(ObjectData* obj, TypedValue* key, TypedValue* val) {
void c_Pair::OffsetSet(ObjectData* obj, TypedValue* key, TypedValue* val) {
Object e(SystemLib::AllocRuntimeExceptionObject(
"Cannot assign to an element of a Tuple"));
"Cannot assign to an element of a Pair"));
throw e;
}
bool c_Tuple::OffsetIsset(ObjectData* obj, TypedValue* key) {
bool c_Pair::OffsetIsset(ObjectData* obj, TypedValue* key) {
assert(key->m_type != KindOfRef);
auto tup = static_cast<c_Tuple*>(obj);
auto pair = static_cast<c_Pair*>(obj);
TypedValue* result;
if (key->m_type == KindOfInt64) {
result = tup->get(key->m_data.num);
result = pair->get(key->m_data.num);
} else {
throwBadKeyType();
result = NULL;
@@ -3203,12 +3182,12 @@ bool c_Tuple::OffsetIsset(ObjectData* obj, TypedValue* key) {
return result ? isset(tvAsCVarRef(result)) : false;
}
bool c_Tuple::OffsetEmpty(ObjectData* obj, TypedValue* key) {
bool c_Pair::OffsetEmpty(ObjectData* obj, TypedValue* key) {
assert(key->m_type != KindOfRef);
auto tup = static_cast<c_Tuple*>(obj);
auto pair = static_cast<c_Pair*>(obj);
TypedValue* result;
if (key->m_type == KindOfInt64) {
result = tup->get(key->m_data.num);
result = pair->get(key->m_data.num);
} else {
throwBadKeyType();
result = NULL;
@@ -3216,101 +3195,90 @@ bool c_Tuple::OffsetEmpty(ObjectData* obj, TypedValue* key) {
return result ? empty(tvAsCVarRef(result)) : true;
}
bool c_Tuple::OffsetContains(ObjectData* obj, TypedValue* key) {
bool c_Pair::OffsetContains(ObjectData* obj, TypedValue* key) {
assert(key->m_type != KindOfRef);
auto tup = static_cast<c_Tuple*>(obj);
auto pair = static_cast<c_Pair*>(obj);
if (key->m_type == KindOfInt64) {
return tup->contains(key->m_data.num);
return pair->contains(key->m_data.num);
} else {
throwBadKeyType();
return false;
}
}
void c_Tuple::OffsetAppend(ObjectData* obj, TypedValue* val) {
void c_Pair::OffsetAppend(ObjectData* obj, TypedValue* val) {
assert(val->m_type != KindOfRef);
auto tup = static_cast<c_Tuple*>(obj);
tup->add(val);
auto pair = static_cast<c_Pair*>(obj);
pair->add(val);
}
void c_Tuple::OffsetUnset(ObjectData* obj, TypedValue* key) {
void c_Pair::OffsetUnset(ObjectData* obj, TypedValue* key) {
Object e(SystemLib::AllocRuntimeExceptionObject(
"Cannot unset element of a Tuple"));
"Cannot unset element of a Pair"));
throw e;
}
bool c_Tuple::Equals(ObjectData* obj1, ObjectData* obj2) {
auto tup1 = static_cast<c_Tuple*>(obj1);
auto tup2 = static_cast<c_Tuple*>(obj2);
uint sz = tup1->m_size;
if (sz != tup2->m_size) {
return false;
}
TypedValue* data1 = tup1->getData();
TypedValue* data2 = tup2->getData();
for (uint i = 0; i < sz; ++i) {
if (!equal(tvAsCVarRef(&data1[i]),
tvAsCVarRef(&data2[i]))) {
return false;
}
}
return true;
bool c_Pair::Equals(ObjectData* obj1, ObjectData* obj2) {
auto pair1 = static_cast<c_Pair*>(obj1);
auto pair2 = static_cast<c_Pair*>(obj2);
return equal(tvAsCVarRef(&pair1->elm0), tvAsCVarRef(&pair2->elm0)) &&
equal(tvAsCVarRef(&pair1->elm1), tvAsCVarRef(&pair2->elm1));
}
void c_Tuple::Unserialize(ObjectData* obj,
void c_Pair::Unserialize(ObjectData* obj,
VariableUnserializer* uns,
int64_t sz,
char type) {
assert(sz == 2);
if (type != 'V') {
throw Exception("Tuple does not support the '%c' serialization "
throw Exception("Pair does not support the '%c' serialization "
"format", type);
}
auto tup = static_cast<c_Tuple*>(obj);
for (int64_t i = 0; i < sz; ++i) {
auto tv = &tup->getData()[tup->m_size];
tv->m_type = KindOfNull;
++tup->m_size;
tvAsVariant(tv).unserialize(uns, Uns::ColValueMode);
}
auto pair = static_cast<c_Pair*>(obj);
pair->m_size = 2;
pair->elm0.m_type = KindOfNull;
pair->elm1.m_type = KindOfNull;
tvAsVariant(&pair->elm0).unserialize(uns, Uns::ColValueMode);
tvAsVariant(&pair->elm1).unserialize(uns, Uns::ColValueMode);
}
c_TupleIterator::c_TupleIterator(VM::Class* cb) :
c_PairIterator::c_PairIterator(VM::Class* cb) :
ExtObjectData(cb) {
}
c_TupleIterator::~c_TupleIterator() {
c_PairIterator::~c_PairIterator() {
}
void c_TupleIterator::t___construct() {
void c_PairIterator::t___construct() {
}
Variant c_TupleIterator::t_current() {
c_Tuple* tup = m_obj.get();
if (!tup->contains(m_pos)) {
Variant c_PairIterator::t_current() {
c_Pair* pair = m_obj.get();
if (!pair->contains(m_pos)) {
throw_iterator_not_valid();
}
return tvAsCVarRef(&tup->getData()[m_pos]);
return tvAsCVarRef(&pair->getElms()[m_pos]);
}
Variant c_TupleIterator::t_key() {
c_Tuple* tup = m_obj.get();
if (!tup->contains(m_pos)) {
Variant c_PairIterator::t_key() {
c_Pair* pair = m_obj.get();
if (!pair->contains(m_pos)) {
throw_iterator_not_valid();
}
return m_pos;
}
bool c_TupleIterator::t_valid() {
bool c_PairIterator::t_valid() {
assert(m_pos >= 0);
c_Tuple* tup = m_obj.get();
return tup && (m_pos < (ssize_t)tup->m_size);
c_Pair* pair = m_obj.get();
return pair && (m_pos < ssize_t(2));
}
void c_TupleIterator::t_next() {
void c_PairIterator::t_next() {
m_pos++;
}
void c_TupleIterator::t_rewind() {
void c_PairIterator::t_rewind() {
m_pos = 0;
}
@@ -3336,7 +3304,7 @@ void c_TupleIterator::t_rewind() {
COLLECTION_MAGIC_METHODS(Vector)
COLLECTION_MAGIC_METHODS(Map)
COLLECTION_MAGIC_METHODS(StableMap)
COLLECTION_MAGIC_METHODS(Tuple)
COLLECTION_MAGIC_METHODS(Pair)
#undef COLLECTION_MAGIC_METHODS
@@ -3344,7 +3312,7 @@ void collectionSerialize(ObjectData* obj, VariableSerializer* serializer) {
assert(obj->isCollection());
int64_t sz = collectionSize(obj);
if (obj->getCollectionType() == Collection::VectorType ||
obj->getCollectionType() == Collection::TupleType) {
obj->getCollectionType() == Collection::PairType) {
serializer->setObjectInfo(obj->o_getClassName(), obj->o_getId(), 'V');
serializer->writeArrayHeader(sz, true);
if (serializer->getType() == VariableSerializer::Serialize ||
@@ -3398,8 +3366,8 @@ void collectionDeepCopyTV(TypedValue* tv) {
case Collection::StableMapType:
obj = collectionDeepCopyStableMap(static_cast<c_StableMap*>(obj));
break;
case Collection::TupleType:
obj = collectionDeepCopyTuple(static_cast<c_Tuple*>(obj));
case Collection::PairType:
obj = collectionDeepCopyPair(static_cast<c_Pair*>(obj));
break;
default:
assert(false);
@@ -3457,13 +3425,10 @@ ObjectData* collectionDeepCopyStableMap(c_StableMap* smp) {
return o.detach();
}
ObjectData* collectionDeepCopyTuple(c_Tuple* tup) {
Object o = tup = static_cast<c_Tuple*>(tup->clone());
size_t sz = tup->m_size;
TypedValue* data = tup->getData();
for (size_t i = 0; i < sz; ++i) {
collectionDeepCopyTV(&data[i]);
}
ObjectData* collectionDeepCopyPair(c_Pair* pair) {
Object o = pair = static_cast<c_Pair*>(pair->clone());
collectionDeepCopyTV(&pair->elm0);
collectionDeepCopyTV(&pair->elm1);
return o.detach();
}
@@ -3472,7 +3437,7 @@ CollectionInit::CollectionInit(int cType, ssize_t nElms) {
case Collection::VectorType: m_data = NEWOBJ(c_Vector)(); break;
case Collection::MapType: m_data = NEWOBJ(c_Map)(); break;
case Collection::StableMapType: m_data = NEWOBJ(c_StableMap)(); break;
case Collection::TupleType: m_data = c_Tuple::alloc(nElms); break;
case Collection::PairType: m_data = NEWOBJ(c_Pair)(); break;
default:
assert(false);
break;
+120 -120
Ver Arquivo
@@ -4705,26 +4705,26 @@ TypedValue* tg_17StableMapIterator_rewind(HPHP::VM::ActRec *ar) {
return &ar->m_r;
}
HPHP::VM::Instance* new_Tuple_Instance(HPHP::VM::Class* cls) {
HPHP::VM::Instance* new_Pair_Instance(HPHP::VM::Class* cls) {
size_t nProps = cls->numDeclProperties();
size_t builtinPropSize = sizeof(c_Tuple) - sizeof(ObjectData);
size_t builtinPropSize = sizeof(c_Pair) - sizeof(ObjectData);
size_t size = HPHP::VM::Instance::sizeForNProps(nProps) + builtinPropSize;
HPHP::VM::Instance *inst = (HPHP::VM::Instance*)ALLOCOBJSZ(size);
new ((void *)inst) c_Tuple(cls);
new ((void *)inst) c_Pair(cls);
return inst;
}
IMPLEMENT_CLASS(Tuple);
IMPLEMENT_CLASS(Pair);
/*
void HPHP::c_Tuple::t___construct()
_ZN4HPHP7c_Tuple13t___constructEv
void HPHP::c_Pair::t___construct()
_ZN4HPHP6c_Pair13t___constructEv
this_ => rdi
*/
void th_5Tuple___construct(ObjectData* this_) asm("_ZN4HPHP7c_Tuple13t___constructEv");
void th_4Pair___construct(ObjectData* this_) asm("_ZN4HPHP6c_Pair13t___constructEv");
TypedValue* tg_5Tuple___construct(HPHP::VM::ActRec *ar) {
TypedValue* tg_4Pair___construct(HPHP::VM::ActRec *ar) {
TypedValue rv;
int64_t count = ar->numArgs();
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
@@ -4733,15 +4733,15 @@ TypedValue* tg_5Tuple___construct(HPHP::VM::ActRec *ar) {
if (count == 0LL) {
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
th_5Tuple___construct((this_));
th_4Pair___construct((this_));
frame_free_locals_inl(ar, 0);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
} else {
throw_toomany_arguments_nr("Tuple::__construct", 0, 1);
throw_toomany_arguments_nr("Pair::__construct", 0, 1);
}
} else {
throw_instance_method_fatal("Tuple::__construct");
throw_instance_method_fatal("Pair::__construct");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
@@ -4752,16 +4752,16 @@ TypedValue* tg_5Tuple___construct(HPHP::VM::ActRec *ar) {
}
/*
bool HPHP::c_Tuple::t_isempty()
_ZN4HPHP7c_Tuple9t_isemptyEv
bool HPHP::c_Pair::t_isempty()
_ZN4HPHP6c_Pair9t_isemptyEv
(return value) => rax
this_ => rdi
*/
bool th_5Tuple_isEmpty(ObjectData* this_) asm("_ZN4HPHP7c_Tuple9t_isemptyEv");
bool th_4Pair_isEmpty(ObjectData* this_) asm("_ZN4HPHP6c_Pair9t_isemptyEv");
TypedValue* tg_5Tuple_isEmpty(HPHP::VM::ActRec *ar) {
TypedValue* tg_4Pair_isEmpty(HPHP::VM::ActRec *ar) {
TypedValue rv;
int64_t count = ar->numArgs();
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
@@ -4769,15 +4769,15 @@ TypedValue* tg_5Tuple_isEmpty(HPHP::VM::ActRec *ar) {
if (this_) {
if (count == 0LL) {
rv.m_type = KindOfBoolean;
rv.m_data.num = (th_5Tuple_isEmpty((this_))) ? 1LL : 0LL;
rv.m_data.num = (th_4Pair_isEmpty((this_))) ? 1LL : 0LL;
frame_free_locals_inl(ar, 0);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
} else {
throw_toomany_arguments_nr("Tuple::isEmpty", 0, 1);
throw_toomany_arguments_nr("Pair::isEmpty", 0, 1);
}
} else {
throw_instance_method_fatal("Tuple::isEmpty");
throw_instance_method_fatal("Pair::isEmpty");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
@@ -4788,16 +4788,16 @@ TypedValue* tg_5Tuple_isEmpty(HPHP::VM::ActRec *ar) {
}
/*
long HPHP::c_Tuple::t_count()
_ZN4HPHP7c_Tuple7t_countEv
long HPHP::c_Pair::t_count()
_ZN4HPHP6c_Pair7t_countEv
(return value) => rax
this_ => rdi
*/
long th_5Tuple_count(ObjectData* this_) asm("_ZN4HPHP7c_Tuple7t_countEv");
long th_4Pair_count(ObjectData* this_) asm("_ZN4HPHP6c_Pair7t_countEv");
TypedValue* tg_5Tuple_count(HPHP::VM::ActRec *ar) {
TypedValue* tg_4Pair_count(HPHP::VM::ActRec *ar) {
TypedValue rv;
int64_t count = ar->numArgs();
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
@@ -4805,15 +4805,15 @@ TypedValue* tg_5Tuple_count(HPHP::VM::ActRec *ar) {
if (this_) {
if (count == 0LL) {
rv.m_type = KindOfInt64;
rv.m_data.num = (int64_t)th_5Tuple_count((this_));
rv.m_data.num = (int64_t)th_4Pair_count((this_));
frame_free_locals_inl(ar, 0);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
} else {
throw_toomany_arguments_nr("Tuple::count", 0, 1);
throw_toomany_arguments_nr("Pair::count", 0, 1);
}
} else {
throw_instance_method_fatal("Tuple::count");
throw_instance_method_fatal("Pair::count");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
@@ -4824,17 +4824,17 @@ TypedValue* tg_5Tuple_count(HPHP::VM::ActRec *ar) {
}
/*
HPHP::Object HPHP::c_Tuple::t_items()
_ZN4HPHP7c_Tuple7t_itemsEv
HPHP::Object HPHP::c_Pair::t_items()
_ZN4HPHP6c_Pair7t_itemsEv
(return value) => rax
_rv => rdi
this_ => rsi
*/
Value* th_5Tuple_items(Value* _rv, ObjectData* this_) asm("_ZN4HPHP7c_Tuple7t_itemsEv");
Value* th_4Pair_items(Value* _rv, ObjectData* this_) asm("_ZN4HPHP6c_Pair7t_itemsEv");
TypedValue* tg_5Tuple_items(HPHP::VM::ActRec *ar) {
TypedValue* tg_4Pair_items(HPHP::VM::ActRec *ar) {
TypedValue rv;
int64_t count = ar->numArgs();
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
@@ -4842,16 +4842,16 @@ TypedValue* tg_5Tuple_items(HPHP::VM::ActRec *ar) {
if (this_) {
if (count == 0LL) {
rv.m_type = KindOfObject;
th_5Tuple_items((&rv.m_data), (this_));
th_4Pair_items((&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("Tuple::items", 0, 1);
throw_toomany_arguments_nr("Pair::items", 0, 1);
}
} else {
throw_instance_method_fatal("Tuple::items");
throw_instance_method_fatal("Pair::items");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
@@ -4862,17 +4862,17 @@ TypedValue* tg_5Tuple_items(HPHP::VM::ActRec *ar) {
}
/*
HPHP::Object HPHP::c_Tuple::t_keys()
_ZN4HPHP7c_Tuple6t_keysEv
HPHP::Object HPHP::c_Pair::t_keys()
_ZN4HPHP6c_Pair6t_keysEv
(return value) => rax
_rv => rdi
this_ => rsi
*/
Value* th_5Tuple_keys(Value* _rv, ObjectData* this_) asm("_ZN4HPHP7c_Tuple6t_keysEv");
Value* th_4Pair_keys(Value* _rv, ObjectData* this_) asm("_ZN4HPHP6c_Pair6t_keysEv");
TypedValue* tg_5Tuple_keys(HPHP::VM::ActRec *ar) {
TypedValue* tg_4Pair_keys(HPHP::VM::ActRec *ar) {
TypedValue rv;
int64_t count = ar->numArgs();
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
@@ -4880,16 +4880,16 @@ TypedValue* tg_5Tuple_keys(HPHP::VM::ActRec *ar) {
if (this_) {
if (count == 0LL) {
rv.m_type = KindOfObject;
th_5Tuple_keys((&rv.m_data), (this_));
th_4Pair_keys((&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("Tuple::keys", 0, 1);
throw_toomany_arguments_nr("Pair::keys", 0, 1);
}
} else {
throw_instance_method_fatal("Tuple::keys");
throw_instance_method_fatal("Pair::keys");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
@@ -4900,17 +4900,17 @@ TypedValue* tg_5Tuple_keys(HPHP::VM::ActRec *ar) {
}
/*
HPHP::Array HPHP::c_Tuple::t_toarray()
_ZN4HPHP7c_Tuple9t_toarrayEv
HPHP::Array HPHP::c_Pair::t_toarray()
_ZN4HPHP6c_Pair9t_toarrayEv
(return value) => rax
_rv => rdi
this_ => rsi
*/
Value* th_5Tuple_toArray(Value* _rv, ObjectData* this_) asm("_ZN4HPHP7c_Tuple9t_toarrayEv");
Value* th_4Pair_toArray(Value* _rv, ObjectData* this_) asm("_ZN4HPHP6c_Pair9t_toarrayEv");
TypedValue* tg_5Tuple_toArray(HPHP::VM::ActRec *ar) {
TypedValue* tg_4Pair_toArray(HPHP::VM::ActRec *ar) {
TypedValue rv;
int64_t count = ar->numArgs();
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
@@ -4918,16 +4918,16 @@ TypedValue* tg_5Tuple_toArray(HPHP::VM::ActRec *ar) {
if (this_) {
if (count == 0LL) {
rv.m_type = KindOfArray;
th_5Tuple_toArray((&rv.m_data), (this_));
th_4Pair_toArray((&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("Tuple::toArray", 0, 1);
throw_toomany_arguments_nr("Pair::toArray", 0, 1);
}
} else {
throw_instance_method_fatal("Tuple::toArray");
throw_instance_method_fatal("Pair::toArray");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
@@ -4938,17 +4938,17 @@ TypedValue* tg_5Tuple_toArray(HPHP::VM::ActRec *ar) {
}
/*
HPHP::Object HPHP::c_Tuple::t_getiterator()
_ZN4HPHP7c_Tuple13t_getiteratorEv
HPHP::Object HPHP::c_Pair::t_getiterator()
_ZN4HPHP6c_Pair13t_getiteratorEv
(return value) => rax
_rv => rdi
this_ => rsi
*/
Value* th_5Tuple_getIterator(Value* _rv, ObjectData* this_) asm("_ZN4HPHP7c_Tuple13t_getiteratorEv");
Value* th_4Pair_getIterator(Value* _rv, ObjectData* this_) asm("_ZN4HPHP6c_Pair13t_getiteratorEv");
TypedValue* tg_5Tuple_getIterator(HPHP::VM::ActRec *ar) {
TypedValue* tg_4Pair_getIterator(HPHP::VM::ActRec *ar) {
TypedValue rv;
int64_t count = ar->numArgs();
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
@@ -4956,16 +4956,16 @@ TypedValue* tg_5Tuple_getIterator(HPHP::VM::ActRec *ar) {
if (this_) {
if (count == 0LL) {
rv.m_type = KindOfObject;
th_5Tuple_getIterator((&rv.m_data), (this_));
th_4Pair_getIterator((&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("Tuple::getIterator", 0, 1);
throw_toomany_arguments_nr("Pair::getIterator", 0, 1);
}
} else {
throw_instance_method_fatal("Tuple::getIterator");
throw_instance_method_fatal("Pair::getIterator");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
@@ -4976,8 +4976,8 @@ TypedValue* tg_5Tuple_getIterator(HPHP::VM::ActRec *ar) {
}
/*
HPHP::Variant HPHP::c_Tuple::t_at(HPHP::Variant const&)
_ZN4HPHP7c_Tuple4t_atERKNS_7VariantE
HPHP::Variant HPHP::c_Pair::t_at(HPHP::Variant const&)
_ZN4HPHP6c_Pair4t_atERKNS_7VariantE
(return value) => rax
_rv => rdi
@@ -4985,25 +4985,25 @@ this_ => rsi
key => rdx
*/
TypedValue* th_5Tuple_at(TypedValue* _rv, ObjectData* this_, TypedValue* key) asm("_ZN4HPHP7c_Tuple4t_atERKNS_7VariantE");
TypedValue* th_4Pair_at(TypedValue* _rv, ObjectData* this_, TypedValue* key) asm("_ZN4HPHP6c_Pair4t_atERKNS_7VariantE");
TypedValue* tg_5Tuple_at(HPHP::VM::ActRec *ar) {
TypedValue* tg_4Pair_at(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) {
th_5Tuple_at((&(rv)), (this_), (args-0));
th_4Pair_at((&(rv)), (this_), (args-0));
if (rv.m_type == KindOfUninit) 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("Tuple::at", count, 1, 1, 1);
throw_wrong_arguments_nr("Pair::at", count, 1, 1, 1);
}
} else {
throw_instance_method_fatal("Tuple::at");
throw_instance_method_fatal("Pair::at");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
@@ -5014,8 +5014,8 @@ TypedValue* tg_5Tuple_at(HPHP::VM::ActRec *ar) {
}
/*
HPHP::Variant HPHP::c_Tuple::t_get(HPHP::Variant const&)
_ZN4HPHP7c_Tuple5t_getERKNS_7VariantE
HPHP::Variant HPHP::c_Pair::t_get(HPHP::Variant const&)
_ZN4HPHP6c_Pair5t_getERKNS_7VariantE
(return value) => rax
_rv => rdi
@@ -5023,25 +5023,25 @@ this_ => rsi
key => rdx
*/
TypedValue* th_5Tuple_get(TypedValue* _rv, ObjectData* this_, TypedValue* key) asm("_ZN4HPHP7c_Tuple5t_getERKNS_7VariantE");
TypedValue* th_4Pair_get(TypedValue* _rv, ObjectData* this_, TypedValue* key) asm("_ZN4HPHP6c_Pair5t_getERKNS_7VariantE");
TypedValue* tg_5Tuple_get(HPHP::VM::ActRec *ar) {
TypedValue* tg_4Pair_get(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) {
th_5Tuple_get((&(rv)), (this_), (args-0));
th_4Pair_get((&(rv)), (this_), (args-0));
if (rv.m_type == KindOfUninit) 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("Tuple::get", count, 1, 1, 1);
throw_wrong_arguments_nr("Pair::get", count, 1, 1, 1);
}
} else {
throw_instance_method_fatal("Tuple::get");
throw_instance_method_fatal("Pair::get");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
@@ -5052,17 +5052,17 @@ TypedValue* tg_5Tuple_get(HPHP::VM::ActRec *ar) {
}
/*
bool HPHP::c_Tuple::t_containskey(HPHP::Variant const&)
_ZN4HPHP7c_Tuple13t_containskeyERKNS_7VariantE
bool HPHP::c_Pair::t_containskey(HPHP::Variant const&)
_ZN4HPHP6c_Pair13t_containskeyERKNS_7VariantE
(return value) => rax
this_ => rdi
key => rsi
*/
bool th_5Tuple_containsKey(ObjectData* this_, TypedValue* key) asm("_ZN4HPHP7c_Tuple13t_containskeyERKNS_7VariantE");
bool th_4Pair_containsKey(ObjectData* this_, TypedValue* key) asm("_ZN4HPHP6c_Pair13t_containskeyERKNS_7VariantE");
TypedValue* tg_5Tuple_containsKey(HPHP::VM::ActRec *ar) {
TypedValue* tg_4Pair_containsKey(HPHP::VM::ActRec *ar) {
TypedValue rv;
int64_t count = ar->numArgs();
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
@@ -5070,15 +5070,15 @@ TypedValue* tg_5Tuple_containsKey(HPHP::VM::ActRec *ar) {
if (this_) {
if (count == 1LL) {
rv.m_type = KindOfBoolean;
rv.m_data.num = (th_5Tuple_containsKey((this_), (args-0))) ? 1LL : 0LL;
rv.m_data.num = (th_4Pair_containsKey((this_), (args-0))) ? 1LL : 0LL;
frame_free_locals_inl(ar, 1);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
} else {
throw_wrong_arguments_nr("Tuple::containsKey", count, 1, 1, 1);
throw_wrong_arguments_nr("Pair::containsKey", count, 1, 1, 1);
}
} else {
throw_instance_method_fatal("Tuple::containsKey");
throw_instance_method_fatal("Pair::containsKey");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
@@ -5088,26 +5088,26 @@ TypedValue* tg_5Tuple_containsKey(HPHP::VM::ActRec *ar) {
return &ar->m_r;
}
HPHP::VM::Instance* new_TupleIterator_Instance(HPHP::VM::Class* cls) {
HPHP::VM::Instance* new_PairIterator_Instance(HPHP::VM::Class* cls) {
size_t nProps = cls->numDeclProperties();
size_t builtinPropSize = sizeof(c_TupleIterator) - sizeof(ObjectData);
size_t builtinPropSize = sizeof(c_PairIterator) - sizeof(ObjectData);
size_t size = HPHP::VM::Instance::sizeForNProps(nProps) + builtinPropSize;
HPHP::VM::Instance *inst = (HPHP::VM::Instance*)ALLOCOBJSZ(size);
new ((void *)inst) c_TupleIterator(cls);
new ((void *)inst) c_PairIterator(cls);
return inst;
}
IMPLEMENT_CLASS(TupleIterator);
IMPLEMENT_CLASS(PairIterator);
/*
void HPHP::c_TupleIterator::t___construct()
_ZN4HPHP15c_TupleIterator13t___constructEv
void HPHP::c_PairIterator::t___construct()
_ZN4HPHP14c_PairIterator13t___constructEv
this_ => rdi
*/
void th_13TupleIterator___construct(ObjectData* this_) asm("_ZN4HPHP15c_TupleIterator13t___constructEv");
void th_12PairIterator___construct(ObjectData* this_) asm("_ZN4HPHP14c_PairIterator13t___constructEv");
TypedValue* tg_13TupleIterator___construct(HPHP::VM::ActRec *ar) {
TypedValue* tg_12PairIterator___construct(HPHP::VM::ActRec *ar) {
TypedValue rv;
int64_t count = ar->numArgs();
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
@@ -5116,15 +5116,15 @@ TypedValue* tg_13TupleIterator___construct(HPHP::VM::ActRec *ar) {
if (count == 0LL) {
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
th_13TupleIterator___construct((this_));
th_12PairIterator___construct((this_));
frame_free_locals_inl(ar, 0);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
} else {
throw_toomany_arguments_nr("TupleIterator::__construct", 0, 1);
throw_toomany_arguments_nr("PairIterator::__construct", 0, 1);
}
} else {
throw_instance_method_fatal("TupleIterator::__construct");
throw_instance_method_fatal("PairIterator::__construct");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
@@ -5135,33 +5135,33 @@ TypedValue* tg_13TupleIterator___construct(HPHP::VM::ActRec *ar) {
}
/*
HPHP::Variant HPHP::c_TupleIterator::t_current()
_ZN4HPHP15c_TupleIterator9t_currentEv
HPHP::Variant HPHP::c_PairIterator::t_current()
_ZN4HPHP14c_PairIterator9t_currentEv
(return value) => rax
_rv => rdi
this_ => rsi
*/
TypedValue* th_13TupleIterator_current(TypedValue* _rv, ObjectData* this_) asm("_ZN4HPHP15c_TupleIterator9t_currentEv");
TypedValue* th_12PairIterator_current(TypedValue* _rv, ObjectData* this_) asm("_ZN4HPHP14c_PairIterator9t_currentEv");
TypedValue* tg_13TupleIterator_current(HPHP::VM::ActRec *ar) {
TypedValue* tg_12PairIterator_current(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) {
th_13TupleIterator_current((&(rv)), (this_));
th_12PairIterator_current((&(rv)), (this_));
if (rv.m_type == KindOfUninit) 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("TupleIterator::current", 0, 1);
throw_toomany_arguments_nr("PairIterator::current", 0, 1);
}
} else {
throw_instance_method_fatal("TupleIterator::current");
throw_instance_method_fatal("PairIterator::current");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
@@ -5172,33 +5172,33 @@ TypedValue* tg_13TupleIterator_current(HPHP::VM::ActRec *ar) {
}
/*
HPHP::Variant HPHP::c_TupleIterator::t_key()
_ZN4HPHP15c_TupleIterator5t_keyEv
HPHP::Variant HPHP::c_PairIterator::t_key()
_ZN4HPHP14c_PairIterator5t_keyEv
(return value) => rax
_rv => rdi
this_ => rsi
*/
TypedValue* th_13TupleIterator_key(TypedValue* _rv, ObjectData* this_) asm("_ZN4HPHP15c_TupleIterator5t_keyEv");
TypedValue* th_12PairIterator_key(TypedValue* _rv, ObjectData* this_) asm("_ZN4HPHP14c_PairIterator5t_keyEv");
TypedValue* tg_13TupleIterator_key(HPHP::VM::ActRec *ar) {
TypedValue* tg_12PairIterator_key(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) {
th_13TupleIterator_key((&(rv)), (this_));
th_12PairIterator_key((&(rv)), (this_));
if (rv.m_type == KindOfUninit) 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("TupleIterator::key", 0, 1);
throw_toomany_arguments_nr("PairIterator::key", 0, 1);
}
} else {
throw_instance_method_fatal("TupleIterator::key");
throw_instance_method_fatal("PairIterator::key");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
@@ -5209,16 +5209,16 @@ TypedValue* tg_13TupleIterator_key(HPHP::VM::ActRec *ar) {
}
/*
bool HPHP::c_TupleIterator::t_valid()
_ZN4HPHP15c_TupleIterator7t_validEv
bool HPHP::c_PairIterator::t_valid()
_ZN4HPHP14c_PairIterator7t_validEv
(return value) => rax
this_ => rdi
*/
bool th_13TupleIterator_valid(ObjectData* this_) asm("_ZN4HPHP15c_TupleIterator7t_validEv");
bool th_12PairIterator_valid(ObjectData* this_) asm("_ZN4HPHP14c_PairIterator7t_validEv");
TypedValue* tg_13TupleIterator_valid(HPHP::VM::ActRec *ar) {
TypedValue* tg_12PairIterator_valid(HPHP::VM::ActRec *ar) {
TypedValue rv;
int64_t count = ar->numArgs();
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
@@ -5226,15 +5226,15 @@ TypedValue* tg_13TupleIterator_valid(HPHP::VM::ActRec *ar) {
if (this_) {
if (count == 0LL) {
rv.m_type = KindOfBoolean;
rv.m_data.num = (th_13TupleIterator_valid((this_))) ? 1LL : 0LL;
rv.m_data.num = (th_12PairIterator_valid((this_))) ? 1LL : 0LL;
frame_free_locals_inl(ar, 0);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
} else {
throw_toomany_arguments_nr("TupleIterator::valid", 0, 1);
throw_toomany_arguments_nr("PairIterator::valid", 0, 1);
}
} else {
throw_instance_method_fatal("TupleIterator::valid");
throw_instance_method_fatal("PairIterator::valid");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
@@ -5245,15 +5245,15 @@ TypedValue* tg_13TupleIterator_valid(HPHP::VM::ActRec *ar) {
}
/*
void HPHP::c_TupleIterator::t_next()
_ZN4HPHP15c_TupleIterator6t_nextEv
void HPHP::c_PairIterator::t_next()
_ZN4HPHP14c_PairIterator6t_nextEv
this_ => rdi
*/
void th_13TupleIterator_next(ObjectData* this_) asm("_ZN4HPHP15c_TupleIterator6t_nextEv");
void th_12PairIterator_next(ObjectData* this_) asm("_ZN4HPHP14c_PairIterator6t_nextEv");
TypedValue* tg_13TupleIterator_next(HPHP::VM::ActRec *ar) {
TypedValue* tg_12PairIterator_next(HPHP::VM::ActRec *ar) {
TypedValue rv;
int64_t count = ar->numArgs();
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
@@ -5262,15 +5262,15 @@ TypedValue* tg_13TupleIterator_next(HPHP::VM::ActRec *ar) {
if (count == 0LL) {
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
th_13TupleIterator_next((this_));
th_12PairIterator_next((this_));
frame_free_locals_inl(ar, 0);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
} else {
throw_toomany_arguments_nr("TupleIterator::next", 0, 1);
throw_toomany_arguments_nr("PairIterator::next", 0, 1);
}
} else {
throw_instance_method_fatal("TupleIterator::next");
throw_instance_method_fatal("PairIterator::next");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
@@ -5281,15 +5281,15 @@ TypedValue* tg_13TupleIterator_next(HPHP::VM::ActRec *ar) {
}
/*
void HPHP::c_TupleIterator::t_rewind()
_ZN4HPHP15c_TupleIterator8t_rewindEv
void HPHP::c_PairIterator::t_rewind()
_ZN4HPHP14c_PairIterator8t_rewindEv
this_ => rdi
*/
void th_13TupleIterator_rewind(ObjectData* this_) asm("_ZN4HPHP15c_TupleIterator8t_rewindEv");
void th_12PairIterator_rewind(ObjectData* this_) asm("_ZN4HPHP14c_PairIterator8t_rewindEv");
TypedValue* tg_13TupleIterator_rewind(HPHP::VM::ActRec *ar) {
TypedValue* tg_12PairIterator_rewind(HPHP::VM::ActRec *ar) {
TypedValue rv;
int64_t count = ar->numArgs();
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
@@ -5298,15 +5298,15 @@ TypedValue* tg_13TupleIterator_rewind(HPHP::VM::ActRec *ar) {
if (count == 0LL) {
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
th_13TupleIterator_rewind((this_));
th_12PairIterator_rewind((this_));
frame_free_locals_inl(ar, 0);
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
return &ar->m_r;
} else {
throw_toomany_arguments_nr("TupleIterator::rewind", 0, 1);
throw_toomany_arguments_nr("PairIterator::rewind", 0, 1);
}
} else {
throw_instance_method_fatal("TupleIterator::rewind");
throw_instance_method_fatal("PairIterator::rewind");
}
rv.m_data.num = 0LL;
rv.m_type = KindOfNull;
+68 -82
Ver Arquivo
@@ -809,30 +809,25 @@ class c_StableMapIterator : public ExtObjectData {
};
///////////////////////////////////////////////////////////////////////////////
// class Tuple
// class Pair
FORWARD_DECLARE_CLASS_BUILTIN(Tuple);
class c_Tuple : public ExtObjectDataFlags<ObjectData::TupleAttrInit|
FORWARD_DECLARE_CLASS_BUILTIN(Pair);
class c_Pair : public ExtObjectDataFlags<ObjectData::PairAttrInit|
ObjectData::UseGet|
ObjectData::UseSet|
ObjectData::UseIsset|
ObjectData::UseUnset> {
public:
DECLARE_CLASS_NO_ALLOCATION(Tuple, Tuple, ObjectData)
virtual void sweep();
void operator delete(void* p) {
c_Tuple* this_ = (c_Tuple*)p;
DELETEOBJSZ(sizeForNumElms(this_->m_capacity))(this_);
}
DECLARE_CLASS(Pair, Pair, ObjectData)
friend class c_TupleIterator;
friend class c_PairIterator;
friend class c_Vector;
friend class c_Map;
friend class c_StableMap;
friend class ArrayIter;
public: c_Tuple(VM::Class* cls = c_Tuple::s_cls);
public: ~c_Tuple();
public: c_Pair(VM::Class* cls = c_Pair::s_cls);
public: ~c_Pair();
public: void t___construct();
public: bool t_isempty();
public: int64_t t_count();
@@ -852,33 +847,33 @@ class c_Tuple : public ExtObjectDataFlags<ObjectData::TupleAttrInit|
public: static void throwOOB(int64_t key) ATTRIBUTE_COLD;
public: TypedValue* at(int64_t key) {
if (UNLIKELY((uint64_t)key >= (uint64_t)m_size)) {
if (UNLIKELY(uint64_t(key) >= uint64_t(2))) {
throwOOB(key);
return NULL;
}
return &getData()[key];
return &getElms()[key];
}
public: TypedValue* get(int64_t key) {
if ((uint64_t)key >= (uint64_t)m_size) {
if (uint64_t(key) >= uint64_t(2)) {
return NULL;
}
return &getData()[key];
return &getElms()[key];
}
public: void add(TypedValue* val) {
assert(val->m_type != KindOfRef);
if (m_size == m_capacity) {
if (m_size == 2) {
Object e(SystemLib::AllocRuntimeExceptionObject(
"Cannot add a new element to a Tuple"));
"Cannot add a new element to a Pair"));
throw e;
}
tvRefcountedIncRef(val);
TypedValue* tv = &getData()[m_size];
TypedValue* tv = &getElms()[m_size];
tv->m_data.num = val->m_data.num;
tv->m_type = val->m_type;
++m_size;
}
public: bool contains(int64_t key) {
return ((uint64_t)key < (uint64_t)m_size);
return (uint64_t(key) < uint64_t(2));
}
public: Array toArrayImpl() const;
@@ -900,41 +895,32 @@ class c_Tuple : public ExtObjectDataFlags<ObjectData::TupleAttrInit|
int64_t sz,
char type);
public: static size_t sizeForNumElms(int nElms) {
return sizeof(c_Tuple) + sizeof(TypedValue) * nElms;
}
public: static c_Tuple* alloc(int nElms) {
c_Tuple* tup = (c_Tuple*)ALLOCOBJSZ(sizeForNumElms(nElms));
new ((void *)tup) c_Tuple();
tup->m_capacity = nElms;
return tup;
}
private:
static void throwBadKeyType();
uint m_size;
uint m_capacity;
TypedValue* getData() const {
return (TypedValue*)(this+1);
TypedValue elm0;
TypedValue elm1;
TypedValue* getElms() const {
return (TypedValue*)(&elm0);
}
friend ObjectData* collectionDeepCopyTuple(c_Tuple* tup);
friend ObjectData* collectionDeepCopyPair(c_Pair* pair);
} __attribute__((aligned(16)));
///////////////////////////////////////////////////////////////////////////////
// class TupleIterator
// class PairIterator
FORWARD_DECLARE_CLASS_BUILTIN(TupleIterator);
class c_TupleIterator : public ExtObjectData {
FORWARD_DECLARE_CLASS_BUILTIN(PairIterator);
class c_PairIterator : public ExtObjectData {
public:
DECLARE_CLASS(TupleIterator, TupleIterator, ObjectData)
friend class c_Tuple;
DECLARE_CLASS(PairIterator, PairIterator, ObjectData)
friend class c_Pair;
// need to implement
public: c_TupleIterator(VM::Class* cls = c_TupleIterator::s_cls);
public: ~c_TupleIterator();
public: c_PairIterator(VM::Class* cls = c_PairIterator::s_cls);
public: ~c_PairIterator();
public: void t___construct();
public: Variant t_current();
public: Variant t_key();
@@ -943,7 +929,7 @@ class c_TupleIterator : public ExtObjectData {
public: void t_rewind();
private:
SmartPtr<c_Tuple> m_obj;
SmartPtr<c_Pair> m_obj;
ssize_t m_pos;
};
@@ -962,8 +948,8 @@ inline TypedValue* collectionGet(ObjectData* obj, TypedValue* key) {
return c_Map::OffsetGet(obj, key);
case Collection::StableMapType:
return c_StableMap::OffsetGet(obj, key);
case Collection::TupleType:
return c_Tuple::OffsetGet(obj, key);
case Collection::PairType:
return c_Pair::OffsetGet(obj, key);
default:
assert(false);
return NULL;
@@ -984,8 +970,8 @@ inline void collectionSet(ObjectData* obj, TypedValue* key, TypedValue* val) {
case Collection::StableMapType:
c_StableMap::OffsetSet(obj, key, val);
break;
case Collection::TupleType:
c_Tuple::OffsetSet(obj, key, val);
case Collection::PairType:
c_Pair::OffsetSet(obj, key, val);
break;
default:
assert(false);
@@ -1001,8 +987,8 @@ inline bool collectionIsset(ObjectData* obj, TypedValue* key) {
return c_Map::OffsetIsset(obj, key);
case Collection::StableMapType:
return c_StableMap::OffsetIsset(obj, key);
case Collection::TupleType:
return c_Tuple::OffsetIsset(obj, key);
case Collection::PairType:
return c_Pair::OffsetIsset(obj, key);
default:
assert(false);
return false;
@@ -1018,8 +1004,8 @@ inline bool collectionEmpty(ObjectData* obj, TypedValue* key) {
return c_Map::OffsetEmpty(obj, key);
case Collection::StableMapType:
return c_StableMap::OffsetEmpty(obj, key);
case Collection::TupleType:
return c_Tuple::OffsetEmpty(obj, key);
case Collection::PairType:
return c_Pair::OffsetEmpty(obj, key);
default:
assert(false);
return false;
@@ -1038,8 +1024,8 @@ inline void collectionUnset(ObjectData* obj, TypedValue* key) {
case Collection::StableMapType:
c_StableMap::OffsetUnset(obj, key);
break;
case Collection::TupleType:
c_Tuple::OffsetUnset(obj, key);
case Collection::PairType:
c_Pair::OffsetUnset(obj, key);
break;
default:
assert(false);
@@ -1059,8 +1045,8 @@ inline void collectionAppend(ObjectData* obj, TypedValue* val) {
case Collection::StableMapType:
c_StableMap::OffsetAppend(obj, val);
break;
case Collection::TupleType:
c_Tuple::OffsetAppend(obj, val);
case Collection::PairType:
c_Pair::OffsetAppend(obj, val);
break;
default:
assert(false);
@@ -1081,9 +1067,9 @@ inline Variant& collectionOffsetGet(ObjectData* obj, int64_t offset) {
c_StableMap* smp = static_cast<c_StableMap*>(obj);
return tvAsVariant(smp->at(offset));
}
case Collection::TupleType: {
c_Tuple* tup = static_cast<c_Tuple*>(obj);
return tvAsVariant(tup->at(offset));
case Collection::PairType: {
c_Pair* pair = static_cast<c_Pair*>(obj);
return tvAsVariant(pair->at(offset));
}
default:
assert(false);
@@ -1107,9 +1093,9 @@ inline Variant& collectionOffsetGet(ObjectData* obj, CStrRef offset) {
c_StableMap* smp = static_cast<c_StableMap*>(obj);
return tvAsVariant(smp->at(key));
}
case Collection::TupleType: {
case Collection::PairType: {
Object e(SystemLib::AllocInvalidArgumentExceptionObject(
"Only integer keys may be used with Tuples"));
"Only integer keys may be used with Pairs"));
throw e;
}
default:
@@ -1127,8 +1113,8 @@ inline Variant& collectionOffsetGet(ObjectData* obj, CVarRef offset) {
return tvAsVariant(c_Map::OffsetGet(obj, key));
case Collection::StableMapType:
return tvAsVariant(c_StableMap::OffsetGet(obj, key));
case Collection::TupleType:
return tvAsVariant(c_Tuple::OffsetGet(obj, key));
case Collection::PairType:
return tvAsVariant(c_Pair::OffsetGet(obj, key));
default:
assert(false);
return tvAsVariant(NULL);
@@ -1168,9 +1154,9 @@ inline void collectionOffsetSet(ObjectData* obj, int64_t offset, CVarRef val) {
smp->set(offset, tv);
break;
}
case Collection::TupleType: {
case Collection::PairType: {
Object e(SystemLib::AllocRuntimeExceptionObject(
"Cannot assign to an element of a Tuple"));
"Cannot assign to an element of a Pair"));
throw e;
}
default:
@@ -1200,9 +1186,9 @@ inline void collectionOffsetSet(ObjectData* obj, CStrRef offset, CVarRef val) {
smp->set(key, tv);
break;
}
case Collection::TupleType: {
case Collection::PairType: {
Object e(SystemLib::AllocRuntimeExceptionObject(
"Cannot assign to an element of a Tuple"));
"Cannot assign to an element of a Pair"));
throw e;
}
default:
@@ -1229,8 +1215,8 @@ inline void collectionOffsetSet(ObjectData* obj, CVarRef offset, CVarRef val) {
c_StableMap::OffsetSet(obj, key, tv);
break;
}
case Collection::TupleType: {
c_Tuple::OffsetSet(obj, key, tv);
case Collection::PairType: {
c_Pair::OffsetSet(obj, key, tv);
break;
}
default:
@@ -1259,8 +1245,8 @@ inline bool collectionOffsetContains(ObjectData* obj, CVarRef offset) {
return c_Map::OffsetContains(obj, key);
case Collection::StableMapType:
return c_StableMap::OffsetContains(obj, key);
case Collection::TupleType:
return c_Tuple::OffsetContains(obj, key);
case Collection::PairType:
return c_Pair::OffsetContains(obj, key);
default:
assert(false);
return false;
@@ -1276,8 +1262,8 @@ inline bool collectionOffsetIsset(ObjectData* obj, CVarRef offset) {
return c_Map::OffsetIsset(obj, key);
case Collection::StableMapType:
return c_StableMap::OffsetIsset(obj, key);
case Collection::TupleType:
return c_Tuple::OffsetIsset(obj, key);
case Collection::PairType:
return c_Pair::OffsetIsset(obj, key);
default:
assert(false);
return false;
@@ -1293,8 +1279,8 @@ inline bool collectionOffsetEmpty(ObjectData* obj, CVarRef offset) {
return c_Map::OffsetEmpty(obj, key);
case Collection::StableMapType:
return c_StableMap::OffsetEmpty(obj, key);
case Collection::TupleType:
return c_Tuple::OffsetEmpty(obj, key);
case Collection::PairType:
return c_Pair::OffsetEmpty(obj, key);
default:
assert(false);
return true;
@@ -1319,8 +1305,8 @@ inline int64_t collectionSize(ObjectData* obj) {
return static_cast<c_Map*>(obj)->t_count();
case Collection::StableMapType:
return static_cast<c_StableMap*>(obj)->t_count();
case Collection::TupleType:
return static_cast<c_Tuple*>(obj)->t_count();
case Collection::PairType:
return static_cast<c_Pair*>(obj)->t_count();
default:
assert(false);
return 0;
@@ -1338,7 +1324,7 @@ inline void collectionReserve(ObjectData* obj, int64_t sz) {
case Collection::StableMapType:
static_cast<c_StableMap*>(obj)->reserve(sz);
break;
case Collection::TupleType:
case Collection::PairType:
// do nothing
break;
default:
@@ -1357,8 +1343,8 @@ inline void collectionUnserialize(ObjectData* obj,
case Collection::VectorType:
c_Vector::Unserialize(obj, uns, sz, type);
break;
case Collection::TupleType:
c_Tuple::Unserialize(obj, uns, sz, type);
case Collection::PairType:
c_Pair::Unserialize(obj, uns, sz, type);
break;
case Collection::MapType:
c_Map::Unserialize(obj, uns, sz, type);
@@ -1381,8 +1367,8 @@ inline bool collectionEquals(ObjectData* obj1, ObjectData* obj2) {
return c_Map::Equals(obj1, obj2);
case Collection::StableMapType:
return c_StableMap::Equals(obj1, obj2);
case Collection::TupleType:
return c_Tuple::Equals(obj1, obj2);
case Collection::PairType:
return c_Pair::Equals(obj1, obj2);
default:
assert(false);
return false;
@@ -1394,7 +1380,7 @@ ArrayData* collectionDeepCopyArray(ArrayData* arr);
ObjectData* collectionDeepCopyVector(c_Vector* vec);
ObjectData* collectionDeepCopyMap(c_Map* mp);
ObjectData* collectionDeepCopyStableMap(c_StableMap* smp);
ObjectData* collectionDeepCopyTuple(c_Tuple* tup);
ObjectData* collectionDeepCopyPair(c_Pair* pair);
class CollectionInit {
public:
+40 -40
Ver Arquivo
@@ -2401,24 +2401,24 @@ TypedValue* tg_17StableMapIterator_key(VM::ActRec *ar);
TypedValue* tg_17StableMapIterator_valid(VM::ActRec *ar);
TypedValue* tg_17StableMapIterator_next(VM::ActRec *ar);
TypedValue* tg_17StableMapIterator_rewind(VM::ActRec *ar);
VM::Instance* new_Tuple_Instance(VM::Class*);
TypedValue* tg_5Tuple___construct(VM::ActRec *ar);
TypedValue* tg_5Tuple_isEmpty(VM::ActRec *ar);
TypedValue* tg_5Tuple_count(VM::ActRec *ar);
TypedValue* tg_5Tuple_items(VM::ActRec *ar);
TypedValue* tg_5Tuple_keys(VM::ActRec *ar);
TypedValue* tg_5Tuple_toArray(VM::ActRec *ar);
TypedValue* tg_5Tuple_getIterator(VM::ActRec *ar);
TypedValue* tg_5Tuple_at(VM::ActRec *ar);
TypedValue* tg_5Tuple_get(VM::ActRec *ar);
TypedValue* tg_5Tuple_containsKey(VM::ActRec *ar);
VM::Instance* new_TupleIterator_Instance(VM::Class*);
TypedValue* tg_13TupleIterator___construct(VM::ActRec *ar);
TypedValue* tg_13TupleIterator_current(VM::ActRec *ar);
TypedValue* tg_13TupleIterator_key(VM::ActRec *ar);
TypedValue* tg_13TupleIterator_valid(VM::ActRec *ar);
TypedValue* tg_13TupleIterator_next(VM::ActRec *ar);
TypedValue* tg_13TupleIterator_rewind(VM::ActRec *ar);
VM::Instance* new_Pair_Instance(VM::Class*);
TypedValue* tg_4Pair___construct(VM::ActRec *ar);
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_toArray(VM::ActRec *ar);
TypedValue* tg_4Pair_getIterator(VM::ActRec *ar);
TypedValue* tg_4Pair_at(VM::ActRec *ar);
TypedValue* tg_4Pair_get(VM::ActRec *ar);
TypedValue* tg_4Pair_containsKey(VM::ActRec *ar);
VM::Instance* new_PairIterator_Instance(VM::Class*);
TypedValue* tg_12PairIterator___construct(VM::ActRec *ar);
TypedValue* tg_12PairIterator_current(VM::ActRec *ar);
TypedValue* tg_12PairIterator_key(VM::ActRec *ar);
TypedValue* tg_12PairIterator_valid(VM::ActRec *ar);
TypedValue* tg_12PairIterator_next(VM::ActRec *ar);
TypedValue* tg_12PairIterator_rewind(VM::ActRec *ar);
VM::Instance* new_Continuation_Instance(VM::Class*);
TypedValue* tg_12Continuation___construct(VM::ActRec *ar);
TypedValue* tg_12Continuation_update(VM::ActRec *ar);
@@ -5481,28 +5481,28 @@ static const HhbcExtMethodInfo hhbc_ext_methods_StableMapIterator[] = {
{ "rewind", tg_17StableMapIterator_rewind }
};
static const long long hhbc_ext_method_count_Tuple = 10;
static const HhbcExtMethodInfo hhbc_ext_methods_Tuple[] = {
{ "__construct", tg_5Tuple___construct },
{ "isEmpty", tg_5Tuple_isEmpty },
{ "count", tg_5Tuple_count },
{ "items", tg_5Tuple_items },
{ "keys", tg_5Tuple_keys },
{ "toArray", tg_5Tuple_toArray },
{ "getIterator", tg_5Tuple_getIterator },
{ "at", tg_5Tuple_at },
{ "get", tg_5Tuple_get },
{ "containsKey", tg_5Tuple_containsKey }
static const long long hhbc_ext_method_count_Pair = 10;
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 },
{ "toArray", tg_4Pair_toArray },
{ "getIterator", tg_4Pair_getIterator },
{ "at", tg_4Pair_at },
{ "get", tg_4Pair_get },
{ "containsKey", tg_4Pair_containsKey }
};
static const long long hhbc_ext_method_count_TupleIterator = 6;
static const HhbcExtMethodInfo hhbc_ext_methods_TupleIterator[] = {
{ "__construct", tg_13TupleIterator___construct },
{ "current", tg_13TupleIterator_current },
{ "key", tg_13TupleIterator_key },
{ "valid", tg_13TupleIterator_valid },
{ "next", tg_13TupleIterator_next },
{ "rewind", tg_13TupleIterator_rewind }
static const long long hhbc_ext_method_count_PairIterator = 6;
static const HhbcExtMethodInfo hhbc_ext_methods_PairIterator[] = {
{ "__construct", tg_12PairIterator___construct },
{ "current", tg_12PairIterator_current },
{ "key", tg_12PairIterator_key },
{ "valid", tg_12PairIterator_valid },
{ "next", tg_12PairIterator_next },
{ "rewind", tg_12PairIterator_rewind }
};
static const long long hhbc_ext_method_count_Continuation = 16;
@@ -6305,8 +6305,8 @@ const HhbcExtClassInfo hhbc_ext_classes[] = {
{ "MapIterator", new_MapIterator_Instance, sizeof(c_MapIterator), hhbc_ext_method_count_MapIterator, hhbc_ext_methods_MapIterator, &c_MapIterator::s_cls },
{ "StableMap", new_StableMap_Instance, sizeof(c_StableMap), hhbc_ext_method_count_StableMap, hhbc_ext_methods_StableMap, &c_StableMap::s_cls },
{ "StableMapIterator", new_StableMapIterator_Instance, sizeof(c_StableMapIterator), hhbc_ext_method_count_StableMapIterator, hhbc_ext_methods_StableMapIterator, &c_StableMapIterator::s_cls },
{ "Tuple", new_Tuple_Instance, sizeof(c_Tuple), hhbc_ext_method_count_Tuple, hhbc_ext_methods_Tuple, &c_Tuple::s_cls },
{ "TupleIterator", new_TupleIterator_Instance, sizeof(c_TupleIterator), hhbc_ext_method_count_TupleIterator, hhbc_ext_methods_TupleIterator, &c_TupleIterator::s_cls },
{ "Pair", new_Pair_Instance, sizeof(c_Pair), hhbc_ext_method_count_Pair, hhbc_ext_methods_Pair, &c_Pair::s_cls },
{ "PairIterator", new_PairIterator_Instance, sizeof(c_PairIterator), hhbc_ext_method_count_PairIterator, hhbc_ext_methods_PairIterator, &c_PairIterator::s_cls },
{ "Continuation", new_Continuation_Instance, sizeof(c_Continuation), hhbc_ext_method_count_Continuation, hhbc_ext_methods_Continuation, &c_Continuation::s_cls },
{ "DummyContinuation", new_DummyContinuation_Instance, sizeof(c_DummyContinuation), hhbc_ext_method_count_DummyContinuation, hhbc_ext_methods_DummyContinuation, &c_DummyContinuation::s_cls },
{ "DateTime", new_DateTime_Instance, sizeof(c_DateTime), hhbc_ext_method_count_DateTime, hhbc_ext_methods_DateTime, &c_DateTime::s_cls },
+1 -1
Ver Arquivo
@@ -3801,7 +3801,7 @@ inline void OPTBLD_INLINE VMExecutionContext::iopNewCol(PC& pc) {
case Collection::VectorType: obj = NEWOBJ(c_Vector)(); break;
case Collection::MapType: obj = NEWOBJ(c_Map)(); break;
case Collection::StableMapType: obj = NEWOBJ(c_StableMap)(); break;
case Collection::TupleType: obj = c_Tuple::alloc(nElms); break;
case Collection::PairType: obj = NEWOBJ(c_Pair)(); break;
default:
obj = nullptr;
raise_error("NewCol: Invalid collection type");
+8 -8
Ver Arquivo
@@ -75,7 +75,7 @@ ArrayData* new_array(int capacity) {
ArrayData* new_tuple(int n, const TypedValue* values) {
HphpArray* a = NEW(HphpArray)(n, values);
a->incRefCount();
TRACE(2, "newTupleHelper: size %d\n", n);
TRACE(2, "new_tuple: size %d\n", n);
return a;
}
@@ -95,10 +95,10 @@ NEW_COLLECTION_HELPER(Vector)
NEW_COLLECTION_HELPER(Map)
NEW_COLLECTION_HELPER(StableMap)
ObjectData* newTupleHelper(int nElms) {
ObjectData *obj = c_Tuple::alloc(nElms);
ObjectData* newPairHelper() {
ObjectData *obj = NEWOBJ(c_Pair)();
obj->incRefCount();
TRACE(2, "newTupleHelper: capacity %d\n", nElms);
TRACE(2, "newPairHelper: capacity 2\n");
return obj;
}
@@ -425,9 +425,9 @@ void collection_setm_ik1_v0(ObjectData* obj, int64_t key, TypedValue* value) {
smp->set(key, value);
break;
}
case Collection::TupleType: {
case Collection::PairType: {
Object e(SystemLib::AllocRuntimeExceptionObject(
"Cannot assign to an element of a Tuple"));
"Cannot assign to an element of a Pair"));
throw e;
}
default:
@@ -454,9 +454,9 @@ void collection_setm_sk1_v0(ObjectData* obj, StringData* key,
smp->set(key, value);
break;
}
case Collection::TupleType: {
case Collection::PairType: {
Object e(SystemLib::AllocRuntimeExceptionObject(
"Cannot assign to an element of a Tuple"));
"Cannot assign to an element of a Pair"));
throw e;
}
default:
+1 -1
Ver Arquivo
@@ -35,7 +35,7 @@ ArrayData* new_tuple(int numArgs, const TypedValue* args);
ObjectData* newVectorHelper(int nElms);
ObjectData* newMapHelper(int nElms);
ObjectData* newStableMapHelper(int nElms);
ObjectData* newTupleHelper(int nElms);
ObjectData* newPairHelper();
StringData* concat_is(int64_t v1, StringData* v2);
StringData* concat_si(StringData* v1, int64_t v2);
+12 -6
Ver Arquivo
@@ -5438,8 +5438,8 @@ void TranslatorX64::translateNewTuple(const Tracelet& t,
printf("%p", ret); // use ret
}
EMIT_CALL(a, new_tuple, IMM(arity), A(i.inputs[0]->location));
// newTupleHelper returns the up-to-date array pointer in rax.
// Therefore, we can bind rax to the result location and mark it as dirty.
// new_tuple() returns the up-to-date array pointer in rax. Therefore, we
// can bind rax to the result location and mark it as dirty.
m_regMap.bind(rax, i.inputs[arity-1]->location, KindOfArray, RegInfo::DIRTY);
}
@@ -5450,22 +5450,28 @@ TranslatorX64::translateNewCol(const Tracelet& t,
assert(i.outStack && !i.outLocal);
assert(i.outStack->outerType() == KindOfObject);
int cType = i.imm[0].u_IVA;
int nElems = i.imm[1].u_IVA;
int nElms = i.imm[1].u_IVA;
void* fptr = nullptr;
switch (cType) {
case Collection::VectorType: fptr = (void*)newVectorHelper; break;
case Collection::MapType: fptr = (void*)newMapHelper; break;
case Collection::StableMapType: fptr = (void*)newStableMapHelper; break;
case Collection::TupleType: fptr = (void*)newTupleHelper; break;
case Collection::PairType: fptr = (void*)newPairHelper; break;
default: assert(false); break;
}
if (false) {
ObjectData* obj1 UNUSED = newVectorHelper(42);
ObjectData* obj2 UNUSED = newMapHelper(42);
ObjectData* obj3 UNUSED = newStableMapHelper(42);
ObjectData* obj4 UNUSED = newTupleHelper(42);
ObjectData* obj4 UNUSED = newPairHelper();
}
if (cType == Collection::PairType) {
// newPairHelper does not take any arguments, since Pairs always
// have exactly two elements
EMIT_CALL(a, fptr);
} else {
EMIT_CALL(a, fptr, IMM(nElms));
}
EMIT_CALL(a, fptr, IMM(nElems));
m_regMap.bind(rax, i.outStack->location, KindOfObject, RegInfo::DIRTY);
}
+28 -28
Ver Arquivo
@@ -22645,7 +22645,7 @@ const char *g_class_map[] = {
NULL,
NULL,
(const char *)0x10006040, "items", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/map.items.php )\n *\n * Returns an Iterable that produces the key/value pairs as Tuples from\n * this Map.\n *\n * @return object\n */",
"/**\n * ( excerpt from http://php.net/manual/en/map.items.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,
@@ -22722,13 +22722,13 @@ const char *g_class_map[] = {
NULL,
NULL,
(const char *)0x10006040, "add", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/map.add.php )\n *\n * Adds the specified key/value Tuple to this Map. If an element with the\n * same key is already present, an exception is thrown.\n *\n * @val mixed\n *\n * @return object\n */",
"/**\n * ( excerpt from http://php.net/manual/en/map.add.php )\n *\n * Adds the specified key/value Pair to this Map. If an element with the\n * same key is already present, an exception is thrown.\n *\n * @val mixed\n *\n * @return object\n */",
(const char *)0x40, (const char *)0x2000, "val", "", (const char *)0xffffffff, "", "", NULL,
NULL,
NULL,
NULL,
(const char *)0x10006040, "addAll", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/map.addall.php )\n *\n * Adds the key/value Tuples produced by the specified Iterable to this\n * Map.\n *\n * @iterable mixed\n *\n * @return object\n */",
"/**\n * ( excerpt from http://php.net/manual/en/map.addall.php )\n *\n * Adds the key/value Pairs produced by the specified Iterable to this\n * Map.\n *\n * @iterable mixed\n *\n * @return object\n */",
(const char *)0x40, (const char *)0x2000, "iterable", "", (const char *)0xffffffff, "", "", NULL,
NULL,
NULL,
@@ -22812,7 +22812,7 @@ const char *g_class_map[] = {
NULL,
NULL,
(const char *)0x10006240, "fromItems", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/map.fromitems.php )\n *\n * Returns a Map built from the key/value Tuples produced by the specified\n * Iterable.\n *\n * @iterable mixed\n *\n * @return object\n */",
"/**\n * ( excerpt from http://php.net/manual/en/map.fromitems.php )\n *\n * Returns a Map built from the key/value Pairs produced by the specified\n * Iterable.\n *\n * @iterable mixed\n *\n * @return object\n */",
(const char *)0x40, (const char *)0x2000, "iterable", "", (const char *)0xffffffff, "", "", NULL,
NULL,
NULL,
@@ -22890,7 +22890,7 @@ const char *g_class_map[] = {
NULL,
NULL,
(const char *)0x10006040, "items", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/stablemap.items.php )\n *\n * Returns an Iterable that produces the key/value pairs as Tuples from\n * this StableMap.\n *\n * @return object\n */",
"/**\n * ( excerpt from http://php.net/manual/en/stablemap.items.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,
@@ -22967,13 +22967,13 @@ const char *g_class_map[] = {
NULL,
NULL,
(const char *)0x10006040, "add", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/stablemap.add.php )\n *\n * Adds the specified key/value Tuple to this StableMap. If an element\n * with the same key is already present, an exception is thrown.\n *\n * @val mixed\n *\n * @return object\n */",
"/**\n * ( excerpt from http://php.net/manual/en/stablemap.add.php )\n *\n * Adds the specified key/value Pair to this StableMap. If an element with\n * the same key is already present, an exception is thrown.\n *\n * @val mixed\n *\n * @return object\n */",
(const char *)0x40, (const char *)0x2000, "val", "", (const char *)0xffffffff, "", "", NULL,
NULL,
NULL,
NULL,
(const char *)0x10006040, "addAll", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/stablemap.addall.php )\n *\n * Adds the key/value Tuples produced by the specified Iterable to the end\n * of this StableMap.\n *\n * @iterable mixed\n *\n * @return object\n */",
"/**\n * ( excerpt from http://php.net/manual/en/stablemap.addall.php )\n *\n * Adds the key/value Pairs produced by the specified Iterable to the end\n * of this StableMap.\n *\n * @iterable mixed\n *\n * @return object\n */",
(const char *)0x40, (const char *)0x2000, "iterable", "", (const char *)0xffffffff, "", "", NULL,
NULL,
NULL,
@@ -23052,7 +23052,7 @@ const char *g_class_map[] = {
NULL,
NULL,
(const char *)0x10006240, "fromItems", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/stablemap.fromitems.php )\n *\n * Returns a StableMap built from the key/value Tuples produced by the\n * specified Iterable.\n *\n * @iterable mixed\n *\n * @return object\n */",
"/**\n * ( excerpt from http://php.net/manual/en/stablemap.fromitems.php )\n *\n * Returns a StableMap built from the key/value Pairs produced by the\n * specified Iterable.\n *\n * @iterable mixed\n *\n * @return object\n */",
(const char *)0x40, (const char *)0x2000, "iterable", "", (const char *)0xffffffff, "", "", NULL,
NULL,
NULL,
@@ -23115,58 +23115,58 @@ const char *g_class_map[] = {
NULL,
NULL,
NULL,
(const char *)0x10006020, "Tuple", "", "", (const char *)0, (const char *)0,
"/**\n * ( excerpt from http://php.net/manual/en/class.tuple.php )\n *\n * An ordered fixed-sized container.\n *\n */",
(const char *)0x10006020, "Pair", "", "", (const char *)0, (const char *)0,
"/**\n * ( excerpt from http://php.net/manual/en/class.pair.php )\n *\n * An ordered fixed-sized container.\n *\n */",
"constvector", NULL,
(const char *)0x10006040, "__construct", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/tuple.construct.php )\n *\n *\n */",
"/**\n * ( excerpt from http://php.net/manual/en/pair.construct.php )\n *\n *\n */",
(const char *)-1, NULL,
NULL,
NULL,
(const char *)0x10006040, "isEmpty", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/tuple.isempty.php )\n *\n * Returns true if this Tuple is empty, false otherwise.\n *\n * @return bool\n */",
"/**\n * ( excerpt from http://php.net/manual/en/pair.isempty.php )\n *\n * Returns true if this Pair is empty, false otherwise.\n *\n * @return bool\n */",
(const char *)0x9, NULL,
NULL,
NULL,
(const char *)0x10006040, "count", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/tuple.count.php )\n *\n * Returns the number of values in the Tuple.\n *\n * @return int\n */",
"/**\n * ( excerpt from http://php.net/manual/en/pair.count.php )\n *\n * Returns the number of values in the Pair.\n *\n * @return int\n */",
(const char *)0xa, NULL,
NULL,
NULL,
(const char *)0x10006040, "items", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/tuple.items.php )\n *\n * Returns an Iterable that produces the values from this Tuple.\n *\n * @return object\n */",
"/**\n * ( excerpt from http://php.net/manual/en/pair.items.php )\n *\n * Returns an Iterable that produces the values from this Pair.\n *\n * @return object\n */",
(const char *)0x40, NULL,
NULL,
NULL,
(const char *)0x10006040, "keys", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/tuple.keys.php )\n *\n * Returns an Iterable that produces the keys from this Tuple.\n *\n * @return object\n */",
"/**\n * ( excerpt from http://php.net/manual/en/pair.keys.php )\n *\n * Returns an Iterable that produces the keys 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/tuple.toarray.php )\n *\n * Returns an array built from the values from this Tuple.\n *\n * @return map\n */",
"/**\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,
NULL,
NULL,
(const char *)0x10006040, "getIterator", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/tuple.getiterator.php )\n *\n * Returns an iterator that points to beginning of this Tuple.\n *\n * @return object\n */",
"/**\n * ( excerpt from http://php.net/manual/en/pair.getiterator.php )\n *\n * Returns an iterator that points to beginning of this Pair.\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/tuple.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 */",
"/**\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,
NULL,
NULL,
NULL,
(const char *)0x10006040, "get", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/tuple.get.php )\n *\n * Returns the value at the specified key. If the key is not present, null\n * is returned.\n *\n * @key mixed\n *\n * @return mixed\n */",
"/**\n * ( excerpt from http://php.net/manual/en/pair.get.php )\n *\n * Returns the value at the specified key. If the key is not present, null\n * is returned.\n *\n * @key mixed\n *\n * @return mixed\n */",
(const char *)0xffffffff, (const char *)0x2000, "key", "", (const char *)0xffffffff, "", "", NULL,
NULL,
NULL,
NULL,
(const char *)0x10006040, "containsKey", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/tuple.containskey.php )\n *\n * Returns true if the specified key is present in the Tuple, returns\n * false otherwise.\n *\n * @key mixed\n *\n * @return bool\n */",
"/**\n * ( excerpt from http://php.net/manual/en/pair.containskey.php )\n *\n * Returns true if the specified key is present in the Pair, returns false\n * otherwise.\n *\n * @key mixed\n *\n * @return bool\n */",
(const char *)0x9, (const char *)0x2000, "key", "", (const char *)0xffffffff, "", "", NULL,
NULL,
NULL,
@@ -23175,36 +23175,36 @@ const char *g_class_map[] = {
NULL,
NULL,
NULL,
(const char *)0x10006020, "TupleIterator", "", "", (const char *)0, (const char *)0,
"/**\n * ( excerpt from http://php.net/manual/en/class.tupleiterator.php )\n *\n * An iterator implementation for iterating over a Tuple.\n *\n */",
(const char *)0x10006020, "PairIterator", "", "", (const char *)0, (const char *)0,
"/**\n * ( excerpt from http://php.net/manual/en/class.pairiterator.php )\n *\n * An iterator implementation for iterating over a Pair.\n *\n */",
"keyediterator", NULL,
(const char *)0x10006040, "__construct", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/tupleiterator.construct.php )\n *\n *\n */",
"/**\n * ( excerpt from http://php.net/manual/en/pairiterator.construct.php )\n *\n *\n */",
(const char *)-1, NULL,
NULL,
NULL,
(const char *)0x10006040, "current", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/tupleiterator.current.php )\n *\n * Returns the current value that the iterator points to.\n *\n * @return mixed\n */",
"/**\n * ( excerpt from http://php.net/manual/en/pairiterator.current.php )\n *\n * Returns the current value that the iterator points to.\n *\n * @return mixed\n */",
(const char *)0xffffffff, NULL,
NULL,
NULL,
(const char *)0x10006040, "key", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/tupleiterator.key.php )\n *\n * Returns the current key that the iterator points to.\n *\n * @return mixed\n */",
"/**\n * ( excerpt from http://php.net/manual/en/pairiterator.key.php )\n *\n * Returns the current key that the iterator points to.\n *\n * @return mixed\n */",
(const char *)0xffffffff, NULL,
NULL,
NULL,
(const char *)0x10006040, "valid", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/tupleiterator.valid.php )\n *\n * Returns true if the iterator points to a valid value, returns false\n * otherwise.\n *\n * @return bool\n */",
"/**\n * ( excerpt from http://php.net/manual/en/pairiterator.valid.php )\n *\n * Returns true if the iterator points to a valid value, returns false\n * otherwise.\n *\n * @return bool\n */",
(const char *)0x9, NULL,
NULL,
NULL,
(const char *)0x10006040, "next", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/tupleiterator.next.php )\n *\n * Advance this iterator forward one position.\n *\n */",
"/**\n * ( excerpt from http://php.net/manual/en/pairiterator.next.php )\n *\n * Advance this iterator forward one position.\n *\n */",
(const char *)-1, NULL,
NULL,
NULL,
(const char *)0x10006040, "rewind", "", (const char*)0, (const char*)0,
"/**\n * ( excerpt from http://php.net/manual/en/tupleiterator.rewind.php )\n *\n * Move this iterator back to the first position.\n *\n */",
"/**\n * ( excerpt from http://php.net/manual/en/pairiterator.rewind.php )\n *\n * Move this iterator back to the first position.\n *\n */",
(const char *)-1, NULL,
NULL,
NULL,
+1 -1
Ver Arquivo
@@ -52,7 +52,7 @@ class MapItemsIterator implements Iterator {
"Call to undefined method MapItemsIterator::keys()");
}
public function current() {
return Tuple {$this->it->key(), $this->it->current()};
return Pair {$this->it->key(), $this->it->current()};
}
}
Diff do arquivo suprimido porque uma ou mais linhas são muito longas
+27 -57
Ver Arquivo
@@ -9786,34 +9786,25 @@ bool TestCodeRun::TestCollectionClasses() {
);
MVCRO("<?hh\n"
"function g((string,int,string) $t) {}\n"
"class C {\n"
" public $t = Tuple {'foo', 42, '!'};\n"
" public $t = Pair {'foo', 42};\n"
"}\n"
"function f() {\n"
" $t = Tuple {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,\n"
" 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,\n"
" 23, 24, 25, 26, 27, 28, 29, 30, 31, 32};\n"
" var_dump(count($t));\n"
" var_dump($t->count());\n"
" var_dump($t->isEmpty());\n"
" echo \"==========\\n\";\n"
" $c = new C;\n"
" $t = $c->t;\n"
" var_dump(count($t));\n"
" var_dump($t->count());\n"
" var_dump($t->isEmpty());\n"
" g($t);\n"
" echo \"==========\\n\";\n"
" foreach ($t as $k => $v) {\n"
" var_dump($k, $v);\n"
" }\n"
" echo \"==========\\n\";\n"
" var_dump($t[0], $t[1], $t[2]);\n"
" var_dump($t[0], $t[1]);\n"
" echo \"==========\\n\";\n"
" var_dump($t->at(0), $t->at(1), $t->at(2));\n"
" var_dump($t->at(0), $t->at(1));\n"
" echo \"==========\\n\";\n"
" var_dump($t->get(0), $t->get(1), $t->get(2), $t->get(3));\n"
" var_dump($t->get(0), $t->get(1), $t->get(2));\n"
" echo \"==========\\n\";\n"
" var_dump((array)$t);\n"
" echo \"==========\\n\";\n"
@@ -9835,54 +9826,41 @@ bool TestCodeRun::TestCollectionClasses() {
"}\n"
"f();\n"
,
"int(32)\n"
"int(32)\n"
"bool(false)\n"
"==========\n"
"int(3)\n"
"int(3)\n"
"int(2)\n"
"int(2)\n"
"bool(false)\n"
"==========\n"
"int(0)\n"
"string(3) \"foo\"\n"
"int(1)\n"
"int(42)\n"
"int(2)\n"
"string(1) \"!\"\n"
"==========\n"
"string(3) \"foo\"\n"
"int(42)\n"
"string(1) \"!\"\n"
"==========\n"
"string(3) \"foo\"\n"
"int(42)\n"
"string(1) \"!\"\n"
"==========\n"
"string(3) \"foo\"\n"
"int(42)\n"
"string(1) \"!\"\n"
"NULL\n"
"==========\n"
"array(3) {\n"
"array(2) {\n"
" [0]=>\n"
" string(3) \"foo\"\n"
" [1]=>\n"
" int(42)\n"
" [2]=>\n"
" string(1) \"!\"\n"
"}\n"
"==========\n"
"string(39) \"V:5:\"Tuple\":3:{s:3:\"foo\";i:42;s:1:\"!\";}\"\n"
"object(Tuple)#6 (3) {\n"
"string(30) \"V:4:\"Pair\":2:{s:3:\"foo\";i:42;}\"\n"
"object(Pair)#5 (2) {\n"
" [0]=>\n"
" string(3) \"foo\"\n"
" [1]=>\n"
" int(42)\n"
" [2]=>\n"
" string(1) \"!\"\n"
"}\n"
"==========\n"
"int(3)\n"
"int(2)\n"
"==========\n"
"bool(true)\n"
"bool(true)\n"
@@ -9890,33 +9868,25 @@ bool TestCodeRun::TestCollectionClasses() {
"string(3) \"foo\"\n"
"int(1)\n"
"int(42)\n"
"int(2)\n"
"string(1) \"!\"\n"
"==========\n"
"array(3) {\n"
"array(2) {\n"
" [0]=>\n"
" string(3) \"foo\"\n"
" [1]=>\n"
" int(42)\n"
" [2]=>\n"
" string(1) \"!\"\n"
"}\n"
"array(3) {\n"
"array(2) {\n"
" [0]=>\n"
" string(3) \"foo\"\n"
" [1]=>\n"
" int(42)\n"
" [2]=>\n"
" string(1) \"!\"\n"
"}\n"
"==========\n"
"object(Tuple)#6 (3) {\n"
"object(Pair)#5 (2) {\n"
" [0]=>\n"
" string(3) \"foo\"\n"
" [1]=>\n"
" int(42)\n"
" [2]=>\n"
" string(1) \"!\"\n"
"}\n"
);
}
@@ -9964,7 +9934,7 @@ bool TestCodeRun::TestCollectionClasses() {
"$mp2 = StableMap::fromItems($mp1->items());\n"
"var_dump($mp2);\n"
"echo \"==========\\n\";\n"
"$tuples = Vector {Tuple {'a', 1}, Tuple {2, 'b'}, Tuple {'z', 9}};\n"
"$tuples = Vector {Pair {'a', 1}, Pair {2, 'b'}, Pair {'z', 9}};\n"
"$mp3 = StableMap::fromItems($tuples);\n"
"var_dump($mp3);\n"
,
@@ -9979,21 +9949,21 @@ bool TestCodeRun::TestCollectionClasses() {
"int(9)\n"
"object(Vector)#10 (3) {\n"
" [0]=>\n"
" object(Tuple)#15 (2) {\n"
" object(Pair)#15 (2) {\n"
" [0]=>\n"
" string(1) \"a\"\n"
" [1]=>\n"
" int(1)\n"
" }\n"
" [1]=>\n"
" object(Tuple)#16 (2) {\n"
" object(Pair)#16 (2) {\n"
" [0]=>\n"
" int(2)\n"
" [1]=>\n"
" string(1) \"b\"\n"
" }\n"
" [2]=>\n"
" object(Tuple)#17 (2) {\n"
" object(Pair)#17 (2) {\n"
" [0]=>\n"
" string(1) \"z\"\n"
" [1]=>\n"
@@ -10003,21 +9973,21 @@ bool TestCodeRun::TestCollectionClasses() {
"==========\n"
"object(Vector)#21 (3) {\n"
" [0]=>\n"
" object(Tuple)#22 (2) {\n"
" object(Pair)#22 (2) {\n"
" [0]=>\n"
" string(1) \"a\"\n"
" [1]=>\n"
" int(1)\n"
" }\n"
" [1]=>\n"
" object(Tuple)#23 (2) {\n"
" object(Pair)#23 (2) {\n"
" [0]=>\n"
" int(2)\n"
" [1]=>\n"
" string(1) \"b\"\n"
" }\n"
" [2]=>\n"
" object(Tuple)#24 (2) {\n"
" object(Pair)#24 (2) {\n"
" [0]=>\n"
" string(1) \"z\"\n"
" [1]=>\n"
@@ -10060,10 +10030,10 @@ bool TestCodeRun::TestCollectionClasses() {
" var_dump($smp->containsKey(2));\n"
" var_dump($smp->containsKey('b'));\n"
" echo \"==========\\n\";\n"
" $tup = Tuple {1, 'b'};\n"
" var_dump($tup->containsKey(0));\n"
" var_dump($tup->containsKey(1));\n"
" var_dump($tup->containsKey(2));\n"
" $pair = Pair {1, 'b'};\n"
" var_dump($pair->containsKey(0));\n"
" var_dump($pair->containsKey(1));\n"
" var_dump($pair->containsKey(2));\n"
"}\n"
"f();\n"
,
@@ -10138,7 +10108,7 @@ bool TestCodeRun::TestCollectionClasses() {
" $a['a']->prop = 33;\n"
" var_dump($a['b']->prop);\n"
" $obj = new stdClass();\n"
" $a = Tuple {$obj, $obj};\n"
" $a = Pair {$obj, $obj};\n"
" $a = unserialize(serialize($a));\n"
" $a[0]->prop = 44;\n"
" var_dump($a[1]->prop);\n"
@@ -26273,13 +26243,13 @@ bool TestCodeRun::TestHint() {
"}\n"
"function f3() {\n"
" $a = StableMap {'a' => 11, 'b' => 22};\n"
" $b = Vector {Tuple {'e', 33}, Tuple {'f', 44}};\n"
" $b = Vector {Pair {'e', 33}, Pair {'f', 44}};\n"
" $a->addAll($b);\n"
" var_dump($a);\n"
"}\n"
"function f4() {\n"
" $a = StableMap {'a' => 11, 'b' => 22};\n"
" $b = StableMap {'c' => Tuple {'e', 33}, 'd' => Tuple {'f', 44}};\n"
" $b = StableMap {'c' => Pair {'e', 33}, 'd' => Pair {'f', 44}};\n"
" $a->addAll($b);\n"
" var_dump($a);\n"
"}\n"
+2 -1
Ver Arquivo
@@ -2317,7 +2317,8 @@ sm_type:
| '(' T_FUNCTION
'(' sm_func_type_list ')'
':' sm_type ')' { only_in_strict_mode(_p); $$.reset(); }
| '(' sm_type_list ',' sm_type ')' { only_in_strict_mode(_p); $$.reset(); }
| '(' sm_type_list ',' sm_type ')' { only_in_strict_mode(_p);
$$.setText("array"); }
;
sm_type_opt:
+7 -6
Ver Arquivo
@@ -1595,7 +1595,7 @@ static const yytype_uint16 yyrline[] =
2220, 2221, 2222, 2223, 2224, 2225, 2226, 2230, 2231, 2235,
2244, 2245, 2251, 2252, 2260, 2263, 2267, 2268, 2272, 2273,
2274, 2275, 2279, 2280, 2284, 2285, 2286, 2288, 2296, 2297,
2298, 2309, 2310, 2313, 2316, 2317, 2320, 2324, 2325
2298, 2309, 2310, 2313, 2316, 2317, 2320, 2325, 2326
};
#endif
@@ -10111,27 +10111,28 @@ yyreduce:
/* Line 1455 of yacc.c */
#line 2320 "../../../../hphp/util/parser/hphp.y"
{ only_in_strict_mode(_p); (yyval).reset(); ;}
{ only_in_strict_mode(_p);
(yyval).setText("array"); ;}
break;
case 677:
/* Line 1455 of yacc.c */
#line 2324 "../../../../hphp/util/parser/hphp.y"
#line 2325 "../../../../hphp/util/parser/hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]); ;}
break;
case 678:
/* Line 1455 of yacc.c */
#line 2325 "../../../../hphp/util/parser/hphp.y"
#line 2326 "../../../../hphp/util/parser/hphp.y"
{ (yyval).reset(); ;}
break;
/* Line 1455 of yacc.c */
#line 10138 "hphp.tab.cpp"
#line 10139 "hphp.tab.cpp"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -10351,7 +10352,7 @@ yyreturn:
/* Line 1675 of yacc.c */
#line 2328 "../../../../hphp/util/parser/hphp.y"
#line 2329 "../../../../hphp/util/parser/hphp.y"
bool Parser::parseImpl() {
return yyparse(this) == 0;