OLD | NEW |
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 "vm/object.h" | 5 #include "vm/object.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
10 #include "vm/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
(...skipping 8489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8500 IntPtrArray::Cast(native_fields).SetAt(index, value); | 8500 IntPtrArray::Cast(native_fields).SetAt(index, value); |
8501 } | 8501 } |
8502 | 8502 |
8503 | 8503 |
8504 bool Instance::IsClosure() const { | 8504 bool Instance::IsClosure() const { |
8505 const Class& cls = Class::Handle(clazz()); | 8505 const Class& cls = Class::Handle(clazz()); |
8506 return cls.IsSignatureClass(); | 8506 return cls.IsSignatureClass(); |
8507 } | 8507 } |
8508 | 8508 |
8509 | 8509 |
| 8510 bool Instance::IsCallable(Function* function, Context* context) const { |
| 8511 Class& cls = Class::Handle(clazz()); |
| 8512 if (cls.IsSignatureClass()) { |
| 8513 if (function != NULL) { |
| 8514 *function = Closure::function(*this); |
| 8515 } |
| 8516 if (context != NULL) { |
| 8517 *context = Closure::context(*this); |
| 8518 } |
| 8519 return true; |
| 8520 } |
| 8521 // Try to resolve a "call" method. |
| 8522 const String& call_symbol = String::Handle(Symbols::Call()); |
| 8523 Function& call_function = Function::Handle(); |
| 8524 do { |
| 8525 call_function = cls.LookupDynamicFunction(call_symbol); |
| 8526 if (!call_function.IsNull()) { |
| 8527 if (function != NULL) { |
| 8528 *function = call_function.raw(); |
| 8529 } |
| 8530 if (context != NULL) { |
| 8531 *context = Isolate::Current()->object_store()->empty_context(); |
| 8532 } |
| 8533 return true; |
| 8534 } |
| 8535 cls = cls.SuperClass(); |
| 8536 } while (!cls.IsNull()); |
| 8537 return false; |
| 8538 } |
| 8539 |
| 8540 |
8510 RawInstance* Instance::New(const Class& cls, Heap::Space space) { | 8541 RawInstance* Instance::New(const Class& cls, Heap::Space space) { |
8511 Instance& result = Instance::Handle(); | 8542 Instance& result = Instance::Handle(); |
8512 { | 8543 { |
8513 intptr_t instance_size = cls.instance_size(); | 8544 intptr_t instance_size = cls.instance_size(); |
8514 ASSERT(instance_size > 0); | 8545 ASSERT(instance_size > 0); |
8515 RawObject* raw = Object::Allocate(cls.id(), instance_size, space); | 8546 RawObject* raw = Object::Allocate(cls.id(), instance_size, space); |
8516 NoGCScope no_gc; | 8547 NoGCScope no_gc; |
8517 result ^= raw; | 8548 result ^= raw; |
8518 } | 8549 } |
8519 return result.raw(); | 8550 return result.raw(); |
(...skipping 3930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12450 } | 12481 } |
12451 return result.raw(); | 12482 return result.raw(); |
12452 } | 12483 } |
12453 | 12484 |
12454 | 12485 |
12455 const char* WeakProperty::ToCString() const { | 12486 const char* WeakProperty::ToCString() const { |
12456 return "_WeakProperty"; | 12487 return "_WeakProperty"; |
12457 } | 12488 } |
12458 | 12489 |
12459 } // namespace dart | 12490 } // namespace dart |
OLD | NEW |