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

Side by Side Diff: runtime/lib/mirrors.cc

Issue 1569213003: Eliminate phase parameter in constructors (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « no previous file | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "lib/mirrors.h" 5 #include "lib/mirrors.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/bootstrap_natives.h" 8 #include "vm/bootstrap_natives.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 1708 matching lines...) Expand 10 before | Expand all | Expand 10 after
1719 1719
1720 type = redirect_type.raw(); 1720 type = redirect_type.raw();
1721 type_arguments = redirect_type.arguments(); 1721 type_arguments = redirect_type.arguments();
1722 1722
1723 redirected_constructor = lookup_constructor.RedirectionTarget(); 1723 redirected_constructor = lookup_constructor.RedirectionTarget();
1724 ASSERT(!redirected_constructor.IsNull()); 1724 ASSERT(!redirected_constructor.IsNull());
1725 redirected_klass = type.type_class(); 1725 redirected_klass = type.type_class();
1726 } 1726 }
1727 1727
1728 const intptr_t num_explicit_args = explicit_args.Length(); 1728 const intptr_t num_explicit_args = explicit_args.Length();
1729 const intptr_t num_implicit_args = 1729 const intptr_t num_implicit_args = 1;
1730 redirected_constructor.IsGenerativeConstructor() ? 2 : 1;
1731 const Array& args = 1730 const Array& args =
1732 Array::Handle(Array::New(num_implicit_args + num_explicit_args)); 1731 Array::Handle(Array::New(num_implicit_args + num_explicit_args));
1733 1732
1734 // Copy over the explicit arguments. 1733 // Copy over the explicit arguments.
1735 Object& explicit_argument = Object::Handle(); 1734 Object& explicit_argument = Object::Handle();
1736 for (int i = 0; i < num_explicit_args; i++) { 1735 for (int i = 0; i < num_explicit_args; i++) {
1737 explicit_argument = explicit_args.At(i); 1736 explicit_argument = explicit_args.At(i);
1738 args.SetAt(i + num_implicit_args, explicit_argument); 1737 args.SetAt(i + num_implicit_args, explicit_argument);
1739 } 1738 }
1740 1739
(...skipping 10 matching lines...) Expand all
1751 redirected_constructor, 1750 redirected_constructor,
1752 explicit_args, 1751 explicit_args,
1753 arg_names, 1752 arg_names,
1754 InvocationMirror::kConstructor, 1753 InvocationMirror::kConstructor,
1755 InvocationMirror::kMethod); 1754 InvocationMirror::kMethod);
1756 UNREACHABLE(); 1755 UNREACHABLE();
1757 } 1756 }
1758 1757
1759 Instance& new_object = Instance::Handle(); 1758 Instance& new_object = Instance::Handle();
1760 if (redirected_constructor.IsGenerativeConstructor()) { 1759 if (redirected_constructor.IsGenerativeConstructor()) {
1761 // Constructors get the uninitialized object and a constructor phase. Note 1760 // Constructors get the uninitialized object.
1762 // we have delayed allocation until after the function type and argument 1761 // Note we have delayed allocation until after the function
1763 // matching checks. 1762 // type and argument matching checks.
1764 new_object = Instance::New(redirected_klass); 1763 new_object = Instance::New(redirected_klass);
1765 if (!type_arguments.IsNull()) { 1764 if (!type_arguments.IsNull()) {
1766 // The type arguments will be null if the class has no type parameters, in 1765 // The type arguments will be null if the class has no type parameters, in
1767 // which case the following call would fail because there is no slot 1766 // which case the following call would fail because there is no slot
1768 // reserved in the object for the type vector. 1767 // reserved in the object for the type vector.
1769 new_object.SetTypeArguments(type_arguments); 1768 new_object.SetTypeArguments(type_arguments);
1770 } 1769 }
1771 args.SetAt(0, new_object); 1770 args.SetAt(0, new_object);
1772 args.SetAt(1, Smi::Handle(Smi::New(Function::kCtorPhaseAll)));
1773 } else { 1771 } else {
1774 // Factories get type arguments. 1772 // Factories get type arguments.
1775 args.SetAt(0, type_arguments); 1773 args.SetAt(0, type_arguments);
1776 } 1774 }
1777 1775
1778 // Invoke the constructor and return the new object. 1776 // Invoke the constructor and return the new object.
1779 const Object& result = 1777 const Object& result =
1780 Object::Handle(DartEntry::InvokeFunction(redirected_constructor, 1778 Object::Handle(DartEntry::InvokeFunction(redirected_constructor,
1781 args, 1779 args,
1782 args_descriptor_array)); 1780 args_descriptor_array));
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
2111 } 2109 }
2112 2110
2113 DEFINE_NATIVE_ENTRY(TypeMirror_subtypeTest, 2) { 2111 DEFINE_NATIVE_ENTRY(TypeMirror_subtypeTest, 2) {
2114 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0)); 2112 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0));
2115 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1)); 2113 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1));
2116 return Bool::Get(a.IsSubtypeOf(b, NULL)).raw(); 2114 return Bool::Get(a.IsSubtypeOf(b, NULL)).raw();
2117 } 2115 }
2118 2116
2119 2117
2120 } // namespace dart 2118 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698