v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
js-raw-json.cc
Go to the documentation of this file.
1// Copyright 2022 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
8#include "src/heap/factory.h"
12
13namespace v8 {
14namespace internal {
15
16// https://tc39.es/proposal-json-parse-with-source/#sec-json.rawjson
18 Handle<Object> text) {
19 Handle<String> json_string;
20 ASSIGN_RETURN_ON_EXCEPTION(isolate, json_string,
21 Object::ToString(isolate, text));
22 Handle<String> flat = String::Flatten(isolate, json_string);
24 if (!JsonParser<uint8_t>::CheckRawJson(isolate, flat)) {
25 DCHECK(isolate->has_exception());
27 }
28 } else {
29 if (!JsonParser<uint16_t>::CheckRawJson(isolate, flat)) {
30 DCHECK(isolate->has_exception());
32 }
33 }
35 isolate->factory()->NewJSObjectFromMap(isolate->js_raw_json_map());
36 result->InObjectPropertyAtPut(JSRawJson::kRawJsonInitialIndex, *flat);
37 JSObject::SetIntegrityLevel(isolate, result, FROZEN, kThrowOnError).Check();
38 return Cast<JSRawJson>(result);
39}
40
41} // namespace internal
42} // namespace v8
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< JSRawJson > Create(Isolate *isolate, Handle< Object > text)
static const int kRawJsonInitialIndex
Definition js-raw-json.h:29
static V8_WARN_UNUSED_RESULT HandleType< String >::MaybeType ToString(Isolate *isolate, HandleType< T > input)
static V8_INLINE HandleType< String > Flatten(Isolate *isolate, HandleType< T > string, AllocationType allocation=AllocationType::kYoung)
static bool IsOneByteRepresentationUnderneath(Tagged< String > string)
Definition string-inl.h:373
#define ASSIGN_RETURN_ON_EXCEPTION(isolate, dst, call)
Definition isolate.h:291
ZoneVector< RpoNumber > & result
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
Definition casting.h:150
#define DCHECK(condition)
Definition logging.h:482