| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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/bootstrap_natives.h" | 5 #include "vm/bootstrap_natives.h" |
| 6 | 6 |
| 7 #include "vm/exceptions.h" | 7 #include "vm/exceptions.h" |
| 8 #include "vm/heap.h" |
| 8 #include "vm/native_entry.h" | 9 #include "vm/native_entry.h" |
| 9 #include "vm/object.h" | 10 #include "vm/object.h" |
| 10 #include "vm/stack_frame.h" | 11 #include "vm/stack_frame.h" |
| 11 #include "vm/symbols.h" | 12 #include "vm/symbols.h" |
| 12 | 13 |
| 13 namespace dart { | 14 namespace dart { |
| 14 | 15 |
| 15 DECLARE_FLAG(bool, enable_type_checks); | 16 DECLARE_FLAG(bool, enable_type_checks); |
| 16 | 17 |
| 17 | 18 |
| 18 DEFINE_NATIVE_ENTRY(Object_cid, 1) { | 19 DEFINE_NATIVE_ENTRY(Object_cid, 1) { |
| 19 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0)); | 20 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0)); |
| 20 return Smi::New(instance.GetClassId()); | 21 return Smi::New(instance.GetClassId()); |
| 21 } | 22 } |
| 22 | 23 |
| 23 | 24 |
| 25 DEFINE_NATIVE_ENTRY(Object_getHash, 1) { |
| 26 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0)); |
| 27 Heap* heap = isolate->heap(); |
| 28 return Smi::New(heap->GetHash(instance.raw())); |
| 29 } |
| 30 |
| 31 |
| 32 DEFINE_NATIVE_ENTRY(Object_setHash, 2) { |
| 33 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0)); |
| 34 GET_NON_NULL_NATIVE_ARGUMENT(Smi, hash, arguments->NativeArgAt(1)); |
| 35 Heap* heap = isolate->heap(); |
| 36 heap->SetHash(instance.raw(), hash.Value()); |
| 37 return Object::null(); |
| 38 } |
| 39 |
| 40 |
| 24 DEFINE_NATIVE_ENTRY(Object_toString, 1) { | 41 DEFINE_NATIVE_ENTRY(Object_toString, 1) { |
| 25 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0)); | 42 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0)); |
| 26 const char* c_str = instance.ToCString(); | 43 const char* c_str = instance.ToCString(); |
| 27 return String::New(c_str); | 44 return String::New(c_str); |
| 28 } | 45 } |
| 29 | 46 |
| 30 | 47 |
| 31 DEFINE_NATIVE_ENTRY(Object_noSuchMethod, 6) { | 48 DEFINE_NATIVE_ENTRY(Object_noSuchMethod, 6) { |
| 32 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0)); | 49 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0)); |
| 33 GET_NON_NULL_NATIVE_ARGUMENT(Bool, is_method, arguments->NativeArgAt(1)); | 50 GET_NON_NULL_NATIVE_ARGUMENT(Bool, is_method, arguments->NativeArgAt(1)); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 } | 189 } |
| 173 | 190 |
| 174 | 191 |
| 175 DEFINE_NATIVE_ENTRY(AbstractType_toString, 1) { | 192 DEFINE_NATIVE_ENTRY(AbstractType_toString, 1) { |
| 176 const AbstractType& type = | 193 const AbstractType& type = |
| 177 AbstractType::CheckedHandle(arguments->NativeArgAt(0)); | 194 AbstractType::CheckedHandle(arguments->NativeArgAt(0)); |
| 178 return type.UserVisibleName(); | 195 return type.UserVisibleName(); |
| 179 } | 196 } |
| 180 | 197 |
| 181 } // namespace dart | 198 } // namespace dart |
| OLD | NEW |