/* +----------------------------------------------------------------------+ | HipHop for PHP | +----------------------------------------------------------------------+ | Copyright (c) 2010- Facebook, Inc. (http://www.facebook.com) | | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ */ #include #include #include #include #include #include #include namespace HPHP { /* HPHP::String HPHP::f_json_encode(HPHP::Variant const&, HPHP::Variant const&) _ZN4HPHP13f_json_encodeERKNS_7VariantES2_ (return value) => rax _rv => rdi value => rsi options => rdx */ Value* fh_json_encode(Value* _rv, TypedValue* value, TypedValue* options) asm("_ZN4HPHP13f_json_encodeERKNS_7VariantES2_"); TypedValue* fg_json_encode(HPHP::VM::ActRec *ar) { TypedValue rv; int64_t count = ar->numArgs(); TypedValue* args UNUSED = ((TypedValue*)ar) - 1; if (count >= 1LL && count <= 2LL) { rv.m_type = KindOfString; Variant defVal1 = 0; fh_json_encode((&rv.m_data), (args-0), (count > 1) ? (args-1) : (TypedValue*)(&defVal1)); if (rv.m_data.num == 0LL) rv.m_type = KindOfNull; frame_free_locals_no_this_inl(ar, 2); memcpy(&ar->m_r, &rv, sizeof(TypedValue)); return &ar->m_r; } else { throw_wrong_arguments_nr("json_encode", count, 1, 2, 1); } rv.m_data.num = 0LL; rv.m_type = KindOfNull; frame_free_locals_no_this_inl(ar, 2); memcpy(&ar->m_r, &rv, sizeof(TypedValue)); return &ar->m_r; return &ar->m_r; } /* HPHP::Variant HPHP::f_json_decode(HPHP::String const&, bool, HPHP::Variant const&) _ZN4HPHP13f_json_decodeERKNS_6StringEbRKNS_7VariantE (return value) => rax _rv => rdi json => rsi assoc => rdx options => rcx */ TypedValue* fh_json_decode(TypedValue* _rv, Value* json, bool assoc, TypedValue* options) asm("_ZN4HPHP13f_json_decodeERKNS_6StringEbRKNS_7VariantE"); TypedValue * fg1_json_decode(TypedValue* rv, HPHP::VM::ActRec* ar, int64_t count) __attribute__((noinline,cold)); TypedValue * fg1_json_decode(TypedValue* rv, HPHP::VM::ActRec* ar, int64_t count) { TypedValue* args UNUSED = ((TypedValue*)ar) - 1; switch (count) { default: // count >= 3 case 2: if ((args-1)->m_type != KindOfBoolean) { tvCastToBooleanInPlace(args-1); } case 1: break; } if (!IS_STRING_TYPE((args-0)->m_type)) { tvCastToStringInPlace(args-0); } Variant defVal2 = 0; fh_json_decode((rv), &args[-0].m_data, (count > 1) ? (bool)(args[-1].m_data.num) : (bool)(false), (count > 2) ? (args-2) : (TypedValue*)(&defVal2)); if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull; return rv; } TypedValue* fg_json_decode(HPHP::VM::ActRec *ar) { TypedValue rv; int64_t count = ar->numArgs(); TypedValue* args UNUSED = ((TypedValue*)ar) - 1; if (count >= 1LL && count <= 3LL) { if ((count <= 1 || (args-1)->m_type == KindOfBoolean) && IS_STRING_TYPE((args-0)->m_type)) { Variant defVal2 = 0; fh_json_decode((&(rv)), &args[-0].m_data, (count > 1) ? (bool)(args[-1].m_data.num) : (bool)(false), (count > 2) ? (args-2) : (TypedValue*)(&defVal2)); if (rv.m_type == KindOfUninit) rv.m_type = KindOfNull; frame_free_locals_no_this_inl(ar, 3); memcpy(&ar->m_r, &rv, sizeof(TypedValue)); return &ar->m_r; } else { fg1_json_decode(&rv, ar, count); frame_free_locals_no_this_inl(ar, 3); memcpy(&ar->m_r, &rv, sizeof(TypedValue)); return &ar->m_r; } } else { throw_wrong_arguments_nr("json_decode", count, 1, 3, 1); } rv.m_data.num = 0LL; rv.m_type = KindOfNull; frame_free_locals_no_this_inl(ar, 3); memcpy(&ar->m_r, &rv, sizeof(TypedValue)); return &ar->m_r; return &ar->m_r; } } // !HPHP