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

Unified Diff: runtime/vm/dart_entry.cc

Issue 2005723004: Fraction class prototype and test (not to be committed). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: work in progress Created 4 years, 5 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
« no previous file with comments | « runtime/vm/dart_entry.h ('k') | runtime/vm/exceptions.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_entry.cc
diff --git a/runtime/vm/dart_entry.cc b/runtime/vm/dart_entry.cc
index c9e7769fba4a0b47400b6ee8dfcaf4302c9ab65f..e2327fff9f610e3d6b37b49bd8177d1d88fe9c84 100644
--- a/runtime/vm/dart_entry.cc
+++ b/runtime/vm/dart_entry.cc
@@ -425,15 +425,22 @@ void ArgumentsDescriptor::InitOnce() {
RawObject* DartLibraryCalls::InstanceCreate(const Library& lib,
const String& class_name,
const String& constructor_name,
+ bool factory,
const Array& arguments) {
const Class& cls = Class::Handle(lib.LookupClassAllowPrivate(class_name));
+ // Class may not be finalized yet, but will be as the constructor is compiled.
ASSERT(!cls.IsNull());
// For now, we only support a non-parameterized or raw type.
- const int kNumExtraArgs = 1; // implicit rcvr arg.
- const Instance& exception_object = Instance::Handle(Instance::New(cls));
+ const int kNumExtraArgs = 1; // Implicit rcvr arg or empty factory type args.
+ Instance& exception_object = Instance::Handle();
const Array& constructor_arguments =
Array::Handle(Array::New(arguments.Length() + kNumExtraArgs));
- constructor_arguments.SetAt(0, exception_object);
+ if (factory) {
+ constructor_arguments.SetAt(0, TypeArguments::Handle());
+ } else {
+ exception_object = Instance::New(cls);
+ constructor_arguments.SetAt(0, exception_object);
+ }
Object& obj = Object::Handle();
for (intptr_t i = 0; i < arguments.Length(); i++) {
obj = arguments.At(i);
@@ -443,13 +450,14 @@ RawObject* DartLibraryCalls::InstanceCreate(const Library& lib,
const String& function_name = String::Handle(
String::Concat(class_name, constructor_name));
const Function& constructor =
- Function::Handle(cls.LookupConstructorAllowPrivate(function_name));
+ Function::Handle(factory ?
+ cls.LookupFactoryAllowPrivate(function_name) :
+ cls.LookupConstructorAllowPrivate(function_name));
ASSERT(!constructor.IsNull());
const Object& retval =
Object::Handle(DartEntry::InvokeFunction(constructor,
constructor_arguments));
- ASSERT(retval.IsNull() || retval.IsError());
- if (retval.IsError()) {
+ if (factory || retval.IsError()) {
return retval.raw();
}
return exception_object.raw();
« no previous file with comments | « runtime/vm/dart_entry.h ('k') | runtime/vm/exceptions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698