OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 // Get prototype template of the global_template | 536 // Get prototype template of the global_template |
537 Handle<ObjectTemplateInfo> data = | 537 Handle<ObjectTemplateInfo> data = |
538 v8::Utils::OpenHandle(*global_template); | 538 v8::Utils::OpenHandle(*global_template); |
539 Handle<FunctionTemplateInfo> global_constructor = | 539 Handle<FunctionTemplateInfo> global_constructor = |
540 Handle<FunctionTemplateInfo>( | 540 Handle<FunctionTemplateInfo>( |
541 FunctionTemplateInfo::cast(data->constructor())); | 541 FunctionTemplateInfo::cast(data->constructor())); |
542 Handle<Object> proto_template(global_constructor->prototype_template()); | 542 Handle<Object> proto_template(global_constructor->prototype_template()); |
543 if (!proto_template->IsUndefined()) { | 543 if (!proto_template->IsUndefined()) { |
544 js_global_template = | 544 js_global_template = |
545 Handle<ObjectTemplateInfo>::cast(proto_template); | 545 Handle<ObjectTemplateInfo>::cast(proto_template); |
546 } | 546 } |
547 } | 547 } |
548 | 548 |
549 if (js_global_template.is_null()) { | 549 if (js_global_template.is_null()) { |
550 Handle<String> name = Handle<String>(Heap::empty_symbol()); | 550 Handle<String> name = Handle<String>(Heap::empty_symbol()); |
551 Handle<Code> code = Handle<Code>(Builtins::builtin(Builtins::Illegal)); | 551 Handle<Code> code = Handle<Code>(Builtins::builtin(Builtins::Illegal)); |
552 js_global_function = | 552 js_global_function = |
553 Factory::NewFunction(name, JS_GLOBAL_OBJECT_TYPE, | 553 Factory::NewFunction(name, JS_GLOBAL_OBJECT_TYPE, |
554 JSGlobalObject::kSize, code, true); | 554 JSGlobalObject::kSize, code, true); |
555 // Change the constructor property of the prototype of the | 555 // Change the constructor property of the prototype of the |
556 // hidden global function to refer to the Object function. | 556 // hidden global function to refer to the Object function. |
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 } | 1188 } |
1189 | 1189 |
1190 | 1190 |
1191 bool Genesis::ConfigureGlobalObjects( | 1191 bool Genesis::ConfigureGlobalObjects( |
1192 v8::Handle<v8::ObjectTemplate> global_proxy_template) { | 1192 v8::Handle<v8::ObjectTemplate> global_proxy_template) { |
1193 Handle<JSObject> global_proxy( | 1193 Handle<JSObject> global_proxy( |
1194 JSObject::cast(global_context()->global_proxy())); | 1194 JSObject::cast(global_context()->global_proxy())); |
1195 Handle<JSObject> js_global(JSObject::cast(global_context()->global())); | 1195 Handle<JSObject> js_global(JSObject::cast(global_context()->global())); |
1196 | 1196 |
1197 if (!global_proxy_template.IsEmpty()) { | 1197 if (!global_proxy_template.IsEmpty()) { |
1198 // Configure the global proxy object. | 1198 // Configure the global proxy object. |
1199 Handle<ObjectTemplateInfo> proxy_data = | 1199 Handle<ObjectTemplateInfo> proxy_data = |
1200 v8::Utils::OpenHandle(*global_proxy_template); | 1200 v8::Utils::OpenHandle(*global_proxy_template); |
1201 if (!ConfigureApiObject(global_proxy, proxy_data)) return false; | 1201 if (!ConfigureApiObject(global_proxy, proxy_data)) return false; |
1202 | 1202 |
1203 // Configure the inner global object. | 1203 // Configure the inner global object. |
1204 Handle<FunctionTemplateInfo> proxy_constructor( | 1204 Handle<FunctionTemplateInfo> proxy_constructor( |
1205 FunctionTemplateInfo::cast(proxy_data->constructor())); | 1205 FunctionTemplateInfo::cast(proxy_data->constructor())); |
1206 if (!proxy_constructor->prototype_template()->IsUndefined()) { | 1206 if (!proxy_constructor->prototype_template()->IsUndefined()) { |
1207 Handle<ObjectTemplateInfo> inner_data( | 1207 Handle<ObjectTemplateInfo> inner_data( |
1208 ObjectTemplateInfo::cast(proxy_constructor->prototype_template())); | 1208 ObjectTemplateInfo::cast(proxy_constructor->prototype_template())); |
1209 if (!ConfigureApiObject(js_global, inner_data)) return false; | 1209 if (!ConfigureApiObject(js_global, inner_data)) return false; |
1210 } | 1210 } |
1211 } | 1211 } |
1212 | 1212 |
1213 SetObjectPrototype(global_proxy, js_global); | 1213 SetObjectPrototype(global_proxy, js_global); |
1214 return true; | 1214 return true; |
1215 } | 1215 } |
1216 | 1216 |
1217 | 1217 |
1218 bool Genesis::ConfigureApiObject(Handle<JSObject> object, | 1218 bool Genesis::ConfigureApiObject(Handle<JSObject> object, |
1219 Handle<ObjectTemplateInfo> object_template) { | 1219 Handle<ObjectTemplateInfo> object_template) { |
1220 ASSERT(!object_template.is_null()); | 1220 ASSERT(!object_template.is_null()); |
1221 ASSERT(object->IsInstanceOf( | 1221 ASSERT(object->IsInstanceOf( |
1222 FunctionTemplateInfo::cast(object_template->constructor()))); | 1222 FunctionTemplateInfo::cast(object_template->constructor()))); |
1223 | 1223 |
1224 bool pending_exception = false; | 1224 bool pending_exception = false; |
1225 Handle<JSObject> obj = | 1225 Handle<JSObject> obj = |
1226 Execution::InstantiateObject(object_template, &pending_exception); | 1226 Execution::InstantiateObject(object_template, &pending_exception); |
1227 if (pending_exception) { | 1227 if (pending_exception) { |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1428 if (!ConfigureGlobalObjects(global_template)) return; | 1428 if (!ConfigureGlobalObjects(global_template)) return; |
1429 | 1429 |
1430 if (!InstallExtensions(extensions)) return; | 1430 if (!InstallExtensions(extensions)) return; |
1431 | 1431 |
1432 if (!InstallSpecialObjects()) return; | 1432 if (!InstallSpecialObjects()) return; |
1433 | 1433 |
1434 result_ = global_context_; | 1434 result_ = global_context_; |
1435 } | 1435 } |
1436 | 1436 |
1437 } } // namespace v8::internal | 1437 } } // namespace v8::internal |
OLD | NEW |