OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/object.h" | 5 #include "vm/object.h" |
6 | 6 |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 // base interfaces and the implementation of the internal classes. | 774 // base interfaces and the implementation of the internal classes. |
775 Error& error = Error::Handle(); | 775 Error& error = Error::Handle(); |
776 error = Bootstrap::Compile(core_lib, script); | 776 error = Bootstrap::Compile(core_lib, script); |
777 if (!error.IsNull()) { | 777 if (!error.IsNull()) { |
778 return error.raw(); | 778 return error.raw(); |
779 } | 779 } |
780 error = Bootstrap::Compile(core_impl_lib, impl_script); | 780 error = Bootstrap::Compile(core_impl_lib, impl_script); |
781 if (!error.IsNull()) { | 781 if (!error.IsNull()) { |
782 return error.raw(); | 782 return error.raw(); |
783 } | 783 } |
| 784 const Script& math_script = Script::Handle(Bootstrap::LoadMathScript()); |
| 785 Library::InitMathLibrary(isolate); |
| 786 const Library& math_lib = Library::Handle(Library::MathLibrary()); |
| 787 ASSERT(!math_lib.IsNull()); |
| 788 error = Bootstrap::Compile(math_lib, math_script); |
| 789 if (!error.IsNull()) { |
| 790 return error.raw(); |
| 791 } |
784 const Script& isolate_script = Script::Handle(Bootstrap::LoadIsolateScript()); | 792 const Script& isolate_script = Script::Handle(Bootstrap::LoadIsolateScript()); |
785 Library::InitIsolateLibrary(isolate); | 793 Library::InitIsolateLibrary(isolate); |
786 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); | 794 const Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); |
787 ASSERT(!isolate_lib.IsNull()); | 795 ASSERT(!isolate_lib.IsNull()); |
788 error = Bootstrap::Compile(isolate_lib, isolate_script); | 796 error = Bootstrap::Compile(isolate_lib, isolate_script); |
789 if (!error.IsNull()) { | 797 if (!error.IsNull()) { |
790 return error.raw(); | 798 return error.raw(); |
791 } | 799 } |
792 const Script& mirrors_script = Script::Handle(Bootstrap::LoadMirrorsScript()); | 800 const Script& mirrors_script = Script::Handle(Bootstrap::LoadMirrorsScript()); |
793 Library::InitMirrorsLibrary(isolate); | 801 Library::InitMirrorsLibrary(isolate); |
794 Library& mirrors_lib = Library::Handle(Library::MirrorsLibrary()); | 802 const Library& mirrors_lib = Library::Handle(Library::MirrorsLibrary()); |
795 ASSERT(!mirrors_lib.IsNull()); | 803 ASSERT(!mirrors_lib.IsNull()); |
796 error = Bootstrap::Compile(mirrors_lib, mirrors_script); | 804 error = Bootstrap::Compile(mirrors_lib, mirrors_script); |
797 if (!error.IsNull()) { | 805 if (!error.IsNull()) { |
798 return error.raw(); | 806 return error.raw(); |
799 } | 807 } |
800 Bootstrap::SetupNativeResolver(); | 808 Bootstrap::SetupNativeResolver(); |
801 | 809 |
802 // Remove the Object superclass cycle by setting the super type to null (not | 810 // Remove the Object superclass cycle by setting the super type to null (not |
803 // to the type of null). | 811 // to the type of null). |
804 cls = object_store->object_class(); | 812 cls = object_store->object_class(); |
(...skipping 4549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5354 const Library& core_impl_lib = | 5362 const Library& core_impl_lib = |
5355 Library::Handle(Library::NewLibraryHelper(core_impl_lib_url, false)); | 5363 Library::Handle(Library::NewLibraryHelper(core_impl_lib_url, false)); |
5356 isolate->object_store()->set_core_impl_library(core_impl_lib); | 5364 isolate->object_store()->set_core_impl_library(core_impl_lib); |
5357 core_impl_lib.Register(); | 5365 core_impl_lib.Register(); |
5358 core_lib.AddImport(core_impl_lib); | 5366 core_lib.AddImport(core_impl_lib); |
5359 core_impl_lib.AddImport(core_lib); | 5367 core_impl_lib.AddImport(core_lib); |
5360 isolate->object_store()->set_root_library(Library::Handle()); | 5368 isolate->object_store()->set_root_library(Library::Handle()); |
5361 } | 5369 } |
5362 | 5370 |
5363 | 5371 |
| 5372 void Library::InitMathLibrary(Isolate* isolate) { |
| 5373 const String& url = String::Handle(String::NewSymbol("dart:math")); |
| 5374 const Library& lib = Library::Handle(Library::New(url)); |
| 5375 lib.Register(); |
| 5376 const Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary()); |
| 5377 lib.AddImport(core_impl_lib); |
| 5378 isolate->object_store()->set_math_library(lib); |
| 5379 } |
| 5380 |
| 5381 |
5364 void Library::InitIsolateLibrary(Isolate* isolate) { | 5382 void Library::InitIsolateLibrary(Isolate* isolate) { |
5365 const String& url = String::Handle(String::NewSymbol("dart:isolate")); | 5383 const String& url = String::Handle(String::NewSymbol("dart:isolate")); |
5366 const Library& lib = Library::Handle(Library::New(url)); | 5384 const Library& lib = Library::Handle(Library::New(url)); |
5367 lib.Register(); | 5385 lib.Register(); |
5368 isolate->object_store()->set_isolate_library(lib); | 5386 isolate->object_store()->set_isolate_library(lib); |
5369 } | 5387 } |
5370 | 5388 |
5371 | 5389 |
5372 void Library::InitMirrorsLibrary(Isolate* isolate) { | 5390 void Library::InitMirrorsLibrary(Isolate* isolate) { |
5373 const String& url = String::Handle(String::NewSymbol("dart:mirrors")); | 5391 const String& url = String::Handle(String::NewSymbol("dart:mirrors")); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5479 RawLibrary* Library::CoreLibrary() { | 5497 RawLibrary* Library::CoreLibrary() { |
5480 return Isolate::Current()->object_store()->core_library(); | 5498 return Isolate::Current()->object_store()->core_library(); |
5481 } | 5499 } |
5482 | 5500 |
5483 | 5501 |
5484 RawLibrary* Library::CoreImplLibrary() { | 5502 RawLibrary* Library::CoreImplLibrary() { |
5485 return Isolate::Current()->object_store()->core_impl_library(); | 5503 return Isolate::Current()->object_store()->core_impl_library(); |
5486 } | 5504 } |
5487 | 5505 |
5488 | 5506 |
| 5507 RawLibrary* Library::MathLibrary() { |
| 5508 return Isolate::Current()->object_store()->math_library(); |
| 5509 } |
| 5510 |
| 5511 |
5489 RawLibrary* Library::IsolateLibrary() { | 5512 RawLibrary* Library::IsolateLibrary() { |
5490 return Isolate::Current()->object_store()->isolate_library(); | 5513 return Isolate::Current()->object_store()->isolate_library(); |
5491 } | 5514 } |
5492 | 5515 |
5493 | 5516 |
5494 RawLibrary* Library::MirrorsLibrary() { | 5517 RawLibrary* Library::MirrorsLibrary() { |
5495 return Isolate::Current()->object_store()->mirrors_library(); | 5518 return Isolate::Current()->object_store()->mirrors_library(); |
5496 } | 5519 } |
5497 | 5520 |
5498 | 5521 |
(...skipping 4520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10019 const String& str = String::Handle(pattern()); | 10042 const String& str = String::Handle(pattern()); |
10020 const char* format = "JSRegExp: pattern=%s flags=%s"; | 10043 const char* format = "JSRegExp: pattern=%s flags=%s"; |
10021 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 10044 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
10022 char* chars = reinterpret_cast<char*>( | 10045 char* chars = reinterpret_cast<char*>( |
10023 Isolate::Current()->current_zone()->Allocate(len + 1)); | 10046 Isolate::Current()->current_zone()->Allocate(len + 1)); |
10024 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 10047 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
10025 return chars; | 10048 return chars; |
10026 } | 10049 } |
10027 | 10050 |
10028 } // namespace dart | 10051 } // namespace dart |
OLD | NEW |