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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 11293290: Fix native argument handling (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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/compiler.cc ('k') | runtime/vm/exceptions_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl.cc
===================================================================
--- runtime/vm/dart_api_impl.cc (revision 14922)
+++ runtime/vm/dart_api_impl.cc (working copy)
@@ -3939,39 +3939,18 @@
DART_EXPORT Dart_Handle Dart_GetNativeArgument(Dart_NativeArguments args,
int index) {
NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
- const int apparent_count = Dart_GetNativeArgumentCount(args);
- if ((index < 0) || (index >= apparent_count)) {
+ if ((index < 0) || (index >= arguments->NativeArgCount())) {
return Api::NewError(
"%s: argument 'index' out of range. Expected 0..%d but saw %d.",
- CURRENT_FUNC, apparent_count - 1, index);
+ CURRENT_FUNC, arguments->NativeArgCount() - 1, index);
}
- // Hide closure object if present.
- index += arguments->Count() - apparent_count;
-
- Isolate* isolate = arguments->isolate();
- CHECK_ISOLATE(isolate);
- if (index == 0) {
- if (arguments->ToInstanceFunction() && arguments->ToClosureFunction()) {
- // Retrieve the receiver from the context.
- const Context& context = Context::Handle(isolate->top_context());
- return Api::NewHandle(isolate, context.At(0));
- }
- }
- return Api::NewHandle(isolate, arguments->At(index));
+ return Api::NewHandle(arguments->isolate(), arguments->NativeArgAt(index));
}
DART_EXPORT int Dart_GetNativeArgumentCount(Dart_NativeArguments args) {
NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
- int count = arguments->Count();
- // In the instance closure function case, the receiver is accessed from
- // the context and the closure at index 0 is hidden, so the apparent
- // argument count remains unchanged.
- if (arguments->ToClosureFunction() && !arguments->ToInstanceFunction()) {
- // The closure at index 0 is hidden and therefore not counted.
- count--;
- }
- return count;
+ return arguments->NativeArgCount();
}
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/exceptions_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698