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

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

Issue 196953007: Fix LibraryMirror.invoke to call through the contents of an implicit getter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: split multitest for easier marking of dart2js partial failures Created 6 years, 9 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
« no previous file with comments | « no previous file | tests/lib/lib.status » ('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/invocation_mirror.h" 5 #include "lib/invocation_mirror.h"
6 #include "vm/bootstrap_natives.h" 6 #include "vm/bootstrap_natives.h"
7 #include "vm/class_finalizer.h" 7 #include "vm/class_finalizer.h"
8 #include "vm/compiler.h" 8 #include "vm/compiler.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/exceptions.h" 10 #include "vm/exceptions.h"
(...skipping 1958 matching lines...) Expand 10 before | Expand all | Expand 10 after
1969 GET_NON_NULL_NATIVE_ARGUMENT( 1969 GET_NON_NULL_NATIVE_ARGUMENT(
1970 String, function_name, arguments->NativeArgAt(2)); 1970 String, function_name, arguments->NativeArgAt(2));
1971 GET_NON_NULL_NATIVE_ARGUMENT(Array, args, arguments->NativeArgAt(3)); 1971 GET_NON_NULL_NATIVE_ARGUMENT(Array, args, arguments->NativeArgAt(3));
1972 GET_NON_NULL_NATIVE_ARGUMENT(Array, arg_names, arguments->NativeArgAt(4)); 1972 GET_NON_NULL_NATIVE_ARGUMENT(Array, arg_names, arguments->NativeArgAt(4));
1973 1973
1974 Function& function = Function::Handle( 1974 Function& function = Function::Handle(
1975 library.LookupLocalFunction(function_name)); 1975 library.LookupLocalFunction(function_name));
1976 1976
1977 if (function.IsNull()) { 1977 if (function.IsNull()) {
1978 // Didn't find a method: try to find a getter and invoke call on its result. 1978 // Didn't find a method: try to find a getter and invoke call on its result.
1979 const String& getter_name = 1979 const Instance& getter_result =
1980 String::Handle(Field::GetterName(function_name)); 1980 Instance::Handle(InvokeLibraryGetter(library, function_name, true));
1981 function = library.LookupLocalFunction(getter_name); 1981 // Make room for the closure (receiver) in arguments.
1982 if (!function.IsNull()) { 1982 intptr_t numArgs = args.Length();
1983 // Invoke getter. 1983 const Array& call_args = Array::Handle(Array::New(numArgs + 1));
1984 const Object& getter_result = Object::Handle( 1984 Object& temp = Object::Handle();
1985 DartEntry::InvokeFunction(function, Object::empty_array())); 1985 for (int i = 0; i < numArgs; i++) {
1986 if (getter_result.IsError()) { 1986 temp = args.At(i);
1987 ThrowInvokeError(Error::Cast(getter_result)); 1987 call_args.SetAt(i + 1, temp);
1988 UNREACHABLE();
1989 }
1990 // Make room for the closure (receiver) in arguments.
1991 intptr_t numArgs = args.Length();
1992 const Array& call_args = Array::Handle(Array::New(numArgs + 1));
1993 Object& temp = Object::Handle();
1994 for (int i = 0; i < numArgs; i++) {
1995 temp = args.At(i);
1996 call_args.SetAt(i + 1, temp);
1997 }
1998 call_args.SetAt(0, getter_result);
1999 const Array& call_args_descriptor_array =
2000 Array::Handle(ArgumentsDescriptor::New(call_args.Length(), arg_names));
2001 // Call closure.
2002 const Object& call_result = Object::Handle(
2003 DartEntry::InvokeClosure(call_args, call_args_descriptor_array));
2004 if (call_result.IsError()) {
2005 ThrowInvokeError(Error::Cast(call_result));
2006 UNREACHABLE();
2007 }
2008 return call_result.raw();
2009 } 1988 }
1989 call_args.SetAt(0, getter_result);
1990 const Array& call_args_descriptor_array =
1991 Array::Handle(ArgumentsDescriptor::New(call_args.Length(), arg_names));
1992 // Call closure.
1993 const Object& call_result = Object::Handle(
1994 DartEntry::InvokeClosure(call_args, call_args_descriptor_array));
1995 if (call_result.IsError()) {
1996 ThrowInvokeError(Error::Cast(call_result));
1997 UNREACHABLE();
1998 }
1999 return call_result.raw();
2010 } 2000 }
2011 2001
2012 const Array& args_descriptor_array = 2002 const Array& args_descriptor_array =
2013 Array::Handle(ArgumentsDescriptor::New(args.Length(), arg_names)); 2003 Array::Handle(ArgumentsDescriptor::New(args.Length(), arg_names));
2014 ArgumentsDescriptor args_descriptor(args_descriptor_array); 2004 ArgumentsDescriptor args_descriptor(args_descriptor_array);
2015 2005
2016 if (function.IsNull() || 2006 if (function.IsNull() ||
2017 !function.AreValidArguments(args_descriptor, NULL) || 2007 !function.AreValidArguments(args_descriptor, NULL) ||
2018 !function.is_visible()) { 2008 !function.is_visible()) {
2019 ThrowNoSuchMethod(Instance::null_instance(), 2009 ThrowNoSuchMethod(Instance::null_instance(),
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
2222 } 2212 }
2223 2213
2224 DEFINE_NATIVE_ENTRY(TypeMirror_moreSpecificTest, 2) { 2214 DEFINE_NATIVE_ENTRY(TypeMirror_moreSpecificTest, 2) {
2225 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0)); 2215 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0));
2226 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1)); 2216 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1));
2227 return Bool::Get(a.IsMoreSpecificThan(b, NULL)).raw(); 2217 return Bool::Get(a.IsMoreSpecificThan(b, NULL)).raw();
2228 } 2218 }
2229 2219
2230 2220
2231 } // namespace dart 2221 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/lib/lib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698