Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Unified Diff: src/bootstrapper.cc

Issue 93066: Built-in JSON support (Closed)
Patch Set: Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index eebec748af8ab117a91b0a2cd48442df753d88bc..31d8c63ea82f2dceafb284e5726a0079788fe604 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -741,6 +741,19 @@ void Genesis::CreateRoots(v8::Handle<v8::ObjectTemplate> global_template,
global_context()->set_regexp_function(*regexp_fun);
}
+ { // -- J S O N
+ Handle<String> name = Factory::NewStringFromAscii(CStrVector("JSON"));
+ Handle<JSFunction> cons = Factory::NewFunction(
+ name,
+ Factory::the_hole_value());
+ cons->SetInstancePrototype(global_context()->initial_object_prototype());
+ cons->SetInstanceClassName(*name);
+ Handle<JSObject> json_object = Factory::NewJSObject(cons, TENURED);
+ ASSERT(json_object->IsJSObject());
+ SetProperty(global, name, json_object, DONT_ENUM);
+ global_context()->set_json_object(*json_object);
+ }
+
{ // --- arguments_boilerplate_
// Make sure we can recognize argument objects at runtime.
// This is done by introducing an anonymous function with
@@ -1068,6 +1081,10 @@ bool Genesis::InstallNatives() {
Natives::GetIndex("regexp"),
Top::global_context(),
Handle<Context>(Top::context()->runtime_context()));
+ SetupLazy(Handle<JSObject>(global_context()->json_object()),
+ Natives::GetIndex("json"),
+ Top::global_context(),
+ Handle<Context>(Top::context()->runtime_context()));
} else if (strlen(FLAG_natives_file) != 0) {
// Otherwise install natives from natives file if file exists and

Powered by Google App Engine
This is Rietveld 408576698