2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010- Facebook, Inc. (http://www.facebook.com) |
6 | Copyright (c) 1997-2010 The PHP Group |
7 +----------------------------------------------------------------------+
8 | This source file is subject to version 3.01 of the PHP license, |
9 | that is bundled with this package in the file LICENSE, and is |
10 | available through the world-wide-web at the following url: |
11 | http://www.php.net/license/3_01.txt |
12 | If you did not receive a copy of the PHP license and are unable to |
13 | obtain it through the world-wide-web, please send a note to |
14 | license@php.net so we can mail you a copy immediately. |
15 +----------------------------------------------------------------------+
18 #include "runtime/ext_hhvm/ext_hhvm.h"
19 #include "runtime/base/builtin_functions.h"
20 #include "runtime/base/array/array_init.h"
21 #include "runtime/ext/ext.h"
22 #include "runtime/vm/class.h"
23 #include "runtime/vm/runtime.h"
28 Value
* fh_gettype(Value
* _rv
, TypedValue
* v
) asm("_ZN4HPHP9f_gettypeERKNS_7VariantE");
30 TypedValue
* fg_gettype(ActRec
* ar
) {
32 TypedValue
* rv
= &rvSpace
;
33 int32_t count
= ar
->numArgs();
34 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
36 rv
->m_type
= KindOfString
;
37 fh_gettype(&(rv
->m_data
), (args
-0));
38 if (rv
->m_data
.num
== 0LL) rv
->m_type
= KindOfNull
;
40 throw_wrong_arguments_nr("gettype", count
, 1, 1, 1);
42 rv
->m_type
= KindOfNull
;
44 frame_free_locals_no_this_inl(ar
, 1);
45 memcpy(&ar
->m_r
, rv
, sizeof(TypedValue
));
49 Value
* fh_get_resource_type(Value
* _rv
, Value
* handle
) asm("_ZN4HPHP19f_get_resource_typeERKNS_6ObjectE");
51 void fg1_get_resource_type(TypedValue
* rv
, ActRec
* ar
, int32_t count
) __attribute__((noinline
,cold
));
52 void fg1_get_resource_type(TypedValue
* rv
, ActRec
* ar
, int32_t count
) {
53 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
54 tvCastToObjectInPlace(args
-0);
55 rv
->m_type
= KindOfString
;
56 fh_get_resource_type(&(rv
->m_data
), &args
[-0].m_data
);
57 if (rv
->m_data
.num
== 0LL) rv
->m_type
= KindOfNull
;
60 TypedValue
* fg_get_resource_type(ActRec
* ar
) {
62 TypedValue
* rv
= &rvSpace
;
63 int32_t count
= ar
->numArgs();
64 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
66 if ((args
- 0)->m_type
== KindOfObject
) {
67 rv
->m_type
= KindOfString
;
68 fh_get_resource_type(&(rv
->m_data
), &args
[-0].m_data
);
69 if (rv
->m_data
.num
== 0LL) rv
->m_type
= KindOfNull
;
71 fg1_get_resource_type(rv
, ar
, count
);
74 throw_wrong_arguments_nr("get_resource_type", count
, 1, 1, 1);
76 rv
->m_type
= KindOfNull
;
78 frame_free_locals_no_this_inl(ar
, 1);
79 memcpy(&ar
->m_r
, rv
, sizeof(TypedValue
));
83 long fh_intval(TypedValue
* v
, long base
) asm("_ZN4HPHP8f_intvalERKNS_7VariantEl");
85 void fg1_intval(TypedValue
* rv
, ActRec
* ar
, int32_t count
) __attribute__((noinline
,cold
));
86 void fg1_intval(TypedValue
* rv
, ActRec
* ar
, int32_t count
) {
87 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
88 tvCastToInt64InPlace(args
-1);
89 rv
->m_type
= KindOfInt64
;
90 rv
->m_data
.num
= (int64_t)fh_intval((args
-0), (count
> 1) ? (long)(args
[-1].m_data
.num
) : (long)(10));
93 TypedValue
* fg_intval(ActRec
* ar
) {
95 TypedValue
* rv
= &rvSpace
;
96 int32_t count
= ar
->numArgs();
97 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
98 if (count
>= 1 && count
<= 2) {
99 if ((count
<= 1 || (args
- 1)->m_type
== KindOfInt64
)) {
100 rv
->m_type
= KindOfInt64
;
101 rv
->m_data
.num
= (int64_t)fh_intval((args
-0), (count
> 1) ? (long)(args
[-1].m_data
.num
) : (long)(10));
103 fg1_intval(rv
, ar
, count
);
106 throw_wrong_arguments_nr("intval", count
, 1, 2, 1);
107 rv
->m_data
.num
= 0LL;
108 rv
->m_type
= KindOfNull
;
110 frame_free_locals_no_this_inl(ar
, 2);
111 memcpy(&ar
->m_r
, rv
, sizeof(TypedValue
));
115 double fh_doubleval(TypedValue
* v
) asm("_ZN4HPHP11f_doublevalERKNS_7VariantE");
117 TypedValue
* fg_doubleval(ActRec
* ar
) {
119 TypedValue
* rv
= &rvSpace
;
120 int32_t count
= ar
->numArgs();
121 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
123 rv
->m_type
= KindOfDouble
;
124 rv
->m_data
.dbl
= fh_doubleval((args
-0));
126 throw_wrong_arguments_nr("doubleval", count
, 1, 1, 1);
127 rv
->m_data
.num
= 0LL;
128 rv
->m_type
= KindOfNull
;
130 frame_free_locals_no_this_inl(ar
, 1);
131 memcpy(&ar
->m_r
, rv
, sizeof(TypedValue
));
135 double fh_floatval(TypedValue
* v
) asm("_ZN4HPHP10f_floatvalERKNS_7VariantE");
137 TypedValue
* fg_floatval(ActRec
* ar
) {
139 TypedValue
* rv
= &rvSpace
;
140 int32_t count
= ar
->numArgs();
141 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
143 rv
->m_type
= KindOfDouble
;
144 rv
->m_data
.dbl
= fh_floatval((args
-0));
146 throw_wrong_arguments_nr("floatval", count
, 1, 1, 1);
147 rv
->m_data
.num
= 0LL;
148 rv
->m_type
= KindOfNull
;
150 frame_free_locals_no_this_inl(ar
, 1);
151 memcpy(&ar
->m_r
, rv
, sizeof(TypedValue
));
155 Value
* fh_strval(Value
* _rv
, TypedValue
* v
) asm("_ZN4HPHP8f_strvalERKNS_7VariantE");
157 TypedValue
* fg_strval(ActRec
* ar
) {
159 TypedValue
* rv
= &rvSpace
;
160 int32_t count
= ar
->numArgs();
161 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
163 rv
->m_type
= KindOfString
;
164 fh_strval(&(rv
->m_data
), (args
-0));
165 if (rv
->m_data
.num
== 0LL) rv
->m_type
= KindOfNull
;
167 throw_wrong_arguments_nr("strval", count
, 1, 1, 1);
168 rv
->m_data
.num
= 0LL;
169 rv
->m_type
= KindOfNull
;
171 frame_free_locals_no_this_inl(ar
, 1);
172 memcpy(&ar
->m_r
, rv
, sizeof(TypedValue
));
176 bool fh_settype(TypedValue
* var
, Value
* type
) asm("_ZN4HPHP9f_settypeERKNS_14VRefParamValueERKNS_6StringE");
178 void fg1_settype(TypedValue
* rv
, ActRec
* ar
, int32_t count
) __attribute__((noinline
,cold
));
179 void fg1_settype(TypedValue
* rv
, ActRec
* ar
, int32_t count
) {
180 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
181 tvCastToStringInPlace(args
-1);
182 rv
->m_type
= KindOfBoolean
;
183 rv
->m_data
.num
= (fh_settype((args
-0), &args
[-1].m_data
)) ? 1LL : 0LL;
186 TypedValue
* fg_settype(ActRec
* ar
) {
188 TypedValue
* rv
= &rvSpace
;
189 int32_t count
= ar
->numArgs();
190 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
192 if (IS_STRING_TYPE((args
- 1)->m_type
)) {
193 rv
->m_type
= KindOfBoolean
;
194 rv
->m_data
.num
= (fh_settype((args
-0), &args
[-1].m_data
)) ? 1LL : 0LL;
196 fg1_settype(rv
, ar
, count
);
199 throw_wrong_arguments_nr("settype", count
, 2, 2, 1);
200 rv
->m_data
.num
= 0LL;
201 rv
->m_type
= KindOfNull
;
203 frame_free_locals_no_this_inl(ar
, 2);
204 memcpy(&ar
->m_r
, rv
, sizeof(TypedValue
));
208 bool fh_is_bool(TypedValue
* var
) asm("_ZN4HPHP9f_is_boolERKNS_7VariantE");
210 TypedValue
* fg_is_bool(ActRec
* ar
) {
212 TypedValue
* rv
= &rvSpace
;
213 int32_t count
= ar
->numArgs();
214 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
216 rv
->m_type
= KindOfBoolean
;
217 rv
->m_data
.num
= (fh_is_bool((args
-0))) ? 1LL : 0LL;
219 throw_wrong_arguments_nr("is_bool", count
, 1, 1, 1);
220 rv
->m_data
.num
= 0LL;
221 rv
->m_type
= KindOfNull
;
223 frame_free_locals_no_this_inl(ar
, 1);
224 memcpy(&ar
->m_r
, rv
, sizeof(TypedValue
));
228 bool fh_is_int(TypedValue
* var
) asm("_ZN4HPHP8f_is_intERKNS_7VariantE");
230 TypedValue
* fg_is_int(ActRec
* ar
) {
232 TypedValue
* rv
= &rvSpace
;
233 int32_t count
= ar
->numArgs();
234 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
236 rv
->m_type
= KindOfBoolean
;
237 rv
->m_data
.num
= (fh_is_int((args
-0))) ? 1LL : 0LL;
239 throw_wrong_arguments_nr("is_int", count
, 1, 1, 1);
240 rv
->m_data
.num
= 0LL;
241 rv
->m_type
= KindOfNull
;
243 frame_free_locals_no_this_inl(ar
, 1);
244 memcpy(&ar
->m_r
, rv
, sizeof(TypedValue
));
248 bool fh_is_integer(TypedValue
* var
) asm("_ZN4HPHP12f_is_integerERKNS_7VariantE");
250 TypedValue
* fg_is_integer(ActRec
* ar
) {
252 TypedValue
* rv
= &rvSpace
;
253 int32_t count
= ar
->numArgs();
254 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
256 rv
->m_type
= KindOfBoolean
;
257 rv
->m_data
.num
= (fh_is_integer((args
-0))) ? 1LL : 0LL;
259 throw_wrong_arguments_nr("is_integer", count
, 1, 1, 1);
260 rv
->m_data
.num
= 0LL;
261 rv
->m_type
= KindOfNull
;
263 frame_free_locals_no_this_inl(ar
, 1);
264 memcpy(&ar
->m_r
, rv
, sizeof(TypedValue
));
268 bool fh_is_long(TypedValue
* var
) asm("_ZN4HPHP9f_is_longERKNS_7VariantE");
270 TypedValue
* fg_is_long(ActRec
* ar
) {
272 TypedValue
* rv
= &rvSpace
;
273 int32_t count
= ar
->numArgs();
274 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
276 rv
->m_type
= KindOfBoolean
;
277 rv
->m_data
.num
= (fh_is_long((args
-0))) ? 1LL : 0LL;
279 throw_wrong_arguments_nr("is_long", count
, 1, 1, 1);
280 rv
->m_data
.num
= 0LL;
281 rv
->m_type
= KindOfNull
;
283 frame_free_locals_no_this_inl(ar
, 1);
284 memcpy(&ar
->m_r
, rv
, sizeof(TypedValue
));
288 bool fh_is_double(TypedValue
* var
) asm("_ZN4HPHP11f_is_doubleERKNS_7VariantE");
290 TypedValue
* fg_is_double(ActRec
* ar
) {
292 TypedValue
* rv
= &rvSpace
;
293 int32_t count
= ar
->numArgs();
294 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
296 rv
->m_type
= KindOfBoolean
;
297 rv
->m_data
.num
= (fh_is_double((args
-0))) ? 1LL : 0LL;
299 throw_wrong_arguments_nr("is_double", count
, 1, 1, 1);
300 rv
->m_data
.num
= 0LL;
301 rv
->m_type
= KindOfNull
;
303 frame_free_locals_no_this_inl(ar
, 1);
304 memcpy(&ar
->m_r
, rv
, sizeof(TypedValue
));
308 bool fh_is_float(TypedValue
* var
) asm("_ZN4HPHP10f_is_floatERKNS_7VariantE");
310 TypedValue
* fg_is_float(ActRec
* ar
) {
312 TypedValue
* rv
= &rvSpace
;
313 int32_t count
= ar
->numArgs();
314 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
316 rv
->m_type
= KindOfBoolean
;
317 rv
->m_data
.num
= (fh_is_float((args
-0))) ? 1LL : 0LL;
319 throw_wrong_arguments_nr("is_float", count
, 1, 1, 1);
320 rv
->m_data
.num
= 0LL;
321 rv
->m_type
= KindOfNull
;
323 frame_free_locals_no_this_inl(ar
, 1);
324 memcpy(&ar
->m_r
, rv
, sizeof(TypedValue
));
328 bool fh_is_numeric(TypedValue
* var
) asm("_ZN4HPHP12f_is_numericERKNS_7VariantE");
330 TypedValue
* fg_is_numeric(ActRec
* ar
) {
332 TypedValue
* rv
= &rvSpace
;
333 int32_t count
= ar
->numArgs();
334 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
336 rv
->m_type
= KindOfBoolean
;
337 rv
->m_data
.num
= (fh_is_numeric((args
-0))) ? 1LL : 0LL;
339 throw_wrong_arguments_nr("is_numeric", count
, 1, 1, 1);
340 rv
->m_data
.num
= 0LL;
341 rv
->m_type
= KindOfNull
;
343 frame_free_locals_no_this_inl(ar
, 1);
344 memcpy(&ar
->m_r
, rv
, sizeof(TypedValue
));
348 bool fh_is_real(TypedValue
* var
) asm("_ZN4HPHP9f_is_realERKNS_7VariantE");
350 TypedValue
* fg_is_real(ActRec
* ar
) {
352 TypedValue
* rv
= &rvSpace
;
353 int32_t count
= ar
->numArgs();
354 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
356 rv
->m_type
= KindOfBoolean
;
357 rv
->m_data
.num
= (fh_is_real((args
-0))) ? 1LL : 0LL;
359 throw_wrong_arguments_nr("is_real", count
, 1, 1, 1);
360 rv
->m_data
.num
= 0LL;
361 rv
->m_type
= KindOfNull
;
363 frame_free_locals_no_this_inl(ar
, 1);
364 memcpy(&ar
->m_r
, rv
, sizeof(TypedValue
));
368 bool fh_is_string(TypedValue
* var
) asm("_ZN4HPHP11f_is_stringERKNS_7VariantE");
370 TypedValue
* fg_is_string(ActRec
* ar
) {
372 TypedValue
* rv
= &rvSpace
;
373 int32_t count
= ar
->numArgs();
374 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
376 rv
->m_type
= KindOfBoolean
;
377 rv
->m_data
.num
= (fh_is_string((args
-0))) ? 1LL : 0LL;
379 throw_wrong_arguments_nr("is_string", count
, 1, 1, 1);
380 rv
->m_data
.num
= 0LL;
381 rv
->m_type
= KindOfNull
;
383 frame_free_locals_no_this_inl(ar
, 1);
384 memcpy(&ar
->m_r
, rv
, sizeof(TypedValue
));
388 bool fh_is_scalar(TypedValue
* var
) asm("_ZN4HPHP11f_is_scalarERKNS_7VariantE");
390 TypedValue
* fg_is_scalar(ActRec
* ar
) {
392 TypedValue
* rv
= &rvSpace
;
393 int32_t count
= ar
->numArgs();
394 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
396 rv
->m_type
= KindOfBoolean
;
397 rv
->m_data
.num
= (fh_is_scalar((args
-0))) ? 1LL : 0LL;
399 throw_wrong_arguments_nr("is_scalar", count
, 1, 1, 1);
400 rv
->m_data
.num
= 0LL;
401 rv
->m_type
= KindOfNull
;
403 frame_free_locals_no_this_inl(ar
, 1);
404 memcpy(&ar
->m_r
, rv
, sizeof(TypedValue
));
408 bool fh_is_array(TypedValue
* var
) asm("_ZN4HPHP10f_is_arrayERKNS_7VariantE");
410 TypedValue
* fg_is_array(ActRec
* ar
) {
412 TypedValue
* rv
= &rvSpace
;
413 int32_t count
= ar
->numArgs();
414 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
416 rv
->m_type
= KindOfBoolean
;
417 rv
->m_data
.num
= (fh_is_array((args
-0))) ? 1LL : 0LL;
419 throw_wrong_arguments_nr("is_array", count
, 1, 1, 1);
420 rv
->m_data
.num
= 0LL;
421 rv
->m_type
= KindOfNull
;
423 frame_free_locals_no_this_inl(ar
, 1);
424 memcpy(&ar
->m_r
, rv
, sizeof(TypedValue
));
428 bool fh_is_object(TypedValue
* var
) asm("_ZN4HPHP11f_is_objectERKNS_7VariantE");
430 TypedValue
* fg_is_object(ActRec
* ar
) {
432 TypedValue
* rv
= &rvSpace
;
433 int32_t count
= ar
->numArgs();
434 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
436 rv
->m_type
= KindOfBoolean
;
437 rv
->m_data
.num
= (fh_is_object((args
-0))) ? 1LL : 0LL;
439 throw_wrong_arguments_nr("is_object", count
, 1, 1, 1);
440 rv
->m_data
.num
= 0LL;
441 rv
->m_type
= KindOfNull
;
443 frame_free_locals_no_this_inl(ar
, 1);
444 memcpy(&ar
->m_r
, rv
, sizeof(TypedValue
));
448 bool fh_is_resource(TypedValue
* var
) asm("_ZN4HPHP13f_is_resourceERKNS_7VariantE");
450 TypedValue
* fg_is_resource(ActRec
* ar
) {
452 TypedValue
* rv
= &rvSpace
;
453 int32_t count
= ar
->numArgs();
454 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
456 rv
->m_type
= KindOfBoolean
;
457 rv
->m_data
.num
= (fh_is_resource((args
-0))) ? 1LL : 0LL;
459 throw_wrong_arguments_nr("is_resource", count
, 1, 1, 1);
460 rv
->m_data
.num
= 0LL;
461 rv
->m_type
= KindOfNull
;
463 frame_free_locals_no_this_inl(ar
, 1);
464 memcpy(&ar
->m_r
, rv
, sizeof(TypedValue
));
468 bool fh_is_null(TypedValue
* var
) asm("_ZN4HPHP9f_is_nullERKNS_7VariantE");
470 TypedValue
* fg_is_null(ActRec
* ar
) {
472 TypedValue
* rv
= &rvSpace
;
473 int32_t count
= ar
->numArgs();
474 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
476 rv
->m_type
= KindOfBoolean
;
477 rv
->m_data
.num
= (fh_is_null((args
-0))) ? 1LL : 0LL;
479 throw_wrong_arguments_nr("is_null", count
, 1, 1, 1);
480 rv
->m_data
.num
= 0LL;
481 rv
->m_type
= KindOfNull
;
483 frame_free_locals_no_this_inl(ar
, 1);
484 memcpy(&ar
->m_r
, rv
, sizeof(TypedValue
));
488 TypedValue
* fh_print_r(TypedValue
* _rv
, TypedValue
* expression
, bool ret
) asm("_ZN4HPHP9f_print_rERKNS_7VariantEb");
490 void fg1_print_r(TypedValue
* rv
, ActRec
* ar
, int32_t count
) __attribute__((noinline
,cold
));
491 void fg1_print_r(TypedValue
* rv
, ActRec
* ar
, int32_t count
) {
492 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
493 tvCastToBooleanInPlace(args
-1);
494 fh_print_r(rv
, (args
-0), (count
> 1) ? (bool)(args
[-1].m_data
.num
) : (bool)(false));
495 if (rv
->m_type
== KindOfUninit
) rv
->m_type
= KindOfNull
;
498 TypedValue
* fg_print_r(ActRec
* ar
) {
500 TypedValue
* rv
= &rvSpace
;
501 int32_t count
= ar
->numArgs();
502 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
503 if (count
>= 1 && count
<= 2) {
504 if ((count
<= 1 || (args
- 1)->m_type
== KindOfBoolean
)) {
505 fh_print_r(rv
, (args
-0), (count
> 1) ? (bool)(args
[-1].m_data
.num
) : (bool)(false));
506 if (rv
->m_type
== KindOfUninit
) rv
->m_type
= KindOfNull
;
508 fg1_print_r(rv
, ar
, count
);
511 throw_wrong_arguments_nr("print_r", count
, 1, 2, 1);
512 rv
->m_data
.num
= 0LL;
513 rv
->m_type
= KindOfNull
;
515 frame_free_locals_no_this_inl(ar
, 2);
516 memcpy(&ar
->m_r
, rv
, sizeof(TypedValue
));
520 TypedValue
* fh_var_export(TypedValue
* _rv
, TypedValue
* expression
, bool ret
) asm("_ZN4HPHP12f_var_exportERKNS_7VariantEb");
522 void fg1_var_export(TypedValue
* rv
, ActRec
* ar
, int32_t count
) __attribute__((noinline
,cold
));
523 void fg1_var_export(TypedValue
* rv
, ActRec
* ar
, int32_t count
) {
524 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
525 tvCastToBooleanInPlace(args
-1);
526 fh_var_export(rv
, (args
-0), (count
> 1) ? (bool)(args
[-1].m_data
.num
) : (bool)(false));
527 if (rv
->m_type
== KindOfUninit
) rv
->m_type
= KindOfNull
;
530 TypedValue
* fg_var_export(ActRec
* ar
) {
532 TypedValue
* rv
= &rvSpace
;
533 int32_t count
= ar
->numArgs();
534 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
535 if (count
>= 1 && count
<= 2) {
536 if ((count
<= 1 || (args
- 1)->m_type
== KindOfBoolean
)) {
537 fh_var_export(rv
, (args
-0), (count
> 1) ? (bool)(args
[-1].m_data
.num
) : (bool)(false));
538 if (rv
->m_type
== KindOfUninit
) rv
->m_type
= KindOfNull
;
540 fg1_var_export(rv
, ar
, count
);
543 throw_wrong_arguments_nr("var_export", count
, 1, 2, 1);
544 rv
->m_data
.num
= 0LL;
545 rv
->m_type
= KindOfNull
;
547 frame_free_locals_no_this_inl(ar
, 2);
548 memcpy(&ar
->m_r
, rv
, sizeof(TypedValue
));
552 void fh_var_dump(int64_t _argc
, TypedValue
* expression
, Value
* _argv
) asm("_ZN4HPHP10f_var_dumpEiRKNS_7VariantERKNS_5ArrayE");
554 TypedValue
* fg_var_dump(ActRec
* ar
) {
556 TypedValue
* rv
= &rvSpace
;
557 int32_t count
= ar
->numArgs();
558 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
560 rv
->m_type
= KindOfNull
;
564 ArrayInit
ai(count
-1);
565 for (int32_t i
= 1; i
< count
; ++i
) {
566 TypedValue
* extraArg
= ar
->getExtraArg(i
-1);
567 if (tvIsStronglyBound(extraArg
)) {
568 ai
.setRef(i
-1, tvAsVariant(extraArg
));
570 ai
.set(i
-1, tvAsVariant(extraArg
));
573 extraArgs
= ai
.create();
575 fh_var_dump(count
, (args
-0), (Value
*)(&extraArgs
));
577 throw_missing_arguments_nr("var_dump", 1, count
, 1);
578 rv
->m_data
.num
= 0LL;
579 rv
->m_type
= KindOfNull
;
581 frame_free_locals_no_this_inl(ar
, 1);
582 memcpy(&ar
->m_r
, rv
, sizeof(TypedValue
));
586 void fh_debug_zval_dump(TypedValue
* variable
) asm("_ZN4HPHP17f_debug_zval_dumpERKNS_7VariantE");
588 TypedValue
* fg_debug_zval_dump(ActRec
* ar
) {
590 TypedValue
* rv
= &rvSpace
;
591 int32_t count
= ar
->numArgs();
592 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
594 rv
->m_type
= KindOfNull
;
595 fh_debug_zval_dump((args
-0));
597 throw_wrong_arguments_nr("debug_zval_dump", count
, 1, 1, 1);
598 rv
->m_data
.num
= 0LL;
599 rv
->m_type
= KindOfNull
;
601 frame_free_locals_no_this_inl(ar
, 1);
602 memcpy(&ar
->m_r
, rv
, sizeof(TypedValue
));
606 TypedValue
* fh_unserialize(TypedValue
* _rv
, Value
* str
, Value
* class_whitelist
) asm("_ZN4HPHP13f_unserializeERKNS_6StringERKNS_5ArrayE");
608 void fg1_unserialize(TypedValue
* rv
, ActRec
* ar
, int32_t count
) __attribute__((noinline
,cold
));
609 void fg1_unserialize(TypedValue
* rv
, ActRec
* ar
, int32_t count
) {
610 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
612 default: // count >= 2
613 if ((args
-1)->m_type
!= KindOfArray
) {
614 tvCastToArrayInPlace(args
-1);
619 if (!IS_STRING_TYPE((args
-0)->m_type
)) {
620 tvCastToStringInPlace(args
-0);
622 Array defVal1
= empty_array
;
623 fh_unserialize(rv
, &args
[-0].m_data
, (count
> 1) ? &args
[-1].m_data
: (Value
*)(&defVal1
));
624 if (rv
->m_type
== KindOfUninit
) rv
->m_type
= KindOfNull
;
627 TypedValue
* fg_unserialize(ActRec
* ar
) {
629 TypedValue
* rv
= &rvSpace
;
630 int32_t count
= ar
->numArgs();
631 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
632 if (count
>= 1 && count
<= 2) {
633 if ((count
<= 1 || (args
- 1)->m_type
== KindOfArray
) &&
634 IS_STRING_TYPE((args
- 0)->m_type
)) {
635 Array defVal1
= empty_array
;
636 fh_unserialize(rv
, &args
[-0].m_data
, (count
> 1) ? &args
[-1].m_data
: (Value
*)(&defVal1
));
637 if (rv
->m_type
== KindOfUninit
) rv
->m_type
= KindOfNull
;
639 fg1_unserialize(rv
, ar
, count
);
642 throw_wrong_arguments_nr("unserialize", count
, 1, 2, 1);
643 rv
->m_data
.num
= 0LL;
644 rv
->m_type
= KindOfNull
;
646 frame_free_locals_no_this_inl(ar
, 2);
647 memcpy(&ar
->m_r
, rv
, sizeof(TypedValue
));
651 Value
* fh_get_defined_vars(Value
* _rv
) asm("_ZN4HPHP18f_get_defined_varsEv");
653 TypedValue
* fg_get_defined_vars(ActRec
* ar
) {
655 TypedValue
* rv
= &rvSpace
;
656 int32_t count
= ar
->numArgs();
657 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
659 rv
->m_type
= KindOfArray
;
660 fh_get_defined_vars(&(rv
->m_data
));
661 if (rv
->m_data
.num
== 0LL) rv
->m_type
= KindOfNull
;
663 throw_toomany_arguments_nr("get_defined_vars", 0, 1);
664 rv
->m_data
.num
= 0LL;
665 rv
->m_type
= KindOfNull
;
667 frame_free_locals_no_this_inl(ar
, 0);
668 memcpy(&ar
->m_r
, rv
, sizeof(TypedValue
));
672 bool fh_import_request_variables(Value
* types
, Value
* prefix
) asm("_ZN4HPHP26f_import_request_variablesERKNS_6StringES2_");
674 void fg1_import_request_variables(TypedValue
* rv
, ActRec
* ar
, int32_t count
) __attribute__((noinline
,cold
));
675 void fg1_import_request_variables(TypedValue
* rv
, ActRec
* ar
, int32_t count
) {
676 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
678 default: // count >= 2
679 if (!IS_STRING_TYPE((args
-1)->m_type
)) {
680 tvCastToStringInPlace(args
-1);
685 if (!IS_STRING_TYPE((args
-0)->m_type
)) {
686 tvCastToStringInPlace(args
-0);
688 rv
->m_type
= KindOfBoolean
;
690 rv
->m_data
.num
= (fh_import_request_variables(&args
[-0].m_data
, (count
> 1) ? &args
[-1].m_data
: (Value
*)(&defVal1
))) ? 1LL : 0LL;
693 TypedValue
* fg_import_request_variables(ActRec
* ar
) {
695 TypedValue
* rv
= &rvSpace
;
696 int32_t count
= ar
->numArgs();
697 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
698 if (count
>= 1 && count
<= 2) {
699 if ((count
<= 1 || IS_STRING_TYPE((args
- 1)->m_type
)) &&
700 IS_STRING_TYPE((args
- 0)->m_type
)) {
701 rv
->m_type
= KindOfBoolean
;
703 rv
->m_data
.num
= (fh_import_request_variables(&args
[-0].m_data
, (count
> 1) ? &args
[-1].m_data
: (Value
*)(&defVal1
))) ? 1LL : 0LL;
705 fg1_import_request_variables(rv
, ar
, count
);
708 throw_wrong_arguments_nr("import_request_variables", count
, 1, 2, 1);
709 rv
->m_data
.num
= 0LL;
710 rv
->m_type
= KindOfNull
;
712 frame_free_locals_no_this_inl(ar
, 2);
713 memcpy(&ar
->m_r
, rv
, sizeof(TypedValue
));
717 long fh_extract(Value
* var_array
, int extract_type
, Value
* prefix
) asm("_ZN4HPHP9f_extractERKNS_5ArrayEiRKNS_6StringE");
719 void fg1_extract(TypedValue
* rv
, ActRec
* ar
, int32_t count
) __attribute__((noinline
,cold
));
720 void fg1_extract(TypedValue
* rv
, ActRec
* ar
, int32_t count
) {
721 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
723 default: // count >= 3
724 if (!IS_STRING_TYPE((args
-2)->m_type
)) {
725 tvCastToStringInPlace(args
-2);
728 if ((args
-1)->m_type
!= KindOfInt64
) {
729 tvCastToInt64InPlace(args
-1);
734 if ((args
-0)->m_type
!= KindOfArray
) {
735 tvCastToArrayInPlace(args
-0);
737 rv
->m_type
= KindOfInt64
;
739 rv
->m_data
.num
= (int64_t)fh_extract(&args
[-0].m_data
, (count
> 1) ? (int)(args
[-1].m_data
.num
) : (int)(k_EXTR_OVERWRITE
), (count
> 2) ? &args
[-2].m_data
: (Value
*)(&defVal2
));
742 TypedValue
* fg_extract(ActRec
* ar
) {
744 TypedValue
* rv
= &rvSpace
;
745 int32_t count
= ar
->numArgs();
746 TypedValue
* args UNUSED
= ((TypedValue
*)ar
) - 1;
747 if (count
>= 1 && count
<= 3) {
748 if ((count
<= 2 || IS_STRING_TYPE((args
- 2)->m_type
)) &&
749 (count
<= 1 || (args
- 1)->m_type
== KindOfInt64
) &&
750 (args
- 0)->m_type
== KindOfArray
) {
751 rv
->m_type
= KindOfInt64
;
753 rv
->m_data
.num
= (int64_t)fh_extract(&args
[-0].m_data
, (count
> 1) ? (int)(args
[-1].m_data
.num
) : (int)(k_EXTR_OVERWRITE
), (count
> 2) ? &args
[-2].m_data
: (Value
*)(&defVal2
));
755 fg1_extract(rv
, ar
, count
);
758 throw_wrong_arguments_nr("extract", count
, 1, 3, 1);
759 rv
->m_data
.num
= 0LL;
760 rv
->m_type
= KindOfNull
;
762 frame_free_locals_no_this_inl(ar
, 3);
763 memcpy(&ar
->m_r
, rv
, sizeof(TypedValue
));