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/dart_api_message.h" | 5 #include "vm/dart_api_message.h" |
6 #include "vm/object.h" | 6 #include "vm/object.h" |
7 #include "vm/object_store.h" | 7 #include "vm/object_store.h" |
8 | 8 |
9 namespace dart { | 9 namespace dart { |
10 | 10 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 } | 74 } |
75 | 75 |
76 | 76 |
77 Dart_CObject* ApiMessageReader::AllocateDartCObjectInt32(int32_t val) { | 77 Dart_CObject* ApiMessageReader::AllocateDartCObjectInt32(int32_t val) { |
78 Dart_CObject* value = AllocateDartCObject(Dart_CObject::kInt32); | 78 Dart_CObject* value = AllocateDartCObject(Dart_CObject::kInt32); |
79 value->value.as_int32 = val; | 79 value->value.as_int32 = val; |
80 return value; | 80 return value; |
81 } | 81 } |
82 | 82 |
83 | 83 |
| 84 Dart_CObject* ApiMessageReader::AllocateDartCObjectInt64(int64_t val) { |
| 85 Dart_CObject* value = AllocateDartCObject(Dart_CObject::kInt64); |
| 86 value->value.as_int64 = val; |
| 87 return value; |
| 88 } |
| 89 |
| 90 |
84 Dart_CObject* ApiMessageReader::AllocateDartCObjectDouble(double val) { | 91 Dart_CObject* ApiMessageReader::AllocateDartCObjectDouble(double val) { |
85 Dart_CObject* value = AllocateDartCObject(Dart_CObject::kDouble); | 92 Dart_CObject* value = AllocateDartCObject(Dart_CObject::kDouble); |
86 value->value.as_double = val; | 93 value->value.as_double = val; |
87 return value; | 94 return value; |
88 } | 95 } |
89 | 96 |
90 | 97 |
91 Dart_CObject* ApiMessageReader::AllocateDartCObjectString(intptr_t length) { | 98 Dart_CObject* ApiMessageReader::AllocateDartCObjectString(intptr_t length) { |
92 // Allocate a Dart_CObject structure followed by an array of chars | 99 // Allocate a Dart_CObject structure followed by an array of chars |
93 // for the string content. The pointer to the string content is set | 100 // for the string content. The pointer to the string content is set |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 if (type_arguments != &type_arguments_marker && | 190 if (type_arguments != &type_arguments_marker && |
184 type_arguments->type != Dart_CObject::kNull) { | 191 type_arguments->type != Dart_CObject::kNull) { |
185 return NULL; | 192 return NULL; |
186 } | 193 } |
187 for (int i = 0; i < len; i++) { | 194 for (int i = 0; i < len; i++) { |
188 value->value.as_array.values[i] = ReadObject(); | 195 value->value.as_array.values[i] = ReadObject(); |
189 } | 196 } |
190 return value; | 197 return value; |
191 break; | 198 break; |
192 } | 199 } |
| 200 case ObjectStore::kMintClass: { |
| 201 int64_t value = Read<int64_t>(); |
| 202 if (kMinInt32 <= value && value <= kMaxInt32) { |
| 203 return AllocateDartCObjectInt32(value); |
| 204 } else { |
| 205 return AllocateDartCObjectInt64(value); |
| 206 } |
| 207 break; |
| 208 } |
193 case ObjectStore::kDoubleClass: { | 209 case ObjectStore::kDoubleClass: { |
194 // Read the double value for the object. | 210 // Read the double value for the object. |
195 Dart_CObject* object = AllocateDartCObjectDouble(Read<double>()); | 211 Dart_CObject* object = AllocateDartCObjectDouble(Read<double>()); |
196 AddBackwardReference(object_id, object); | 212 AddBackwardReference(object_id, object); |
197 return object; | 213 return object; |
198 break; | 214 break; |
199 } | 215 } |
200 case ObjectStore::kOneByteStringClass: { | 216 case ObjectStore::kOneByteStringClass: { |
201 intptr_t len = ReadSmiValue(); | 217 intptr_t len = ReadSmiValue(); |
202 intptr_t hash = ReadSmiValue(); | 218 intptr_t hash = ReadSmiValue(); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 return ReadObjectImpl(value); | 302 return ReadObjectImpl(value); |
287 } | 303 } |
288 | 304 |
289 | 305 |
290 void ApiMessageReader::AddBackwardReference(intptr_t id, Dart_CObject* obj) { | 306 void ApiMessageReader::AddBackwardReference(intptr_t id, Dart_CObject* obj) { |
291 ASSERT((id - kMaxPredefinedObjectIds) == backward_references_.length()); | 307 ASSERT((id - kMaxPredefinedObjectIds) == backward_references_.length()); |
292 backward_references_.Add(obj); | 308 backward_references_.Add(obj); |
293 } | 309 } |
294 | 310 |
295 } // namespace dart | 311 } // namespace dart |
OLD | NEW |