2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010- Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #include "hphp/runtime/base/list_assignment.h"
18 #include "hphp/runtime/base/complex_types.h"
21 ///////////////////////////////////////////////////////////////////////////////
22 // ListAssignmentElement
24 ListAssignmentElement::ListAssignmentElement(Variant
&var
, int index
, ...)
29 m_indices
.push_back(index
);
30 index
= va_arg(ap
, int);
35 void ListAssignmentElement::assign(CArrRef data
) {
36 assert(!m_indices
.empty());
38 unsigned int size
= m_indices
.size();
39 for (unsigned int i
= 0; i
< size
; i
++) {
40 tmp
= tmp
.rvalAt(m_indices
[i
]);
45 ///////////////////////////////////////////////////////////////////////////////
48 Variant
list_assign(CVarRef data
, ListAssignmentElement
*elem
, ...) {
49 Array adata
= data
.toArray();
50 vector
<ListAssignmentElement
*> elems
;
55 elems
.push_back(elem
);
56 elem
= va_arg(ap
, ListAssignmentElement
*);
60 for (int i
= elems
.size() - 1; i
>= 0; i
--) {
61 elems
[i
]->assign(adata
);
67 ///////////////////////////////////////////////////////////////////////////////