| 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/object_store.h" | 5 #include "vm/object_store.h" |
| 6 | 6 |
| 7 #include "vm/exceptions.h" | 7 #include "vm/exceptions.h" |
| 8 #include "vm/isolate.h" | 8 #include "vm/isolate.h" |
| 9 #include "vm/object.h" | 9 #include "vm/object.h" |
| 10 #include "vm/raw_object.h" | 10 #include "vm/raw_object.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 129 |
| 130 void ObjectStore::InitKeywordTable() { | 130 void ObjectStore::InitKeywordTable() { |
| 131 // Set up the keywords symbol array so that we can access it while scanning. | 131 // Set up the keywords symbol array so that we can access it while scanning. |
| 132 Array& keywords = Array::Handle(keyword_symbols()); | 132 Array& keywords = Array::Handle(keyword_symbols()); |
| 133 ASSERT(keywords.IsNull()); | 133 ASSERT(keywords.IsNull()); |
| 134 keywords = Array::New(Token::numKeywords, Heap::kOld); | 134 keywords = Array::New(Token::numKeywords, Heap::kOld); |
| 135 ASSERT(!keywords.IsError() && !keywords.IsNull()); | 135 ASSERT(!keywords.IsError() && !keywords.IsNull()); |
| 136 set_keyword_symbols(keywords); | 136 set_keyword_symbols(keywords); |
| 137 } | 137 } |
| 138 | 138 |
| 139 | |
| 140 RawClass* ObjectStore::GetClass(int index) { | |
| 141 switch (index) { | |
| 142 case kObjectClass: return object_class_; | |
| 143 case kIntegerImplementationClass: return integer_implementation_class_; | |
| 144 case kSmiClass: return smi_class_; | |
| 145 case kMintClass: return mint_class_; | |
| 146 case kBigintClass: return bigint_class_; | |
| 147 case kDoubleClass: return double_class_; | |
| 148 case kOneByteStringClass: return one_byte_string_class_; | |
| 149 case kTwoByteStringClass: return two_byte_string_class_; | |
| 150 case kFourByteStringClass: return four_byte_string_class_; | |
| 151 case kExternalOneByteStringClass: return external_one_byte_string_class_; | |
| 152 case kExternalTwoByteStringClass: return external_two_byte_string_class_; | |
| 153 case kExternalFourByteStringClass: return external_four_byte_string_class_; | |
| 154 case kBoolClass: return bool_class_; | |
| 155 case kArrayClass: return array_class_; | |
| 156 case kImmutableArrayClass: return immutable_array_class_; | |
| 157 case kGrowableObjectArrayClass: return growable_object_array_class_; | |
| 158 case kInt8ArrayClass: return int8_array_class_; | |
| 159 case kUint8ArrayClass: return uint8_array_class_; | |
| 160 case kInt16ArrayClass: return int16_array_class_; | |
| 161 case kUint16ArrayClass: return uint16_array_class_; | |
| 162 case kInt32ArrayClass: return int32_array_class_; | |
| 163 case kUint32ArrayClass: return uint32_array_class_; | |
| 164 case kInt64ArrayClass: return int64_array_class_; | |
| 165 case kUint64ArrayClass: return uint64_array_class_; | |
| 166 case kFloat32ArrayClass: return float32_array_class_; | |
| 167 case kFloat64ArrayClass: return float64_array_class_; | |
| 168 case kExternalInt8ArrayClass: return external_int8_array_class_; | |
| 169 case kExternalUint8ArrayClass: return external_uint8_array_class_; | |
| 170 case kExternalInt16ArrayClass: return external_int16_array_class_; | |
| 171 case kExternalUint16ArrayClass: return external_uint16_array_class_; | |
| 172 case kExternalInt32ArrayClass: return external_int32_array_class_; | |
| 173 case kExternalUint32ArrayClass: return external_uint32_array_class_; | |
| 174 case kExternalInt64ArrayClass: return external_int64_array_class_; | |
| 175 case kExternalUint64ArrayClass: return external_uint64_array_class_; | |
| 176 case kExternalFloat32ArrayClass: return external_float32_array_class_; | |
| 177 case kExternalFloat64ArrayClass: return external_float64_array_class_; | |
| 178 case kStacktraceClass: return stacktrace_class_; | |
| 179 case kJSRegExpClass: return jsregexp_class_; | |
| 180 default: break; | |
| 181 } | |
| 182 UNREACHABLE(); | |
| 183 return Class::null(); | |
| 184 } | |
| 185 | |
| 186 | |
| 187 int ObjectStore::GetClassIndex(const RawClass* raw_class) { | |
| 188 ASSERT(raw_class->IsHeapObject()); | |
| 189 if (raw_class == object_class_) { | |
| 190 return kObjectClass; | |
| 191 } else if (raw_class == integer_implementation_class_) { | |
| 192 return kIntegerImplementationClass; | |
| 193 } else if (raw_class == smi_class_) { | |
| 194 return kSmiClass; | |
| 195 } else if (raw_class == mint_class_) { | |
| 196 return kMintClass; | |
| 197 } else if (raw_class == bigint_class_) { | |
| 198 return kBigintClass; | |
| 199 } else if (raw_class == double_class_) { | |
| 200 return kDoubleClass; | |
| 201 } else if (raw_class == one_byte_string_class_) { | |
| 202 return kOneByteStringClass; | |
| 203 } else if (raw_class == two_byte_string_class_) { | |
| 204 return kTwoByteStringClass; | |
| 205 } else if (raw_class == four_byte_string_class_) { | |
| 206 return kFourByteStringClass; | |
| 207 } else if (raw_class == external_one_byte_string_class_) { | |
| 208 return kExternalOneByteStringClass; | |
| 209 } else if (raw_class == external_two_byte_string_class_) { | |
| 210 return kExternalTwoByteStringClass; | |
| 211 } else if (raw_class == external_four_byte_string_class_) { | |
| 212 return kExternalFourByteStringClass; | |
| 213 } else if (raw_class == bool_class_) { | |
| 214 return kBoolClass; | |
| 215 } else if (raw_class == array_class_) { | |
| 216 return kArrayClass; | |
| 217 } else if (raw_class == immutable_array_class_) { | |
| 218 return kImmutableArrayClass; | |
| 219 } else if (raw_class == growable_object_array_class_) { | |
| 220 return kGrowableObjectArrayClass; | |
| 221 } else if (raw_class == int8_array_class_) { | |
| 222 return kInt8ArrayClass; | |
| 223 } else if (raw_class == uint8_array_class_) { | |
| 224 return kUint8ArrayClass; | |
| 225 } else if (raw_class == int16_array_class_) { | |
| 226 return kInt16ArrayClass; | |
| 227 } else if (raw_class == uint16_array_class_) { | |
| 228 return kUint16ArrayClass; | |
| 229 } else if (raw_class == int32_array_class_) { | |
| 230 return kInt32ArrayClass; | |
| 231 } else if (raw_class == uint32_array_class_) { | |
| 232 return kUint32ArrayClass; | |
| 233 } else if (raw_class == int64_array_class_) { | |
| 234 return kInt64ArrayClass; | |
| 235 } else if (raw_class == uint64_array_class_) { | |
| 236 return kUint64ArrayClass; | |
| 237 } else if (raw_class == float32_array_class_) { | |
| 238 return kFloat32ArrayClass; | |
| 239 } else if (raw_class == float64_array_class_) { | |
| 240 return kFloat64ArrayClass; | |
| 241 } else if (raw_class == external_int8_array_class_) { | |
| 242 return kExternalInt8ArrayClass; | |
| 243 } else if (raw_class == external_uint8_array_class_) { | |
| 244 return kExternalUint8ArrayClass; | |
| 245 } else if (raw_class == external_int16_array_class_) { | |
| 246 return kExternalInt16ArrayClass; | |
| 247 } else if (raw_class == external_uint16_array_class_) { | |
| 248 return kExternalUint16ArrayClass; | |
| 249 } else if (raw_class == external_int32_array_class_) { | |
| 250 return kExternalInt32ArrayClass; | |
| 251 } else if (raw_class == external_uint32_array_class_) { | |
| 252 return kExternalUint32ArrayClass; | |
| 253 } else if (raw_class == external_int64_array_class_) { | |
| 254 return kExternalInt64ArrayClass; | |
| 255 } else if (raw_class == external_uint64_array_class_) { | |
| 256 return kExternalUint64ArrayClass; | |
| 257 } else if (raw_class == external_float32_array_class_) { | |
| 258 return kExternalFloat32ArrayClass; | |
| 259 } else if (raw_class == external_float64_array_class_) { | |
| 260 return kExternalFloat64ArrayClass; | |
| 261 } else if (raw_class == stacktrace_class_) { | |
| 262 return kStacktraceClass; | |
| 263 } else if (raw_class == jsregexp_class_) { | |
| 264 return kJSRegExpClass; | |
| 265 } | |
| 266 return kInvalidIndex; | |
| 267 } | |
| 268 | |
| 269 | |
| 270 RawType* ObjectStore::GetType(int index) { | |
| 271 switch (index) { | |
| 272 case kObjectType: return object_type(); | |
| 273 case kNullType: return null_type(); | |
| 274 case kDynamicType: return dynamic_type(); | |
| 275 case kVoidType: return void_type(); | |
| 276 case kFunctionInterface: return function_interface(); | |
| 277 case kNumberInterface: return number_interface(); | |
| 278 case kDoubleInterface: return double_interface(); | |
| 279 case kIntInterface: return int_interface(); | |
| 280 case kBoolInterface: return bool_interface(); | |
| 281 case kStringInterface: return string_interface(); | |
| 282 case kListInterface: return list_interface(); | |
| 283 case kByteArrayInterface: return byte_array_interface(); | |
| 284 default: break; | |
| 285 } | |
| 286 UNREACHABLE(); | |
| 287 return Type::null(); | |
| 288 } | |
| 289 | |
| 290 | |
| 291 int ObjectStore::GetTypeIndex(const RawType* raw_type) { | |
| 292 ASSERT(raw_type->IsHeapObject()); | |
| 293 if (raw_type == object_type()) { | |
| 294 return kObjectType; | |
| 295 } else if (raw_type == null_type()) { | |
| 296 return kNullType; | |
| 297 } else if (raw_type == dynamic_type()) { | |
| 298 return kDynamicType; | |
| 299 } else if (raw_type == void_type()) { | |
| 300 return kVoidType; | |
| 301 } else if (raw_type == function_interface()) { | |
| 302 return kFunctionInterface; | |
| 303 } else if (raw_type == number_interface()) { | |
| 304 return kNumberInterface; | |
| 305 } else if (raw_type == double_interface()) { | |
| 306 return kDoubleInterface; | |
| 307 } else if (raw_type == int_interface()) { | |
| 308 return kIntInterface; | |
| 309 } else if (raw_type == bool_interface()) { | |
| 310 return kBoolInterface; | |
| 311 } else if (raw_type == string_interface()) { | |
| 312 return kStringInterface; | |
| 313 } else if (raw_type == list_interface()) { | |
| 314 return kListInterface; | |
| 315 } else if (raw_type == byte_array_interface()) { | |
| 316 return kByteArrayInterface; | |
| 317 } | |
| 318 return kInvalidIndex; | |
| 319 } | |
| 320 | |
| 321 } // namespace dart | 139 } // namespace dart |
| OLD | NEW |