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/cpu.h" | 10 #include "vm/cpu.h" |
(...skipping 13074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13085 if (native_fields.IsNull()) { | 13085 if (native_fields.IsNull()) { |
13086 // Allocate backing storage for the native fields. | 13086 // Allocate backing storage for the native fields. |
13087 native_fields = TypedData::New(kIntPtrCid, NumNativeFields()); | 13087 native_fields = TypedData::New(kIntPtrCid, NumNativeFields()); |
13088 StorePointer(NativeFieldsAddr(), native_fields.raw()); | 13088 StorePointer(NativeFieldsAddr(), native_fields.raw()); |
13089 } | 13089 } |
13090 intptr_t byte_offset = index * sizeof(intptr_t); | 13090 intptr_t byte_offset = index * sizeof(intptr_t); |
13091 TypedData::Cast(native_fields).SetIntPtr(byte_offset, value); | 13091 TypedData::Cast(native_fields).SetIntPtr(byte_offset, value); |
13092 } | 13092 } |
13093 | 13093 |
13094 | 13094 |
| 13095 void Instance::SetNativeFields(uint16_t num_native_fields, |
| 13096 const intptr_t* field_values) const { |
| 13097 ASSERT(num_native_fields == NumNativeFields()); |
| 13098 ASSERT(field_values != NULL); |
| 13099 Object& native_fields = Object::Handle(*NativeFieldsAddr()); |
| 13100 if (native_fields.IsNull()) { |
| 13101 // Allocate backing storage for the native fields. |
| 13102 native_fields = TypedData::New(kIntPtrCid, NumNativeFields()); |
| 13103 StorePointer(NativeFieldsAddr(), native_fields.raw()); |
| 13104 } |
| 13105 for (uint16_t i = 0; i < num_native_fields; i++) { |
| 13106 intptr_t byte_offset = i * sizeof(intptr_t); |
| 13107 TypedData::Cast(native_fields).SetIntPtr(byte_offset, field_values[i]); |
| 13108 } |
| 13109 } |
| 13110 |
| 13111 |
13095 bool Instance::IsClosure() const { | 13112 bool Instance::IsClosure() const { |
13096 const Class& cls = Class::Handle(clazz()); | 13113 const Class& cls = Class::Handle(clazz()); |
13097 return cls.IsSignatureClass(); | 13114 return cls.IsSignatureClass(); |
13098 } | 13115 } |
13099 | 13116 |
13100 | 13117 |
13101 bool Instance::IsCallable(Function* function, Context* context) const { | 13118 bool Instance::IsCallable(Function* function, Context* context) const { |
13102 Class& cls = Class::Handle(clazz()); | 13119 Class& cls = Class::Handle(clazz()); |
13103 if (cls.IsSignatureClass()) { | 13120 if (cls.IsSignatureClass()) { |
13104 if (function != NULL) { | 13121 if (function != NULL) { |
(...skipping 5926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19031 return tag_label.ToCString(); | 19048 return tag_label.ToCString(); |
19032 } | 19049 } |
19033 | 19050 |
19034 | 19051 |
19035 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 19052 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
19036 Instance::PrintJSONImpl(stream, ref); | 19053 Instance::PrintJSONImpl(stream, ref); |
19037 } | 19054 } |
19038 | 19055 |
19039 | 19056 |
19040 } // namespace dart | 19057 } // namespace dart |
OLD | NEW |