PageRenderTime 68ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/src/runtime/ext/ext_preg.ext_hhvm.cpp

http://github.com/facebook/hiphop-php
C++ | 968 lines | 707 code | 93 blank | 168 comment | 223 complexity | cd23ac88da67424e4c796ca5fc266746 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
  1. /*
  2. +----------------------------------------------------------------------+
  3. | HipHop for PHP |
  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. +----------------------------------------------------------------------+
  16. */
  17. #include <runtime/ext_hhvm/ext_hhvm.h>
  18. #include <runtime/base/builtin_functions.h>
  19. #include <runtime/base/array/array_init.h>
  20. #include <runtime/ext/ext.h>
  21. #include <runtime/vm/class.h>
  22. #include <runtime/vm/runtime.h>
  23. #include <exception>
  24. namespace HPHP {
  25. /*
  26. HPHP::Variant HPHP::f_preg_grep(HPHP::String const&, HPHP::Array const&, int)
  27. _ZN4HPHP11f_preg_grepERKNS_6StringERKNS_5ArrayEi
  28. (return value) => rax
  29. _rv => rdi
  30. pattern => rsi
  31. input => rdx
  32. flags => rcx
  33. */
  34. TypedValue* fh_preg_grep(TypedValue* _rv, Value* pattern, Value* input, int flags) asm("_ZN4HPHP11f_preg_grepERKNS_6StringERKNS_5ArrayEi");
  35. TypedValue * fg1_preg_grep(TypedValue* rv, HPHP::VM::ActRec* ar, long long count) __attribute__((noinline,cold));
  36. TypedValue * fg1_preg_grep(TypedValue* rv, HPHP::VM::ActRec* ar, long long count) {
  37. TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
  38. switch (count) {
  39. default: // count >= 3
  40. if ((args-2)->m_type != KindOfInt64) {
  41. tvCastToInt64InPlace(args-2);
  42. }
  43. case 2:
  44. break;
  45. }
  46. if ((args-1)->m_type != KindOfArray) {
  47. tvCastToArrayInPlace(args-1);
  48. }
  49. if (!IS_STRING_TYPE((args-0)->m_type)) {
  50. tvCastToStringInPlace(args-0);
  51. }
  52. fh_preg_grep((rv), (Value*)(args-0), (Value*)(args-1), (count > 2) ? (int)(args[-2].m_data.num) : (int)(0));
  53. if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull;
  54. return rv;
  55. }
  56. TypedValue* fg_preg_grep(HPHP::VM::ActRec *ar) {
  57. TypedValue rv;
  58. long long count = ar->numArgs();
  59. TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
  60. if (count >= 2LL && count <= 3LL) {
  61. if ((count <= 2 || (args-2)->m_type == KindOfInt64) && (args-1)->m_type == KindOfArray && IS_STRING_TYPE((args-0)->m_type)) {
  62. fh_preg_grep((&(rv)), (Value*)(args-0), (Value*)(args-1), (count > 2) ? (int)(args[-2].m_data.num) : (int)(0));
  63. if (rv.m_type == KindOfUninit) rv.m_type = KindOfNull;
  64. frame_free_locals_no_this_inl(ar, 3);
  65. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  66. return &ar->m_r;
  67. } else {
  68. fg1_preg_grep(&rv, ar, count);
  69. frame_free_locals_no_this_inl(ar, 3);
  70. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  71. return &ar->m_r;
  72. }
  73. } else {
  74. throw_wrong_arguments_nr("preg_grep", count, 2, 3, 1);
  75. }
  76. rv.m_data.num = 0LL;
  77. rv._count = 0;
  78. rv.m_type = KindOfNull;
  79. frame_free_locals_no_this_inl(ar, 3);
  80. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  81. return &ar->m_r;
  82. return &ar->m_r;
  83. }
  84. /*
  85. HPHP::Variant HPHP::f_preg_match(HPHP::String const&, HPHP::String const&, HPHP::VRefParamValue const&, int, int)
  86. _ZN4HPHP12f_preg_matchERKNS_6StringES2_RKNS_14VRefParamValueEii
  87. (return value) => rax
  88. _rv => rdi
  89. pattern => rsi
  90. subject => rdx
  91. matches => rcx
  92. flags => r8
  93. offset => r9
  94. */
  95. TypedValue* fh_preg_match(TypedValue* _rv, Value* pattern, Value* subject, TypedValue* matches, int flags, int offset) asm("_ZN4HPHP12f_preg_matchERKNS_6StringES2_RKNS_14VRefParamValueEii");
  96. TypedValue * fg1_preg_match(TypedValue* rv, HPHP::VM::ActRec* ar, long long count) __attribute__((noinline,cold));
  97. TypedValue * fg1_preg_match(TypedValue* rv, HPHP::VM::ActRec* ar, long long count) {
  98. TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
  99. switch (count) {
  100. default: // count >= 5
  101. if ((args-4)->m_type != KindOfInt64) {
  102. tvCastToInt64InPlace(args-4);
  103. }
  104. case 4:
  105. if ((args-3)->m_type != KindOfInt64) {
  106. tvCastToInt64InPlace(args-3);
  107. }
  108. case 3:
  109. case 2:
  110. break;
  111. }
  112. if (!IS_STRING_TYPE((args-1)->m_type)) {
  113. tvCastToStringInPlace(args-1);
  114. }
  115. if (!IS_STRING_TYPE((args-0)->m_type)) {
  116. tvCastToStringInPlace(args-0);
  117. }
  118. VRefParamValue defVal2 = null;
  119. fh_preg_match((rv), (Value*)(args-0), (Value*)(args-1), (count > 2) ? (args-2) : (TypedValue*)(&defVal2), (count > 3) ? (int)(args[-3].m_data.num) : (int)(0), (count > 4) ? (int)(args[-4].m_data.num) : (int)(0));
  120. if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull;
  121. return rv;
  122. }
  123. TypedValue* fg_preg_match(HPHP::VM::ActRec *ar) {
  124. TypedValue rv;
  125. long long count = ar->numArgs();
  126. TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
  127. if (count >= 2LL && count <= 5LL) {
  128. if ((count <= 4 || (args-4)->m_type == KindOfInt64) && (count <= 3 || (args-3)->m_type == KindOfInt64) && IS_STRING_TYPE((args-1)->m_type) && IS_STRING_TYPE((args-0)->m_type)) {
  129. VRefParamValue defVal2 = null;
  130. fh_preg_match((&(rv)), (Value*)(args-0), (Value*)(args-1), (count > 2) ? (args-2) : (TypedValue*)(&defVal2), (count > 3) ? (int)(args[-3].m_data.num) : (int)(0), (count > 4) ? (int)(args[-4].m_data.num) : (int)(0));
  131. if (rv.m_type == KindOfUninit) rv.m_type = KindOfNull;
  132. frame_free_locals_no_this_inl(ar, 5);
  133. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  134. return &ar->m_r;
  135. } else {
  136. fg1_preg_match(&rv, ar, count);
  137. frame_free_locals_no_this_inl(ar, 5);
  138. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  139. return &ar->m_r;
  140. }
  141. } else {
  142. throw_wrong_arguments_nr("preg_match", count, 2, 5, 1);
  143. }
  144. rv.m_data.num = 0LL;
  145. rv._count = 0;
  146. rv.m_type = KindOfNull;
  147. frame_free_locals_no_this_inl(ar, 5);
  148. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  149. return &ar->m_r;
  150. return &ar->m_r;
  151. }
  152. /*
  153. HPHP::Variant HPHP::f_preg_match_all(HPHP::String const&, HPHP::String const&, HPHP::VRefParamValue const&, int, int)
  154. _ZN4HPHP16f_preg_match_allERKNS_6StringES2_RKNS_14VRefParamValueEii
  155. (return value) => rax
  156. _rv => rdi
  157. pattern => rsi
  158. subject => rdx
  159. matches => rcx
  160. flags => r8
  161. offset => r9
  162. */
  163. TypedValue* fh_preg_match_all(TypedValue* _rv, Value* pattern, Value* subject, TypedValue* matches, int flags, int offset) asm("_ZN4HPHP16f_preg_match_allERKNS_6StringES2_RKNS_14VRefParamValueEii");
  164. TypedValue * fg1_preg_match_all(TypedValue* rv, HPHP::VM::ActRec* ar, long long count) __attribute__((noinline,cold));
  165. TypedValue * fg1_preg_match_all(TypedValue* rv, HPHP::VM::ActRec* ar, long long count) {
  166. TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
  167. switch (count) {
  168. default: // count >= 5
  169. if ((args-4)->m_type != KindOfInt64) {
  170. tvCastToInt64InPlace(args-4);
  171. }
  172. case 4:
  173. if ((args-3)->m_type != KindOfInt64) {
  174. tvCastToInt64InPlace(args-3);
  175. }
  176. case 3:
  177. break;
  178. }
  179. if (!IS_STRING_TYPE((args-1)->m_type)) {
  180. tvCastToStringInPlace(args-1);
  181. }
  182. if (!IS_STRING_TYPE((args-0)->m_type)) {
  183. tvCastToStringInPlace(args-0);
  184. }
  185. fh_preg_match_all((rv), (Value*)(args-0), (Value*)(args-1), (args-2), (count > 3) ? (int)(args[-3].m_data.num) : (int)(0), (count > 4) ? (int)(args[-4].m_data.num) : (int)(0));
  186. if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull;
  187. return rv;
  188. }
  189. TypedValue* fg_preg_match_all(HPHP::VM::ActRec *ar) {
  190. TypedValue rv;
  191. long long count = ar->numArgs();
  192. TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
  193. if (count >= 3LL && count <= 5LL) {
  194. if ((count <= 4 || (args-4)->m_type == KindOfInt64) && (count <= 3 || (args-3)->m_type == KindOfInt64) && IS_STRING_TYPE((args-1)->m_type) && IS_STRING_TYPE((args-0)->m_type)) {
  195. fh_preg_match_all((&(rv)), (Value*)(args-0), (Value*)(args-1), (args-2), (count > 3) ? (int)(args[-3].m_data.num) : (int)(0), (count > 4) ? (int)(args[-4].m_data.num) : (int)(0));
  196. if (rv.m_type == KindOfUninit) rv.m_type = KindOfNull;
  197. frame_free_locals_no_this_inl(ar, 5);
  198. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  199. return &ar->m_r;
  200. } else {
  201. fg1_preg_match_all(&rv, ar, count);
  202. frame_free_locals_no_this_inl(ar, 5);
  203. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  204. return &ar->m_r;
  205. }
  206. } else {
  207. throw_wrong_arguments_nr("preg_match_all", count, 3, 5, 1);
  208. }
  209. rv.m_data.num = 0LL;
  210. rv._count = 0;
  211. rv.m_type = KindOfNull;
  212. frame_free_locals_no_this_inl(ar, 5);
  213. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  214. return &ar->m_r;
  215. return &ar->m_r;
  216. }
  217. /*
  218. HPHP::Variant HPHP::f_preg_replace(HPHP::Variant const&, HPHP::Variant const&, HPHP::Variant const&, int, HPHP::VRefParamValue const&)
  219. _ZN4HPHP14f_preg_replaceERKNS_7VariantES2_S2_iRKNS_14VRefParamValueE
  220. (return value) => rax
  221. _rv => rdi
  222. pattern => rsi
  223. replacement => rdx
  224. subject => rcx
  225. limit => r8
  226. count => r9
  227. */
  228. TypedValue* fh_preg_replace(TypedValue* _rv, TypedValue* pattern, TypedValue* replacement, TypedValue* subject, int limit, TypedValue* count) asm("_ZN4HPHP14f_preg_replaceERKNS_7VariantES2_S2_iRKNS_14VRefParamValueE");
  229. TypedValue * fg1_preg_replace(TypedValue* rv, HPHP::VM::ActRec* ar, long long count) __attribute__((noinline,cold));
  230. TypedValue * fg1_preg_replace(TypedValue* rv, HPHP::VM::ActRec* ar, long long count) {
  231. TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
  232. tvCastToInt64InPlace(args-3);
  233. VRefParamValue defVal4 = null;
  234. fh_preg_replace((rv), (args-0), (args-1), (args-2), (count > 3) ? (int)(args[-3].m_data.num) : (int)(-1), (count > 4) ? (args-4) : (TypedValue*)(&defVal4));
  235. if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull;
  236. return rv;
  237. }
  238. TypedValue* fg_preg_replace(HPHP::VM::ActRec *ar) {
  239. TypedValue rv;
  240. long long count = ar->numArgs();
  241. TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
  242. if (count >= 3LL && count <= 5LL) {
  243. if ((count <= 3 || (args-3)->m_type == KindOfInt64)) {
  244. VRefParamValue defVal4 = null;
  245. fh_preg_replace((&(rv)), (args-0), (args-1), (args-2), (count > 3) ? (int)(args[-3].m_data.num) : (int)(-1), (count > 4) ? (args-4) : (TypedValue*)(&defVal4));
  246. if (rv.m_type == KindOfUninit) rv.m_type = KindOfNull;
  247. frame_free_locals_no_this_inl(ar, 5);
  248. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  249. return &ar->m_r;
  250. } else {
  251. fg1_preg_replace(&rv, ar, count);
  252. frame_free_locals_no_this_inl(ar, 5);
  253. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  254. return &ar->m_r;
  255. }
  256. } else {
  257. throw_wrong_arguments_nr("preg_replace", count, 3, 5, 1);
  258. }
  259. rv.m_data.num = 0LL;
  260. rv._count = 0;
  261. rv.m_type = KindOfNull;
  262. frame_free_locals_no_this_inl(ar, 5);
  263. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  264. return &ar->m_r;
  265. return &ar->m_r;
  266. }
  267. /*
  268. HPHP::Variant HPHP::f_preg_replace_callback(HPHP::Variant const&, HPHP::Variant const&, HPHP::Variant const&, int, HPHP::VRefParamValue const&)
  269. _ZN4HPHP23f_preg_replace_callbackERKNS_7VariantES2_S2_iRKNS_14VRefParamValueE
  270. (return value) => rax
  271. _rv => rdi
  272. pattern => rsi
  273. callback => rdx
  274. subject => rcx
  275. limit => r8
  276. count => r9
  277. */
  278. TypedValue* fh_preg_replace_callback(TypedValue* _rv, TypedValue* pattern, TypedValue* callback, TypedValue* subject, int limit, TypedValue* count) asm("_ZN4HPHP23f_preg_replace_callbackERKNS_7VariantES2_S2_iRKNS_14VRefParamValueE");
  279. TypedValue * fg1_preg_replace_callback(TypedValue* rv, HPHP::VM::ActRec* ar, long long count) __attribute__((noinline,cold));
  280. TypedValue * fg1_preg_replace_callback(TypedValue* rv, HPHP::VM::ActRec* ar, long long count) {
  281. TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
  282. tvCastToInt64InPlace(args-3);
  283. VRefParamValue defVal4 = null;
  284. fh_preg_replace_callback((rv), (args-0), (args-1), (args-2), (count > 3) ? (int)(args[-3].m_data.num) : (int)(-1), (count > 4) ? (args-4) : (TypedValue*)(&defVal4));
  285. if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull;
  286. return rv;
  287. }
  288. TypedValue* fg_preg_replace_callback(HPHP::VM::ActRec *ar) {
  289. TypedValue rv;
  290. long long count = ar->numArgs();
  291. TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
  292. if (count >= 3LL && count <= 5LL) {
  293. if ((count <= 3 || (args-3)->m_type == KindOfInt64)) {
  294. VRefParamValue defVal4 = null;
  295. fh_preg_replace_callback((&(rv)), (args-0), (args-1), (args-2), (count > 3) ? (int)(args[-3].m_data.num) : (int)(-1), (count > 4) ? (args-4) : (TypedValue*)(&defVal4));
  296. if (rv.m_type == KindOfUninit) rv.m_type = KindOfNull;
  297. frame_free_locals_no_this_inl(ar, 5);
  298. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  299. return &ar->m_r;
  300. } else {
  301. fg1_preg_replace_callback(&rv, ar, count);
  302. frame_free_locals_no_this_inl(ar, 5);
  303. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  304. return &ar->m_r;
  305. }
  306. } else {
  307. throw_wrong_arguments_nr("preg_replace_callback", count, 3, 5, 1);
  308. }
  309. rv.m_data.num = 0LL;
  310. rv._count = 0;
  311. rv.m_type = KindOfNull;
  312. frame_free_locals_no_this_inl(ar, 5);
  313. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  314. return &ar->m_r;
  315. return &ar->m_r;
  316. }
  317. /*
  318. HPHP::Variant HPHP::f_preg_split(HPHP::Variant const&, HPHP::Variant const&, int, int)
  319. _ZN4HPHP12f_preg_splitERKNS_7VariantES2_ii
  320. (return value) => rax
  321. _rv => rdi
  322. pattern => rsi
  323. subject => rdx
  324. limit => rcx
  325. flags => r8
  326. */
  327. TypedValue* fh_preg_split(TypedValue* _rv, TypedValue* pattern, TypedValue* subject, int limit, int flags) asm("_ZN4HPHP12f_preg_splitERKNS_7VariantES2_ii");
  328. TypedValue * fg1_preg_split(TypedValue* rv, HPHP::VM::ActRec* ar, long long count) __attribute__((noinline,cold));
  329. TypedValue * fg1_preg_split(TypedValue* rv, HPHP::VM::ActRec* ar, long long count) {
  330. TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
  331. switch (count) {
  332. default: // count >= 4
  333. if ((args-3)->m_type != KindOfInt64) {
  334. tvCastToInt64InPlace(args-3);
  335. }
  336. case 3:
  337. if ((args-2)->m_type != KindOfInt64) {
  338. tvCastToInt64InPlace(args-2);
  339. }
  340. case 2:
  341. break;
  342. }
  343. fh_preg_split((rv), (args-0), (args-1), (count > 2) ? (int)(args[-2].m_data.num) : (int)(-1), (count > 3) ? (int)(args[-3].m_data.num) : (int)(0));
  344. if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull;
  345. return rv;
  346. }
  347. TypedValue* fg_preg_split(HPHP::VM::ActRec *ar) {
  348. TypedValue rv;
  349. long long count = ar->numArgs();
  350. TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
  351. if (count >= 2LL && count <= 4LL) {
  352. if ((count <= 3 || (args-3)->m_type == KindOfInt64) && (count <= 2 || (args-2)->m_type == KindOfInt64)) {
  353. fh_preg_split((&(rv)), (args-0), (args-1), (count > 2) ? (int)(args[-2].m_data.num) : (int)(-1), (count > 3) ? (int)(args[-3].m_data.num) : (int)(0));
  354. if (rv.m_type == KindOfUninit) rv.m_type = KindOfNull;
  355. frame_free_locals_no_this_inl(ar, 4);
  356. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  357. return &ar->m_r;
  358. } else {
  359. fg1_preg_split(&rv, ar, count);
  360. frame_free_locals_no_this_inl(ar, 4);
  361. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  362. return &ar->m_r;
  363. }
  364. } else {
  365. throw_wrong_arguments_nr("preg_split", count, 2, 4, 1);
  366. }
  367. rv.m_data.num = 0LL;
  368. rv._count = 0;
  369. rv.m_type = KindOfNull;
  370. frame_free_locals_no_this_inl(ar, 4);
  371. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  372. return &ar->m_r;
  373. return &ar->m_r;
  374. }
  375. /*
  376. HPHP::String HPHP::f_preg_quote(HPHP::String const&, HPHP::String const&)
  377. _ZN4HPHP12f_preg_quoteERKNS_6StringES2_
  378. (return value) => rax
  379. _rv => rdi
  380. str => rsi
  381. delimiter => rdx
  382. */
  383. Value* fh_preg_quote(Value* _rv, Value* str, Value* delimiter) asm("_ZN4HPHP12f_preg_quoteERKNS_6StringES2_");
  384. TypedValue * fg1_preg_quote(TypedValue* rv, HPHP::VM::ActRec* ar, long long count) __attribute__((noinline,cold));
  385. TypedValue * fg1_preg_quote(TypedValue* rv, HPHP::VM::ActRec* ar, long long count) {
  386. TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
  387. rv->_count = 0;
  388. rv->m_type = KindOfString;
  389. switch (count) {
  390. default: // count >= 2
  391. if (!IS_STRING_TYPE((args-1)->m_type)) {
  392. tvCastToStringInPlace(args-1);
  393. }
  394. case 1:
  395. break;
  396. }
  397. if (!IS_STRING_TYPE((args-0)->m_type)) {
  398. tvCastToStringInPlace(args-0);
  399. }
  400. fh_preg_quote((Value*)(rv), (Value*)(args-0), (count > 1) ? (Value*)(args-1) : (Value*)(&null_string));
  401. if (rv->m_data.num == 0LL) rv->m_type = KindOfNull;
  402. return rv;
  403. }
  404. TypedValue* fg_preg_quote(HPHP::VM::ActRec *ar) {
  405. TypedValue rv;
  406. long long count = ar->numArgs();
  407. TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
  408. if (count >= 1LL && count <= 2LL) {
  409. if ((count <= 1 || IS_STRING_TYPE((args-1)->m_type)) && IS_STRING_TYPE((args-0)->m_type)) {
  410. rv._count = 0;
  411. rv.m_type = KindOfString;
  412. fh_preg_quote((Value*)(&(rv)), (Value*)(args-0), (count > 1) ? (Value*)(args-1) : (Value*)(&null_string));
  413. if (rv.m_data.num == 0LL) rv.m_type = KindOfNull;
  414. frame_free_locals_no_this_inl(ar, 2);
  415. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  416. return &ar->m_r;
  417. } else {
  418. fg1_preg_quote(&rv, ar, count);
  419. frame_free_locals_no_this_inl(ar, 2);
  420. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  421. return &ar->m_r;
  422. }
  423. } else {
  424. throw_wrong_arguments_nr("preg_quote", count, 1, 2, 1);
  425. }
  426. rv.m_data.num = 0LL;
  427. rv._count = 0;
  428. rv.m_type = KindOfNull;
  429. frame_free_locals_no_this_inl(ar, 2);
  430. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  431. return &ar->m_r;
  432. return &ar->m_r;
  433. }
  434. /*
  435. long long HPHP::f_preg_last_error()
  436. _ZN4HPHP17f_preg_last_errorEv
  437. (return value) => rax
  438. */
  439. long long fh_preg_last_error() asm("_ZN4HPHP17f_preg_last_errorEv");
  440. TypedValue* fg_preg_last_error(HPHP::VM::ActRec *ar) {
  441. TypedValue rv;
  442. long long count = ar->numArgs();
  443. TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
  444. if (count == 0LL) {
  445. rv._count = 0;
  446. rv.m_type = KindOfInt64;
  447. rv.m_data.num = (long long)fh_preg_last_error();
  448. frame_free_locals_no_this_inl(ar, 0);
  449. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  450. return &ar->m_r;
  451. } else {
  452. throw_toomany_arguments_nr("preg_last_error", 0, 1);
  453. }
  454. rv.m_data.num = 0LL;
  455. rv._count = 0;
  456. rv.m_type = KindOfNull;
  457. frame_free_locals_no_this_inl(ar, 0);
  458. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  459. return &ar->m_r;
  460. return &ar->m_r;
  461. }
  462. /*
  463. HPHP::String HPHP::f_ereg_replace(HPHP::String const&, HPHP::String const&, HPHP::String const&)
  464. _ZN4HPHP14f_ereg_replaceERKNS_6StringES2_S2_
  465. (return value) => rax
  466. _rv => rdi
  467. pattern => rsi
  468. replacement => rdx
  469. str => rcx
  470. */
  471. Value* fh_ereg_replace(Value* _rv, Value* pattern, Value* replacement, Value* str) asm("_ZN4HPHP14f_ereg_replaceERKNS_6StringES2_S2_");
  472. TypedValue * fg1_ereg_replace(TypedValue* rv, HPHP::VM::ActRec* ar, long long count) __attribute__((noinline,cold));
  473. TypedValue * fg1_ereg_replace(TypedValue* rv, HPHP::VM::ActRec* ar, long long count) {
  474. TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
  475. rv->_count = 0;
  476. rv->m_type = KindOfString;
  477. if (!IS_STRING_TYPE((args-2)->m_type)) {
  478. tvCastToStringInPlace(args-2);
  479. }
  480. if (!IS_STRING_TYPE((args-1)->m_type)) {
  481. tvCastToStringInPlace(args-1);
  482. }
  483. if (!IS_STRING_TYPE((args-0)->m_type)) {
  484. tvCastToStringInPlace(args-0);
  485. }
  486. fh_ereg_replace((Value*)(rv), (Value*)(args-0), (Value*)(args-1), (Value*)(args-2));
  487. if (rv->m_data.num == 0LL) rv->m_type = KindOfNull;
  488. return rv;
  489. }
  490. TypedValue* fg_ereg_replace(HPHP::VM::ActRec *ar) {
  491. TypedValue rv;
  492. long long count = ar->numArgs();
  493. TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
  494. if (count == 3LL) {
  495. if (IS_STRING_TYPE((args-2)->m_type) && IS_STRING_TYPE((args-1)->m_type) && IS_STRING_TYPE((args-0)->m_type)) {
  496. rv._count = 0;
  497. rv.m_type = KindOfString;
  498. fh_ereg_replace((Value*)(&(rv)), (Value*)(args-0), (Value*)(args-1), (Value*)(args-2));
  499. if (rv.m_data.num == 0LL) rv.m_type = KindOfNull;
  500. frame_free_locals_no_this_inl(ar, 3);
  501. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  502. return &ar->m_r;
  503. } else {
  504. fg1_ereg_replace(&rv, ar, count);
  505. frame_free_locals_no_this_inl(ar, 3);
  506. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  507. return &ar->m_r;
  508. }
  509. } else {
  510. throw_wrong_arguments_nr("ereg_replace", count, 3, 3, 1);
  511. }
  512. rv.m_data.num = 0LL;
  513. rv._count = 0;
  514. rv.m_type = KindOfNull;
  515. frame_free_locals_no_this_inl(ar, 3);
  516. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  517. return &ar->m_r;
  518. return &ar->m_r;
  519. }
  520. /*
  521. HPHP::String HPHP::f_eregi_replace(HPHP::String const&, HPHP::String const&, HPHP::String const&)
  522. _ZN4HPHP15f_eregi_replaceERKNS_6StringES2_S2_
  523. (return value) => rax
  524. _rv => rdi
  525. pattern => rsi
  526. replacement => rdx
  527. str => rcx
  528. */
  529. Value* fh_eregi_replace(Value* _rv, Value* pattern, Value* replacement, Value* str) asm("_ZN4HPHP15f_eregi_replaceERKNS_6StringES2_S2_");
  530. TypedValue * fg1_eregi_replace(TypedValue* rv, HPHP::VM::ActRec* ar, long long count) __attribute__((noinline,cold));
  531. TypedValue * fg1_eregi_replace(TypedValue* rv, HPHP::VM::ActRec* ar, long long count) {
  532. TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
  533. rv->_count = 0;
  534. rv->m_type = KindOfString;
  535. if (!IS_STRING_TYPE((args-2)->m_type)) {
  536. tvCastToStringInPlace(args-2);
  537. }
  538. if (!IS_STRING_TYPE((args-1)->m_type)) {
  539. tvCastToStringInPlace(args-1);
  540. }
  541. if (!IS_STRING_TYPE((args-0)->m_type)) {
  542. tvCastToStringInPlace(args-0);
  543. }
  544. fh_eregi_replace((Value*)(rv), (Value*)(args-0), (Value*)(args-1), (Value*)(args-2));
  545. if (rv->m_data.num == 0LL) rv->m_type = KindOfNull;
  546. return rv;
  547. }
  548. TypedValue* fg_eregi_replace(HPHP::VM::ActRec *ar) {
  549. TypedValue rv;
  550. long long count = ar->numArgs();
  551. TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
  552. if (count == 3LL) {
  553. if (IS_STRING_TYPE((args-2)->m_type) && IS_STRING_TYPE((args-1)->m_type) && IS_STRING_TYPE((args-0)->m_type)) {
  554. rv._count = 0;
  555. rv.m_type = KindOfString;
  556. fh_eregi_replace((Value*)(&(rv)), (Value*)(args-0), (Value*)(args-1), (Value*)(args-2));
  557. if (rv.m_data.num == 0LL) rv.m_type = KindOfNull;
  558. frame_free_locals_no_this_inl(ar, 3);
  559. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  560. return &ar->m_r;
  561. } else {
  562. fg1_eregi_replace(&rv, ar, count);
  563. frame_free_locals_no_this_inl(ar, 3);
  564. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  565. return &ar->m_r;
  566. }
  567. } else {
  568. throw_wrong_arguments_nr("eregi_replace", count, 3, 3, 1);
  569. }
  570. rv.m_data.num = 0LL;
  571. rv._count = 0;
  572. rv.m_type = KindOfNull;
  573. frame_free_locals_no_this_inl(ar, 3);
  574. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  575. return &ar->m_r;
  576. return &ar->m_r;
  577. }
  578. /*
  579. HPHP::Variant HPHP::f_ereg(HPHP::String const&, HPHP::String const&, HPHP::VRefParamValue const&)
  580. _ZN4HPHP6f_eregERKNS_6StringES2_RKNS_14VRefParamValueE
  581. (return value) => rax
  582. _rv => rdi
  583. pattern => rsi
  584. str => rdx
  585. regs => rcx
  586. */
  587. TypedValue* fh_ereg(TypedValue* _rv, Value* pattern, Value* str, TypedValue* regs) asm("_ZN4HPHP6f_eregERKNS_6StringES2_RKNS_14VRefParamValueE");
  588. TypedValue * fg1_ereg(TypedValue* rv, HPHP::VM::ActRec* ar, long long count) __attribute__((noinline,cold));
  589. TypedValue * fg1_ereg(TypedValue* rv, HPHP::VM::ActRec* ar, long long count) {
  590. TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
  591. switch (count) {
  592. default: // count >= 3
  593. case 2:
  594. break;
  595. }
  596. if (!IS_STRING_TYPE((args-1)->m_type)) {
  597. tvCastToStringInPlace(args-1);
  598. }
  599. if (!IS_STRING_TYPE((args-0)->m_type)) {
  600. tvCastToStringInPlace(args-0);
  601. }
  602. VRefParamValue defVal2 = null;
  603. fh_ereg((rv), (Value*)(args-0), (Value*)(args-1), (count > 2) ? (args-2) : (TypedValue*)(&defVal2));
  604. if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull;
  605. return rv;
  606. }
  607. TypedValue* fg_ereg(HPHP::VM::ActRec *ar) {
  608. TypedValue rv;
  609. long long count = ar->numArgs();
  610. TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
  611. if (count >= 2LL && count <= 3LL) {
  612. if (IS_STRING_TYPE((args-1)->m_type) && IS_STRING_TYPE((args-0)->m_type)) {
  613. VRefParamValue defVal2 = null;
  614. fh_ereg((&(rv)), (Value*)(args-0), (Value*)(args-1), (count > 2) ? (args-2) : (TypedValue*)(&defVal2));
  615. if (rv.m_type == KindOfUninit) rv.m_type = KindOfNull;
  616. frame_free_locals_no_this_inl(ar, 3);
  617. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  618. return &ar->m_r;
  619. } else {
  620. fg1_ereg(&rv, ar, count);
  621. frame_free_locals_no_this_inl(ar, 3);
  622. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  623. return &ar->m_r;
  624. }
  625. } else {
  626. throw_wrong_arguments_nr("ereg", count, 2, 3, 1);
  627. }
  628. rv.m_data.num = 0LL;
  629. rv._count = 0;
  630. rv.m_type = KindOfNull;
  631. frame_free_locals_no_this_inl(ar, 3);
  632. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  633. return &ar->m_r;
  634. return &ar->m_r;
  635. }
  636. /*
  637. HPHP::Variant HPHP::f_eregi(HPHP::String const&, HPHP::String const&, HPHP::VRefParamValue const&)
  638. _ZN4HPHP7f_eregiERKNS_6StringES2_RKNS_14VRefParamValueE
  639. (return value) => rax
  640. _rv => rdi
  641. pattern => rsi
  642. str => rdx
  643. regs => rcx
  644. */
  645. TypedValue* fh_eregi(TypedValue* _rv, Value* pattern, Value* str, TypedValue* regs) asm("_ZN4HPHP7f_eregiERKNS_6StringES2_RKNS_14VRefParamValueE");
  646. TypedValue * fg1_eregi(TypedValue* rv, HPHP::VM::ActRec* ar, long long count) __attribute__((noinline,cold));
  647. TypedValue * fg1_eregi(TypedValue* rv, HPHP::VM::ActRec* ar, long long count) {
  648. TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
  649. switch (count) {
  650. default: // count >= 3
  651. case 2:
  652. break;
  653. }
  654. if (!IS_STRING_TYPE((args-1)->m_type)) {
  655. tvCastToStringInPlace(args-1);
  656. }
  657. if (!IS_STRING_TYPE((args-0)->m_type)) {
  658. tvCastToStringInPlace(args-0);
  659. }
  660. VRefParamValue defVal2 = null;
  661. fh_eregi((rv), (Value*)(args-0), (Value*)(args-1), (count > 2) ? (args-2) : (TypedValue*)(&defVal2));
  662. if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull;
  663. return rv;
  664. }
  665. TypedValue* fg_eregi(HPHP::VM::ActRec *ar) {
  666. TypedValue rv;
  667. long long count = ar->numArgs();
  668. TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
  669. if (count >= 2LL && count <= 3LL) {
  670. if (IS_STRING_TYPE((args-1)->m_type) && IS_STRING_TYPE((args-0)->m_type)) {
  671. VRefParamValue defVal2 = null;
  672. fh_eregi((&(rv)), (Value*)(args-0), (Value*)(args-1), (count > 2) ? (args-2) : (TypedValue*)(&defVal2));
  673. if (rv.m_type == KindOfUninit) rv.m_type = KindOfNull;
  674. frame_free_locals_no_this_inl(ar, 3);
  675. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  676. return &ar->m_r;
  677. } else {
  678. fg1_eregi(&rv, ar, count);
  679. frame_free_locals_no_this_inl(ar, 3);
  680. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  681. return &ar->m_r;
  682. }
  683. } else {
  684. throw_wrong_arguments_nr("eregi", count, 2, 3, 1);
  685. }
  686. rv.m_data.num = 0LL;
  687. rv._count = 0;
  688. rv.m_type = KindOfNull;
  689. frame_free_locals_no_this_inl(ar, 3);
  690. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  691. return &ar->m_r;
  692. return &ar->m_r;
  693. }
  694. /*
  695. HPHP::Variant HPHP::f_split(HPHP::String const&, HPHP::String const&, int)
  696. _ZN4HPHP7f_splitERKNS_6StringES2_i
  697. (return value) => rax
  698. _rv => rdi
  699. pattern => rsi
  700. str => rdx
  701. limit => rcx
  702. */
  703. TypedValue* fh_split(TypedValue* _rv, Value* pattern, Value* str, int limit) asm("_ZN4HPHP7f_splitERKNS_6StringES2_i");
  704. TypedValue * fg1_split(TypedValue* rv, HPHP::VM::ActRec* ar, long long count) __attribute__((noinline,cold));
  705. TypedValue * fg1_split(TypedValue* rv, HPHP::VM::ActRec* ar, long long count) {
  706. TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
  707. switch (count) {
  708. default: // count >= 3
  709. if ((args-2)->m_type != KindOfInt64) {
  710. tvCastToInt64InPlace(args-2);
  711. }
  712. case 2:
  713. break;
  714. }
  715. if (!IS_STRING_TYPE((args-1)->m_type)) {
  716. tvCastToStringInPlace(args-1);
  717. }
  718. if (!IS_STRING_TYPE((args-0)->m_type)) {
  719. tvCastToStringInPlace(args-0);
  720. }
  721. fh_split((rv), (Value*)(args-0), (Value*)(args-1), (count > 2) ? (int)(args[-2].m_data.num) : (int)(-1));
  722. if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull;
  723. return rv;
  724. }
  725. TypedValue* fg_split(HPHP::VM::ActRec *ar) {
  726. TypedValue rv;
  727. long long count = ar->numArgs();
  728. TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
  729. if (count >= 2LL && count <= 3LL) {
  730. if ((count <= 2 || (args-2)->m_type == KindOfInt64) && IS_STRING_TYPE((args-1)->m_type) && IS_STRING_TYPE((args-0)->m_type)) {
  731. fh_split((&(rv)), (Value*)(args-0), (Value*)(args-1), (count > 2) ? (int)(args[-2].m_data.num) : (int)(-1));
  732. if (rv.m_type == KindOfUninit) rv.m_type = KindOfNull;
  733. frame_free_locals_no_this_inl(ar, 3);
  734. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  735. return &ar->m_r;
  736. } else {
  737. fg1_split(&rv, ar, count);
  738. frame_free_locals_no_this_inl(ar, 3);
  739. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  740. return &ar->m_r;
  741. }
  742. } else {
  743. throw_wrong_arguments_nr("split", count, 2, 3, 1);
  744. }
  745. rv.m_data.num = 0LL;
  746. rv._count = 0;
  747. rv.m_type = KindOfNull;
  748. frame_free_locals_no_this_inl(ar, 3);
  749. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  750. return &ar->m_r;
  751. return &ar->m_r;
  752. }
  753. /*
  754. HPHP::Variant HPHP::f_spliti(HPHP::String const&, HPHP::String const&, int)
  755. _ZN4HPHP8f_splitiERKNS_6StringES2_i
  756. (return value) => rax
  757. _rv => rdi
  758. pattern => rsi
  759. str => rdx
  760. limit => rcx
  761. */
  762. TypedValue* fh_spliti(TypedValue* _rv, Value* pattern, Value* str, int limit) asm("_ZN4HPHP8f_splitiERKNS_6StringES2_i");
  763. TypedValue * fg1_spliti(TypedValue* rv, HPHP::VM::ActRec* ar, long long count) __attribute__((noinline,cold));
  764. TypedValue * fg1_spliti(TypedValue* rv, HPHP::VM::ActRec* ar, long long count) {
  765. TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
  766. switch (count) {
  767. default: // count >= 3
  768. if ((args-2)->m_type != KindOfInt64) {
  769. tvCastToInt64InPlace(args-2);
  770. }
  771. case 2:
  772. break;
  773. }
  774. if (!IS_STRING_TYPE((args-1)->m_type)) {
  775. tvCastToStringInPlace(args-1);
  776. }
  777. if (!IS_STRING_TYPE((args-0)->m_type)) {
  778. tvCastToStringInPlace(args-0);
  779. }
  780. fh_spliti((rv), (Value*)(args-0), (Value*)(args-1), (count > 2) ? (int)(args[-2].m_data.num) : (int)(-1));
  781. if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull;
  782. return rv;
  783. }
  784. TypedValue* fg_spliti(HPHP::VM::ActRec *ar) {
  785. TypedValue rv;
  786. long long count = ar->numArgs();
  787. TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
  788. if (count >= 2LL && count <= 3LL) {
  789. if ((count <= 2 || (args-2)->m_type == KindOfInt64) && IS_STRING_TYPE((args-1)->m_type) && IS_STRING_TYPE((args-0)->m_type)) {
  790. fh_spliti((&(rv)), (Value*)(args-0), (Value*)(args-1), (count > 2) ? (int)(args[-2].m_data.num) : (int)(-1));
  791. if (rv.m_type == KindOfUninit) rv.m_type = KindOfNull;
  792. frame_free_locals_no_this_inl(ar, 3);
  793. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  794. return &ar->m_r;
  795. } else {
  796. fg1_spliti(&rv, ar, count);
  797. frame_free_locals_no_this_inl(ar, 3);
  798. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  799. return &ar->m_r;
  800. }
  801. } else {
  802. throw_wrong_arguments_nr("spliti", count, 2, 3, 1);
  803. }
  804. rv.m_data.num = 0LL;
  805. rv._count = 0;
  806. rv.m_type = KindOfNull;
  807. frame_free_locals_no_this_inl(ar, 3);
  808. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  809. return &ar->m_r;
  810. return &ar->m_r;
  811. }
  812. /*
  813. HPHP::String HPHP::f_sql_regcase(HPHP::String const&)
  814. _ZN4HPHP13f_sql_regcaseERKNS_6StringE
  815. (return value) => rax
  816. _rv => rdi
  817. str => rsi
  818. */
  819. Value* fh_sql_regcase(Value* _rv, Value* str) asm("_ZN4HPHP13f_sql_regcaseERKNS_6StringE");
  820. TypedValue * fg1_sql_regcase(TypedValue* rv, HPHP::VM::ActRec* ar, long long count) __attribute__((noinline,cold));
  821. TypedValue * fg1_sql_regcase(TypedValue* rv, HPHP::VM::ActRec* ar, long long count) {
  822. TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
  823. rv->_count = 0;
  824. rv->m_type = KindOfString;
  825. tvCastToStringInPlace(args-0);
  826. fh_sql_regcase((Value*)(rv), (Value*)(args-0));
  827. if (rv->m_data.num == 0LL) rv->m_type = KindOfNull;
  828. return rv;
  829. }
  830. TypedValue* fg_sql_regcase(HPHP::VM::ActRec *ar) {
  831. TypedValue rv;
  832. long long count = ar->numArgs();
  833. TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
  834. if (count == 1LL) {
  835. if (IS_STRING_TYPE((args-0)->m_type)) {
  836. rv._count = 0;
  837. rv.m_type = KindOfString;
  838. fh_sql_regcase((Value*)(&(rv)), (Value*)(args-0));
  839. if (rv.m_data.num == 0LL) rv.m_type = KindOfNull;
  840. frame_free_locals_no_this_inl(ar, 1);
  841. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  842. return &ar->m_r;
  843. } else {
  844. fg1_sql_regcase(&rv, ar, count);
  845. frame_free_locals_no_this_inl(ar, 1);
  846. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  847. return &ar->m_r;
  848. }
  849. } else {
  850. throw_wrong_arguments_nr("sql_regcase", count, 1, 1, 1);
  851. }
  852. rv.m_data.num = 0LL;
  853. rv._count = 0;
  854. rv.m_type = KindOfNull;
  855. frame_free_locals_no_this_inl(ar, 1);
  856. memcpy(&ar->m_r, &rv, sizeof(TypedValue));
  857. return &ar->m_r;
  858. return &ar->m_r;
  859. }
  860. } // !HPHP