#include "src/json/json-stringifier.h"
#include "src/base/strings.h"
#include "src/common/assert-scope.h"
#include "src/common/message-template.h"
#include "src/execution/protectors-inl.h"
#include "src/numbers/conversions.h"
#include "src/objects/elements-kind.h"
#include "src/objects/heap-number-inl.h"
#include "src/objects/js-array-inl.h"
#include "src/objects/js-raw-json-inl.h"
#include "src/objects/lookup.h"
#include "src/objects/objects-inl.h"
#include "src/objects/oddball-inl.h"
#include "src/objects/ordered-hash-table.h"
#include "src/objects/smi.h"
#include "src/objects/tagged.h"
#include "src/strings/string-builder-inl.h"
namespace v8 {
namespace internal {
class JsonStringifier { … };
MaybeHandle<Object> JsonStringify(Isolate* isolate, Handle<Object> object,
Handle<Object> replacer, Handle<Object> gap) { … }
const char* const JsonStringifier::JsonEscapeTable = …;
const bool JsonStringifier::JsonDoNotEscapeFlagTable[] = …;
JsonStringifier::JsonStringifier(Isolate* isolate)
: … { … }
MaybeHandle<Object> JsonStringifier::Stringify(Handle<Object> object,
Handle<Object> replacer,
Handle<Object> gap) { … }
bool JsonStringifier::InitializeReplacer(Handle<Object> replacer) { … }
bool JsonStringifier::InitializeGap(Handle<Object> gap) { … }
MaybeHandle<Object> JsonStringifier::ApplyToJsonFunction(Handle<Object> object,
Handle<Object> key) { … }
MaybeHandle<Object> JsonStringifier::ApplyReplacerFunction(
Handle<Object> value, Handle<Object> key,
DirectHandle<Object> initial_holder) { … }
Handle<JSReceiver> JsonStringifier::CurrentHolder(
DirectHandle<Object> value, DirectHandle<Object> initial_holder) { … }
JsonStringifier::Result JsonStringifier::StackPush(Handle<Object> object,
Handle<Object> key) { … }
void JsonStringifier::StackPop() { … }
class CircularStructureMessageBuilder { … };
Handle<String> JsonStringifier::ConstructCircularStructureErrorMessage(
DirectHandle<Object> last_key, size_t start_index) { … }
bool MayHaveInterestingProperties(Isolate* isolate, Tagged<JSReceiver> object) { … }
template <bool deferred_string_key>
JsonStringifier::Result JsonStringifier::Serialize_(Handle<Object> object,
bool comma,
Handle<Object> key) { … }
JsonStringifier::Result JsonStringifier::SerializeJSPrimitiveWrapper(
Handle<JSPrimitiveWrapper> object, Handle<Object> key) { … }
JsonStringifier::Result JsonStringifier::SerializeSmi(Tagged<Smi> object) { … }
JsonStringifier::Result JsonStringifier::SerializeDouble(double number) { … }
namespace {
bool CanTreatHoleAsUndefined(Isolate* isolate, Tagged<JSArray> object) { … }
}
JsonStringifier::Result JsonStringifier::SerializeJSArray(
Handle<JSArray> object, Handle<Object> key) { … }
template <ElementsKind kind>
JsonStringifier::Result JsonStringifier::SerializeFixedArrayWithInterruptCheck(
DirectHandle<JSArray> array, uint32_t length, uint32_t* slow_path_index) { … }
template <ElementsKind kind>
JsonStringifier::Result
JsonStringifier::SerializeFixedArrayWithPossibleTransitions(
DirectHandle<JSArray> array, uint32_t length, uint32_t* slow_path_index) { … }
template <ElementsKind kind, typename T>
JsonStringifier::Result JsonStringifier::SerializeFixedArrayElement(
Tagged<T> elements, uint32_t i, Tagged<JSArray> array,
bool bailout_on_hole) { … }
JsonStringifier::Result JsonStringifier::SerializeArrayLikeSlow(
Handle<JSReceiver> object, uint32_t start, uint32_t length) { … }
namespace {
V8_INLINE bool CanFastSerializeJSObject(PtrComprCageBase cage_base,
Tagged<JSObject> raw_object,
Isolate* isolate) { … }
}
JsonStringifier::Result JsonStringifier::SerializeJSObject(
Handle<JSObject> object, Handle<Object> key) { … }
JsonStringifier::Result JsonStringifier::SerializeJSReceiverSlow(
Handle<JSReceiver> object) { … }
JsonStringifier::Result JsonStringifier::SerializeJSProxy(
Handle<JSProxy> object, Handle<Object> key) { … }
template <typename SrcChar, typename DestChar, bool raw_json>
bool JsonStringifier::SerializeStringUnchecked_(
base::Vector<const SrcChar> src, NoExtendBuilder<DestChar>* dest) { … }
template <typename SrcChar, typename DestChar, bool raw_json>
bool JsonStringifier::SerializeString_(Tagged<String> string,
const DisallowGarbageCollection& no_gc) { … }
template <typename DestChar>
bool JsonStringifier::TrySerializeSimplePropertyKey(
Tagged<String> key, const DisallowGarbageCollection& no_gc) { … }
template <>
bool JsonStringifier::DoNotEscape(uint8_t c) { … }
template <>
bool JsonStringifier::DoNotEscape(uint16_t c) { … }
void JsonStringifier::NewLine() { … }
void JsonStringifier::NewLineOutline() { … }
void JsonStringifier::Separator(bool first) { … }
void JsonStringifier::SerializeDeferredKey(bool deferred_comma,
Handle<Object> deferred_key) { … }
template <bool raw_json>
bool JsonStringifier::SerializeString(Handle<String> object) { … }
void JsonStringifier::Extend() { … }
void JsonStringifier::ChangeEncoding() { … }
}
}