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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 7858)
+++ runtime/vm/object.cc (working copy)
@@ -781,9 +781,17 @@
if (!error.IsNull()) {
return error.raw();
}
+ const Script& math_script = Script::Handle(Bootstrap::LoadMathScript());
+ Library::InitMathLibrary(isolate);
+ const Library& math_lib = Library::Handle(Library::MathLibrary());
+ ASSERT(!math_lib.IsNull());
+ error = Bootstrap::Compile(math_lib, math_script);
+ if (!error.IsNull()) {
+ return error.raw();
+ }
const Script& isolate_script = Script::Handle(Bootstrap::LoadIsolateScript());
Library::InitIsolateLibrary(isolate);
- Library& isolate_lib = Library::Handle(Library::IsolateLibrary());
+ const Library& isolate_lib = Library::Handle(Library::IsolateLibrary());
ASSERT(!isolate_lib.IsNull());
error = Bootstrap::Compile(isolate_lib, isolate_script);
if (!error.IsNull()) {
@@ -791,7 +799,7 @@
}
const Script& mirrors_script = Script::Handle(Bootstrap::LoadMirrorsScript());
Library::InitMirrorsLibrary(isolate);
- Library& mirrors_lib = Library::Handle(Library::MirrorsLibrary());
+ const Library& mirrors_lib = Library::Handle(Library::MirrorsLibrary());
ASSERT(!mirrors_lib.IsNull());
error = Bootstrap::Compile(mirrors_lib, mirrors_script);
if (!error.IsNull()) {
@@ -5361,6 +5369,16 @@
}
+void Library::InitMathLibrary(Isolate* isolate) {
+ const String& url = String::Handle(String::NewSymbol("dart:math"));
+ const Library& lib = Library::Handle(Library::New(url));
+ lib.Register();
+ const Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary());
+ lib.AddImport(core_impl_lib);
+ isolate->object_store()->set_math_library(lib);
+}
+
+
void Library::InitIsolateLibrary(Isolate* isolate) {
const String& url = String::Handle(String::NewSymbol("dart:isolate"));
const Library& lib = Library::Handle(Library::New(url));
@@ -5486,6 +5504,11 @@
}
+RawLibrary* Library::MathLibrary() {
+ return Isolate::Current()->object_store()->math_library();
+}
+
+
RawLibrary* Library::IsolateLibrary() {
return Isolate::Current()->object_store()->isolate_library();
}
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_store.h » ('j') | tests/lib/lib.status » ('J')

Powered by Google App Engine
This is Rietveld 408576698