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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 } | 73 } |
74 | 74 |
75 | 75 |
76 Dart_CObject* ApiMessageReader::AllocateDartCObjectInt32(int32_t val) { | 76 Dart_CObject* ApiMessageReader::AllocateDartCObjectInt32(int32_t val) { |
77 Dart_CObject* value = AllocateDartCObject(Dart_CObject::kInt32); | 77 Dart_CObject* value = AllocateDartCObject(Dart_CObject::kInt32); |
78 value->value.as_int32 = val; | 78 value->value.as_int32 = val; |
79 return value; | 79 return value; |
80 } | 80 } |
81 | 81 |
82 | 82 |
| 83 Dart_CObject* ApiMessageReader::AllocateDartCObjectInt64(int64_t val) { |
| 84 Dart_CObject* value = AllocateDartCObject(Dart_CObject::kInt64); |
| 85 value->value.as_int64 = val; |
| 86 return value; |
| 87 } |
| 88 |
| 89 |
83 Dart_CObject* ApiMessageReader::AllocateDartCObjectDouble(double val) { | 90 Dart_CObject* ApiMessageReader::AllocateDartCObjectDouble(double val) { |
84 Dart_CObject* value = AllocateDartCObject(Dart_CObject::kDouble); | 91 Dart_CObject* value = AllocateDartCObject(Dart_CObject::kDouble); |
85 value->value.as_double = val; | 92 value->value.as_double = val; |
86 return value; | 93 return value; |
87 } | 94 } |
88 | 95 |
89 | 96 |
90 Dart_CObject* ApiMessageReader::AllocateDartCObjectString(intptr_t length) { | 97 Dart_CObject* ApiMessageReader::AllocateDartCObjectString(intptr_t length) { |
91 // Allocate a Dart_CObject structure followed by an array of chars | 98 // Allocate a Dart_CObject structure followed by an array of chars |
92 // for the string content. The pointer to the string content is set | 99 // for the string content. The pointer to the string content is set |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 if (type_arguments != &type_arguments_marker && | 167 if (type_arguments != &type_arguments_marker && |
161 type_arguments->type != Dart_CObject::kNull) { | 168 type_arguments->type != Dart_CObject::kNull) { |
162 return NULL; | 169 return NULL; |
163 } | 170 } |
164 for (int i = 0; i < len; i++) { | 171 for (int i = 0; i < len; i++) { |
165 value->value.as_array.values[i] = ReadObject(); | 172 value->value.as_array.values[i] = ReadObject(); |
166 } | 173 } |
167 return value; | 174 return value; |
168 break; | 175 break; |
169 } | 176 } |
| 177 case ObjectStore::kMintClass: { |
| 178 int64_t value = Read<int64_t>(); |
| 179 if (kMinInt32 <= value && value <= kMaxInt32) { |
| 180 return AllocateDartCObjectInt32(value); |
| 181 } else { |
| 182 return AllocateDartCObjectInt64(value); |
| 183 } |
| 184 break; |
| 185 } |
170 case ObjectStore::kDoubleClass: { | 186 case ObjectStore::kDoubleClass: { |
171 // Read the double value for the object. | 187 // Read the double value for the object. |
172 Dart_CObject* object = AllocateDartCObjectDouble(Read<double>()); | 188 Dart_CObject* object = AllocateDartCObjectDouble(Read<double>()); |
173 AddBackwardReference(object_id, object); | 189 AddBackwardReference(object_id, object); |
174 return object; | 190 return object; |
175 break; | 191 break; |
176 } | 192 } |
177 case ObjectStore::kOneByteStringClass: { | 193 case ObjectStore::kOneByteStringClass: { |
178 intptr_t len = ReadSmiValue(); | 194 intptr_t len = ReadSmiValue(); |
179 intptr_t hash = ReadSmiValue(); | 195 intptr_t hash = ReadSmiValue(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 return ReadObjectImpl(value); | 266 return ReadObjectImpl(value); |
251 } | 267 } |
252 | 268 |
253 | 269 |
254 void ApiMessageReader::AddBackwardReference(intptr_t id, Dart_CObject* obj) { | 270 void ApiMessageReader::AddBackwardReference(intptr_t id, Dart_CObject* obj) { |
255 ASSERT((id - kMaxPredefinedObjectIds) == backward_references_.length()); | 271 ASSERT((id - kMaxPredefinedObjectIds) == backward_references_.length()); |
256 backward_references_.Add(obj); | 272 backward_references_.Add(obj); |
257 } | 273 } |
258 | 274 |
259 } // namespace dart | 275 } // namespace dart |
OLD | NEW |