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 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1178 cls = object_store->array_class(); // Was allocated above. | 1178 cls = object_store->array_class(); // Was allocated above. |
1179 RegisterPrivateClass(cls, Symbols::_List(), core_lib); | 1179 RegisterPrivateClass(cls, Symbols::_List(), core_lib); |
1180 pending_classes.Add(cls); | 1180 pending_classes.Add(cls); |
1181 // We cannot use NewNonParameterizedType(cls), because Array is parameterized. | 1181 // We cannot use NewNonParameterizedType(cls), because Array is parameterized. |
1182 // Warning: class _List has not been patched yet. Its declared number of type | 1182 // Warning: class _List has not been patched yet. Its declared number of type |
1183 // parameters is still 0. It will become 1 after patching. The array type | 1183 // parameters is still 0. It will become 1 after patching. The array type |
1184 // allocated below represents the raw type _List and not _List<E> as we | 1184 // allocated below represents the raw type _List and not _List<E> as we |
1185 // could expect. Use with caution. | 1185 // could expect. Use with caution. |
1186 type ^= Type::New(Object::Handle(zone, cls.raw()), | 1186 type ^= Type::New(Object::Handle(zone, cls.raw()), |
1187 TypeArguments::Handle(zone), | 1187 TypeArguments::Handle(zone), |
1188 Token::kNoSourcePos); | 1188 TokenPosition::kNoSource); |
1189 type.SetIsFinalized(); | 1189 type.SetIsFinalized(); |
1190 type ^= type.Canonicalize(); | 1190 type ^= type.Canonicalize(); |
1191 object_store->set_array_type(type); | 1191 object_store->set_array_type(type); |
1192 | 1192 |
1193 cls = object_store->growable_object_array_class(); // Was allocated above. | 1193 cls = object_store->growable_object_array_class(); // Was allocated above. |
1194 RegisterPrivateClass(cls, Symbols::_GrowableList(), core_lib); | 1194 RegisterPrivateClass(cls, Symbols::_GrowableList(), core_lib); |
1195 pending_classes.Add(cls); | 1195 pending_classes.Add(cls); |
1196 | 1196 |
1197 cls = Class::New<Array>(kImmutableArrayCid); | 1197 cls = Class::New<Array>(kImmutableArrayCid); |
1198 object_store->set_immutable_array_class(cls); | 1198 object_store->set_immutable_array_class(cls); |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1579 Smi& value = Smi::Handle(zone); | 1579 Smi& value = Smi::Handle(zone); |
1580 String& field_name = String::Handle(zone); | 1580 String& field_name = String::Handle(zone); |
1581 | 1581 |
1582 #define CLASS_LIST_WITH_NULL(V) \ | 1582 #define CLASS_LIST_WITH_NULL(V) \ |
1583 V(Null) \ | 1583 V(Null) \ |
1584 CLASS_LIST_NO_OBJECT(V) | 1584 CLASS_LIST_NO_OBJECT(V) |
1585 | 1585 |
1586 #define ADD_SET_FIELD(clazz) \ | 1586 #define ADD_SET_FIELD(clazz) \ |
1587 field_name = Symbols::New("cid"#clazz); \ | 1587 field_name = Symbols::New("cid"#clazz); \ |
1588 field = Field::New(field_name, true, false, true, false, cls, \ | 1588 field = Field::New(field_name, true, false, true, false, cls, \ |
1589 Type::Handle(Type::IntType()), 0); \ | 1589 Type::Handle(Type::IntType()), TokenPosition::kMinSource); \ |
1590 value = Smi::New(k##clazz##Cid); \ | 1590 value = Smi::New(k##clazz##Cid); \ |
1591 field.SetStaticValue(value, true); \ | 1591 field.SetStaticValue(value, true); \ |
1592 cls.AddField(field); \ | 1592 cls.AddField(field); \ |
1593 | 1593 |
1594 CLASS_LIST_WITH_NULL(ADD_SET_FIELD) | 1594 CLASS_LIST_WITH_NULL(ADD_SET_FIELD) |
1595 #undef ADD_SET_FIELD | 1595 #undef ADD_SET_FIELD |
1596 | 1596 |
1597 isolate->object_store()->InitKnownObjects(); | 1597 isolate->object_store()->InitKnownObjects(); |
1598 | 1598 |
1599 return Error::null(); | 1599 return Error::null(); |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1965 bool Class::IsInFullSnapshot() const { | 1965 bool Class::IsInFullSnapshot() const { |
1966 NoSafepointScope no_safepoint; | 1966 NoSafepointScope no_safepoint; |
1967 return raw_ptr()->library_->ptr()->is_in_fullsnapshot_; | 1967 return raw_ptr()->library_->ptr()->is_in_fullsnapshot_; |
1968 } | 1968 } |
1969 | 1969 |
1970 | 1970 |
1971 RawAbstractType* Class::RareType() const { | 1971 RawAbstractType* Class::RareType() const { |
1972 const Type& type = Type::Handle(Type::New( | 1972 const Type& type = Type::Handle(Type::New( |
1973 *this, | 1973 *this, |
1974 Object::null_type_arguments(), | 1974 Object::null_type_arguments(), |
1975 Token::kNoSourcePos)); | 1975 TokenPosition::kNoSource)); |
1976 return ClassFinalizer::FinalizeType(*this, | 1976 return ClassFinalizer::FinalizeType(*this, |
1977 type, | 1977 type, |
1978 ClassFinalizer::kCanonicalize); | 1978 ClassFinalizer::kCanonicalize); |
1979 } | 1979 } |
1980 | 1980 |
1981 | 1981 |
1982 RawAbstractType* Class::DeclarationType() const { | 1982 RawAbstractType* Class::DeclarationType() const { |
1983 const TypeArguments& args = TypeArguments::Handle(type_parameters()); | 1983 const TypeArguments& args = TypeArguments::Handle(type_parameters()); |
1984 const Type& type = Type::Handle(Type::New( | 1984 const Type& type = Type::Handle(Type::New( |
1985 *this, | 1985 *this, |
1986 args, | 1986 args, |
1987 Token::kNoSourcePos)); | 1987 TokenPosition::kNoSource)); |
1988 return ClassFinalizer::FinalizeType(*this, | 1988 return ClassFinalizer::FinalizeType(*this, |
1989 type, | 1989 type, |
1990 ClassFinalizer::kCanonicalize); | 1990 ClassFinalizer::kCanonicalize); |
1991 } | 1991 } |
1992 | 1992 |
1993 | 1993 |
1994 template <class FakeObject> | 1994 template <class FakeObject> |
1995 RawClass* Class::New() { | 1995 RawClass* Class::New() { |
1996 ASSERT(Object::class_class() != Class::null()); | 1996 ASSERT(Object::class_class() != Class::null()); |
1997 Class& result = Class::Handle(); | 1997 Class& result = Class::Handle(); |
(...skipping 17 matching lines...) Expand all Loading... |
2015 result.set_is_finalized(); | 2015 result.set_is_finalized(); |
2016 } else { | 2016 } else { |
2017 // VM backed classes are almost ready: run checks and resolve class | 2017 // VM backed classes are almost ready: run checks and resolve class |
2018 // references, but do not recompute size. | 2018 // references, but do not recompute size. |
2019 result.set_is_prefinalized(); | 2019 result.set_is_prefinalized(); |
2020 } | 2020 } |
2021 result.set_type_arguments_field_offset_in_words(kNoTypeArguments); | 2021 result.set_type_arguments_field_offset_in_words(kNoTypeArguments); |
2022 result.set_num_type_arguments(0); | 2022 result.set_num_type_arguments(0); |
2023 result.set_num_own_type_arguments(0); | 2023 result.set_num_own_type_arguments(0); |
2024 result.set_num_native_fields(0); | 2024 result.set_num_native_fields(0); |
2025 result.set_token_pos(Token::kNoSourcePos); | 2025 result.set_token_pos(TokenPosition::kNoSource); |
2026 result.InitEmptyFields(); | 2026 result.InitEmptyFields(); |
2027 Isolate::Current()->RegisterClass(result); | 2027 Isolate::Current()->RegisterClass(result); |
2028 return result.raw(); | 2028 return result.raw(); |
2029 } | 2029 } |
2030 | 2030 |
2031 | 2031 |
2032 | 2032 |
2033 static void ReportTooManyTypeArguments(const Class& cls) { | 2033 static void ReportTooManyTypeArguments(const Class& cls) { |
2034 Report::MessageF(Report::kError, | 2034 Report::MessageF(Report::kError, |
2035 Script::Handle(cls.script()), | 2035 Script::Handle(cls.script()), |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2615 RawFunction::Kind kind) const { | 2615 RawFunction::Kind kind) const { |
2616 Function& invocation = Function::Handle( | 2616 Function& invocation = Function::Handle( |
2617 Function::New(String::Handle(Symbols::New(target_name)), | 2617 Function::New(String::Handle(Symbols::New(target_name)), |
2618 kind, | 2618 kind, |
2619 false, // Not static. | 2619 false, // Not static. |
2620 false, // Not const. | 2620 false, // Not const. |
2621 false, // Not abstract. | 2621 false, // Not abstract. |
2622 false, // Not external. | 2622 false, // Not external. |
2623 false, // Not native. | 2623 false, // Not native. |
2624 *this, | 2624 *this, |
2625 0)); // token_pos | 2625 TokenPosition::kMinSource)); |
2626 ArgumentsDescriptor desc(args_desc); | 2626 ArgumentsDescriptor desc(args_desc); |
2627 invocation.set_num_fixed_parameters(desc.PositionalCount()); | 2627 invocation.set_num_fixed_parameters(desc.PositionalCount()); |
2628 invocation.SetNumOptionalParameters(desc.NamedCount(), | 2628 invocation.SetNumOptionalParameters(desc.NamedCount(), |
2629 false); // Not positional. | 2629 false); // Not positional. |
2630 invocation.set_parameter_types(Array::Handle(Array::New(desc.Count(), | 2630 invocation.set_parameter_types(Array::Handle(Array::New(desc.Count(), |
2631 Heap::kOld))); | 2631 Heap::kOld))); |
2632 invocation.set_parameter_names(Array::Handle(Array::New(desc.Count(), | 2632 invocation.set_parameter_names(Array::Handle(Array::New(desc.Count(), |
2633 Heap::kOld))); | 2633 Heap::kOld))); |
2634 // Receiver. | 2634 // Receiver. |
2635 invocation.SetParameterTypeAt(0, Object::dynamic_type()); | 2635 invocation.SetParameterTypeAt(0, Object::dynamic_type()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2672 const Class& owner = Class::Handle(closure_function.Owner()); | 2672 const Class& owner = Class::Handle(closure_function.Owner()); |
2673 Function& extractor = Function::Handle( | 2673 Function& extractor = Function::Handle( |
2674 Function::New(String::Handle(Symbols::New(getter_name)), | 2674 Function::New(String::Handle(Symbols::New(getter_name)), |
2675 RawFunction::kMethodExtractor, | 2675 RawFunction::kMethodExtractor, |
2676 false, // Not static. | 2676 false, // Not static. |
2677 false, // Not const. | 2677 false, // Not const. |
2678 false, // Not abstract. | 2678 false, // Not abstract. |
2679 false, // Not external. | 2679 false, // Not external. |
2680 false, // Not native. | 2680 false, // Not native. |
2681 owner, | 2681 owner, |
2682 ClassifyingTokenPositions::kMethodExtractor)); // token_pos | 2682 TokenPosition::kMethodExtractor)); |
2683 | 2683 |
2684 // Initialize signature: receiver is a single fixed parameter. | 2684 // Initialize signature: receiver is a single fixed parameter. |
2685 const intptr_t kNumParameters = 1; | 2685 const intptr_t kNumParameters = 1; |
2686 extractor.set_num_fixed_parameters(kNumParameters); | 2686 extractor.set_num_fixed_parameters(kNumParameters); |
2687 extractor.SetNumOptionalParameters(0, 0); | 2687 extractor.SetNumOptionalParameters(0, 0); |
2688 extractor.set_parameter_types(Object::extractor_parameter_types()); | 2688 extractor.set_parameter_types(Object::extractor_parameter_types()); |
2689 extractor.set_parameter_names(Object::extractor_parameter_names()); | 2689 extractor.set_parameter_names(Object::extractor_parameter_names()); |
2690 extractor.set_result_type(Object::dynamic_type()); | 2690 extractor.set_result_type(Object::dynamic_type()); |
2691 | 2691 |
2692 extractor.set_extracted_method_closure(closure_function); | 2692 extractor.set_extracted_method_closure(closure_function); |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3084 ASSERT(fake.IsInstance()); | 3084 ASSERT(fake.IsInstance()); |
3085 result.set_handle_vtable(fake.vtable()); | 3085 result.set_handle_vtable(fake.vtable()); |
3086 result.set_instance_size(FakeInstance::InstanceSize()); | 3086 result.set_instance_size(FakeInstance::InstanceSize()); |
3087 result.set_next_field_offset(FakeInstance::NextFieldOffset()); | 3087 result.set_next_field_offset(FakeInstance::NextFieldOffset()); |
3088 result.set_id(index); | 3088 result.set_id(index); |
3089 result.set_state_bits(0); | 3089 result.set_state_bits(0); |
3090 result.set_type_arguments_field_offset_in_words(kNoTypeArguments); | 3090 result.set_type_arguments_field_offset_in_words(kNoTypeArguments); |
3091 result.set_num_type_arguments(kUnknownNumTypeArguments); | 3091 result.set_num_type_arguments(kUnknownNumTypeArguments); |
3092 result.set_num_own_type_arguments(kUnknownNumTypeArguments); | 3092 result.set_num_own_type_arguments(kUnknownNumTypeArguments); |
3093 result.set_num_native_fields(0); | 3093 result.set_num_native_fields(0); |
3094 result.set_token_pos(Token::kNoSourcePos); | 3094 result.set_token_pos(TokenPosition::kNoSource); |
3095 result.InitEmptyFields(); | 3095 result.InitEmptyFields(); |
3096 Isolate::Current()->RegisterClass(result); | 3096 Isolate::Current()->RegisterClass(result); |
3097 return result.raw(); | 3097 return result.raw(); |
3098 } | 3098 } |
3099 | 3099 |
3100 | 3100 |
3101 RawClass* Class::New(const String& name, | 3101 RawClass* Class::New(const String& name, |
3102 const Script& script, | 3102 const Script& script, |
3103 intptr_t token_pos) { | 3103 TokenPosition token_pos) { |
3104 Class& result = Class::Handle(New<Instance>(kIllegalCid)); | 3104 Class& result = Class::Handle(New<Instance>(kIllegalCid)); |
3105 result.set_name(name); | 3105 result.set_name(name); |
3106 result.set_script(script); | 3106 result.set_script(script); |
3107 result.set_token_pos(token_pos); | 3107 result.set_token_pos(token_pos); |
3108 return result.raw(); | 3108 return result.raw(); |
3109 } | 3109 } |
3110 | 3110 |
3111 | 3111 |
3112 RawClass* Class::NewNativeWrapper(const Library& library, | 3112 RawClass* Class::NewNativeWrapper(const Library& library, |
3113 const String& name, | 3113 const String& name, |
3114 int field_count) { | 3114 int field_count) { |
3115 Class& cls = Class::Handle(library.LookupClass(name)); | 3115 Class& cls = Class::Handle(library.LookupClass(name)); |
3116 if (cls.IsNull()) { | 3116 if (cls.IsNull()) { |
3117 cls = New(name, Script::Handle(), Token::kNoSourcePos); | 3117 cls = New(name, Script::Handle(), TokenPosition::kNoSource); |
3118 cls.SetFields(Object::empty_array()); | 3118 cls.SetFields(Object::empty_array()); |
3119 cls.SetFunctions(Object::empty_array()); | 3119 cls.SetFunctions(Object::empty_array()); |
3120 // Set super class to Object. | 3120 // Set super class to Object. |
3121 cls.set_super_type(Type::Handle(Type::ObjectType())); | 3121 cls.set_super_type(Type::Handle(Type::ObjectType())); |
3122 // Compute instance size. First word contains a pointer to a properly | 3122 // Compute instance size. First word contains a pointer to a properly |
3123 // sized typed array once the first native field has been set. | 3123 // sized typed array once the first native field has been set. |
3124 intptr_t instance_size = sizeof(RawInstance) + kWordSize; | 3124 intptr_t instance_size = sizeof(RawInstance) + kWordSize; |
3125 cls.set_instance_size(RoundedAllocationSize(instance_size)); | 3125 cls.set_instance_size(RoundedAllocationSize(instance_size)); |
3126 cls.set_next_field_offset(instance_size); | 3126 cls.set_next_field_offset(instance_size); |
3127 cls.set_num_native_fields(field_count); | 3127 cls.set_num_native_fields(field_count); |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3352 } | 3352 } |
3353 UNREACHABLE(); | 3353 UNREACHABLE(); |
3354 } | 3354 } |
3355 | 3355 |
3356 | 3356 |
3357 void Class::set_script(const Script& value) const { | 3357 void Class::set_script(const Script& value) const { |
3358 StorePointer(&raw_ptr()->script_, value.raw()); | 3358 StorePointer(&raw_ptr()->script_, value.raw()); |
3359 } | 3359 } |
3360 | 3360 |
3361 | 3361 |
3362 void Class::set_token_pos(intptr_t token_pos) const { | 3362 void Class::set_token_pos(TokenPosition token_pos) const { |
3363 ASSERT(!Token::IsClassifying(token_pos)); | 3363 ASSERT(!token_pos.IsClassifying()); |
3364 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); | 3364 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); |
3365 } | 3365 } |
3366 | 3366 |
3367 | 3367 |
3368 intptr_t Class::ComputeEndTokenPos() const { | 3368 TokenPosition Class::ComputeEndTokenPos() const { |
3369 // Return the begin token for synthetic classes. | 3369 // Return the begin token for synthetic classes. |
3370 if (IsMixinApplication() || IsTopLevel()) { | 3370 if (IsMixinApplication() || IsTopLevel()) { |
3371 return token_pos(); | 3371 return token_pos(); |
3372 } | 3372 } |
3373 const Script& scr = Script::Handle(script()); | 3373 const Script& scr = Script::Handle(script()); |
3374 ASSERT(!scr.IsNull()); | 3374 ASSERT(!scr.IsNull()); |
3375 const TokenStream& tkns = TokenStream::Handle(scr.tokens()); | 3375 const TokenStream& tkns = TokenStream::Handle(scr.tokens()); |
3376 TokenStream::Iterator tkit( | 3376 TokenStream::Iterator tkit(tkns, |
3377 tkns, token_pos(), TokenStream::Iterator::kNoNewlines); | 3377 token_pos(), |
| 3378 TokenStream::Iterator::kNoNewlines); |
3378 intptr_t level = 0; | 3379 intptr_t level = 0; |
3379 while (tkit.CurrentTokenKind() != Token::kEOS) { | 3380 while (tkit.CurrentTokenKind() != Token::kEOS) { |
3380 if (tkit.CurrentTokenKind() == Token::kLBRACE) { | 3381 if (tkit.CurrentTokenKind() == Token::kLBRACE) { |
3381 level++; | 3382 level++; |
3382 } else if (tkit.CurrentTokenKind() == Token::kRBRACE) { | 3383 } else if (tkit.CurrentTokenKind() == Token::kRBRACE) { |
3383 if (--level == 0) { | 3384 if (--level == 0) { |
3384 return tkit.CurrentPosition(); | 3385 return tkit.CurrentPosition(); |
3385 } | 3386 } |
3386 } | 3387 } |
3387 tkit.Advance(); | 3388 tkit.Advance(); |
3388 } | 3389 } |
3389 UNREACHABLE(); | 3390 UNREACHABLE(); |
3390 return 0; | 3391 return TokenPosition::kNoSource; |
3391 } | 3392 } |
3392 | 3393 |
3393 | 3394 |
3394 void Class::set_is_implemented() const { | 3395 void Class::set_is_implemented() const { |
3395 set_state_bits(ImplementedBit::update(true, raw_ptr()->state_bits_)); | 3396 set_state_bits(ImplementedBit::update(true, raw_ptr()->state_bits_)); |
3396 } | 3397 } |
3397 | 3398 |
3398 | 3399 |
3399 void Class::set_is_abstract() const { | 3400 void Class::set_is_abstract() const { |
3400 set_state_bits(AbstractBit::update(true, raw_ptr()->state_bits_)); | 3401 set_state_bits(AbstractBit::update(true, raw_ptr()->state_bits_)); |
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4239 set_constants(new_canonical_list); | 4240 set_constants(new_canonical_list); |
4240 new_canonical_list.SetAt(index, constant); | 4241 new_canonical_list.SetAt(index, constant); |
4241 } else { | 4242 } else { |
4242 canonical_list.SetAt(index, constant); | 4243 canonical_list.SetAt(index, constant); |
4243 } | 4244 } |
4244 } | 4245 } |
4245 | 4246 |
4246 | 4247 |
4247 RawUnresolvedClass* UnresolvedClass::New(const LibraryPrefix& library_prefix, | 4248 RawUnresolvedClass* UnresolvedClass::New(const LibraryPrefix& library_prefix, |
4248 const String& ident, | 4249 const String& ident, |
4249 intptr_t token_pos) { | 4250 TokenPosition token_pos) { |
4250 const UnresolvedClass& type = UnresolvedClass::Handle(UnresolvedClass::New()); | 4251 const UnresolvedClass& type = UnresolvedClass::Handle(UnresolvedClass::New()); |
4251 type.set_library_prefix(library_prefix); | 4252 type.set_library_prefix(library_prefix); |
4252 type.set_ident(ident); | 4253 type.set_ident(ident); |
4253 type.set_token_pos(token_pos); | 4254 type.set_token_pos(token_pos); |
4254 return type.raw(); | 4255 return type.raw(); |
4255 } | 4256 } |
4256 | 4257 |
4257 | 4258 |
4258 RawUnresolvedClass* UnresolvedClass::New() { | 4259 RawUnresolvedClass* UnresolvedClass::New() { |
4259 ASSERT(Object::unresolved_class_class() != Class::null()); | 4260 ASSERT(Object::unresolved_class_class() != Class::null()); |
4260 RawObject* raw = Object::Allocate(UnresolvedClass::kClassId, | 4261 RawObject* raw = Object::Allocate(UnresolvedClass::kClassId, |
4261 UnresolvedClass::InstanceSize(), | 4262 UnresolvedClass::InstanceSize(), |
4262 Heap::kOld); | 4263 Heap::kOld); |
4263 return reinterpret_cast<RawUnresolvedClass*>(raw); | 4264 return reinterpret_cast<RawUnresolvedClass*>(raw); |
4264 } | 4265 } |
4265 | 4266 |
4266 | 4267 |
4267 void UnresolvedClass::set_token_pos(intptr_t token_pos) const { | 4268 void UnresolvedClass::set_token_pos(TokenPosition token_pos) const { |
4268 ASSERT(!Token::IsClassifying(token_pos)); | 4269 ASSERT(!token_pos.IsClassifying()); |
4269 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); | 4270 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); |
4270 } | 4271 } |
4271 | 4272 |
4272 | 4273 |
4273 void UnresolvedClass::set_ident(const String& ident) const { | 4274 void UnresolvedClass::set_ident(const String& ident) const { |
4274 StorePointer(&raw_ptr()->ident_, ident.raw()); | 4275 StorePointer(&raw_ptr()->ident_, ident.raw()); |
4275 } | 4276 } |
4276 | 4277 |
4277 | 4278 |
4278 void UnresolvedClass::set_library_prefix( | 4279 void UnresolvedClass::set_library_prefix( |
(...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5252 RawScript* Function::eval_script() const { | 5253 RawScript* Function::eval_script() const { |
5253 const Object& obj = Object::Handle(raw_ptr()->data_); | 5254 const Object& obj = Object::Handle(raw_ptr()->data_); |
5254 if (obj.IsScript()) { | 5255 if (obj.IsScript()) { |
5255 return Script::Cast(obj).raw(); | 5256 return Script::Cast(obj).raw(); |
5256 } | 5257 } |
5257 return Script::null(); | 5258 return Script::null(); |
5258 } | 5259 } |
5259 | 5260 |
5260 | 5261 |
5261 void Function::set_eval_script(const Script& script) const { | 5262 void Function::set_eval_script(const Script& script) const { |
5262 ASSERT(token_pos() == 0); | 5263 ASSERT(token_pos() == TokenPosition::kMinSource); |
5263 ASSERT(raw_ptr()->data_ == Object::null()); | 5264 ASSERT(raw_ptr()->data_ == Object::null()); |
5264 set_data(script); | 5265 set_data(script); |
5265 } | 5266 } |
5266 | 5267 |
5267 | 5268 |
5268 RawFunction* Function::extracted_method_closure() const { | 5269 RawFunction* Function::extracted_method_closure() const { |
5269 ASSERT(kind() == RawFunction::kMethodExtractor); | 5270 ASSERT(kind() == RawFunction::kMethodExtractor); |
5270 const Object& obj = Object::Handle(raw_ptr()->data_); | 5271 const Object& obj = Object::Handle(raw_ptr()->data_); |
5271 ASSERT(obj.IsFunction()); | 5272 ASSERT(obj.IsFunction()); |
5272 return Function::Cast(obj).raw(); | 5273 return Function::Cast(obj).raw(); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5402 // class may be. In this case, the scope class of the function type is reset | 5403 // class may be. In this case, the scope class of the function type is reset |
5403 // to _Closure class as well as the owner of the signature function. | 5404 // to _Closure class as well as the owner of the signature function. |
5404 Class& scope_class = Class::Handle(Owner()); | 5405 Class& scope_class = Class::Handle(Owner()); |
5405 if (!scope_class.IsTypedefClass() && | 5406 if (!scope_class.IsTypedefClass() && |
5406 (is_static() || | 5407 (is_static() || |
5407 !scope_class.IsGeneric() || | 5408 !scope_class.IsGeneric() || |
5408 HasInstantiatedSignature())) { | 5409 HasInstantiatedSignature())) { |
5409 scope_class = Isolate::Current()->object_store()->closure_class(); | 5410 scope_class = Isolate::Current()->object_store()->closure_class(); |
5410 if (IsSignatureFunction()) { | 5411 if (IsSignatureFunction()) { |
5411 set_owner(scope_class); | 5412 set_owner(scope_class); |
5412 set_token_pos(Token::kNoSourcePos); | 5413 set_token_pos(TokenPosition::kNoSource); |
5413 } | 5414 } |
5414 } | 5415 } |
5415 const TypeArguments& signature_type_arguments = | 5416 const TypeArguments& signature_type_arguments = |
5416 TypeArguments::Handle(scope_class.type_parameters()); | 5417 TypeArguments::Handle(scope_class.type_parameters()); |
5417 // Return the still unfinalized signature type. | 5418 // Return the still unfinalized signature type. |
5418 type = FunctionType::New(scope_class, | 5419 type = FunctionType::New(scope_class, |
5419 signature_type_arguments, | 5420 signature_type_arguments, |
5420 *this, | 5421 *this, |
5421 token_pos()); | 5422 token_pos()); |
5422 | 5423 |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5694 } | 5695 } |
5695 | 5696 |
5696 | 5697 |
5697 void Function::set_recognized_kind(MethodRecognizer::Kind value) const { | 5698 void Function::set_recognized_kind(MethodRecognizer::Kind value) const { |
5698 // Prevent multiple settings of kind. | 5699 // Prevent multiple settings of kind. |
5699 ASSERT((value == MethodRecognizer::kUnknown) || !IsRecognized()); | 5700 ASSERT((value == MethodRecognizer::kUnknown) || !IsRecognized()); |
5700 set_kind_tag(RecognizedBits::update(value, raw_ptr()->kind_tag_)); | 5701 set_kind_tag(RecognizedBits::update(value, raw_ptr()->kind_tag_)); |
5701 } | 5702 } |
5702 | 5703 |
5703 | 5704 |
5704 void Function::set_token_pos(intptr_t token_pos) const { | 5705 void Function::set_token_pos(TokenPosition token_pos) const { |
5705 ASSERT(!Token::IsClassifying(token_pos) || IsMethodExtractor()); | 5706 ASSERT(!token_pos.IsClassifying() || IsMethodExtractor()); |
5706 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); | 5707 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); |
5707 } | 5708 } |
5708 | 5709 |
5709 | 5710 |
5710 void Function::set_kind_tag(intptr_t value) const { | 5711 void Function::set_kind_tag(intptr_t value) const { |
5711 StoreNonPointer(&raw_ptr()->kind_tag_, static_cast<uint32_t>(value)); | 5712 StoreNonPointer(&raw_ptr()->kind_tag_, static_cast<uint32_t>(value)); |
5712 } | 5713 } |
5713 | 5714 |
5714 | 5715 |
5715 void Function::set_num_fixed_parameters(intptr_t value) const { | 5716 void Function::set_num_fixed_parameters(intptr_t value) const { |
(...skipping 23 matching lines...) Expand all Loading... |
5739 | 5740 |
5740 bool Function::IsOptimizable() const { | 5741 bool Function::IsOptimizable() const { |
5741 if (FLAG_coverage_dir != NULL) { | 5742 if (FLAG_coverage_dir != NULL) { |
5742 // Do not optimize if collecting coverage data. | 5743 // Do not optimize if collecting coverage data. |
5743 return false; | 5744 return false; |
5744 } | 5745 } |
5745 if (is_native()) { | 5746 if (is_native()) { |
5746 // Native methods don't need to be optimized. | 5747 // Native methods don't need to be optimized. |
5747 return false; | 5748 return false; |
5748 } | 5749 } |
| 5750 const intptr_t function_length = end_token_pos().Pos() - token_pos().Pos(); |
5749 if (is_optimizable() && (script() != Script::null()) && | 5751 if (is_optimizable() && (script() != Script::null()) && |
5750 ((end_token_pos() - token_pos()) < FLAG_huge_method_cutoff_in_tokens)) { | 5752 (function_length < FLAG_huge_method_cutoff_in_tokens)) { |
5751 // Additional check needed for implicit getters. | 5753 // Additional check needed for implicit getters. |
5752 return (unoptimized_code() == Object::null()) || | 5754 return (unoptimized_code() == Object::null()) || |
5753 (Code::Handle(unoptimized_code()).Size() < | 5755 (Code::Handle(unoptimized_code()).Size() < |
5754 FLAG_huge_method_cutoff_in_code_size); | 5756 FLAG_huge_method_cutoff_in_code_size); |
5755 } | 5757 } |
5756 return false; | 5758 return false; |
5757 } | 5759 } |
5758 | 5760 |
5759 | 5761 |
5760 bool Function::IsNativeAutoSetupScope() const { | 5762 bool Function::IsNativeAutoSetupScope() const { |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6314 | 6316 |
6315 | 6317 |
6316 RawFunction* Function::New(const String& name, | 6318 RawFunction* Function::New(const String& name, |
6317 RawFunction::Kind kind, | 6319 RawFunction::Kind kind, |
6318 bool is_static, | 6320 bool is_static, |
6319 bool is_const, | 6321 bool is_const, |
6320 bool is_abstract, | 6322 bool is_abstract, |
6321 bool is_external, | 6323 bool is_external, |
6322 bool is_native, | 6324 bool is_native, |
6323 const Object& owner, | 6325 const Object& owner, |
6324 intptr_t token_pos) { | 6326 TokenPosition token_pos) { |
6325 ASSERT(!owner.IsNull()); | 6327 ASSERT(!owner.IsNull()); |
6326 const Function& result = Function::Handle(Function::New()); | 6328 const Function& result = Function::Handle(Function::New()); |
6327 result.set_parameter_types(Object::empty_array()); | 6329 result.set_parameter_types(Object::empty_array()); |
6328 result.set_parameter_names(Object::empty_array()); | 6330 result.set_parameter_names(Object::empty_array()); |
6329 result.set_name(name); | 6331 result.set_name(name); |
6330 result.set_kind(kind); | 6332 result.set_kind(kind); |
6331 result.set_recognized_kind(MethodRecognizer::kUnknown); | 6333 result.set_recognized_kind(MethodRecognizer::kUnknown); |
6332 result.set_modifier(RawFunction::kNoModifier); | 6334 result.set_modifier(RawFunction::kNoModifier); |
6333 result.set_is_static(is_static); | 6335 result.set_is_static(is_static); |
6334 result.set_is_const(is_const); | 6336 result.set_is_const(is_const); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6394 type ^= type.CloneUninstantiated(new_owner); | 6396 type ^= type.CloneUninstantiated(new_owner); |
6395 clone.SetParameterTypeAt(i, type); | 6397 clone.SetParameterTypeAt(i, type); |
6396 } | 6398 } |
6397 } | 6399 } |
6398 return clone.raw(); | 6400 return clone.raw(); |
6399 } | 6401 } |
6400 | 6402 |
6401 | 6403 |
6402 RawFunction* Function::NewClosureFunction(const String& name, | 6404 RawFunction* Function::NewClosureFunction(const String& name, |
6403 const Function& parent, | 6405 const Function& parent, |
6404 intptr_t token_pos) { | 6406 TokenPosition token_pos) { |
6405 ASSERT(!parent.IsNull()); | 6407 ASSERT(!parent.IsNull()); |
6406 // Use the owner defining the parent function and not the class containing it. | 6408 // Use the owner defining the parent function and not the class containing it. |
6407 const Object& parent_owner = Object::Handle(parent.raw_ptr()->owner_); | 6409 const Object& parent_owner = Object::Handle(parent.raw_ptr()->owner_); |
6408 ASSERT(!parent_owner.IsNull()); | 6410 ASSERT(!parent_owner.IsNull()); |
6409 const Function& result = Function::Handle( | 6411 const Function& result = Function::Handle( |
6410 Function::New(name, | 6412 Function::New(name, |
6411 RawFunction::kClosureFunction, | 6413 RawFunction::kClosureFunction, |
6412 /* is_static = */ parent.is_static(), | 6414 /* is_static = */ parent.is_static(), |
6413 /* is_const = */ false, | 6415 /* is_const = */ false, |
6414 /* is_abstract = */ false, | 6416 /* is_abstract = */ false, |
6415 /* is_external = */ false, | 6417 /* is_external = */ false, |
6416 parent.is_native(), | 6418 parent.is_native(), |
6417 parent_owner, | 6419 parent_owner, |
6418 token_pos)); | 6420 token_pos)); |
6419 result.set_parent_function(parent); | 6421 result.set_parent_function(parent); |
6420 return result.raw(); | 6422 return result.raw(); |
6421 } | 6423 } |
6422 | 6424 |
6423 | 6425 |
6424 RawFunction* Function::NewSignatureFunction(const Class& owner, | 6426 RawFunction* Function::NewSignatureFunction(const Class& owner, |
6425 intptr_t token_pos) { | 6427 TokenPosition token_pos) { |
6426 const Function& result = Function::Handle(Function::New( | 6428 const Function& result = Function::Handle(Function::New( |
6427 Symbols::AnonymousSignature(), | 6429 Symbols::AnonymousSignature(), |
6428 RawFunction::kSignatureFunction, | 6430 RawFunction::kSignatureFunction, |
6429 /* is_static = */ false, | 6431 /* is_static = */ false, |
6430 /* is_const = */ false, | 6432 /* is_const = */ false, |
6431 /* is_abstract = */ false, | 6433 /* is_abstract = */ false, |
6432 /* is_external = */ false, | 6434 /* is_external = */ false, |
6433 /* is_native = */ false, | 6435 /* is_native = */ false, |
6434 owner, // Same as function type scope class. | 6436 owner, // Same as function type scope class. |
6435 token_pos)); | 6437 token_pos)); |
6436 result.set_is_reflectable(false); | 6438 result.set_is_reflectable(false); |
6437 result.set_is_visible(false); | 6439 result.set_is_visible(false); |
6438 result.set_is_debuggable(false); | 6440 result.set_is_debuggable(false); |
6439 return result.raw(); | 6441 return result.raw(); |
6440 } | 6442 } |
6441 | 6443 |
6442 | 6444 |
6443 RawFunction* Function::NewEvalFunction(const Class& owner, | 6445 RawFunction* Function::NewEvalFunction(const Class& owner, |
6444 const Script& script, | 6446 const Script& script, |
6445 bool is_static) { | 6447 bool is_static) { |
6446 const Function& result = Function::Handle( | 6448 const Function& result = Function::Handle( |
6447 Function::New(String::Handle(Symbols::New(":Eval")), | 6449 Function::New(String::Handle(Symbols::New(":Eval")), |
6448 RawFunction::kRegularFunction, | 6450 RawFunction::kRegularFunction, |
6449 is_static, | 6451 is_static, |
6450 /* is_const = */ false, | 6452 /* is_const = */ false, |
6451 /* is_abstract = */ false, | 6453 /* is_abstract = */ false, |
6452 /* is_external = */ false, | 6454 /* is_external = */ false, |
6453 /* is_native = */ false, | 6455 /* is_native = */ false, |
6454 owner, | 6456 owner, |
6455 /* token_pos = */ 0)); | 6457 TokenPosition::kMinSource)); |
6456 ASSERT(!script.IsNull()); | 6458 ASSERT(!script.IsNull()); |
6457 result.set_is_debuggable(false); | 6459 result.set_is_debuggable(false); |
6458 result.set_is_visible(true); | 6460 result.set_is_visible(true); |
6459 result.set_eval_script(script); | 6461 result.set_eval_script(script); |
6460 return result.raw(); | 6462 return result.raw(); |
6461 } | 6463 } |
6462 | 6464 |
6463 RawFunction* Function::ImplicitClosureFunction() const { | 6465 RawFunction* Function::ImplicitClosureFunction() const { |
6464 // Return the existing implicit closure function if any. | 6466 // Return the existing implicit closure function if any. |
6465 if (implicit_closure_function() != Function::null()) { | 6467 if (implicit_closure_function() != Function::null()) { |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6736 const Object& obj = Object::Handle(raw_ptr()->owner_); | 6738 const Object& obj = Object::Handle(raw_ptr()->owner_); |
6737 if (obj.IsClass()) { | 6739 if (obj.IsClass()) { |
6738 return Class::Cast(obj).raw(); | 6740 return Class::Cast(obj).raw(); |
6739 } | 6741 } |
6740 ASSERT(obj.IsPatchClass()); | 6742 ASSERT(obj.IsPatchClass()); |
6741 return PatchClass::Cast(obj).origin_class(); | 6743 return PatchClass::Cast(obj).origin_class(); |
6742 } | 6744 } |
6743 | 6745 |
6744 | 6746 |
6745 RawScript* Function::script() const { | 6747 RawScript* Function::script() const { |
6746 if (token_pos() == 0) { | 6748 if (token_pos() == TokenPosition::kMinSource) { |
6747 // Testing for position 0 is an optimization that relies on temporary | 6749 // Testing for position 0 is an optimization that relies on temporary |
6748 // eval functions having token position 0. | 6750 // eval functions having token position 0. |
6749 const Script& script = Script::Handle(eval_script()); | 6751 const Script& script = Script::Handle(eval_script()); |
6750 if (!script.IsNull()) { | 6752 if (!script.IsNull()) { |
6751 return script.raw(); | 6753 return script.raw(); |
6752 } | 6754 } |
6753 } | 6755 } |
6754 if (IsClosureFunction()) { | 6756 if (IsClosureFunction()) { |
6755 return Function::Handle(parent_function()).script(); | 6757 return Function::Handle(parent_function()).script(); |
6756 } | 6758 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6839 // relaxed. In particular we might start associating some source with the | 6841 // relaxed. In particular we might start associating some source with the |
6840 // forwarding constructors when it becomes possible to specify a particular | 6842 // forwarding constructors when it becomes possible to specify a particular |
6841 // constructor from the mixin to use. | 6843 // constructor from the mixin to use. |
6842 return String::null(); | 6844 return String::null(); |
6843 } | 6845 } |
6844 const Script& func_script = Script::Handle(script()); | 6846 const Script& func_script = Script::Handle(script()); |
6845 const TokenStream& stream = TokenStream::Handle(func_script.tokens()); | 6847 const TokenStream& stream = TokenStream::Handle(func_script.tokens()); |
6846 if (!func_script.HasSource()) { | 6848 if (!func_script.HasSource()) { |
6847 // When source is not available, avoid printing the whole token stream and | 6849 // When source is not available, avoid printing the whole token stream and |
6848 // doing expensive position calculations. | 6850 // doing expensive position calculations. |
6849 return stream.GenerateSource(token_pos(), end_token_pos() + 1); | 6851 return stream.GenerateSource(token_pos(), end_token_pos().Next()); |
6850 } | 6852 } |
6851 | 6853 |
6852 const TokenStream::Iterator tkit(stream, end_token_pos()); | 6854 const TokenStream::Iterator tkit(stream, end_token_pos()); |
6853 intptr_t from_line; | 6855 intptr_t from_line; |
6854 intptr_t from_col; | 6856 intptr_t from_col; |
6855 intptr_t to_line; | 6857 intptr_t to_line; |
6856 intptr_t to_col; | 6858 intptr_t to_col; |
6857 func_script.GetTokenLocation(token_pos(), &from_line, &from_col); | 6859 func_script.GetTokenLocation(token_pos(), &from_line, &from_col); |
6858 func_script.GetTokenLocation(end_token_pos(), &to_line, &to_col); | 6860 func_script.GetTokenLocation(end_token_pos(), &to_line, &to_col); |
6859 intptr_t last_tok_len = String::Handle(tkit.CurrentLiteral()).Length(); | 6861 intptr_t last_tok_len = String::Handle(tkit.CurrentLiteral()).Length(); |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7346 } | 7348 } |
7347 | 7349 |
7348 | 7350 |
7349 RawField* Field::New(const String& name, | 7351 RawField* Field::New(const String& name, |
7350 bool is_static, | 7352 bool is_static, |
7351 bool is_final, | 7353 bool is_final, |
7352 bool is_const, | 7354 bool is_const, |
7353 bool is_reflectable, | 7355 bool is_reflectable, |
7354 const Class& owner, | 7356 const Class& owner, |
7355 const AbstractType& type, | 7357 const AbstractType& type, |
7356 intptr_t token_pos) { | 7358 TokenPosition token_pos) { |
7357 ASSERT(!owner.IsNull()); | 7359 ASSERT(!owner.IsNull()); |
7358 const Field& result = Field::Handle(Field::New()); | 7360 const Field& result = Field::Handle(Field::New()); |
7359 result.set_name(name); | 7361 result.set_name(name); |
7360 result.set_is_static(is_static); | 7362 result.set_is_static(is_static); |
7361 if (!is_static) { | 7363 if (!is_static) { |
7362 result.SetOffset(0); | 7364 result.SetOffset(0); |
7363 } | 7365 } |
7364 result.set_is_final(is_final); | 7366 result.set_is_final(is_final); |
7365 result.set_is_const(is_const); | 7367 result.set_is_const(is_const); |
7366 result.set_is_reflectable(is_reflectable); | 7368 result.set_is_reflectable(is_reflectable); |
(...skipping 13 matching lines...) Expand all Loading... |
7380 result.set_guarded_list_length(Field::kNoFixedLength); | 7382 result.set_guarded_list_length(Field::kNoFixedLength); |
7381 } | 7383 } |
7382 return result.raw(); | 7384 return result.raw(); |
7383 } | 7385 } |
7384 | 7386 |
7385 | 7387 |
7386 RawField* Field::NewTopLevel(const String& name, | 7388 RawField* Field::NewTopLevel(const String& name, |
7387 bool is_final, | 7389 bool is_final, |
7388 bool is_const, | 7390 bool is_const, |
7389 const Object& owner, | 7391 const Object& owner, |
7390 intptr_t token_pos) { | 7392 TokenPosition token_pos) { |
7391 ASSERT(!owner.IsNull()); | 7393 ASSERT(!owner.IsNull()); |
7392 const Field& result = Field::Handle(Field::New()); | 7394 const Field& result = Field::Handle(Field::New()); |
7393 result.set_name(name); | 7395 result.set_name(name); |
7394 result.set_is_static(true); | 7396 result.set_is_static(true); |
7395 result.set_is_final(is_final); | 7397 result.set_is_final(is_final); |
7396 result.set_is_const(is_const); | 7398 result.set_is_const(is_const); |
7397 result.set_is_reflectable(true); | 7399 result.set_is_reflectable(true); |
7398 result.set_is_double_initialized(false); | 7400 result.set_is_double_initialized(false); |
7399 result.set_owner(owner); | 7401 result.set_owner(owner); |
7400 result.set_token_pos(token_pos); | 7402 result.set_token_pos(token_pos); |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7979 RawString* TokenStream::PrivateKey() const { | 7981 RawString* TokenStream::PrivateKey() const { |
7980 return raw_ptr()->private_key_; | 7982 return raw_ptr()->private_key_; |
7981 } | 7983 } |
7982 | 7984 |
7983 | 7985 |
7984 void TokenStream::SetPrivateKey(const String& value) const { | 7986 void TokenStream::SetPrivateKey(const String& value) const { |
7985 StorePointer(&raw_ptr()->private_key_, value.raw()); | 7987 StorePointer(&raw_ptr()->private_key_, value.raw()); |
7986 } | 7988 } |
7987 | 7989 |
7988 RawString* TokenStream::GenerateSource() const { | 7990 RawString* TokenStream::GenerateSource() const { |
7989 return GenerateSource(0, kMaxElements); | 7991 return GenerateSource(TokenPosition::kMinSource, |
| 7992 TokenPosition::kMaxSource); |
7990 } | 7993 } |
7991 | 7994 |
7992 RawString* TokenStream::GenerateSource(intptr_t start_pos, | 7995 RawString* TokenStream::GenerateSource(TokenPosition start_pos, |
7993 intptr_t end_pos) const { | 7996 TokenPosition end_pos) const { |
7994 Iterator iterator(*this, start_pos, Iterator::kAllTokens); | 7997 Iterator iterator(*this, start_pos, Iterator::kAllTokens); |
7995 const ExternalTypedData& data = ExternalTypedData::Handle(GetStream()); | 7998 const ExternalTypedData& data = ExternalTypedData::Handle(GetStream()); |
7996 const GrowableObjectArray& literals = | 7999 const GrowableObjectArray& literals = |
7997 GrowableObjectArray::Handle(GrowableObjectArray::New(data.Length())); | 8000 GrowableObjectArray::Handle(GrowableObjectArray::New(data.Length())); |
7998 const String& private_key = String::Handle(PrivateKey()); | 8001 const String& private_key = String::Handle(PrivateKey()); |
7999 intptr_t private_len = private_key.Length(); | 8002 intptr_t private_len = private_key.Length(); |
8000 | 8003 |
8001 Token::Kind curr = iterator.CurrentTokenKind(); | 8004 Token::Kind curr = iterator.CurrentTokenKind(); |
8002 Token::Kind prev = Token::kILLEGAL; | 8005 Token::Kind prev = Token::kILLEGAL; |
8003 // Handles used in the loop. | 8006 // Handles used in the loop. |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8157 | 8160 |
8158 // Setup for next iteration. | 8161 // Setup for next iteration. |
8159 prev = curr; | 8162 prev = curr; |
8160 curr = next; | 8163 curr = next; |
8161 } | 8164 } |
8162 const Array& source = Array::Handle(Array::MakeArray(literals)); | 8165 const Array& source = Array::Handle(Array::MakeArray(literals)); |
8163 return String::ConcatAll(source); | 8166 return String::ConcatAll(source); |
8164 } | 8167 } |
8165 | 8168 |
8166 | 8169 |
8167 intptr_t TokenStream::ComputeSourcePosition(intptr_t tok_pos) const { | 8170 TokenPosition TokenStream::ComputeSourcePosition( |
8168 Iterator iterator(*this, 0, Iterator::kAllTokens); | 8171 TokenPosition tok_pos) const { |
8169 intptr_t src_pos = 0; | 8172 Iterator iterator(*this, TokenPosition::kMinSource, Iterator::kAllTokens); |
| 8173 TokenPosition src_pos = TokenPosition::kMinSource; |
8170 Token::Kind kind = iterator.CurrentTokenKind(); | 8174 Token::Kind kind = iterator.CurrentTokenKind(); |
8171 while (iterator.CurrentPosition() < tok_pos && kind != Token::kEOS) { | 8175 while ((iterator.CurrentPosition() < tok_pos) && (kind != Token::kEOS)) { |
8172 iterator.Advance(); | 8176 iterator.Advance(); |
8173 kind = iterator.CurrentTokenKind(); | 8177 kind = iterator.CurrentTokenKind(); |
8174 src_pos += 1; | 8178 src_pos.Next(); |
8175 } | 8179 } |
8176 return src_pos; | 8180 return src_pos; |
8177 } | 8181 } |
8178 | 8182 |
8179 | 8183 |
8180 RawTokenStream* TokenStream::New() { | 8184 RawTokenStream* TokenStream::New() { |
8181 ASSERT(Object::token_stream_class() != Class::null()); | 8185 ASSERT(Object::token_stream_class() != Class::null()); |
8182 RawObject* raw = Object::Allocate(TokenStream::kClassId, | 8186 RawObject* raw = Object::Allocate(TokenStream::kClassId, |
8183 TokenStream::InstanceSize(), | 8187 TokenStream::InstanceSize(), |
8184 Heap::kOld); | 8188 Heap::kOld); |
(...skipping 14 matching lines...) Expand all Loading... |
8199 ExternalTypedData::New(kExternalTypedDataUint8ArrayCid, | 8203 ExternalTypedData::New(kExternalTypedDataUint8ArrayCid, |
8200 data, len, Heap::kOld)); | 8204 data, len, Heap::kOld)); |
8201 stream.AddFinalizer(data, DataFinalizer); | 8205 stream.AddFinalizer(data, DataFinalizer); |
8202 const TokenStream& result = TokenStream::Handle(zone, TokenStream::New()); | 8206 const TokenStream& result = TokenStream::Handle(zone, TokenStream::New()); |
8203 result.SetStream(stream); | 8207 result.SetStream(stream); |
8204 return result.raw(); | 8208 return result.raw(); |
8205 } | 8209 } |
8206 | 8210 |
8207 | 8211 |
8208 // CompressedTokenMap maps String and LiteralToken keys to Smi values. | 8212 // CompressedTokenMap maps String and LiteralToken keys to Smi values. |
8209 // It also supports lookup by Scanner::TokenDescriptor. | 8213 // It also supports lookup by TokenDescriptor. |
8210 class CompressedTokenTraits { | 8214 class CompressedTokenTraits { |
8211 public: | 8215 public: |
8212 static bool IsMatch(const Scanner::TokenDescriptor& descriptor, | 8216 static bool IsMatch(const Scanner::TokenDescriptor& descriptor, |
8213 const Object& key) { | 8217 const Object& key) { |
8214 if (!key.IsLiteralToken()) { | 8218 if (!key.IsLiteralToken()) { |
8215 return false; | 8219 return false; |
8216 } | 8220 } |
8217 const LiteralToken& token = LiteralToken::Cast(key); | 8221 const LiteralToken& token = LiteralToken::Cast(key); |
8218 return (token.literal() == descriptor.literal->raw()) && | 8222 return (token.literal() == descriptor.literal->raw()) && |
8219 (token.kind() == descriptor.kind); | 8223 (token.kind() == descriptor.kind); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8437 } | 8441 } |
8438 const String& private_key = String::Handle(PrivateKey()); | 8442 const String& private_key = String::Handle(PrivateKey()); |
8439 jsobj.AddProperty("privateKey", private_key); | 8443 jsobj.AddProperty("privateKey", private_key); |
8440 // TODO(johnmccutchan): Add support for printing LiteralTokens and add | 8444 // TODO(johnmccutchan): Add support for printing LiteralTokens and add |
8441 // them to members array. | 8445 // them to members array. |
8442 JSONArray members(&jsobj, "members"); | 8446 JSONArray members(&jsobj, "members"); |
8443 } | 8447 } |
8444 | 8448 |
8445 | 8449 |
8446 TokenStream::Iterator::Iterator(const TokenStream& tokens, | 8450 TokenStream::Iterator::Iterator(const TokenStream& tokens, |
8447 intptr_t token_pos, | 8451 TokenPosition token_pos, |
8448 Iterator::StreamType stream_type) | 8452 Iterator::StreamType stream_type) |
8449 : tokens_(TokenStream::Handle(tokens.raw())), | 8453 : tokens_(TokenStream::Handle(tokens.raw())), |
8450 data_(ExternalTypedData::Handle(tokens.GetStream())), | 8454 data_(ExternalTypedData::Handle(tokens.GetStream())), |
8451 stream_(reinterpret_cast<uint8_t*>(data_.DataAddr(0)), data_.Length()), | 8455 stream_(reinterpret_cast<uint8_t*>(data_.DataAddr(0)), data_.Length()), |
8452 token_objects_(Array::Handle( | 8456 token_objects_(Array::Handle( |
8453 GrowableObjectArray::Handle(tokens.TokenObjects()).data())), | 8457 GrowableObjectArray::Handle(tokens.TokenObjects()).data())), |
8454 obj_(Object::Handle()), | 8458 obj_(Object::Handle()), |
8455 cur_token_pos_(token_pos), | 8459 cur_token_pos_(token_pos.Pos()), |
8456 cur_token_kind_(Token::kILLEGAL), | 8460 cur_token_kind_(Token::kILLEGAL), |
8457 cur_token_obj_index_(-1), | 8461 cur_token_obj_index_(-1), |
8458 stream_type_(stream_type) { | 8462 stream_type_(stream_type) { |
8459 ASSERT(token_pos != Token::kNoSourcePos); | 8463 ASSERT(token_pos != TokenPosition::kNoSource); |
8460 if (token_pos >= 0) { | 8464 if (token_pos.IsReal()) { |
8461 SetCurrentPosition(token_pos); | 8465 SetCurrentPosition(token_pos); |
8462 } | 8466 } |
8463 } | 8467 } |
8464 | 8468 |
8465 | 8469 |
8466 void TokenStream::Iterator::SetStream(const TokenStream& tokens, | 8470 void TokenStream::Iterator::SetStream(const TokenStream& tokens, |
8467 intptr_t token_pos) { | 8471 TokenPosition token_pos) { |
8468 tokens_ = tokens.raw(); | 8472 tokens_ = tokens.raw(); |
8469 data_ = tokens.GetStream(); | 8473 data_ = tokens.GetStream(); |
8470 stream_.SetStream(reinterpret_cast<uint8_t*>(data_.DataAddr(0)), | 8474 stream_.SetStream(reinterpret_cast<uint8_t*>(data_.DataAddr(0)), |
8471 data_.Length()); | 8475 data_.Length()); |
8472 token_objects_ = GrowableObjectArray::Handle(tokens.TokenObjects()).data(); | 8476 token_objects_ = GrowableObjectArray::Handle(tokens.TokenObjects()).data(); |
8473 obj_ = Object::null(); | 8477 obj_ = Object::null(); |
8474 cur_token_pos_ = token_pos; | 8478 cur_token_pos_ = token_pos.Pos(); |
8475 cur_token_kind_ = Token::kILLEGAL; | 8479 cur_token_kind_ = Token::kILLEGAL; |
8476 cur_token_obj_index_ = -1; | 8480 cur_token_obj_index_ = -1; |
8477 SetCurrentPosition(token_pos); | 8481 SetCurrentPosition(token_pos); |
8478 } | 8482 } |
8479 | 8483 |
8480 | 8484 |
8481 bool TokenStream::Iterator::IsValid() const { | 8485 bool TokenStream::Iterator::IsValid() const { |
8482 return !tokens_.IsNull(); | 8486 return !tokens_.IsNull(); |
8483 } | 8487 } |
8484 | 8488 |
(...skipping 21 matching lines...) Expand all Loading... |
8506 } else { | 8510 } else { |
8507 ASSERT(obj_.IsString()); // Must be an identifier. | 8511 ASSERT(obj_.IsString()); // Must be an identifier. |
8508 kind = Token::kIDENT; | 8512 kind = Token::kIDENT; |
8509 } | 8513 } |
8510 } | 8514 } |
8511 stream_.SetPosition(saved_position); | 8515 stream_.SetPosition(saved_position); |
8512 return kind; | 8516 return kind; |
8513 } | 8517 } |
8514 | 8518 |
8515 | 8519 |
8516 intptr_t TokenStream::Iterator::CurrentPosition() const { | 8520 TokenPosition TokenStream::Iterator::CurrentPosition() const { |
8517 return cur_token_pos_; | 8521 return TokenPosition(cur_token_pos_); |
8518 } | 8522 } |
8519 | 8523 |
8520 | 8524 |
8521 void TokenStream::Iterator::SetCurrentPosition(intptr_t value) { | 8525 void TokenStream::Iterator::SetCurrentPosition(TokenPosition token_pos) { |
8522 stream_.SetPosition(value); | 8526 stream_.SetPosition(token_pos.value()); |
8523 Advance(); | 8527 Advance(); |
8524 } | 8528 } |
8525 | 8529 |
8526 | 8530 |
8527 void TokenStream::Iterator::Advance() { | 8531 void TokenStream::Iterator::Advance() { |
8528 intptr_t value; | 8532 intptr_t value; |
8529 do { | 8533 do { |
8530 cur_token_pos_ = stream_.Position(); | 8534 cur_token_pos_ = stream_.Position(); |
8531 value = ReadToken(); | 8535 value = ReadToken(); |
8532 } while ((stream_type_ == kNoNewlines) && | 8536 } while ((stream_type_ == kNoNewlines) && |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8610 Zone* zone = Thread::Current()->zone(); | 8614 Zone* zone = Thread::Current()->zone(); |
8611 const GrowableObjectArray& info = | 8615 const GrowableObjectArray& info = |
8612 GrowableObjectArray::Handle(zone, GrowableObjectArray::New()); | 8616 GrowableObjectArray::Handle(zone, GrowableObjectArray::New()); |
8613 const String& source = String::Handle(zone, Source()); | 8617 const String& source = String::Handle(zone, Source()); |
8614 const String& key = Symbols::Empty(); | 8618 const String& key = Symbols::Empty(); |
8615 const Object& line_separator = Object::Handle(zone); | 8619 const Object& line_separator = Object::Handle(zone); |
8616 const TokenStream& tkns = TokenStream::Handle(zone, tokens()); | 8620 const TokenStream& tkns = TokenStream::Handle(zone, tokens()); |
8617 Smi& value = Smi::Handle(zone); | 8621 Smi& value = Smi::Handle(zone); |
8618 String& tokenValue = String::Handle(zone); | 8622 String& tokenValue = String::Handle(zone); |
8619 ASSERT(!tkns.IsNull()); | 8623 ASSERT(!tkns.IsNull()); |
8620 TokenStream::Iterator tkit(tkns, 0, TokenStream::Iterator::kAllTokens); | 8624 TokenStream::Iterator tkit(tkns, |
| 8625 TokenPosition::kMinSource, |
| 8626 TokenStream::Iterator::kAllTokens); |
8621 int current_line = -1; | 8627 int current_line = -1; |
8622 Scanner s(source, key); | 8628 Scanner s(source, key); |
8623 s.Scan(); | 8629 s.Scan(); |
8624 bool skippedNewline = false; | 8630 bool skippedNewline = false; |
8625 while (tkit.CurrentTokenKind() != Token::kEOS) { | 8631 while (tkit.CurrentTokenKind() != Token::kEOS) { |
8626 if (tkit.CurrentTokenKind() == Token::kNEWLINE) { | 8632 if (tkit.CurrentTokenKind() == Token::kNEWLINE) { |
8627 // Skip newlines from the token stream. | 8633 // Skip newlines from the token stream. |
8628 skippedNewline = true; | 8634 skippedNewline = true; |
8629 tkit.Advance(); | 8635 tkit.Advance(); |
8630 continue; | 8636 continue; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8665 if (token_line != current_line) { | 8671 if (token_line != current_line) { |
8666 // emit line | 8672 // emit line |
8667 info.Add(line_separator); | 8673 info.Add(line_separator); |
8668 value = Smi::New(token_line + line_offset()); | 8674 value = Smi::New(token_line + line_offset()); |
8669 info.Add(value); | 8675 info.Add(value); |
8670 current_line = token_line; | 8676 current_line = token_line; |
8671 } | 8677 } |
8672 // TODO(hausner): Could optimize here by not reporting tokens | 8678 // TODO(hausner): Could optimize here by not reporting tokens |
8673 // that will never be a location used by the debugger, e.g. | 8679 // that will never be a location used by the debugger, e.g. |
8674 // braces, semicolons, most keywords etc. | 8680 // braces, semicolons, most keywords etc. |
8675 value = Smi::New(tkit.CurrentPosition()); | 8681 value = Smi::New(tkit.CurrentPosition().Pos()); |
8676 info.Add(value); | 8682 info.Add(value); |
8677 int column = s.current_token().position.column; | 8683 int column = s.current_token().position.column; |
8678 // On the first line of the script we must add the column offset. | 8684 // On the first line of the script we must add the column offset. |
8679 if (token_line == 1) { | 8685 if (token_line == 1) { |
8680 column += col_offset(); | 8686 column += col_offset(); |
8681 } | 8687 } |
8682 value = Smi::New(column); | 8688 value = Smi::New(column); |
8683 info.Add(value); | 8689 info.Add(value); |
8684 tkit.Advance(); | 8690 tkit.Advance(); |
8685 s.Scan(); | 8691 s.Scan(); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8752 | 8758 |
8753 void Script::SetLocationOffset(intptr_t line_offset, | 8759 void Script::SetLocationOffset(intptr_t line_offset, |
8754 intptr_t col_offset) const { | 8760 intptr_t col_offset) const { |
8755 ASSERT(line_offset >= 0); | 8761 ASSERT(line_offset >= 0); |
8756 ASSERT(col_offset >= 0); | 8762 ASSERT(col_offset >= 0); |
8757 StoreNonPointer(&raw_ptr()->line_offset_, line_offset); | 8763 StoreNonPointer(&raw_ptr()->line_offset_, line_offset); |
8758 StoreNonPointer(&raw_ptr()->col_offset_, col_offset); | 8764 StoreNonPointer(&raw_ptr()->col_offset_, col_offset); |
8759 } | 8765 } |
8760 | 8766 |
8761 | 8767 |
8762 void Script::GetTokenLocation(intptr_t token_pos, | 8768 void Script::GetTokenLocation(TokenPosition token_pos, |
8763 intptr_t* line, | 8769 intptr_t* line, |
8764 intptr_t* column, | 8770 intptr_t* column, |
8765 intptr_t* token_len) const { | 8771 intptr_t* token_len) const { |
8766 ASSERT(line != NULL); | 8772 ASSERT(line != NULL); |
8767 const TokenStream& tkns = TokenStream::Handle(tokens()); | 8773 const TokenStream& tkns = TokenStream::Handle(tokens()); |
8768 if (tkns.IsNull()) { | 8774 if (tkns.IsNull()) { |
8769 ASSERT(Dart::IsRunningPrecompiledCode()); | 8775 ASSERT(Dart::IsRunningPrecompiledCode()); |
8770 *line = -1; | 8776 *line = -1; |
8771 if (column != NULL) { | 8777 if (column != NULL) { |
8772 *column = -1; | 8778 *column = -1; |
8773 } | 8779 } |
8774 if (token_len != NULL) { | 8780 if (token_len != NULL) { |
8775 *token_len = 1; | 8781 *token_len = 1; |
8776 } | 8782 } |
8777 return; | 8783 return; |
8778 } | 8784 } |
8779 if (column == NULL) { | 8785 if (column == NULL) { |
8780 TokenStream::Iterator tkit(tkns, 0, TokenStream::Iterator::kAllTokens); | 8786 TokenStream::Iterator tkit(tkns, |
| 8787 TokenPosition::kMinSource, |
| 8788 TokenStream::Iterator::kAllTokens); |
8781 intptr_t cur_line = line_offset() + 1; | 8789 intptr_t cur_line = line_offset() + 1; |
8782 while (tkit.CurrentPosition() < token_pos && | 8790 while ((tkit.CurrentPosition() < token_pos) && |
8783 tkit.CurrentTokenKind() != Token::kEOS) { | 8791 (tkit.CurrentTokenKind() != Token::kEOS)) { |
8784 if (tkit.CurrentTokenKind() == Token::kNEWLINE) { | 8792 if (tkit.CurrentTokenKind() == Token::kNEWLINE) { |
8785 cur_line++; | 8793 cur_line++; |
8786 } | 8794 } |
8787 tkit.Advance(); | 8795 tkit.Advance(); |
8788 } | 8796 } |
8789 *line = cur_line; | 8797 *line = cur_line; |
8790 } else { | 8798 } else { |
8791 const String& src = String::Handle(Source()); | 8799 const String& src = String::Handle(Source()); |
8792 intptr_t src_pos = tkns.ComputeSourcePosition(token_pos); | 8800 TokenPosition src_pos = tkns.ComputeSourcePosition(token_pos); |
8793 Scanner scanner(src, Symbols::Empty()); | 8801 Scanner scanner(src, Symbols::Empty()); |
8794 scanner.ScanTo(src_pos); | 8802 scanner.ScanTo(src_pos); |
8795 intptr_t relative_line = scanner.CurrentPosition().line; | 8803 intptr_t relative_line = scanner.CurrentPosition().line; |
8796 *line = relative_line + line_offset(); | 8804 *line = relative_line + line_offset(); |
8797 *column = scanner.CurrentPosition().column; | 8805 *column = scanner.CurrentPosition().column; |
8798 if (token_len != NULL) { | 8806 if (token_len != NULL) { |
8799 if (scanner.current_token().literal != NULL) { | 8807 if (scanner.current_token().literal != NULL) { |
8800 *token_len = scanner.current_token().literal->Length(); | 8808 *token_len = scanner.current_token().literal->Length(); |
8801 } else { | 8809 } else { |
8802 *token_len = 1; | 8810 *token_len = 1; |
8803 } | 8811 } |
8804 } | 8812 } |
8805 // On the first line of the script we must add the column offset. | 8813 // On the first line of the script we must add the column offset. |
8806 if (relative_line == 1) { | 8814 if (relative_line == 1) { |
8807 *column += col_offset(); | 8815 *column += col_offset(); |
8808 } | 8816 } |
8809 } | 8817 } |
8810 } | 8818 } |
8811 | 8819 |
8812 | 8820 |
8813 void Script::TokenRangeAtLine(intptr_t line_number, | 8821 void Script::TokenRangeAtLine(intptr_t line_number, |
8814 intptr_t* first_token_index, | 8822 TokenPosition* first_token_index, |
8815 intptr_t* last_token_index) const { | 8823 TokenPosition* last_token_index) const { |
8816 ASSERT(first_token_index != NULL && last_token_index != NULL); | 8824 ASSERT(first_token_index != NULL && last_token_index != NULL); |
8817 ASSERT(line_number > 0); | 8825 ASSERT(line_number > 0); |
8818 *first_token_index = -1; | 8826 *first_token_index = TokenPosition::kNoSource; |
8819 *last_token_index = -1; | 8827 *last_token_index = TokenPosition::kNoSource; |
8820 const TokenStream& tkns = TokenStream::Handle(tokens()); | 8828 const TokenStream& tkns = TokenStream::Handle(tokens()); |
8821 line_number -= line_offset(); | 8829 line_number -= line_offset(); |
8822 if (line_number < 1) line_number = 1; | 8830 if (line_number < 1) line_number = 1; |
8823 TokenStream::Iterator tkit(tkns, 0, TokenStream::Iterator::kAllTokens); | 8831 TokenStream::Iterator tkit(tkns, |
| 8832 TokenPosition::kMinSource, |
| 8833 TokenStream::Iterator::kAllTokens); |
8824 // Scan through the token stream to the required line. | 8834 // Scan through the token stream to the required line. |
8825 intptr_t cur_line = 1; | 8835 intptr_t cur_line = 1; |
8826 while (cur_line < line_number && tkit.CurrentTokenKind() != Token::kEOS) { | 8836 while (cur_line < line_number && tkit.CurrentTokenKind() != Token::kEOS) { |
8827 if (tkit.CurrentTokenKind() == Token::kNEWLINE) { | 8837 if (tkit.CurrentTokenKind() == Token::kNEWLINE) { |
8828 cur_line++; | 8838 cur_line++; |
8829 } | 8839 } |
8830 tkit.Advance(); | 8840 tkit.Advance(); |
8831 } | 8841 } |
8832 if (tkit.CurrentTokenKind() == Token::kEOS) { | 8842 if (tkit.CurrentTokenKind() == Token::kEOS) { |
8833 // End of token stream before reaching required line. | 8843 // End of token stream before reaching required line. |
8834 return; | 8844 return; |
8835 } | 8845 } |
8836 if (tkit.CurrentTokenKind() == Token::kNEWLINE) { | 8846 if (tkit.CurrentTokenKind() == Token::kNEWLINE) { |
8837 // No tokens on the current line. If there is a valid token afterwards, put | 8847 // No tokens on the current line. If there is a valid token afterwards, put |
8838 // it into first_token_index. | 8848 // it into first_token_index. |
8839 while (tkit.CurrentTokenKind() == Token::kNEWLINE && | 8849 while (tkit.CurrentTokenKind() == Token::kNEWLINE && |
8840 tkit.CurrentTokenKind() != Token::kEOS) { | 8850 tkit.CurrentTokenKind() != Token::kEOS) { |
8841 tkit.Advance(); | 8851 tkit.Advance(); |
8842 } | 8852 } |
8843 if (tkit.CurrentTokenKind() != Token::kEOS) { | 8853 if (tkit.CurrentTokenKind() != Token::kEOS) { |
8844 *first_token_index = tkit.CurrentPosition(); | 8854 *first_token_index = tkit.CurrentPosition(); |
8845 } | 8855 } |
8846 return; | 8856 return; |
8847 } | 8857 } |
8848 *first_token_index = tkit.CurrentPosition(); | 8858 *first_token_index = tkit.CurrentPosition(); |
8849 // We cannot do "CurrentPosition() - 1" for the last token, because we do not | 8859 // We cannot do "CurrentPosition() - 1" for the last token, because we do not |
8850 // know whether the previous token is a simple one or not. | 8860 // know whether the previous token is a simple one or not. |
8851 intptr_t end_pos = *first_token_index; | 8861 TokenPosition end_pos = *first_token_index; |
8852 while (tkit.CurrentTokenKind() != Token::kNEWLINE && | 8862 while (tkit.CurrentTokenKind() != Token::kNEWLINE && |
8853 tkit.CurrentTokenKind() != Token::kEOS) { | 8863 tkit.CurrentTokenKind() != Token::kEOS) { |
8854 end_pos = tkit.CurrentPosition(); | 8864 end_pos = tkit.CurrentPosition(); |
8855 tkit.Advance(); | 8865 tkit.Advance(); |
8856 } | 8866 } |
8857 *last_token_index = end_pos; | 8867 *last_token_index = end_pos; |
8858 } | 8868 } |
8859 | 8869 |
8860 | 8870 |
8861 RawString* Script::GetLine(intptr_t line_number, Heap::Space space) const { | 8871 RawString* Script::GetLine(intptr_t line_number, Heap::Space space) const { |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9144 next_ix_++; | 9154 next_ix_++; |
9145 obj = array_.At(next_ix_); | 9155 obj = array_.At(next_ix_); |
9146 } | 9156 } |
9147 } | 9157 } |
9148 | 9158 |
9149 | 9159 |
9150 static void ReportTooManyImports(const Library& lib) { | 9160 static void ReportTooManyImports(const Library& lib) { |
9151 const String& url = String::Handle(lib.url()); | 9161 const String& url = String::Handle(lib.url()); |
9152 Report::MessageF(Report::kError, | 9162 Report::MessageF(Report::kError, |
9153 Script::Handle(lib.LookupScript(url)), | 9163 Script::Handle(lib.LookupScript(url)), |
9154 Token::kNoSourcePos, | 9164 TokenPosition::kNoSource, |
9155 Report::AtLocation, | 9165 Report::AtLocation, |
9156 "too many imports in library '%s'", | 9166 "too many imports in library '%s'", |
9157 url.ToCString()); | 9167 url.ToCString()); |
9158 UNREACHABLE(); | 9168 UNREACHABLE(); |
9159 } | 9169 } |
9160 | 9170 |
9161 | 9171 |
9162 void Library::set_num_imports(intptr_t value) const { | 9172 void Library::set_num_imports(intptr_t value) const { |
9163 if (!Utils::IsUint(16, value)) { | 9173 if (!Utils::IsUint(16, value)) { |
9164 ReportTooManyImports(*this); | 9174 ReportTooManyImports(*this); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9331 GrowableHandlePtrArray<const String> pieces(Thread::Current()->zone(), 3); | 9341 GrowableHandlePtrArray<const String> pieces(Thread::Current()->zone(), 3); |
9332 pieces.Add(cname); | 9342 pieces.Add(cname); |
9333 pieces.Add(Symbols::At()); | 9343 pieces.Add(Symbols::At()); |
9334 pieces.Add(String::Handle(param.name())); | 9344 pieces.Add(String::Handle(param.name())); |
9335 return Symbols::FromConcatAll(pieces); | 9345 return Symbols::FromConcatAll(pieces); |
9336 } | 9346 } |
9337 | 9347 |
9338 | 9348 |
9339 void Library::AddMetadata(const Object& owner, | 9349 void Library::AddMetadata(const Object& owner, |
9340 const String& name, | 9350 const String& name, |
9341 intptr_t token_pos) const { | 9351 TokenPosition token_pos) const { |
9342 const String& metaname = String::Handle(Symbols::New(name)); | 9352 const String& metaname = String::Handle(Symbols::New(name)); |
9343 const Field& field = Field::Handle( | 9353 const Field& field = Field::Handle( |
9344 Field::NewTopLevel(metaname, | 9354 Field::NewTopLevel(metaname, |
9345 false, // is_final | 9355 false, // is_final |
9346 false, // is_const | 9356 false, // is_const |
9347 owner, | 9357 owner, |
9348 token_pos)); | 9358 token_pos)); |
9349 field.SetFieldType(Object::dynamic_type()); | 9359 field.SetFieldType(Object::dynamic_type()); |
9350 field.set_is_reflectable(false); | 9360 field.set_is_reflectable(false); |
9351 field.SetStaticValue(Array::empty_array(), true); | 9361 field.SetStaticValue(Array::empty_array(), true); |
9352 GrowableObjectArray& metadata = | 9362 GrowableObjectArray& metadata = |
9353 GrowableObjectArray::Handle(this->metadata()); | 9363 GrowableObjectArray::Handle(this->metadata()); |
9354 metadata.Add(field, Heap::kOld); | 9364 metadata.Add(field, Heap::kOld); |
9355 } | 9365 } |
9356 | 9366 |
9357 | 9367 |
9358 void Library::AddClassMetadata(const Class& cls, | 9368 void Library::AddClassMetadata(const Class& cls, |
9359 const Object& tl_owner, | 9369 const Object& tl_owner, |
9360 intptr_t token_pos) const { | 9370 TokenPosition token_pos) const { |
9361 // We use the toplevel class as the owner of a class's metadata field because | 9371 // We use the toplevel class as the owner of a class's metadata field because |
9362 // a class's metadata is in scope of the library, not the class. | 9372 // a class's metadata is in scope of the library, not the class. |
9363 AddMetadata(tl_owner, | 9373 AddMetadata(tl_owner, |
9364 String::Handle(MakeClassMetaName(cls)), | 9374 String::Handle(MakeClassMetaName(cls)), |
9365 token_pos); | 9375 token_pos); |
9366 } | 9376 } |
9367 | 9377 |
9368 | 9378 |
9369 void Library::AddFieldMetadata(const Field& field, | 9379 void Library::AddFieldMetadata(const Field& field, |
9370 intptr_t token_pos) const { | 9380 TokenPosition token_pos) const { |
9371 AddMetadata(Object::Handle(field.RawOwner()), | 9381 AddMetadata(Object::Handle(field.RawOwner()), |
9372 String::Handle(MakeFieldMetaName(field)), | 9382 String::Handle(MakeFieldMetaName(field)), |
9373 token_pos); | 9383 token_pos); |
9374 } | 9384 } |
9375 | 9385 |
9376 | 9386 |
9377 void Library::AddFunctionMetadata(const Function& func, | 9387 void Library::AddFunctionMetadata(const Function& func, |
9378 intptr_t token_pos) const { | 9388 TokenPosition token_pos) const { |
9379 AddMetadata(Object::Handle(func.RawOwner()), | 9389 AddMetadata(Object::Handle(func.RawOwner()), |
9380 String::Handle(MakeFunctionMetaName(func)), | 9390 String::Handle(MakeFunctionMetaName(func)), |
9381 token_pos); | 9391 token_pos); |
9382 } | 9392 } |
9383 | 9393 |
9384 | 9394 |
9385 void Library::AddTypeParameterMetadata(const TypeParameter& param, | 9395 void Library::AddTypeParameterMetadata(const TypeParameter& param, |
9386 intptr_t token_pos) const { | 9396 TokenPosition token_pos) const { |
9387 AddMetadata(Class::Handle(param.parameterized_class()), | 9397 AddMetadata(Class::Handle(param.parameterized_class()), |
9388 String::Handle(MakeTypeParameterMetaName(param)), | 9398 String::Handle(MakeTypeParameterMetaName(param)), |
9389 token_pos); | 9399 token_pos); |
9390 } | 9400 } |
9391 | 9401 |
9392 | 9402 |
9393 void Library::AddLibraryMetadata(const Object& tl_owner, | 9403 void Library::AddLibraryMetadata(const Object& tl_owner, |
9394 intptr_t token_pos) const { | 9404 TokenPosition token_pos) const { |
9395 AddMetadata(tl_owner, Symbols::TopLevel(), token_pos); | 9405 AddMetadata(tl_owner, Symbols::TopLevel(), token_pos); |
9396 } | 9406 } |
9397 | 9407 |
9398 | 9408 |
9399 RawString* Library::MakeMetadataName(const Object& obj) const { | 9409 RawString* Library::MakeMetadataName(const Object& obj) const { |
9400 if (obj.IsClass()) { | 9410 if (obj.IsClass()) { |
9401 return MakeClassMetaName(Class::Cast(obj)); | 9411 return MakeClassMetaName(Class::Cast(obj)); |
9402 } else if (obj.IsField()) { | 9412 } else if (obj.IsField()) { |
9403 return MakeFieldMetaName(Field::Cast(obj)); | 9413 return MakeFieldMetaName(Field::Cast(obj)); |
9404 } else if (obj.IsFunction()) { | 9414 } else if (obj.IsFunction()) { |
(...skipping 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10836 void LibraryPrefix::PrintJSONImpl(JSONStream* stream, bool ref) const { | 10846 void LibraryPrefix::PrintJSONImpl(JSONStream* stream, bool ref) const { |
10837 Object::PrintJSONImpl(stream, ref); | 10847 Object::PrintJSONImpl(stream, ref); |
10838 } | 10848 } |
10839 | 10849 |
10840 | 10850 |
10841 void Namespace::set_metadata_field(const Field& value) const { | 10851 void Namespace::set_metadata_field(const Field& value) const { |
10842 StorePointer(&raw_ptr()->metadata_field_, value.raw()); | 10852 StorePointer(&raw_ptr()->metadata_field_, value.raw()); |
10843 } | 10853 } |
10844 | 10854 |
10845 | 10855 |
10846 void Namespace::AddMetadata(const Object& owner, intptr_t token_pos) { | 10856 void Namespace::AddMetadata(const Object& owner, TokenPosition token_pos) { |
10847 ASSERT(Field::Handle(metadata_field()).IsNull()); | 10857 ASSERT(Field::Handle(metadata_field()).IsNull()); |
10848 Field& field = Field::Handle(Field::NewTopLevel(Symbols::TopLevel(), | 10858 Field& field = Field::Handle(Field::NewTopLevel(Symbols::TopLevel(), |
10849 false, // is_final | 10859 false, // is_final |
10850 false, // is_const | 10860 false, // is_const |
10851 owner, | 10861 owner, |
10852 token_pos)); | 10862 token_pos)); |
10853 field.set_is_reflectable(false); | 10863 field.set_is_reflectable(false); |
10854 field.SetFieldType(Object::dynamic_type()); | 10864 field.SetFieldType(Object::dynamic_type()); |
10855 field.SetStaticValue(Array::empty_array(), true); | 10865 field.SetStaticValue(Array::empty_array(), true); |
10856 set_metadata_field(field); | 10866 set_metadata_field(field); |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11405 // "*" in a printf format specifier tells it to read the field width from | 11415 // "*" in a printf format specifier tells it to read the field width from |
11406 // the printf argument list. | 11416 // the printf argument list. |
11407 THR_Print("%-*s\tkind \tdeopt-id\ttok-ix\ttry-ix\n", | 11417 THR_Print("%-*s\tkind \tdeopt-id\ttok-ix\ttry-ix\n", |
11408 addr_width, "pc"); | 11418 addr_width, "pc"); |
11409 } | 11419 } |
11410 | 11420 |
11411 | 11421 |
11412 const char* PcDescriptors::ToCString() const { | 11422 const char* PcDescriptors::ToCString() const { |
11413 // "*" in a printf format specifier tells it to read the field width from | 11423 // "*" in a printf format specifier tells it to read the field width from |
11414 // the printf argument list. | 11424 // the printf argument list. |
11415 #define FORMAT "%#-*" Px "\t%s\t%" Pd "\t\t%" Pd "\t%" Pd "\n" | 11425 #define FORMAT "%#-*" Px "\t%s\t%" Pd "\t\t%s\t%" Pd "\n" |
11416 if (Length() == 0) { | 11426 if (Length() == 0) { |
11417 return "empty PcDescriptors\n"; | 11427 return "empty PcDescriptors\n"; |
11418 } | 11428 } |
11419 // 4 bits per hex digit. | 11429 // 4 bits per hex digit. |
11420 const int addr_width = kBitsPerWord / 4; | 11430 const int addr_width = kBitsPerWord / 4; |
11421 // First compute the buffer size required. | 11431 // First compute the buffer size required. |
11422 intptr_t len = 1; // Trailing '\0'. | 11432 intptr_t len = 1; // Trailing '\0'. |
11423 { | 11433 { |
11424 Iterator iter(*this, RawPcDescriptors::kAnyKind); | 11434 Iterator iter(*this, RawPcDescriptors::kAnyKind); |
11425 while (iter.MoveNext()) { | 11435 while (iter.MoveNext()) { |
11426 len += OS::SNPrint(NULL, 0, FORMAT, addr_width, | 11436 len += OS::SNPrint(NULL, 0, FORMAT, addr_width, |
11427 iter.PcOffset(), | 11437 iter.PcOffset(), |
11428 KindAsStr(iter.Kind()), | 11438 KindAsStr(iter.Kind()), |
11429 iter.DeoptId(), | 11439 iter.DeoptId(), |
11430 iter.TokenPos(), | 11440 iter.TokenPos().ToCString(), |
11431 iter.TryIndex()); | 11441 iter.TryIndex()); |
11432 } | 11442 } |
11433 } | 11443 } |
11434 // Allocate the buffer. | 11444 // Allocate the buffer. |
11435 char* buffer = Thread::Current()->zone()->Alloc<char>(len); | 11445 char* buffer = Thread::Current()->zone()->Alloc<char>(len); |
11436 // Layout the fields in the buffer. | 11446 // Layout the fields in the buffer. |
11437 intptr_t index = 0; | 11447 intptr_t index = 0; |
11438 Iterator iter(*this, RawPcDescriptors::kAnyKind); | 11448 Iterator iter(*this, RawPcDescriptors::kAnyKind); |
11439 while (iter.MoveNext()) { | 11449 while (iter.MoveNext()) { |
11440 index += OS::SNPrint((buffer + index), (len - index), FORMAT, addr_width, | 11450 index += OS::SNPrint((buffer + index), (len - index), FORMAT, addr_width, |
11441 iter.PcOffset(), | 11451 iter.PcOffset(), |
11442 KindAsStr(iter.Kind()), | 11452 KindAsStr(iter.Kind()), |
11443 iter.DeoptId(), | 11453 iter.DeoptId(), |
11444 iter.TokenPos(), | 11454 iter.TokenPos().ToCString(), |
11445 iter.TryIndex()); | 11455 iter.TryIndex()); |
11446 } | 11456 } |
11447 return buffer; | 11457 return buffer; |
11448 #undef FORMAT | 11458 #undef FORMAT |
11449 } | 11459 } |
11450 | 11460 |
11451 | 11461 |
11452 void PcDescriptors::PrintToJSONObject(JSONObject* jsobj, bool ref) const { | 11462 void PcDescriptors::PrintToJSONObject(JSONObject* jsobj, bool ref) const { |
11453 AddCommonObjectProperties(jsobj, "Object", ref); | 11463 AddCommonObjectProperties(jsobj, "Object", ref); |
11454 // TODO(johnmccutchan): Generate a stable id. PcDescriptors hang off a Code | 11464 // TODO(johnmccutchan): Generate a stable id. PcDescriptors hang off a Code |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11576 | 11586 |
11577 | 11587 |
11578 void CodeSourceMap::PrintJSONImpl(JSONStream* stream, bool ref) const { | 11588 void CodeSourceMap::PrintJSONImpl(JSONStream* stream, bool ref) const { |
11579 Object::PrintJSONImpl(stream, ref); | 11589 Object::PrintJSONImpl(stream, ref); |
11580 } | 11590 } |
11581 | 11591 |
11582 | 11592 |
11583 const char* CodeSourceMap::ToCString() const { | 11593 const char* CodeSourceMap::ToCString() const { |
11584 // "*" in a printf format specifier tells it to read the field width from | 11594 // "*" in a printf format specifier tells it to read the field width from |
11585 // the printf argument list. | 11595 // the printf argument list. |
11586 #define FORMAT "%#-*" Px "\t%" Pd "\n" | 11596 #define FORMAT "%#-*" Px "\t%s\n" |
11587 if (Length() == 0) { | 11597 if (Length() == 0) { |
11588 return "empty CodeSourceMap\n"; | 11598 return "empty CodeSourceMap\n"; |
11589 } | 11599 } |
11590 // 4 bits per hex digit. | 11600 // 4 bits per hex digit. |
11591 const int addr_width = kBitsPerWord / 4; | 11601 const int addr_width = kBitsPerWord / 4; |
11592 // First compute the buffer size required. | 11602 // First compute the buffer size required. |
11593 intptr_t len = 1; // Trailing '\0'. | 11603 intptr_t len = 1; // Trailing '\0'. |
11594 { | 11604 { |
11595 Iterator iter(*this); | 11605 Iterator iter(*this); |
11596 while (iter.MoveNext()) { | 11606 while (iter.MoveNext()) { |
11597 len += OS::SNPrint(NULL, 0, FORMAT, addr_width, | 11607 len += OS::SNPrint(NULL, 0, FORMAT, addr_width, |
11598 iter.PcOffset(), | 11608 iter.PcOffset(), |
11599 iter.TokenPos()); | 11609 iter.TokenPos().ToCString()); |
11600 } | 11610 } |
11601 } | 11611 } |
11602 // Allocate the buffer. | 11612 // Allocate the buffer. |
11603 char* buffer = Thread::Current()->zone()->Alloc<char>(len); | 11613 char* buffer = Thread::Current()->zone()->Alloc<char>(len); |
11604 // Layout the fields in the buffer. | 11614 // Layout the fields in the buffer. |
11605 intptr_t index = 0; | 11615 intptr_t index = 0; |
11606 Iterator iter(*this); | 11616 Iterator iter(*this); |
11607 while (iter.MoveNext()) { | 11617 while (iter.MoveNext()) { |
11608 index += OS::SNPrint((buffer + index), (len - index), FORMAT, addr_width, | 11618 index += OS::SNPrint((buffer + index), (len - index), FORMAT, addr_width, |
11609 iter.PcOffset(), | 11619 iter.PcOffset(), |
11610 iter.TokenPos()); | 11620 iter.TokenPos().ToCString()); |
11611 } | 11621 } |
11612 return buffer; | 11622 return buffer; |
11613 #undef FORMAT | 11623 #undef FORMAT |
11614 } | 11624 } |
11615 | 11625 |
11616 | 11626 |
11617 // Encode integer in SLEB128 format. | 11627 // Encode integer in SLEB128 format. |
11618 void CodeSourceMap::EncodeInteger(GrowableArray<uint8_t>* data, | 11628 void CodeSourceMap::EncodeInteger(GrowableArray<uint8_t>* data, |
11619 intptr_t value) { | 11629 intptr_t value) { |
11620 return EncodeSLEB128(data, value); | 11630 return EncodeSLEB128(data, value); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11790 const RawLocalVarDescriptors::VarInfoKind kind = info.kind(); | 11800 const RawLocalVarDescriptors::VarInfoKind kind = info.kind(); |
11791 const int32_t index = info.index(); | 11801 const int32_t index = info.index(); |
11792 if (kind == RawLocalVarDescriptors::kContextLevel) { | 11802 if (kind == RawLocalVarDescriptors::kContextLevel) { |
11793 return OS::SNPrint(buffer, len, | 11803 return OS::SNPrint(buffer, len, |
11794 "%2" Pd " %-13s level=%-3d scope=%-3d" | 11804 "%2" Pd " %-13s level=%-3d scope=%-3d" |
11795 " begin=%-3d end=%d\n", | 11805 " begin=%-3d end=%d\n", |
11796 i, | 11806 i, |
11797 LocalVarDescriptors::KindToCString(kind), | 11807 LocalVarDescriptors::KindToCString(kind), |
11798 index, | 11808 index, |
11799 info.scope_id, | 11809 info.scope_id, |
11800 info.begin_pos, | 11810 static_cast<int>(info.begin_pos.Pos()), |
11801 info.end_pos); | 11811 static_cast<int>(info.end_pos.Pos())); |
11802 } else if (kind == RawLocalVarDescriptors::kContextVar) { | 11812 } else if (kind == RawLocalVarDescriptors::kContextVar) { |
11803 return OS::SNPrint(buffer, len, | 11813 return OS::SNPrint(buffer, len, |
11804 "%2" Pd " %-13s level=%-3d index=%-3d" | 11814 "%2" Pd " %-13s level=%-3d index=%-3d" |
11805 " begin=%-3d end=%-3d name=%s\n", | 11815 " begin=%-3d end=%-3d name=%s\n", |
11806 i, | 11816 i, |
11807 LocalVarDescriptors::KindToCString(kind), | 11817 LocalVarDescriptors::KindToCString(kind), |
11808 info.scope_id, | 11818 info.scope_id, |
11809 index, | 11819 index, |
11810 info.begin_pos, | 11820 static_cast<int>(info.begin_pos.Pos()), |
11811 info.end_pos, | 11821 static_cast<int>(info.end_pos.Pos()), |
11812 var_name.ToCString()); | 11822 var_name.ToCString()); |
11813 } else { | 11823 } else { |
11814 return OS::SNPrint(buffer, len, | 11824 return OS::SNPrint(buffer, len, |
11815 "%2" Pd " %-13s scope=%-3d index=%-3d" | 11825 "%2" Pd " %-13s scope=%-3d index=%-3d" |
11816 " begin=%-3d end=%-3d name=%s\n", | 11826 " begin=%-3d end=%-3d name=%s\n", |
11817 i, | 11827 i, |
11818 LocalVarDescriptors::KindToCString(kind), | 11828 LocalVarDescriptors::KindToCString(kind), |
11819 info.scope_id, | 11829 info.scope_id, |
11820 index, | 11830 index, |
11821 info.begin_pos, | 11831 static_cast<int>(info.begin_pos.Pos()), |
11822 info.end_pos, | 11832 static_cast<int>(info.end_pos.Pos()), |
11823 var_name.ToCString()); | 11833 var_name.ToCString()); |
11824 } | 11834 } |
11825 } | 11835 } |
11826 | 11836 |
11827 | 11837 |
11828 const char* LocalVarDescriptors::ToCString() const { | 11838 const char* LocalVarDescriptors::ToCString() const { |
11829 if (IsNull()) { | 11839 if (IsNull()) { |
11830 return "LocalVarDescriptors(NULL)"; | 11840 return "LocalVarDescriptors(NULL)"; |
11831 } | 11841 } |
11832 if (Length() == 0) { | 11842 if (Length() == 0) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11867 } | 11877 } |
11868 JSONArray members(&jsobj, "members"); | 11878 JSONArray members(&jsobj, "members"); |
11869 String& var_name = String::Handle(); | 11879 String& var_name = String::Handle(); |
11870 for (intptr_t i = 0; i < Length(); i++) { | 11880 for (intptr_t i = 0; i < Length(); i++) { |
11871 RawLocalVarDescriptors::VarInfo info; | 11881 RawLocalVarDescriptors::VarInfo info; |
11872 var_name = GetName(i); | 11882 var_name = GetName(i); |
11873 GetInfo(i, &info); | 11883 GetInfo(i, &info); |
11874 JSONObject var(&members); | 11884 JSONObject var(&members); |
11875 var.AddProperty("name", var_name.ToCString()); | 11885 var.AddProperty("name", var_name.ToCString()); |
11876 var.AddProperty("index", static_cast<intptr_t>(info.index())); | 11886 var.AddProperty("index", static_cast<intptr_t>(info.index())); |
11877 var.AddProperty("beginPos", static_cast<intptr_t>(info.begin_pos)); | 11887 var.AddProperty("beginPos", info.begin_pos); |
11878 var.AddProperty("endPos", static_cast<intptr_t>(info.end_pos)); | 11888 var.AddProperty("endPos", info.end_pos); |
11879 var.AddProperty("scopeId", static_cast<intptr_t>(info.scope_id)); | 11889 var.AddProperty("scopeId", static_cast<intptr_t>(info.scope_id)); |
11880 var.AddProperty("kind", KindToCString(info.kind())); | 11890 var.AddProperty("kind", KindToCString(info.kind())); |
11881 } | 11891 } |
11882 } | 11892 } |
11883 | 11893 |
11884 | 11894 |
11885 const char* LocalVarDescriptors::KindToCString( | 11895 const char* LocalVarDescriptors::KindToCString( |
11886 RawLocalVarDescriptors::VarInfoKind kind) { | 11896 RawLocalVarDescriptors::VarInfoKind kind) { |
11887 switch (kind) { | 11897 switch (kind) { |
11888 case RawLocalVarDescriptors::kStackVar: | 11898 case RawLocalVarDescriptors::kStackVar: |
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12945 if (ref) { | 12955 if (ref) { |
12946 return; | 12956 return; |
12947 } | 12957 } |
12948 jsobj.AddProperty("_argumentsDescriptor", | 12958 jsobj.AddProperty("_argumentsDescriptor", |
12949 Object::Handle(arguments_descriptor())); | 12959 Object::Handle(arguments_descriptor())); |
12950 jsobj.AddProperty("_entries", Object::Handle(ic_data())); | 12960 jsobj.AddProperty("_entries", Object::Handle(ic_data())); |
12951 } | 12961 } |
12952 | 12962 |
12953 | 12963 |
12954 void ICData::PrintToJSONArray(const JSONArray& jsarray, | 12964 void ICData::PrintToJSONArray(const JSONArray& jsarray, |
12955 intptr_t token_pos, | 12965 TokenPosition token_pos, |
12956 bool is_static_call) const { | 12966 bool is_static_call) const { |
12957 Isolate* isolate = Isolate::Current(); | 12967 Isolate* isolate = Isolate::Current(); |
12958 Class& cls = Class::Handle(); | 12968 Class& cls = Class::Handle(); |
12959 Function& func = Function::Handle(); | 12969 Function& func = Function::Handle(); |
12960 | 12970 |
12961 JSONObject jsobj(&jsarray); | 12971 JSONObject jsobj(&jsarray); |
12962 jsobj.AddProperty("name", String::Handle(target_name()).ToCString()); | 12972 jsobj.AddProperty("name", String::Handle(target_name()).ToCString()); |
12963 jsobj.AddProperty("tokenPos", token_pos); | 12973 jsobj.AddProperty("tokenPos", token_pos); |
12964 // TODO(rmacnak): Figure out how to stringify DeoptReasons(). | 12974 // TODO(rmacnak): Figure out how to stringify DeoptReasons(). |
12965 // jsobj.AddProperty("deoptReasons", ...); | 12975 // jsobj.AddProperty("deoptReasons", ...); |
(...skipping 15 matching lines...) Expand all Loading... |
12981 } else { | 12991 } else { |
12982 cache_entry.AddProperty("receiverContainer", cls); | 12992 cache_entry.AddProperty("receiverContainer", cls); |
12983 } | 12993 } |
12984 cache_entry.AddProperty("count", count); | 12994 cache_entry.AddProperty("count", count); |
12985 cache_entry.AddProperty("target", func); | 12995 cache_entry.AddProperty("target", func); |
12986 } | 12996 } |
12987 } | 12997 } |
12988 | 12998 |
12989 | 12999 |
12990 void ICData::PrintToJSONArrayNew(const JSONArray& jsarray, | 13000 void ICData::PrintToJSONArrayNew(const JSONArray& jsarray, |
12991 intptr_t token_pos, | 13001 TokenPosition token_pos, |
12992 bool is_static_call) const { | 13002 bool is_static_call) const { |
12993 Isolate* isolate = Isolate::Current(); | 13003 Isolate* isolate = Isolate::Current(); |
12994 Class& cls = Class::Handle(); | 13004 Class& cls = Class::Handle(); |
12995 Function& func = Function::Handle(); | 13005 Function& func = Function::Handle(); |
12996 | 13006 |
12997 JSONObject jsobj(&jsarray); | 13007 JSONObject jsobj(&jsarray); |
12998 jsobj.AddProperty("name", String::Handle(target_name()).ToCString()); | 13008 jsobj.AddProperty("name", String::Handle(target_name()).ToCString()); |
12999 jsobj.AddProperty("tokenPos", token_pos); | 13009 jsobj.AddProperty("tokenPos", token_pos.value()); |
13000 // TODO(rmacnak): Figure out how to stringify DeoptReasons(). | 13010 // TODO(rmacnak): Figure out how to stringify DeoptReasons(). |
13001 // jsobj.AddProperty("deoptReasons", ...); | 13011 // jsobj.AddProperty("deoptReasons", ...); |
13002 | 13012 |
13003 JSONArray cache_entries(&jsobj, "cacheEntries"); | 13013 JSONArray cache_entries(&jsobj, "cacheEntries"); |
13004 for (intptr_t i = 0; i < NumberOfChecks(); i++) { | 13014 for (intptr_t i = 0; i < NumberOfChecks(); i++) { |
13005 JSONObject cache_entry(&cache_entries); | 13015 JSONObject cache_entry(&cache_entries); |
13006 func = GetTargetAt(i); | 13016 func = GetTargetAt(i); |
13007 intptr_t count = GetCountAt(i); | 13017 intptr_t count = GetCountAt(i); |
13008 if (!is_static_call) { | 13018 if (!is_static_call) { |
13009 intptr_t cid = GetReceiverClassIdAt(i); | 13019 intptr_t cid = GetReceiverClassIdAt(i); |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13609 code ^= Code::LookupCodeInVmIsolate(pc); | 13619 code ^= Code::LookupCodeInVmIsolate(pc); |
13610 if (!code.IsNull() && (code.compile_timestamp() == timestamp) && | 13620 if (!code.IsNull() && (code.compile_timestamp() == timestamp) && |
13611 (code.EntryPoint() == pc)) { | 13621 (code.EntryPoint() == pc)) { |
13612 // Found code in VM isolate. | 13622 // Found code in VM isolate. |
13613 return code.raw(); | 13623 return code.raw(); |
13614 } | 13624 } |
13615 return Code::null(); | 13625 return Code::null(); |
13616 } | 13626 } |
13617 | 13627 |
13618 | 13628 |
13619 intptr_t Code::GetTokenIndexOfPC(uword pc) const { | 13629 TokenPosition Code::GetTokenIndexOfPC(uword pc) const { |
13620 uword pc_offset = pc - EntryPoint(); | 13630 uword pc_offset = pc - EntryPoint(); |
13621 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); | 13631 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); |
13622 PcDescriptors::Iterator iter(descriptors, RawPcDescriptors::kAnyKind); | 13632 PcDescriptors::Iterator iter(descriptors, RawPcDescriptors::kAnyKind); |
13623 while (iter.MoveNext()) { | 13633 while (iter.MoveNext()) { |
13624 if (iter.PcOffset() == pc_offset) { | 13634 if (iter.PcOffset() == pc_offset) { |
13625 return iter.TokenPos(); | 13635 return iter.TokenPos(); |
13626 } | 13636 } |
13627 } | 13637 } |
13628 return -1; | 13638 return TokenPosition::kNoSource; |
13629 } | 13639 } |
13630 | 13640 |
13631 | 13641 |
13632 uword Code::GetPcForDeoptId(intptr_t deopt_id, | 13642 uword Code::GetPcForDeoptId(intptr_t deopt_id, |
13633 RawPcDescriptors::Kind kind) const { | 13643 RawPcDescriptors::Kind kind) const { |
13634 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); | 13644 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); |
13635 PcDescriptors::Iterator iter(descriptors, kind); | 13645 PcDescriptors::Iterator iter(descriptors, kind); |
13636 while (iter.MoveNext()) { | 13646 while (iter.MoveNext()) { |
13637 if (iter.DeoptId() == deopt_id) { | 13647 if (iter.DeoptId() == deopt_id) { |
13638 uword pc_offset = iter.PcOffset(); | 13648 uword pc_offset = iter.PcOffset(); |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14116 Heap::kOld); | 14126 Heap::kOld); |
14117 NoSafepointScope no_safepoint; | 14127 NoSafepointScope no_safepoint; |
14118 result ^= raw; | 14128 result ^= raw; |
14119 result.set_num_variables(num_variables); | 14129 result.set_num_variables(num_variables); |
14120 result.set_is_implicit(is_implicit); | 14130 result.set_is_implicit(is_implicit); |
14121 } | 14131 } |
14122 return result.raw(); | 14132 return result.raw(); |
14123 } | 14133 } |
14124 | 14134 |
14125 | 14135 |
14126 intptr_t ContextScope::TokenIndexAt(intptr_t scope_index) const { | 14136 TokenPosition ContextScope::TokenIndexAt(intptr_t scope_index) const { |
14127 return Smi::Value(VariableDescAddr(scope_index)->token_pos); | 14137 return TokenPosition(Smi::Value(VariableDescAddr(scope_index)->token_pos)); |
14128 } | 14138 } |
14129 | 14139 |
14130 | 14140 |
14131 void ContextScope::SetTokenIndexAt(intptr_t scope_index, | 14141 void ContextScope::SetTokenIndexAt(intptr_t scope_index, |
14132 intptr_t token_pos) const { | 14142 TokenPosition token_pos) const { |
14133 StoreSmi(&VariableDescAddr(scope_index)->token_pos, | 14143 StoreSmi(&VariableDescAddr(scope_index)->token_pos, |
14134 Smi::New(token_pos)); | 14144 Smi::New(token_pos.value())); |
14135 } | 14145 } |
14136 | 14146 |
14137 | 14147 |
14138 RawString* ContextScope::NameAt(intptr_t scope_index) const { | 14148 RawString* ContextScope::NameAt(intptr_t scope_index) const { |
14139 return VariableDescAddr(scope_index)->name; | 14149 return VariableDescAddr(scope_index)->name; |
14140 } | 14150 } |
14141 | 14151 |
14142 | 14152 |
14143 void ContextScope::SetNameAt(intptr_t scope_index, const String& name) const { | 14153 void ContextScope::SetNameAt(intptr_t scope_index, const String& name) const { |
14144 StorePointer(&(VariableDescAddr(scope_index)->name), name.raw()); | 14154 StorePointer(&(VariableDescAddr(scope_index)->name), name.raw()); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14215 Smi::New(context_level)); | 14225 Smi::New(context_level)); |
14216 } | 14226 } |
14217 | 14227 |
14218 | 14228 |
14219 const char* ContextScope::ToCString() const { | 14229 const char* ContextScope::ToCString() const { |
14220 const char* prev_cstr = "ContextScope:"; | 14230 const char* prev_cstr = "ContextScope:"; |
14221 String& name = String::Handle(); | 14231 String& name = String::Handle(); |
14222 for (int i = 0; i < num_variables(); i++) { | 14232 for (int i = 0; i < num_variables(); i++) { |
14223 name = NameAt(i); | 14233 name = NameAt(i); |
14224 const char* cname = name.ToCString(); | 14234 const char* cname = name.ToCString(); |
14225 intptr_t pos = TokenIndexAt(i); | 14235 TokenPosition pos = TokenIndexAt(i); |
14226 intptr_t idx = ContextIndexAt(i); | 14236 intptr_t idx = ContextIndexAt(i); |
14227 intptr_t lvl = ContextLevelAt(i); | 14237 intptr_t lvl = ContextLevelAt(i); |
14228 char* chars = OS::SCreate(Thread::Current()->zone(), | 14238 char* chars = OS::SCreate(Thread::Current()->zone(), |
14229 "%s\nvar %s token-pos %" Pd " ctx lvl %" Pd " index %" Pd "", | 14239 "%s\nvar %s token-pos %s ctx lvl %" Pd " index %" Pd "", |
14230 prev_cstr, cname, pos, lvl, idx); | 14240 prev_cstr, cname, pos.ToCString(), lvl, idx); |
14231 prev_cstr = chars; | 14241 prev_cstr = chars; |
14232 } | 14242 } |
14233 return prev_cstr; | 14243 return prev_cstr; |
14234 } | 14244 } |
14235 | 14245 |
14236 | 14246 |
14237 void ContextScope::PrintJSONImpl(JSONStream* stream, bool ref) const { | 14247 void ContextScope::PrintJSONImpl(JSONStream* stream, bool ref) const { |
14238 Object::PrintJSONImpl(stream, ref); | 14248 Object::PrintJSONImpl(stream, ref); |
14239 } | 14249 } |
14240 | 14250 |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14541 ASSERT(Object::language_error_class() != Class::null()); | 14551 ASSERT(Object::language_error_class() != Class::null()); |
14542 RawObject* raw = Object::Allocate(LanguageError::kClassId, | 14552 RawObject* raw = Object::Allocate(LanguageError::kClassId, |
14543 LanguageError::InstanceSize(), | 14553 LanguageError::InstanceSize(), |
14544 Heap::kOld); | 14554 Heap::kOld); |
14545 return reinterpret_cast<RawLanguageError*>(raw); | 14555 return reinterpret_cast<RawLanguageError*>(raw); |
14546 } | 14556 } |
14547 | 14557 |
14548 | 14558 |
14549 RawLanguageError* LanguageError::NewFormattedV(const Error& prev_error, | 14559 RawLanguageError* LanguageError::NewFormattedV(const Error& prev_error, |
14550 const Script& script, | 14560 const Script& script, |
14551 intptr_t token_pos, | 14561 TokenPosition token_pos, |
14552 bool report_after_token, | 14562 bool report_after_token, |
14553 Report::Kind kind, | 14563 Report::Kind kind, |
14554 Heap::Space space, | 14564 Heap::Space space, |
14555 const char* format, | 14565 const char* format, |
14556 va_list args) { | 14566 va_list args) { |
14557 ASSERT(Object::language_error_class() != Class::null()); | 14567 ASSERT(Object::language_error_class() != Class::null()); |
14558 LanguageError& result = LanguageError::Handle(); | 14568 LanguageError& result = LanguageError::Handle(); |
14559 { | 14569 { |
14560 RawObject* raw = Object::Allocate(LanguageError::kClassId, | 14570 RawObject* raw = Object::Allocate(LanguageError::kClassId, |
14561 LanguageError::InstanceSize(), | 14571 LanguageError::InstanceSize(), |
14562 space); | 14572 space); |
14563 NoSafepointScope no_safepoint; | 14573 NoSafepointScope no_safepoint; |
14564 result ^= raw; | 14574 result ^= raw; |
14565 } | 14575 } |
14566 result.set_previous_error(prev_error); | 14576 result.set_previous_error(prev_error); |
14567 result.set_script(script); | 14577 result.set_script(script); |
14568 result.set_token_pos(token_pos); | 14578 result.set_token_pos(token_pos); |
14569 result.set_report_after_token(report_after_token); | 14579 result.set_report_after_token(report_after_token); |
14570 result.set_kind(kind); | 14580 result.set_kind(kind); |
14571 result.set_message(String::Handle( | 14581 result.set_message(String::Handle( |
14572 String::NewFormattedV(format, args, space))); | 14582 String::NewFormattedV(format, args, space))); |
14573 return result.raw(); | 14583 return result.raw(); |
14574 } | 14584 } |
14575 | 14585 |
14576 | 14586 |
14577 RawLanguageError* LanguageError::NewFormatted(const Error& prev_error, | 14587 RawLanguageError* LanguageError::NewFormatted(const Error& prev_error, |
14578 const Script& script, | 14588 const Script& script, |
14579 intptr_t token_pos, | 14589 TokenPosition token_pos, |
14580 bool report_after_token, | 14590 bool report_after_token, |
14581 Report::Kind kind, | 14591 Report::Kind kind, |
14582 Heap::Space space, | 14592 Heap::Space space, |
14583 const char* format, ...) { | 14593 const char* format, ...) { |
14584 va_list args; | 14594 va_list args; |
14585 va_start(args, format); | 14595 va_start(args, format); |
14586 RawLanguageError* result = LanguageError::NewFormattedV( | 14596 RawLanguageError* result = LanguageError::NewFormattedV( |
14587 prev_error, script, token_pos, report_after_token, | 14597 prev_error, script, token_pos, report_after_token, |
14588 kind, space, format, args); | 14598 kind, space, format, args); |
14589 NoSafepointScope no_safepoint; | 14599 NoSafepointScope no_safepoint; |
(...skipping 23 matching lines...) Expand all Loading... |
14613 void LanguageError::set_previous_error(const Error& value) const { | 14623 void LanguageError::set_previous_error(const Error& value) const { |
14614 StorePointer(&raw_ptr()->previous_error_, value.raw()); | 14624 StorePointer(&raw_ptr()->previous_error_, value.raw()); |
14615 } | 14625 } |
14616 | 14626 |
14617 | 14627 |
14618 void LanguageError::set_script(const Script& value) const { | 14628 void LanguageError::set_script(const Script& value) const { |
14619 StorePointer(&raw_ptr()->script_, value.raw()); | 14629 StorePointer(&raw_ptr()->script_, value.raw()); |
14620 } | 14630 } |
14621 | 14631 |
14622 | 14632 |
14623 void LanguageError::set_token_pos(intptr_t token_pos) const { | 14633 void LanguageError::set_token_pos(TokenPosition token_pos) const { |
14624 ASSERT(!Token::IsClassifying(token_pos)); | 14634 ASSERT(!token_pos.IsClassifying()); |
14625 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); | 14635 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); |
14626 } | 14636 } |
14627 | 14637 |
14628 | 14638 |
14629 void LanguageError::set_report_after_token(bool value) { | 14639 void LanguageError::set_report_after_token(bool value) { |
14630 StoreNonPointer(&raw_ptr()->report_after_token_, value); | 14640 StoreNonPointer(&raw_ptr()->report_after_token_, value); |
14631 } | 14641 } |
14632 | 14642 |
14633 | 14643 |
14634 void LanguageError::set_kind(uint8_t value) const { | 14644 void LanguageError::set_kind(uint8_t value) const { |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15025 if (!type.IsCanonical()) { | 15035 if (!type.IsCanonical()) { |
15026 type ^= type.Canonicalize(); | 15036 type ^= type.Canonicalize(); |
15027 signature.SetSignatureType(type); | 15037 signature.SetSignatureType(type); |
15028 } | 15038 } |
15029 return type.raw(); | 15039 return type.raw(); |
15030 } | 15040 } |
15031 const Class& scope_cls = Class::Handle(type.scope_class()); | 15041 const Class& scope_cls = Class::Handle(type.scope_class()); |
15032 ASSERT(scope_cls.NumTypeArguments() > 0); | 15042 ASSERT(scope_cls.NumTypeArguments() > 0); |
15033 TypeArguments& type_arguments = TypeArguments::Handle(GetTypeArguments()); | 15043 TypeArguments& type_arguments = TypeArguments::Handle(GetTypeArguments()); |
15034 type = FunctionType::New( | 15044 type = FunctionType::New( |
15035 scope_cls, type_arguments, signature, Token::kNoSourcePos); | 15045 scope_cls, type_arguments, signature, TokenPosition::kNoSource); |
15036 type.SetIsFinalized(); | 15046 type.SetIsFinalized(); |
15037 type ^= type.Canonicalize(); | 15047 type ^= type.Canonicalize(); |
15038 return type.raw(); | 15048 return type.raw(); |
15039 } | 15049 } |
15040 Type& type = Type::Handle(); | 15050 Type& type = Type::Handle(); |
15041 if (!cls.IsGeneric()) { | 15051 if (!cls.IsGeneric()) { |
15042 type = cls.CanonicalType(); | 15052 type = cls.CanonicalType(); |
15043 } | 15053 } |
15044 if (type.IsNull()) { | 15054 if (type.IsNull()) { |
15045 TypeArguments& type_arguments = TypeArguments::Handle(); | 15055 TypeArguments& type_arguments = TypeArguments::Handle(); |
15046 if (cls.NumTypeArguments() > 0) { | 15056 if (cls.NumTypeArguments() > 0) { |
15047 type_arguments = GetTypeArguments(); | 15057 type_arguments = GetTypeArguments(); |
15048 } | 15058 } |
15049 type = Type::New(cls, type_arguments, Token::kNoSourcePos); | 15059 type = Type::New(cls, type_arguments, TokenPosition::kNoSource); |
15050 type.SetIsFinalized(); | 15060 type.SetIsFinalized(); |
15051 type ^= type.Canonicalize(); | 15061 type ^= type.Canonicalize(); |
15052 } | 15062 } |
15053 return type.raw(); | 15063 return type.raw(); |
15054 } | 15064 } |
15055 | 15065 |
15056 | 15066 |
15057 RawTypeArguments* Instance::GetTypeArguments() const { | 15067 RawTypeArguments* Instance::GetTypeArguments() const { |
15058 const Class& cls = Class::Handle(clazz()); | 15068 const Class& cls = Class::Handle(clazz()); |
15059 intptr_t field_offset = cls.type_arguments_field_offset(); | 15069 intptr_t field_offset = cls.type_arguments_field_offset(); |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15366 } else { | 15376 } else { |
15367 if (IsClosure()) { | 15377 if (IsClosure()) { |
15368 return Closure::Cast(*this).ToCString(); | 15378 return Closure::Cast(*this).ToCString(); |
15369 } | 15379 } |
15370 const Class& cls = Class::Handle(clazz()); | 15380 const Class& cls = Class::Handle(clazz()); |
15371 TypeArguments& type_arguments = TypeArguments::Handle(); | 15381 TypeArguments& type_arguments = TypeArguments::Handle(); |
15372 const intptr_t num_type_arguments = cls.NumTypeArguments(); | 15382 const intptr_t num_type_arguments = cls.NumTypeArguments(); |
15373 if (num_type_arguments > 0) { | 15383 if (num_type_arguments > 0) { |
15374 type_arguments = GetTypeArguments(); | 15384 type_arguments = GetTypeArguments(); |
15375 } | 15385 } |
15376 const Type& type = | 15386 const Type& type = Type::Handle( |
15377 Type::Handle(Type::New(cls, type_arguments, Token::kNoSourcePos)); | 15387 Type::New(cls, type_arguments, TokenPosition::kNoSource)); |
15378 const String& type_name = String::Handle(type.UserVisibleName()); | 15388 const String& type_name = String::Handle(type.UserVisibleName()); |
15379 return OS::SCreate(Thread::Current()->zone(), | 15389 return OS::SCreate(Thread::Current()->zone(), |
15380 "Instance of '%s'", type_name.ToCString()); | 15390 "Instance of '%s'", type_name.ToCString()); |
15381 } | 15391 } |
15382 } | 15392 } |
15383 | 15393 |
15384 | 15394 |
15385 void Instance::PrintSharedInstanceJSON(JSONObject* jsobj, | 15395 void Instance::PrintSharedInstanceJSON(JSONObject* jsobj, |
15386 bool ref) const { | 15396 bool ref) const { |
15387 AddCommonObjectProperties(jsobj, "Instance", ref); | 15397 AddCommonObjectProperties(jsobj, "Instance", ref); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15506 UNREACHABLE(); | 15516 UNREACHABLE(); |
15507 return NULL; | 15517 return NULL; |
15508 } | 15518 } |
15509 | 15519 |
15510 | 15520 |
15511 void AbstractType::set_arguments(const TypeArguments& value) const { | 15521 void AbstractType::set_arguments(const TypeArguments& value) const { |
15512 // AbstractType is an abstract class. | 15522 // AbstractType is an abstract class. |
15513 UNREACHABLE(); | 15523 UNREACHABLE(); |
15514 } | 15524 } |
15515 | 15525 |
15516 intptr_t AbstractType::token_pos() const { | 15526 TokenPosition AbstractType::token_pos() const { |
15517 // AbstractType is an abstract class. | 15527 // AbstractType is an abstract class. |
15518 UNREACHABLE(); | 15528 UNREACHABLE(); |
15519 return -1; | 15529 return TokenPosition::kNoSource; |
15520 } | 15530 } |
15521 | 15531 |
15522 | 15532 |
15523 bool AbstractType::IsInstantiated(TrailPtr trail) const { | 15533 bool AbstractType::IsInstantiated(TrailPtr trail) const { |
15524 // AbstractType is an abstract class. | 15534 // AbstractType is an abstract class. |
15525 UNREACHABLE(); | 15535 UNREACHABLE(); |
15526 return false; | 15536 return false; |
15527 } | 15537 } |
15528 | 15538 |
15529 | 15539 |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16103 } | 16113 } |
16104 | 16114 |
16105 | 16115 |
16106 RawType* Type::NewNonParameterizedType(const Class& type_class) { | 16116 RawType* Type::NewNonParameterizedType(const Class& type_class) { |
16107 ASSERT(type_class.NumTypeArguments() == 0); | 16117 ASSERT(type_class.NumTypeArguments() == 0); |
16108 Type& type = Type::Handle(type_class.CanonicalType()); | 16118 Type& type = Type::Handle(type_class.CanonicalType()); |
16109 if (type.IsNull()) { | 16119 if (type.IsNull()) { |
16110 const TypeArguments& no_type_arguments = TypeArguments::Handle(); | 16120 const TypeArguments& no_type_arguments = TypeArguments::Handle(); |
16111 type ^= Type::New(Object::Handle(type_class.raw()), | 16121 type ^= Type::New(Object::Handle(type_class.raw()), |
16112 no_type_arguments, | 16122 no_type_arguments, |
16113 Token::kNoSourcePos); | 16123 TokenPosition::kNoSource); |
16114 type.SetIsFinalized(); | 16124 type.SetIsFinalized(); |
16115 type ^= type.Canonicalize(); | 16125 type ^= type.Canonicalize(); |
16116 } | 16126 } |
16117 ASSERT(type.IsFinalized()); | 16127 ASSERT(type.IsFinalized()); |
16118 return type.raw(); | 16128 return type.raw(); |
16119 } | 16129 } |
16120 | 16130 |
16121 | 16131 |
16122 void Type::SetIsFinalized() const { | 16132 void Type::SetIsFinalized() const { |
16123 ASSERT(!IsFinalized()); | 16133 ASSERT(!IsFinalized()); |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16561 RawType* Type::New(Heap::Space space) { | 16571 RawType* Type::New(Heap::Space space) { |
16562 RawObject* raw = Object::Allocate(Type::kClassId, | 16572 RawObject* raw = Object::Allocate(Type::kClassId, |
16563 Type::InstanceSize(), | 16573 Type::InstanceSize(), |
16564 space); | 16574 space); |
16565 return reinterpret_cast<RawType*>(raw); | 16575 return reinterpret_cast<RawType*>(raw); |
16566 } | 16576 } |
16567 | 16577 |
16568 | 16578 |
16569 RawType* Type::New(const Object& clazz, | 16579 RawType* Type::New(const Object& clazz, |
16570 const TypeArguments& arguments, | 16580 const TypeArguments& arguments, |
16571 intptr_t token_pos, | 16581 TokenPosition token_pos, |
16572 Heap::Space space) { | 16582 Heap::Space space) { |
16573 const Type& result = Type::Handle(Type::New(space)); | 16583 const Type& result = Type::Handle(Type::New(space)); |
16574 result.set_type_class(clazz); | 16584 result.set_type_class(clazz); |
16575 result.set_arguments(arguments); | 16585 result.set_arguments(arguments); |
16576 result.set_token_pos(token_pos); | 16586 result.set_token_pos(token_pos); |
16577 result.StoreNonPointer(&result.raw_ptr()->type_state_, RawType::kAllocated); | 16587 result.StoreNonPointer(&result.raw_ptr()->type_state_, RawType::kAllocated); |
16578 return result.raw(); | 16588 return result.raw(); |
16579 } | 16589 } |
16580 | 16590 |
16581 | 16591 |
16582 void Type::set_token_pos(intptr_t token_pos) const { | 16592 void Type::set_token_pos(TokenPosition token_pos) const { |
16583 ASSERT(!Token::IsClassifying(token_pos)); | 16593 ASSERT(!token_pos.IsClassifying()); |
16584 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); | 16594 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); |
16585 } | 16595 } |
16586 | 16596 |
16587 | 16597 |
16588 void Type::set_type_state(int8_t state) const { | 16598 void Type::set_type_state(int8_t state) const { |
16589 ASSERT((state >= RawType::kAllocated) && | 16599 ASSERT((state >= RawType::kAllocated) && |
16590 (state <= RawType::kFinalizedUninstantiated)); | 16600 (state <= RawType::kFinalizedUninstantiated)); |
16591 StoreNonPointer(&raw_ptr()->type_state_, state); | 16601 StoreNonPointer(&raw_ptr()->type_state_, state); |
16592 } | 16602 } |
16593 | 16603 |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16991 // In case the type is first canonicalized at runtime, its type argument | 17001 // In case the type is first canonicalized at runtime, its type argument |
16992 // vector may be longer than necessary. This is not an issue. | 17002 // vector may be longer than necessary. This is not an issue. |
16993 ASSERT(type_args.IsNull() || | 17003 ASSERT(type_args.IsNull() || |
16994 (type_args.Length() >= scope_cls.NumTypeArguments())); | 17004 (type_args.Length() >= scope_cls.NumTypeArguments())); |
16995 type_args = type_args.Canonicalize(trail); | 17005 type_args = type_args.Canonicalize(trail); |
16996 set_arguments(type_args); | 17006 set_arguments(type_args); |
16997 | 17007 |
16998 // Replace the actual function by a signature function. | 17008 // Replace the actual function by a signature function. |
16999 const Function& fun = Function::Handle(zone, signature()); | 17009 const Function& fun = Function::Handle(zone, signature()); |
17000 if (!fun.IsSignatureFunction()) { | 17010 if (!fun.IsSignatureFunction()) { |
17001 Function& sig_fun = | 17011 Function& sig_fun = Function::Handle(zone, |
17002 Function::Handle(zone, | 17012 Function::NewSignatureFunction(scope_cls, TokenPosition::kNoSource)); |
17003 Function::NewSignatureFunction(scope_cls, | |
17004 Token::kNoSourcePos)); | |
17005 type = fun.result_type(); | 17013 type = fun.result_type(); |
17006 type = type.Canonicalize(trail); | 17014 type = type.Canonicalize(trail); |
17007 sig_fun.set_result_type(type); | 17015 sig_fun.set_result_type(type); |
17008 const intptr_t num_params = fun.NumParameters(); | 17016 const intptr_t num_params = fun.NumParameters(); |
17009 sig_fun.set_num_fixed_parameters(fun.num_fixed_parameters()); | 17017 sig_fun.set_num_fixed_parameters(fun.num_fixed_parameters()); |
17010 sig_fun.SetNumOptionalParameters(fun.NumOptionalParameters(), | 17018 sig_fun.SetNumOptionalParameters(fun.NumOptionalParameters(), |
17011 fun.HasOptionalPositionalParameters()); | 17019 fun.HasOptionalPositionalParameters()); |
17012 sig_fun.set_parameter_types(Array::Handle(Array::New(num_params, | 17020 sig_fun.set_parameter_types(Array::Handle(Array::New(num_params, |
17013 Heap::kOld))); | 17021 Heap::kOld))); |
17014 for (intptr_t i = 0; i < num_params; i++) { | 17022 for (intptr_t i = 0; i < num_params; i++) { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17105 RawObject* raw = Object::Allocate(FunctionType::kClassId, | 17113 RawObject* raw = Object::Allocate(FunctionType::kClassId, |
17106 FunctionType::InstanceSize(), | 17114 FunctionType::InstanceSize(), |
17107 space); | 17115 space); |
17108 return reinterpret_cast<RawFunctionType*>(raw); | 17116 return reinterpret_cast<RawFunctionType*>(raw); |
17109 } | 17117 } |
17110 | 17118 |
17111 | 17119 |
17112 RawFunctionType* FunctionType::New(const Class& clazz, | 17120 RawFunctionType* FunctionType::New(const Class& clazz, |
17113 const TypeArguments& arguments, | 17121 const TypeArguments& arguments, |
17114 const Function& signature, | 17122 const Function& signature, |
17115 intptr_t token_pos, | 17123 TokenPosition token_pos, |
17116 Heap::Space space) { | 17124 Heap::Space space) { |
17117 const FunctionType& result = FunctionType::Handle(FunctionType::New(space)); | 17125 const FunctionType& result = FunctionType::Handle(FunctionType::New(space)); |
17118 result.set_scope_class(clazz); | 17126 result.set_scope_class(clazz); |
17119 result.set_arguments(arguments); | 17127 result.set_arguments(arguments); |
17120 result.set_signature(signature); | 17128 result.set_signature(signature); |
17121 result.set_token_pos(token_pos); | 17129 result.set_token_pos(token_pos); |
17122 result.StoreNonPointer(&result.raw_ptr()->type_state_, | 17130 result.StoreNonPointer(&result.raw_ptr()->type_state_, |
17123 RawFunctionType::kAllocated); | 17131 RawFunctionType::kAllocated); |
17124 return result.raw(); | 17132 return result.raw(); |
17125 } | 17133 } |
17126 | 17134 |
17127 | 17135 |
17128 void FunctionType::set_token_pos(intptr_t token_pos) const { | 17136 void FunctionType::set_token_pos(TokenPosition token_pos) const { |
17129 ASSERT(!Token::IsClassifying(token_pos)); | 17137 ASSERT(!token_pos.IsClassifying()); |
17130 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); | 17138 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); |
17131 } | 17139 } |
17132 | 17140 |
17133 | 17141 |
17134 void FunctionType::set_type_state(int8_t state) const { | 17142 void FunctionType::set_type_state(int8_t state) const { |
17135 ASSERT((state >= RawFunctionType::kAllocated) && | 17143 ASSERT((state >= RawFunctionType::kAllocated) && |
17136 (state <= RawFunctionType::kFinalizedUninstantiated)); | 17144 (state <= RawFunctionType::kFinalizedUninstantiated)); |
17137 StoreNonPointer(&raw_ptr()->type_state_, state); | 17145 StoreNonPointer(&raw_ptr()->type_state_, state); |
17138 } | 17146 } |
17139 | 17147 |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17539 TypeParameter::InstanceSize(), | 17547 TypeParameter::InstanceSize(), |
17540 Heap::kOld); | 17548 Heap::kOld); |
17541 return reinterpret_cast<RawTypeParameter*>(raw); | 17549 return reinterpret_cast<RawTypeParameter*>(raw); |
17542 } | 17550 } |
17543 | 17551 |
17544 | 17552 |
17545 RawTypeParameter* TypeParameter::New(const Class& parameterized_class, | 17553 RawTypeParameter* TypeParameter::New(const Class& parameterized_class, |
17546 intptr_t index, | 17554 intptr_t index, |
17547 const String& name, | 17555 const String& name, |
17548 const AbstractType& bound, | 17556 const AbstractType& bound, |
17549 intptr_t token_pos) { | 17557 TokenPosition token_pos) { |
17550 const TypeParameter& result = TypeParameter::Handle(TypeParameter::New()); | 17558 const TypeParameter& result = TypeParameter::Handle(TypeParameter::New()); |
17551 result.set_parameterized_class(parameterized_class); | 17559 result.set_parameterized_class(parameterized_class); |
17552 result.set_index(index); | 17560 result.set_index(index); |
17553 result.set_name(name); | 17561 result.set_name(name); |
17554 result.set_bound(bound); | 17562 result.set_bound(bound); |
17555 result.set_token_pos(token_pos); | 17563 result.set_token_pos(token_pos); |
17556 result.StoreNonPointer(&result.raw_ptr()->type_state_, | 17564 result.StoreNonPointer(&result.raw_ptr()->type_state_, |
17557 RawTypeParameter::kAllocated); | 17565 RawTypeParameter::kAllocated); |
17558 return result.raw(); | 17566 return result.raw(); |
17559 } | 17567 } |
17560 | 17568 |
17561 | 17569 |
17562 void TypeParameter::set_token_pos(intptr_t token_pos) const { | 17570 void TypeParameter::set_token_pos(TokenPosition token_pos) const { |
17563 ASSERT(!Token::IsClassifying(token_pos)); | 17571 ASSERT(!token_pos.IsClassifying()); |
17564 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); | 17572 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); |
17565 } | 17573 } |
17566 | 17574 |
17567 | 17575 |
17568 void TypeParameter::set_type_state(int8_t state) const { | 17576 void TypeParameter::set_type_state(int8_t state) const { |
17569 ASSERT((state == RawTypeParameter::kAllocated) || | 17577 ASSERT((state == RawTypeParameter::kAllocated) || |
17570 (state == RawTypeParameter::kBeingFinalized) || | 17578 (state == RawTypeParameter::kBeingFinalized) || |
17571 (state == RawTypeParameter::kFinalizedUninstantiated)); | 17579 (state == RawTypeParameter::kFinalizedUninstantiated)); |
17572 StoreNonPointer(&raw_ptr()->type_state_, state); | 17580 StoreNonPointer(&raw_ptr()->type_state_, state); |
17573 } | 17581 } |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17830 const String& vm_name = String::Handle(Name()); | 17838 const String& vm_name = String::Handle(Name()); |
17831 AddNameProperties(&jsobj, user_name, vm_name); | 17839 AddNameProperties(&jsobj, user_name, vm_name); |
17832 if (ref) { | 17840 if (ref) { |
17833 return; | 17841 return; |
17834 } | 17842 } |
17835 jsobj.AddProperty("targetType", AbstractType::Handle(type())); | 17843 jsobj.AddProperty("targetType", AbstractType::Handle(type())); |
17836 jsobj.AddProperty("bound", AbstractType::Handle(bound())); | 17844 jsobj.AddProperty("bound", AbstractType::Handle(bound())); |
17837 } | 17845 } |
17838 | 17846 |
17839 | 17847 |
17840 intptr_t MixinAppType::token_pos() const { | 17848 TokenPosition MixinAppType::token_pos() const { |
17841 return AbstractType::Handle(MixinTypeAt(0)).token_pos(); | 17849 return AbstractType::Handle(MixinTypeAt(0)).token_pos(); |
17842 } | 17850 } |
17843 | 17851 |
17844 | 17852 |
17845 intptr_t MixinAppType::Depth() const { | 17853 intptr_t MixinAppType::Depth() const { |
17846 return Array::Handle(mixin_types()).Length(); | 17854 return Array::Handle(mixin_types()).Length(); |
17847 } | 17855 } |
17848 | 17856 |
17849 | 17857 |
17850 RawString* MixinAppType::Name() const { | 17858 RawString* MixinAppType::Name() const { |
(...skipping 4489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22340 jsobj.AddProperty("valueAsString", ToCStringInternal(&idx)); | 22348 jsobj.AddProperty("valueAsString", ToCStringInternal(&idx)); |
22341 } | 22349 } |
22342 | 22350 |
22343 | 22351 |
22344 static intptr_t PrintOneStacktrace(Zone* zone, | 22352 static intptr_t PrintOneStacktrace(Zone* zone, |
22345 GrowableArray<char*>* frame_strings, | 22353 GrowableArray<char*>* frame_strings, |
22346 uword pc, | 22354 uword pc, |
22347 const Function& function, | 22355 const Function& function, |
22348 const Code& code, | 22356 const Code& code, |
22349 intptr_t frame_index) { | 22357 intptr_t frame_index) { |
22350 const intptr_t token_pos = code.GetTokenIndexOfPC(pc); | 22358 const TokenPosition token_pos = code.GetTokenIndexOfPC(pc); |
22351 const Script& script = Script::Handle(zone, function.script()); | 22359 const Script& script = Script::Handle(zone, function.script()); |
22352 const String& function_name = | 22360 const String& function_name = |
22353 String::Handle(zone, function.QualifiedUserVisibleName()); | 22361 String::Handle(zone, function.QualifiedUserVisibleName()); |
22354 const String& url = String::Handle(zone, script.url()); | 22362 const String& url = String::Handle(zone, script.url()); |
22355 intptr_t line = -1; | 22363 intptr_t line = -1; |
22356 intptr_t column = -1; | 22364 intptr_t column = -1; |
22357 if (token_pos >= 0) { | 22365 if (token_pos.IsReal()) { |
22358 if (script.HasSource()) { | 22366 if (script.HasSource()) { |
22359 script.GetTokenLocation(token_pos, &line, &column); | 22367 script.GetTokenLocation(token_pos, &line, &column); |
22360 } else { | 22368 } else { |
22361 script.GetTokenLocation(token_pos, &line, NULL); | 22369 script.GetTokenLocation(token_pos, &line, NULL); |
22362 } | 22370 } |
22363 } | 22371 } |
22364 char* chars = NULL; | 22372 char* chars = NULL; |
22365 if (column >= 0) { | 22373 if (column >= 0) { |
22366 chars = OS::SCreate(zone, | 22374 chars = OS::SCreate(zone, |
22367 "#%-6" Pd " %s (%s:%" Pd ":%" Pd ")\n", | 22375 "#%-6" Pd " %s (%s:%" Pd ":%" Pd ")\n", |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22855 return tag_label.ToCString(); | 22863 return tag_label.ToCString(); |
22856 } | 22864 } |
22857 | 22865 |
22858 | 22866 |
22859 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 22867 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
22860 Instance::PrintJSONImpl(stream, ref); | 22868 Instance::PrintJSONImpl(stream, ref); |
22861 } | 22869 } |
22862 | 22870 |
22863 | 22871 |
22864 } // namespace dart | 22872 } // namespace dart |
OLD | NEW |