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

Side by Side Diff: vm/dart_api_impl.cc

Issue 11087070: - Get rid of RawClosure class and use RawInstance for closures. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 2 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 | « vm/code_generator.cc ('k') | vm/dart_entry.h » ('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 "include/dart_api.h" 5 #include "include/dart_api.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/dart.h" 10 #include "vm/dart.h"
(...skipping 2366 matching lines...) Expand 10 before | Expand all | Expand 10 after
2377 2377
2378 2378
2379 // --- Closures --- 2379 // --- Closures ---
2380 2380
2381 2381
2382 DART_EXPORT bool Dart_IsClosure(Dart_Handle object) { 2382 DART_EXPORT bool Dart_IsClosure(Dart_Handle object) {
2383 // We can't use a fast class index check here because there are many 2383 // We can't use a fast class index check here because there are many
2384 // different signature classes for closures. 2384 // different signature classes for closures.
2385 Isolate* isolate = Isolate::Current(); 2385 Isolate* isolate = Isolate::Current();
2386 DARTSCOPE(isolate); 2386 DARTSCOPE(isolate);
2387 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object)); 2387 const Instance& closure_obj = Api::UnwrapInstanceHandle(isolate, object);
2388 return obj.IsClosure(); 2388 return (!closure_obj.IsNull() && closure_obj.IsClosure());
2389 } 2389 }
2390 2390
2391 2391
2392 DART_EXPORT Dart_Handle Dart_ClosureFunction(Dart_Handle closure) { 2392 DART_EXPORT Dart_Handle Dart_ClosureFunction(Dart_Handle closure) {
2393 Isolate* isolate = Isolate::Current(); 2393 Isolate* isolate = Isolate::Current();
2394 DARTSCOPE(isolate); 2394 DARTSCOPE(isolate);
2395 const Closure& closure_obj = Api::UnwrapClosureHandle(isolate, closure); 2395 const Instance& closure_obj = Api::UnwrapInstanceHandle(isolate, closure);
2396 if (closure_obj.IsNull()) { 2396 if (closure_obj.IsNull() || !closure_obj.IsClosure()) {
2397 RETURN_TYPE_ERROR(isolate, closure, Closure); 2397 RETURN_TYPE_ERROR(isolate, closure, Instance);
2398 } 2398 }
2399
2399 ASSERT(ClassFinalizer::AllClassesFinalized()); 2400 ASSERT(ClassFinalizer::AllClassesFinalized());
2400 2401
2401 RawFunction* rf = closure_obj.function(); 2402 RawFunction* rf = Closure::function(closure_obj);
2402 return Api::NewHandle(isolate, rf); 2403 return Api::NewHandle(isolate, rf);
2403 } 2404 }
2404 2405
2405 2406
2406 DART_EXPORT Dart_Handle Dart_InvokeClosure(Dart_Handle closure, 2407 DART_EXPORT Dart_Handle Dart_InvokeClosure(Dart_Handle closure,
2407 int number_of_arguments, 2408 int number_of_arguments,
2408 Dart_Handle* arguments) { 2409 Dart_Handle* arguments) {
2409 Isolate* isolate = Isolate::Current(); 2410 Isolate* isolate = Isolate::Current();
2410 DARTSCOPE(isolate); 2411 DARTSCOPE(isolate);
2411 const Closure& closure_obj = Api::UnwrapClosureHandle(isolate, closure); 2412 const Instance& closure_obj = Api::UnwrapInstanceHandle(isolate, closure);
2412 if (closure_obj.IsNull()) { 2413 if (closure_obj.IsNull() || !closure_obj.IsClosure()) {
2413 RETURN_TYPE_ERROR(isolate, closure, Closure); 2414 RETURN_TYPE_ERROR(isolate, closure, Instance);
2414 } 2415 }
2415 if (number_of_arguments < 0) { 2416 if (number_of_arguments < 0) {
2416 return Api::NewError( 2417 return Api::NewError(
2417 "%s expects argument 'number_of_arguments' to be non-negative.", 2418 "%s expects argument 'number_of_arguments' to be non-negative.",
2418 CURRENT_FUNC); 2419 CURRENT_FUNC);
2419 } 2420 }
2420 ASSERT(ClassFinalizer::AllClassesFinalized()); 2421 ASSERT(ClassFinalizer::AllClassesFinalized());
2421 2422
2422 // Now try to invoke the closure. 2423 // Now try to invoke the closure.
2423 GrowableArray<const Object*> dart_arguments(number_of_arguments); 2424 GrowableArray<const Object*> dart_arguments(number_of_arguments);
(...skipping 2052 matching lines...) Expand 10 before | Expand all | Expand 10 after
4476 } 4477 }
4477 { 4478 {
4478 NoGCScope no_gc; 4479 NoGCScope no_gc;
4479 RawObject* raw_obj = obj.raw(); 4480 RawObject* raw_obj = obj.raw();
4480 isolate->heap()->SetPeer(raw_obj, peer); 4481 isolate->heap()->SetPeer(raw_obj, peer);
4481 } 4482 }
4482 return Api::Success(isolate); 4483 return Api::Success(isolate);
4483 } 4484 }
4484 4485
4485 } // namespace dart 4486 } // namespace dart
OLDNEW
« no previous file with comments | « vm/code_generator.cc ('k') | vm/dart_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698