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

Side by Side Diff: runtime/vm/object.cc

Issue 10389150: - Add a math library. Currently it mostly matches the Math class in dart:core. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 4517 matching lines...) Expand 10 before | Expand all | Expand 10 after
5322 const Library& core_impl_lib = 5330 const Library& core_impl_lib =
5323 Library::Handle(Library::NewLibraryHelper(core_impl_lib_url, false)); 5331 Library::Handle(Library::NewLibraryHelper(core_impl_lib_url, false));
5324 isolate->object_store()->set_core_impl_library(core_impl_lib); 5332 isolate->object_store()->set_core_impl_library(core_impl_lib);
5325 core_impl_lib.Register(); 5333 core_impl_lib.Register();
5326 core_lib.AddImport(core_impl_lib); 5334 core_lib.AddImport(core_impl_lib);
5327 core_impl_lib.AddImport(core_lib); 5335 core_impl_lib.AddImport(core_lib);
5328 isolate->object_store()->set_root_library(Library::Handle()); 5336 isolate->object_store()->set_root_library(Library::Handle());
5329 } 5337 }
5330 5338
5331 5339
5340 void Library::InitMathLibrary(Isolate* isolate) {
5341 const String& url = String::Handle(String::NewSymbol("dart:math"));
5342 const Library& lib = Library::Handle(Library::New(url));
5343 lib.Register();
5344 isolate->object_store()->set_math_library(lib);
5345 }
5346
5347
5332 void Library::InitIsolateLibrary(Isolate* isolate) { 5348 void Library::InitIsolateLibrary(Isolate* isolate) {
5333 const String& url = String::Handle(String::NewSymbol("dart:isolate")); 5349 const String& url = String::Handle(String::NewSymbol("dart:isolate"));
5334 const Library& lib = Library::Handle(Library::New(url)); 5350 const Library& lib = Library::Handle(Library::New(url));
5335 lib.Register(); 5351 lib.Register();
5336 isolate->object_store()->set_isolate_library(lib); 5352 isolate->object_store()->set_isolate_library(lib);
5337 } 5353 }
5338 5354
5339 5355
5340 void Library::InitMirrorsLibrary(Isolate* isolate) { 5356 void Library::InitMirrorsLibrary(Isolate* isolate) {
5341 const String& url = String::Handle(String::NewSymbol("dart:mirrors")); 5357 const String& url = String::Handle(String::NewSymbol("dart:mirrors"));
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
5447 RawLibrary* Library::CoreLibrary() { 5463 RawLibrary* Library::CoreLibrary() {
5448 return Isolate::Current()->object_store()->core_library(); 5464 return Isolate::Current()->object_store()->core_library();
5449 } 5465 }
5450 5466
5451 5467
5452 RawLibrary* Library::CoreImplLibrary() { 5468 RawLibrary* Library::CoreImplLibrary() {
5453 return Isolate::Current()->object_store()->core_impl_library(); 5469 return Isolate::Current()->object_store()->core_impl_library();
5454 } 5470 }
5455 5471
5456 5472
5473 RawLibrary* Library::MathLibrary() {
5474 return Isolate::Current()->object_store()->math_library();
5475 }
5476
5477
5457 RawLibrary* Library::IsolateLibrary() { 5478 RawLibrary* Library::IsolateLibrary() {
5458 return Isolate::Current()->object_store()->isolate_library(); 5479 return Isolate::Current()->object_store()->isolate_library();
5459 } 5480 }
5460 5481
5461 5482
5462 RawLibrary* Library::MirrorsLibrary() { 5483 RawLibrary* Library::MirrorsLibrary() {
5463 return Isolate::Current()->object_store()->mirrors_library(); 5484 return Isolate::Current()->object_store()->mirrors_library();
5464 } 5485 }
5465 5486
5466 5487
(...skipping 4453 matching lines...) Expand 10 before | Expand all | Expand 10 after
9920 const String& str = String::Handle(pattern()); 9941 const String& str = String::Handle(pattern());
9921 const char* format = "JSRegExp: pattern=%s flags=%s"; 9942 const char* format = "JSRegExp: pattern=%s flags=%s";
9922 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 9943 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
9923 char* chars = reinterpret_cast<char*>( 9944 char* chars = reinterpret_cast<char*>(
9924 Isolate::Current()->current_zone()->Allocate(len + 1)); 9945 Isolate::Current()->current_zone()->Allocate(len + 1));
9925 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 9946 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
9926 return chars; 9947 return chars;
9927 } 9948 }
9928 9949
9929 } // namespace dart 9950 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698