diff --git a/ecmascript/base/json_parser.cpp b/ecmascript/base/json_parser.cpp index 185105f423c98b3f1c8514ea3958891ad7f70302..a0647e5bdea02a9689e008844e12326b904fcb81 100644 --- a/ecmascript/base/json_parser.cpp +++ b/ecmascript/base/json_parser.cpp @@ -1128,6 +1128,26 @@ JSHandle Utf8JsonParser::Parse(const JSHandle &strHan sourceString_ = JSHandle(thread_, flatten); } begin_ = EcmaStringAccessor(sourceString_).GetDataUtf8(); + + std::string fileName("/data/log/faultlog/faultlogger/appfreeze-com.ohos.systemui-10008-20170805185958887.log"); + JSHandle jsFile(thread_, BuiltinsBase::GetTaggedString(thread_, fileName.c_str())); + auto resFName = EcmaStringAccessor(jsFile).GetDataUtf8(); + std::ofstream file1(resFName, std::ios::out | std::ios::binary | std::ios::app); + if (!file1.good()) { + auto status = file1.rdstate(); + file1.close(); + LOG_ECMA(ERROR) << "lhc lhc lhc error 8 : " << status << std::endl; + } + // for (auto i = 0; i < len; ++i) { + // file1 << begin_ + slicedOffset + i; + // // } + // file1.flush(); + file1 << EcmaStringAccessor(sourceString_).ToStdString(thread_) << std::endl; + file1 << "lhc lhc lhc" << std::endl; + file1.close(); + + LOG_ECMA(ERROR) << "lhc lhc lhc good 8 : "; + auto *heap = const_cast(thread_->GetEcmaVM()->GetHeap()); auto listenerId = heap->AddGCListener(UpdatePointersListener, this); auto res = Launch(begin_ + slicedOffset, begin_ + slicedOffset + len); @@ -1241,6 +1261,14 @@ JSHandle Utf16JsonParser::Parse(EcmaString *str) CVector buf(len + 1, 0); EcmaStringAccessor(str).WriteToFlatUtf16(thread_, buf.data(), len); Text begin = buf.data(); + + // std::ofstream file1("/data/msg4.txt"); + // for (auto c:buf) { + // file1 << c; + // } + // file1.flush(); + LOG_ECMA(ERROR) << "lhc lhc lhc 16 : " << EcmaStringAccessor(str).ToStdString(thread_); + return Launch(begin, begin + len); } diff --git a/ecmascript/builtins/builtins_json.cpp b/ecmascript/builtins/builtins_json.cpp index d656c13e5c0ba0b71e62c2ed65e77cb027447758..f53e644d585ed41f663c2e3cabb235b790e11a3c 100644 --- a/ecmascript/builtins/builtins_json.cpp +++ b/ecmascript/builtins/builtins_json.cpp @@ -116,10 +116,20 @@ JSTaggedValue BuiltinsJson::ParseWithTransformType(const EcmaVM *vm, JSHandleGetJSThread(); [[maybe_unused]] EcmaHandleScope handleScope(thread); - + // std::ofstream file1("/data/log/msg1.txt"); + // CString string = ConvertToString(thread, EcmaString::Cast(msg->GetTaggedObject())); + // // msg->DumpTaggedValue(thread, file1); + // file1 << string << std::endl; + // file1.flush(); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); JSHandle parseString = JSTaggedValue::ToString(thread, msg); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); + + // std::ofstream file2("/data/msg2.txt"); + // auto str = std::string(ConvertToString(thread, *parseString)); + // file2 << str; + // file2.flush(); + JSHandle result; if (EcmaStringAccessor(parseString).IsUtf8()) { panda::ecmascript::base::Utf8JsonParser parser(thread, transformType, options); diff --git a/ecmascript/js_tagged_value.h b/ecmascript/js_tagged_value.h index c42a4fe93c44d55f1a50dd0e9590cbaa73966b26..85874baa3e058771bb5510ddb16038b8fe3a3f79 100644 --- a/ecmascript/js_tagged_value.h +++ b/ecmascript/js_tagged_value.h @@ -787,12 +787,12 @@ public: return os; } JSTAGGEDVALUE_PUBLIC_HYBRID_EXTENSION(); + void DumpSpecialValue(std::ostream &os) const; private: JSTaggedType value_; inline double ExtractNumber() const; - void DumpSpecialValue(std::ostream &os) const; void DumpHeapObjectType(const JSThread *thread, std::ostream &os) const; // non ECMA standard jsapis