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 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1177 cls = object_store->array_class(); // Was allocated above. | 1177 cls = object_store->array_class(); // Was allocated above. |
1178 RegisterPrivateClass(cls, Symbols::_List(), core_lib); | 1178 RegisterPrivateClass(cls, Symbols::_List(), core_lib); |
1179 pending_classes.Add(cls); | 1179 pending_classes.Add(cls); |
1180 // We cannot use NewNonParameterizedType(cls), because Array is parameterized. | 1180 // We cannot use NewNonParameterizedType(cls), because Array is parameterized. |
1181 // Warning: class _List has not been patched yet. Its declared number of type | 1181 // Warning: class _List has not been patched yet. Its declared number of type |
1182 // parameters is still 0. It will become 1 after patching. The array type | 1182 // parameters is still 0. It will become 1 after patching. The array type |
1183 // allocated below represents the raw type _List and not _List<E> as we | 1183 // allocated below represents the raw type _List and not _List<E> as we |
1184 // could expect. Use with caution. | 1184 // could expect. Use with caution. |
1185 type ^= Type::New(Object::Handle(zone, cls.raw()), | 1185 type ^= Type::New(Object::Handle(zone, cls.raw()), |
1186 TypeArguments::Handle(zone), | 1186 TypeArguments::Handle(zone), |
1187 Token::kNoSourcePos); | 1187 TokenDescriptor::kNoSource); |
1188 type.SetIsFinalized(); | 1188 type.SetIsFinalized(); |
1189 type ^= type.Canonicalize(); | 1189 type ^= type.Canonicalize(); |
1190 object_store->set_array_type(type); | 1190 object_store->set_array_type(type); |
1191 | 1191 |
1192 cls = object_store->growable_object_array_class(); // Was allocated above. | 1192 cls = object_store->growable_object_array_class(); // Was allocated above. |
1193 RegisterPrivateClass(cls, Symbols::_GrowableList(), core_lib); | 1193 RegisterPrivateClass(cls, Symbols::_GrowableList(), core_lib); |
1194 pending_classes.Add(cls); | 1194 pending_classes.Add(cls); |
1195 | 1195 |
1196 cls = Class::New<Array>(kImmutableArrayCid); | 1196 cls = Class::New<Array>(kImmutableArrayCid); |
1197 object_store->set_immutable_array_class(cls); | 1197 object_store->set_immutable_array_class(cls); |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1578 Smi& value = Smi::Handle(zone); | 1578 Smi& value = Smi::Handle(zone); |
1579 String& field_name = String::Handle(zone); | 1579 String& field_name = String::Handle(zone); |
1580 | 1580 |
1581 #define CLASS_LIST_WITH_NULL(V) \ | 1581 #define CLASS_LIST_WITH_NULL(V) \ |
1582 V(Null) \ | 1582 V(Null) \ |
1583 CLASS_LIST_NO_OBJECT(V) | 1583 CLASS_LIST_NO_OBJECT(V) |
1584 | 1584 |
1585 #define ADD_SET_FIELD(clazz) \ | 1585 #define ADD_SET_FIELD(clazz) \ |
1586 field_name = Symbols::New("cid"#clazz); \ | 1586 field_name = Symbols::New("cid"#clazz); \ |
1587 field = Field::New(field_name, true, false, true, false, cls, \ | 1587 field = Field::New(field_name, true, false, true, false, cls, \ |
1588 Type::Handle(Type::IntType()), 0); \ | 1588 Type::Handle(Type::IntType()), TokenDescriptor::kMinSource); \ |
1589 value = Smi::New(k##clazz##Cid); \ | 1589 value = Smi::New(k##clazz##Cid); \ |
1590 field.SetStaticValue(value, true); \ | 1590 field.SetStaticValue(value, true); \ |
1591 cls.AddField(field); \ | 1591 cls.AddField(field); \ |
1592 | 1592 |
1593 CLASS_LIST_WITH_NULL(ADD_SET_FIELD) | 1593 CLASS_LIST_WITH_NULL(ADD_SET_FIELD) |
1594 #undef ADD_SET_FIELD | 1594 #undef ADD_SET_FIELD |
1595 | 1595 |
1596 isolate->object_store()->InitKnownObjects(); | 1596 isolate->object_store()->InitKnownObjects(); |
1597 | 1597 |
1598 return Error::null(); | 1598 return Error::null(); |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1964 bool Class::IsInFullSnapshot() const { | 1964 bool Class::IsInFullSnapshot() const { |
1965 NoSafepointScope no_safepoint; | 1965 NoSafepointScope no_safepoint; |
1966 return raw_ptr()->library_->ptr()->is_in_fullsnapshot_; | 1966 return raw_ptr()->library_->ptr()->is_in_fullsnapshot_; |
1967 } | 1967 } |
1968 | 1968 |
1969 | 1969 |
1970 RawAbstractType* Class::RareType() const { | 1970 RawAbstractType* Class::RareType() const { |
1971 const Type& type = Type::Handle(Type::New( | 1971 const Type& type = Type::Handle(Type::New( |
1972 *this, | 1972 *this, |
1973 Object::null_type_arguments(), | 1973 Object::null_type_arguments(), |
1974 Token::kNoSourcePos)); | 1974 TokenDescriptor::kNoSource)); |
1975 return ClassFinalizer::FinalizeType(*this, | 1975 return ClassFinalizer::FinalizeType(*this, |
1976 type, | 1976 type, |
1977 ClassFinalizer::kCanonicalize); | 1977 ClassFinalizer::kCanonicalize); |
1978 } | 1978 } |
1979 | 1979 |
1980 | 1980 |
1981 RawAbstractType* Class::DeclarationType() const { | 1981 RawAbstractType* Class::DeclarationType() const { |
1982 const TypeArguments& args = TypeArguments::Handle(type_parameters()); | 1982 const TypeArguments& args = TypeArguments::Handle(type_parameters()); |
1983 const Type& type = Type::Handle(Type::New( | 1983 const Type& type = Type::Handle(Type::New( |
1984 *this, | 1984 *this, |
1985 args, | 1985 args, |
1986 Token::kNoSourcePos)); | 1986 TokenDescriptor::kNoSource)); |
1987 return ClassFinalizer::FinalizeType(*this, | 1987 return ClassFinalizer::FinalizeType(*this, |
1988 type, | 1988 type, |
1989 ClassFinalizer::kCanonicalize); | 1989 ClassFinalizer::kCanonicalize); |
1990 } | 1990 } |
1991 | 1991 |
1992 | 1992 |
1993 template <class FakeObject> | 1993 template <class FakeObject> |
1994 RawClass* Class::New() { | 1994 RawClass* Class::New() { |
1995 ASSERT(Object::class_class() != Class::null()); | 1995 ASSERT(Object::class_class() != Class::null()); |
1996 Class& result = Class::Handle(); | 1996 Class& result = Class::Handle(); |
(...skipping 17 matching lines...) Expand all Loading... |
2014 result.set_is_finalized(); | 2014 result.set_is_finalized(); |
2015 } else { | 2015 } else { |
2016 // VM backed classes are almost ready: run checks and resolve class | 2016 // VM backed classes are almost ready: run checks and resolve class |
2017 // references, but do not recompute size. | 2017 // references, but do not recompute size. |
2018 result.set_is_prefinalized(); | 2018 result.set_is_prefinalized(); |
2019 } | 2019 } |
2020 result.set_type_arguments_field_offset_in_words(kNoTypeArguments); | 2020 result.set_type_arguments_field_offset_in_words(kNoTypeArguments); |
2021 result.set_num_type_arguments(0); | 2021 result.set_num_type_arguments(0); |
2022 result.set_num_own_type_arguments(0); | 2022 result.set_num_own_type_arguments(0); |
2023 result.set_num_native_fields(0); | 2023 result.set_num_native_fields(0); |
2024 result.set_token_pos(Token::kNoSourcePos); | 2024 result.set_token_pos(TokenDescriptor::kNoSource); |
2025 result.InitEmptyFields(); | 2025 result.InitEmptyFields(); |
2026 Isolate::Current()->RegisterClass(result); | 2026 Isolate::Current()->RegisterClass(result); |
2027 return result.raw(); | 2027 return result.raw(); |
2028 } | 2028 } |
2029 | 2029 |
2030 | 2030 |
2031 | 2031 |
2032 static void ReportTooManyTypeArguments(const Class& cls) { | 2032 static void ReportTooManyTypeArguments(const Class& cls) { |
2033 Report::MessageF(Report::kError, | 2033 Report::MessageF(Report::kError, |
2034 Script::Handle(cls.script()), | 2034 Script::Handle(cls.script()), |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2614 RawFunction::Kind kind) const { | 2614 RawFunction::Kind kind) const { |
2615 Function& invocation = Function::Handle( | 2615 Function& invocation = Function::Handle( |
2616 Function::New(String::Handle(Symbols::New(target_name)), | 2616 Function::New(String::Handle(Symbols::New(target_name)), |
2617 kind, | 2617 kind, |
2618 false, // Not static. | 2618 false, // Not static. |
2619 false, // Not const. | 2619 false, // Not const. |
2620 false, // Not abstract. | 2620 false, // Not abstract. |
2621 false, // Not external. | 2621 false, // Not external. |
2622 false, // Not native. | 2622 false, // Not native. |
2623 *this, | 2623 *this, |
2624 0)); // token_pos | 2624 TokenDescriptor::kMinSource)); |
2625 ArgumentsDescriptor desc(args_desc); | 2625 ArgumentsDescriptor desc(args_desc); |
2626 invocation.set_num_fixed_parameters(desc.PositionalCount()); | 2626 invocation.set_num_fixed_parameters(desc.PositionalCount()); |
2627 invocation.SetNumOptionalParameters(desc.NamedCount(), | 2627 invocation.SetNumOptionalParameters(desc.NamedCount(), |
2628 false); // Not positional. | 2628 false); // Not positional. |
2629 invocation.set_parameter_types(Array::Handle(Array::New(desc.Count(), | 2629 invocation.set_parameter_types(Array::Handle(Array::New(desc.Count(), |
2630 Heap::kOld))); | 2630 Heap::kOld))); |
2631 invocation.set_parameter_names(Array::Handle(Array::New(desc.Count(), | 2631 invocation.set_parameter_names(Array::Handle(Array::New(desc.Count(), |
2632 Heap::kOld))); | 2632 Heap::kOld))); |
2633 // Receiver. | 2633 // Receiver. |
2634 invocation.SetParameterTypeAt(0, Object::dynamic_type()); | 2634 invocation.SetParameterTypeAt(0, Object::dynamic_type()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2671 const Class& owner = Class::Handle(closure_function.Owner()); | 2671 const Class& owner = Class::Handle(closure_function.Owner()); |
2672 Function& extractor = Function::Handle( | 2672 Function& extractor = Function::Handle( |
2673 Function::New(String::Handle(Symbols::New(getter_name)), | 2673 Function::New(String::Handle(Symbols::New(getter_name)), |
2674 RawFunction::kMethodExtractor, | 2674 RawFunction::kMethodExtractor, |
2675 false, // Not static. | 2675 false, // Not static. |
2676 false, // Not const. | 2676 false, // Not const. |
2677 false, // Not abstract. | 2677 false, // Not abstract. |
2678 false, // Not external. | 2678 false, // Not external. |
2679 false, // Not native. | 2679 false, // Not native. |
2680 owner, | 2680 owner, |
2681 ClassifyingTokenPositions::kMethodExtractor)); // token_pos | 2681 TokenDescriptor::kMethodExtractor)); |
2682 | 2682 |
2683 // Initialize signature: receiver is a single fixed parameter. | 2683 // Initialize signature: receiver is a single fixed parameter. |
2684 const intptr_t kNumParameters = 1; | 2684 const intptr_t kNumParameters = 1; |
2685 extractor.set_num_fixed_parameters(kNumParameters); | 2685 extractor.set_num_fixed_parameters(kNumParameters); |
2686 extractor.SetNumOptionalParameters(0, 0); | 2686 extractor.SetNumOptionalParameters(0, 0); |
2687 extractor.set_parameter_types(Object::extractor_parameter_types()); | 2687 extractor.set_parameter_types(Object::extractor_parameter_types()); |
2688 extractor.set_parameter_names(Object::extractor_parameter_names()); | 2688 extractor.set_parameter_names(Object::extractor_parameter_names()); |
2689 extractor.set_result_type(Object::dynamic_type()); | 2689 extractor.set_result_type(Object::dynamic_type()); |
2690 | 2690 |
2691 extractor.set_extracted_method_closure(closure_function); | 2691 extractor.set_extracted_method_closure(closure_function); |
(...skipping 392 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(TokenDescriptor::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 TokenDescriptor 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(), TokenDescriptor::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(TokenDescriptor token_pos) const { |
3363 ASSERT(!Token::IsClassifying(token_pos)); | 3363 ASSERT(!TokenDescriptor(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 TokenDescriptor 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().value(), |
| 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 TokenDescriptor(tkit.CurrentPosition()); |
3385 } | 3386 } |
3386 } | 3387 } |
3387 tkit.Advance(); | 3388 tkit.Advance(); |
3388 } | 3389 } |
3389 UNREACHABLE(); | 3390 UNREACHABLE(); |
3390 return 0; | 3391 return TokenDescriptor::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 TokenDescriptor 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(TokenDescriptor token_pos) const { |
4268 ASSERT(!Token::IsClassifying(token_pos)); | 4269 ASSERT(!TokenDescriptor(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() == TokenDescriptor::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(TokenDescriptor::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(TokenDescriptor token_pos) const { |
5705 ASSERT(!Token::IsClassifying(token_pos) || IsMethodExtractor()); | 5706 ASSERT(!TokenDescriptor(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 = |
| 5751 end_token_pos().value() - token_pos().value(); |
5749 if (is_optimizable() && (script() != Script::null()) && | 5752 if (is_optimizable() && (script() != Script::null()) && |
5750 ((end_token_pos() - token_pos()) < FLAG_huge_method_cutoff_in_tokens)) { | 5753 (function_length < FLAG_huge_method_cutoff_in_tokens)) { |
5751 // Additional check needed for implicit getters. | 5754 // Additional check needed for implicit getters. |
5752 return (unoptimized_code() == Object::null()) || | 5755 return (unoptimized_code() == Object::null()) || |
5753 (Code::Handle(unoptimized_code()).Size() < | 5756 (Code::Handle(unoptimized_code()).Size() < |
5754 FLAG_huge_method_cutoff_in_code_size); | 5757 FLAG_huge_method_cutoff_in_code_size); |
5755 } | 5758 } |
5756 return false; | 5759 return false; |
5757 } | 5760 } |
5758 | 5761 |
5759 | 5762 |
5760 bool Function::IsNativeAutoSetupScope() const { | 5763 bool Function::IsNativeAutoSetupScope() const { |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6314 | 6317 |
6315 | 6318 |
6316 RawFunction* Function::New(const String& name, | 6319 RawFunction* Function::New(const String& name, |
6317 RawFunction::Kind kind, | 6320 RawFunction::Kind kind, |
6318 bool is_static, | 6321 bool is_static, |
6319 bool is_const, | 6322 bool is_const, |
6320 bool is_abstract, | 6323 bool is_abstract, |
6321 bool is_external, | 6324 bool is_external, |
6322 bool is_native, | 6325 bool is_native, |
6323 const Object& owner, | 6326 const Object& owner, |
6324 intptr_t token_pos) { | 6327 TokenDescriptor token_pos) { |
6325 ASSERT(!owner.IsNull()); | 6328 ASSERT(!owner.IsNull()); |
6326 const Function& result = Function::Handle(Function::New()); | 6329 const Function& result = Function::Handle(Function::New()); |
6327 result.set_parameter_types(Object::empty_array()); | 6330 result.set_parameter_types(Object::empty_array()); |
6328 result.set_parameter_names(Object::empty_array()); | 6331 result.set_parameter_names(Object::empty_array()); |
6329 result.set_name(name); | 6332 result.set_name(name); |
6330 result.set_kind(kind); | 6333 result.set_kind(kind); |
6331 result.set_recognized_kind(MethodRecognizer::kUnknown); | 6334 result.set_recognized_kind(MethodRecognizer::kUnknown); |
6332 result.set_modifier(RawFunction::kNoModifier); | 6335 result.set_modifier(RawFunction::kNoModifier); |
6333 result.set_is_static(is_static); | 6336 result.set_is_static(is_static); |
6334 result.set_is_const(is_const); | 6337 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); | 6397 type ^= type.CloneUninstantiated(new_owner); |
6395 clone.SetParameterTypeAt(i, type); | 6398 clone.SetParameterTypeAt(i, type); |
6396 } | 6399 } |
6397 } | 6400 } |
6398 return clone.raw(); | 6401 return clone.raw(); |
6399 } | 6402 } |
6400 | 6403 |
6401 | 6404 |
6402 RawFunction* Function::NewClosureFunction(const String& name, | 6405 RawFunction* Function::NewClosureFunction(const String& name, |
6403 const Function& parent, | 6406 const Function& parent, |
6404 intptr_t token_pos) { | 6407 TokenDescriptor token_pos) { |
6405 ASSERT(!parent.IsNull()); | 6408 ASSERT(!parent.IsNull()); |
6406 // Use the owner defining the parent function and not the class containing it. | 6409 // Use the owner defining the parent function and not the class containing it. |
6407 const Object& parent_owner = Object::Handle(parent.raw_ptr()->owner_); | 6410 const Object& parent_owner = Object::Handle(parent.raw_ptr()->owner_); |
6408 ASSERT(!parent_owner.IsNull()); | 6411 ASSERT(!parent_owner.IsNull()); |
6409 const Function& result = Function::Handle( | 6412 const Function& result = Function::Handle( |
6410 Function::New(name, | 6413 Function::New(name, |
6411 RawFunction::kClosureFunction, | 6414 RawFunction::kClosureFunction, |
6412 /* is_static = */ parent.is_static(), | 6415 /* is_static = */ parent.is_static(), |
6413 /* is_const = */ false, | 6416 /* is_const = */ false, |
6414 /* is_abstract = */ false, | 6417 /* is_abstract = */ false, |
6415 /* is_external = */ false, | 6418 /* is_external = */ false, |
6416 parent.is_native(), | 6419 parent.is_native(), |
6417 parent_owner, | 6420 parent_owner, |
6418 token_pos)); | 6421 token_pos)); |
6419 result.set_parent_function(parent); | 6422 result.set_parent_function(parent); |
6420 return result.raw(); | 6423 return result.raw(); |
6421 } | 6424 } |
6422 | 6425 |
6423 | 6426 |
6424 RawFunction* Function::NewSignatureFunction(const Class& owner, | 6427 RawFunction* Function::NewSignatureFunction(const Class& owner, |
6425 intptr_t token_pos) { | 6428 TokenDescriptor token_pos) { |
6426 const Function& result = Function::Handle(Function::New( | 6429 const Function& result = Function::Handle(Function::New( |
6427 Symbols::AnonymousSignature(), | 6430 Symbols::AnonymousSignature(), |
6428 RawFunction::kSignatureFunction, | 6431 RawFunction::kSignatureFunction, |
6429 /* is_static = */ false, | 6432 /* is_static = */ false, |
6430 /* is_const = */ false, | 6433 /* is_const = */ false, |
6431 /* is_abstract = */ false, | 6434 /* is_abstract = */ false, |
6432 /* is_external = */ false, | 6435 /* is_external = */ false, |
6433 /* is_native = */ false, | 6436 /* is_native = */ false, |
6434 owner, // Same as function type scope class. | 6437 owner, // Same as function type scope class. |
6435 token_pos)); | 6438 token_pos)); |
6436 result.set_is_reflectable(false); | 6439 result.set_is_reflectable(false); |
6437 result.set_is_visible(false); | 6440 result.set_is_visible(false); |
6438 result.set_is_debuggable(false); | 6441 result.set_is_debuggable(false); |
6439 return result.raw(); | 6442 return result.raw(); |
6440 } | 6443 } |
6441 | 6444 |
6442 | 6445 |
6443 RawFunction* Function::NewEvalFunction(const Class& owner, | 6446 RawFunction* Function::NewEvalFunction(const Class& owner, |
6444 const Script& script, | 6447 const Script& script, |
6445 bool is_static) { | 6448 bool is_static) { |
6446 const Function& result = Function::Handle( | 6449 const Function& result = Function::Handle( |
6447 Function::New(String::Handle(Symbols::New(":Eval")), | 6450 Function::New(String::Handle(Symbols::New(":Eval")), |
6448 RawFunction::kRegularFunction, | 6451 RawFunction::kRegularFunction, |
6449 is_static, | 6452 is_static, |
6450 /* is_const = */ false, | 6453 /* is_const = */ false, |
6451 /* is_abstract = */ false, | 6454 /* is_abstract = */ false, |
6452 /* is_external = */ false, | 6455 /* is_external = */ false, |
6453 /* is_native = */ false, | 6456 /* is_native = */ false, |
6454 owner, | 6457 owner, |
6455 /* token_pos = */ 0)); | 6458 TokenDescriptor::kMinSource)); |
6456 ASSERT(!script.IsNull()); | 6459 ASSERT(!script.IsNull()); |
6457 result.set_is_debuggable(false); | 6460 result.set_is_debuggable(false); |
6458 result.set_is_visible(true); | 6461 result.set_is_visible(true); |
6459 result.set_eval_script(script); | 6462 result.set_eval_script(script); |
6460 return result.raw(); | 6463 return result.raw(); |
6461 } | 6464 } |
6462 | 6465 |
6463 RawFunction* Function::ImplicitClosureFunction() const { | 6466 RawFunction* Function::ImplicitClosureFunction() const { |
6464 // Return the existing implicit closure function if any. | 6467 // Return the existing implicit closure function if any. |
6465 if (implicit_closure_function() != Function::null()) { | 6468 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_); | 6739 const Object& obj = Object::Handle(raw_ptr()->owner_); |
6737 if (obj.IsClass()) { | 6740 if (obj.IsClass()) { |
6738 return Class::Cast(obj).raw(); | 6741 return Class::Cast(obj).raw(); |
6739 } | 6742 } |
6740 ASSERT(obj.IsPatchClass()); | 6743 ASSERT(obj.IsPatchClass()); |
6741 return PatchClass::Cast(obj).origin_class(); | 6744 return PatchClass::Cast(obj).origin_class(); |
6742 } | 6745 } |
6743 | 6746 |
6744 | 6747 |
6745 RawScript* Function::script() const { | 6748 RawScript* Function::script() const { |
6746 if (token_pos() == 0) { | 6749 if (token_pos() == TokenDescriptor::kMinSource) { |
6747 // Testing for position 0 is an optimization that relies on temporary | 6750 // Testing for position 0 is an optimization that relies on temporary |
6748 // eval functions having token position 0. | 6751 // eval functions having token position 0. |
6749 const Script& script = Script::Handle(eval_script()); | 6752 const Script& script = Script::Handle(eval_script()); |
6750 if (!script.IsNull()) { | 6753 if (!script.IsNull()) { |
6751 return script.raw(); | 6754 return script.raw(); |
6752 } | 6755 } |
6753 } | 6756 } |
6754 if (IsClosureFunction()) { | 6757 if (IsClosureFunction()) { |
6755 return Function::Handle(parent_function()).script(); | 6758 return Function::Handle(parent_function()).script(); |
6756 } | 6759 } |
(...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 | 6842 // relaxed. In particular we might start associating some source with the |
6840 // forwarding constructors when it becomes possible to specify a particular | 6843 // forwarding constructors when it becomes possible to specify a particular |
6841 // constructor from the mixin to use. | 6844 // constructor from the mixin to use. |
6842 return String::null(); | 6845 return String::null(); |
6843 } | 6846 } |
6844 const Script& func_script = Script::Handle(script()); | 6847 const Script& func_script = Script::Handle(script()); |
6845 const TokenStream& stream = TokenStream::Handle(func_script.tokens()); | 6848 const TokenStream& stream = TokenStream::Handle(func_script.tokens()); |
6846 if (!func_script.HasSource()) { | 6849 if (!func_script.HasSource()) { |
6847 // When source is not available, avoid printing the whole token stream and | 6850 // When source is not available, avoid printing the whole token stream and |
6848 // doing expensive position calculations. | 6851 // doing expensive position calculations. |
6849 return stream.GenerateSource(token_pos(), end_token_pos() + 1); | 6852 return stream.GenerateSource(token_pos(), |
| 6853 TokenDescriptor(end_token_pos().value() + 1)); |
6850 } | 6854 } |
6851 | 6855 |
6852 const TokenStream::Iterator tkit(stream, end_token_pos()); | 6856 const TokenStream::Iterator tkit(stream, end_token_pos().value()); |
6853 intptr_t from_line; | 6857 intptr_t from_line; |
6854 intptr_t from_col; | 6858 intptr_t from_col; |
6855 intptr_t to_line; | 6859 intptr_t to_line; |
6856 intptr_t to_col; | 6860 intptr_t to_col; |
6857 func_script.GetTokenLocation(token_pos(), &from_line, &from_col); | 6861 func_script.GetTokenLocation(token_pos(), &from_line, &from_col); |
6858 func_script.GetTokenLocation(end_token_pos(), &to_line, &to_col); | 6862 func_script.GetTokenLocation(end_token_pos(), &to_line, &to_col); |
6859 intptr_t last_tok_len = String::Handle(tkit.CurrentLiteral()).Length(); | 6863 intptr_t last_tok_len = String::Handle(tkit.CurrentLiteral()).Length(); |
6860 // Handle special cases for end tokens of closures (where we exclude the last | 6864 // Handle special cases for end tokens of closures (where we exclude the last |
6861 // token): | 6865 // token): |
6862 // (1) "foo(() => null, bar);": End token is `,', but we don't print it. | 6866 // (1) "foo(() => null, bar);": End token is `,', but we don't print it. |
(...skipping 16 matching lines...) Expand all Loading... |
6879 // Construct fingerprint from token stream. The token stream contains also | 6883 // Construct fingerprint from token stream. The token stream contains also |
6880 // arguments. | 6884 // arguments. |
6881 int32_t Function::SourceFingerprint() const { | 6885 int32_t Function::SourceFingerprint() const { |
6882 uint32_t result = IsImplicitClosureFunction() | 6886 uint32_t result = IsImplicitClosureFunction() |
6883 ? String::Handle(Function::Handle(parent_function()).Signature()).Hash() | 6887 ? String::Handle(Function::Handle(parent_function()).Signature()).Hash() |
6884 : String::Handle(Signature()).Hash(); | 6888 : String::Handle(Signature()).Hash(); |
6885 TokenStream::Iterator tokens_iterator(TokenStream::Handle( | 6889 TokenStream::Iterator tokens_iterator(TokenStream::Handle( |
6886 Script::Handle(script()).tokens()), token_pos()); | 6890 Script::Handle(script()).tokens()), token_pos()); |
6887 Object& obj = Object::Handle(); | 6891 Object& obj = Object::Handle(); |
6888 String& literal = String::Handle(); | 6892 String& literal = String::Handle(); |
6889 while (tokens_iterator.CurrentPosition() < end_token_pos()) { | 6893 while (tokens_iterator.CurrentPosition() < end_token_pos().value()) { |
6890 uint32_t val = 0; | 6894 uint32_t val = 0; |
6891 obj = tokens_iterator.CurrentToken(); | 6895 obj = tokens_iterator.CurrentToken(); |
6892 if (obj.IsSmi()) { | 6896 if (obj.IsSmi()) { |
6893 val = Smi::Cast(obj).Value(); | 6897 val = Smi::Cast(obj).Value(); |
6894 } else { | 6898 } else { |
6895 literal = tokens_iterator.MakeLiteralToken(obj); | 6899 literal = tokens_iterator.MakeLiteralToken(obj); |
6896 val = literal.Hash(); | 6900 val = literal.Hash(); |
6897 } | 6901 } |
6898 result = 31 * result + val; | 6902 result = 31 * result + val; |
6899 tokens_iterator.Advance(); | 6903 tokens_iterator.Advance(); |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7346 } | 7350 } |
7347 | 7351 |
7348 | 7352 |
7349 RawField* Field::New(const String& name, | 7353 RawField* Field::New(const String& name, |
7350 bool is_static, | 7354 bool is_static, |
7351 bool is_final, | 7355 bool is_final, |
7352 bool is_const, | 7356 bool is_const, |
7353 bool is_reflectable, | 7357 bool is_reflectable, |
7354 const Class& owner, | 7358 const Class& owner, |
7355 const AbstractType& type, | 7359 const AbstractType& type, |
7356 intptr_t token_pos) { | 7360 TokenDescriptor token_pos) { |
7357 ASSERT(!owner.IsNull()); | 7361 ASSERT(!owner.IsNull()); |
7358 const Field& result = Field::Handle(Field::New()); | 7362 const Field& result = Field::Handle(Field::New()); |
7359 result.set_name(name); | 7363 result.set_name(name); |
7360 result.set_is_static(is_static); | 7364 result.set_is_static(is_static); |
7361 if (!is_static) { | 7365 if (!is_static) { |
7362 result.SetOffset(0); | 7366 result.SetOffset(0); |
7363 } | 7367 } |
7364 result.set_is_final(is_final); | 7368 result.set_is_final(is_final); |
7365 result.set_is_const(is_const); | 7369 result.set_is_const(is_const); |
7366 result.set_is_reflectable(is_reflectable); | 7370 result.set_is_reflectable(is_reflectable); |
(...skipping 13 matching lines...) Expand all Loading... |
7380 result.set_guarded_list_length(Field::kNoFixedLength); | 7384 result.set_guarded_list_length(Field::kNoFixedLength); |
7381 } | 7385 } |
7382 return result.raw(); | 7386 return result.raw(); |
7383 } | 7387 } |
7384 | 7388 |
7385 | 7389 |
7386 RawField* Field::NewTopLevel(const String& name, | 7390 RawField* Field::NewTopLevel(const String& name, |
7387 bool is_final, | 7391 bool is_final, |
7388 bool is_const, | 7392 bool is_const, |
7389 const Object& owner, | 7393 const Object& owner, |
7390 intptr_t token_pos) { | 7394 TokenDescriptor token_pos) { |
7391 ASSERT(!owner.IsNull()); | 7395 ASSERT(!owner.IsNull()); |
7392 const Field& result = Field::Handle(Field::New()); | 7396 const Field& result = Field::Handle(Field::New()); |
7393 result.set_name(name); | 7397 result.set_name(name); |
7394 result.set_is_static(true); | 7398 result.set_is_static(true); |
7395 result.set_is_final(is_final); | 7399 result.set_is_final(is_final); |
7396 result.set_is_const(is_const); | 7400 result.set_is_const(is_const); |
7397 result.set_is_reflectable(true); | 7401 result.set_is_reflectable(true); |
7398 result.set_is_double_initialized(false); | 7402 result.set_is_double_initialized(false); |
7399 result.set_owner(owner); | 7403 result.set_owner(owner); |
7400 result.set_token_pos(token_pos); | 7404 result.set_token_pos(token_pos); |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7979 RawString* TokenStream::PrivateKey() const { | 7983 RawString* TokenStream::PrivateKey() const { |
7980 return raw_ptr()->private_key_; | 7984 return raw_ptr()->private_key_; |
7981 } | 7985 } |
7982 | 7986 |
7983 | 7987 |
7984 void TokenStream::SetPrivateKey(const String& value) const { | 7988 void TokenStream::SetPrivateKey(const String& value) const { |
7985 StorePointer(&raw_ptr()->private_key_, value.raw()); | 7989 StorePointer(&raw_ptr()->private_key_, value.raw()); |
7986 } | 7990 } |
7987 | 7991 |
7988 RawString* TokenStream::GenerateSource() const { | 7992 RawString* TokenStream::GenerateSource() const { |
7989 return GenerateSource(0, kMaxElements); | 7993 return GenerateSource(TokenDescriptor::kMinSource, |
| 7994 TokenDescriptor::kMaxSource); |
7990 } | 7995 } |
7991 | 7996 |
7992 RawString* TokenStream::GenerateSource(intptr_t start_pos, | 7997 RawString* TokenStream::GenerateSource(TokenDescriptor start_pos, |
7993 intptr_t end_pos) const { | 7998 TokenDescriptor end_pos) const { |
7994 Iterator iterator(*this, start_pos, Iterator::kAllTokens); | 7999 Iterator iterator(*this, start_pos, Iterator::kAllTokens); |
7995 const ExternalTypedData& data = ExternalTypedData::Handle(GetStream()); | 8000 const ExternalTypedData& data = ExternalTypedData::Handle(GetStream()); |
7996 const GrowableObjectArray& literals = | 8001 const GrowableObjectArray& literals = |
7997 GrowableObjectArray::Handle(GrowableObjectArray::New(data.Length())); | 8002 GrowableObjectArray::Handle(GrowableObjectArray::New(data.Length())); |
7998 const String& private_key = String::Handle(PrivateKey()); | 8003 const String& private_key = String::Handle(PrivateKey()); |
7999 intptr_t private_len = private_key.Length(); | 8004 intptr_t private_len = private_key.Length(); |
8000 | 8005 |
8001 Token::Kind curr = iterator.CurrentTokenKind(); | 8006 Token::Kind curr = iterator.CurrentTokenKind(); |
8002 Token::Kind prev = Token::kILLEGAL; | 8007 Token::Kind prev = Token::kILLEGAL; |
8003 // Handles used in the loop. | 8008 // Handles used in the loop. |
8004 Object& obj = Object::Handle(); | 8009 Object& obj = Object::Handle(); |
8005 String& literal = String::Handle(); | 8010 String& literal = String::Handle(); |
8006 // Current indentation level. | 8011 // Current indentation level. |
8007 int indent = 0; | 8012 int indent = 0; |
8008 | 8013 |
8009 while ((curr != Token::kEOS) && (iterator.CurrentPosition() < end_pos)) { | 8014 while ((curr != Token::kEOS) && |
| 8015 (iterator.CurrentPosition() < end_pos.value())) { |
8010 // Remember current values for this token. | 8016 // Remember current values for this token. |
8011 obj = iterator.CurrentToken(); | 8017 obj = iterator.CurrentToken(); |
8012 literal = iterator.MakeLiteralToken(obj); | 8018 literal = iterator.MakeLiteralToken(obj); |
8013 // Advance to be able to use next token kind. | 8019 // Advance to be able to use next token kind. |
8014 iterator.Advance(); | 8020 iterator.Advance(); |
8015 Token::Kind next = iterator.CurrentTokenKind(); | 8021 Token::Kind next = iterator.CurrentTokenKind(); |
8016 | 8022 |
8017 // Handle the current token. | 8023 // Handle the current token. |
8018 if (curr == Token::kSTRING) { | 8024 if (curr == Token::kSTRING) { |
8019 bool escape_characters = false; | 8025 bool escape_characters = false; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8157 | 8163 |
8158 // Setup for next iteration. | 8164 // Setup for next iteration. |
8159 prev = curr; | 8165 prev = curr; |
8160 curr = next; | 8166 curr = next; |
8161 } | 8167 } |
8162 const Array& source = Array::Handle(Array::MakeArray(literals)); | 8168 const Array& source = Array::Handle(Array::MakeArray(literals)); |
8163 return String::ConcatAll(source); | 8169 return String::ConcatAll(source); |
8164 } | 8170 } |
8165 | 8171 |
8166 | 8172 |
8167 intptr_t TokenStream::ComputeSourcePosition(intptr_t tok_pos) const { | 8173 TokenDescriptor TokenStream::ComputeSourcePosition( |
8168 Iterator iterator(*this, 0, Iterator::kAllTokens); | 8174 TokenDescriptor tok_pos) const { |
8169 intptr_t src_pos = 0; | 8175 Iterator iterator(*this, TokenDescriptor::kMinSource, Iterator::kAllTokens); |
| 8176 TokenDescriptor src_pos = TokenDescriptor::kMinSource; |
8170 Token::Kind kind = iterator.CurrentTokenKind(); | 8177 Token::Kind kind = iterator.CurrentTokenKind(); |
8171 while (iterator.CurrentPosition() < tok_pos && kind != Token::kEOS) { | 8178 while (iterator.CurrentPosition() < tok_pos.value() && kind != Token::kEOS) { |
8172 iterator.Advance(); | 8179 iterator.Advance(); |
8173 kind = iterator.CurrentTokenKind(); | 8180 kind = iterator.CurrentTokenKind(); |
8174 src_pos += 1; | 8181 src_pos.Next(); |
8175 } | 8182 } |
8176 return src_pos; | 8183 return src_pos; |
8177 } | 8184 } |
8178 | 8185 |
8179 | 8186 |
8180 RawTokenStream* TokenStream::New() { | 8187 RawTokenStream* TokenStream::New() { |
8181 ASSERT(Object::token_stream_class() != Class::null()); | 8188 ASSERT(Object::token_stream_class() != Class::null()); |
8182 RawObject* raw = Object::Allocate(TokenStream::kClassId, | 8189 RawObject* raw = Object::Allocate(TokenStream::kClassId, |
8183 TokenStream::InstanceSize(), | 8190 TokenStream::InstanceSize(), |
8184 Heap::kOld); | 8191 Heap::kOld); |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8449 : tokens_(TokenStream::Handle(tokens.raw())), | 8456 : tokens_(TokenStream::Handle(tokens.raw())), |
8450 data_(ExternalTypedData::Handle(tokens.GetStream())), | 8457 data_(ExternalTypedData::Handle(tokens.GetStream())), |
8451 stream_(reinterpret_cast<uint8_t*>(data_.DataAddr(0)), data_.Length()), | 8458 stream_(reinterpret_cast<uint8_t*>(data_.DataAddr(0)), data_.Length()), |
8452 token_objects_(Array::Handle( | 8459 token_objects_(Array::Handle( |
8453 GrowableObjectArray::Handle(tokens.TokenObjects()).data())), | 8460 GrowableObjectArray::Handle(tokens.TokenObjects()).data())), |
8454 obj_(Object::Handle()), | 8461 obj_(Object::Handle()), |
8455 cur_token_pos_(token_pos), | 8462 cur_token_pos_(token_pos), |
8456 cur_token_kind_(Token::kILLEGAL), | 8463 cur_token_kind_(Token::kILLEGAL), |
8457 cur_token_obj_index_(-1), | 8464 cur_token_obj_index_(-1), |
8458 stream_type_(stream_type) { | 8465 stream_type_(stream_type) { |
8459 ASSERT(token_pos != Token::kNoSourcePos); | 8466 ASSERT(token_pos != TokenDescriptor::kNoSource.value()); |
8460 if (token_pos >= 0) { | 8467 if (TokenDescriptor(token_pos).IsReal()) { |
8461 SetCurrentPosition(token_pos); | 8468 SetCurrentPosition(token_pos); |
8462 } | 8469 } |
8463 } | 8470 } |
8464 | 8471 |
8465 | 8472 |
| 8473 TokenStream::Iterator::Iterator(const TokenStream& tokens, |
| 8474 TokenDescriptor token_pos, |
| 8475 Iterator::StreamType stream_type) |
| 8476 : tokens_(TokenStream::Handle(tokens.raw())), |
| 8477 data_(ExternalTypedData::Handle(tokens.GetStream())), |
| 8478 stream_(reinterpret_cast<uint8_t*>(data_.DataAddr(0)), data_.Length()), |
| 8479 token_objects_(Array::Handle( |
| 8480 GrowableObjectArray::Handle(tokens.TokenObjects()).data())), |
| 8481 obj_(Object::Handle()), |
| 8482 cur_token_pos_(token_pos.value()), |
| 8483 cur_token_kind_(Token::kILLEGAL), |
| 8484 cur_token_obj_index_(-1), |
| 8485 stream_type_(stream_type) { |
| 8486 ASSERT(token_pos != TokenDescriptor::kNoSource); |
| 8487 if (token_pos.IsReal()) { |
| 8488 SetCurrentPosition(token_pos.value()); |
| 8489 } |
| 8490 } |
| 8491 |
| 8492 |
8466 void TokenStream::Iterator::SetStream(const TokenStream& tokens, | 8493 void TokenStream::Iterator::SetStream(const TokenStream& tokens, |
8467 intptr_t token_pos) { | 8494 intptr_t token_pos) { |
8468 tokens_ = tokens.raw(); | 8495 tokens_ = tokens.raw(); |
8469 data_ = tokens.GetStream(); | 8496 data_ = tokens.GetStream(); |
8470 stream_.SetStream(reinterpret_cast<uint8_t*>(data_.DataAddr(0)), | 8497 stream_.SetStream(reinterpret_cast<uint8_t*>(data_.DataAddr(0)), |
8471 data_.Length()); | 8498 data_.Length()); |
8472 token_objects_ = GrowableObjectArray::Handle(tokens.TokenObjects()).data(); | 8499 token_objects_ = GrowableObjectArray::Handle(tokens.TokenObjects()).data(); |
8473 obj_ = Object::null(); | 8500 obj_ = Object::null(); |
8474 cur_token_pos_ = token_pos; | 8501 cur_token_pos_ = token_pos; |
8475 cur_token_kind_ = Token::kILLEGAL; | 8502 cur_token_kind_ = Token::kILLEGAL; |
8476 cur_token_obj_index_ = -1; | 8503 cur_token_obj_index_ = -1; |
8477 SetCurrentPosition(token_pos); | 8504 SetCurrentPosition(token_pos); |
8478 } | 8505 } |
8479 | 8506 |
8480 | 8507 |
| 8508 void TokenStream::Iterator::SetStream(const TokenStream& tokens, |
| 8509 TokenDescriptor token_pos) { |
| 8510 SetStream(tokens, token_pos.value()); |
| 8511 } |
| 8512 |
| 8513 |
8481 bool TokenStream::Iterator::IsValid() const { | 8514 bool TokenStream::Iterator::IsValid() const { |
8482 return !tokens_.IsNull(); | 8515 return !tokens_.IsNull(); |
8483 } | 8516 } |
8484 | 8517 |
8485 | 8518 |
8486 Token::Kind TokenStream::Iterator::LookaheadTokenKind(intptr_t num_tokens) { | 8519 Token::Kind TokenStream::Iterator::LookaheadTokenKind(intptr_t num_tokens) { |
8487 intptr_t saved_position = stream_.Position(); | 8520 intptr_t saved_position = stream_.Position(); |
8488 Token::Kind kind = Token::kILLEGAL; | 8521 Token::Kind kind = Token::kILLEGAL; |
8489 intptr_t value = -1; | 8522 intptr_t value = -1; |
8490 intptr_t count = 0; | 8523 intptr_t count = 0; |
(...skipping 26 matching lines...) Expand all Loading... |
8517 return cur_token_pos_; | 8550 return cur_token_pos_; |
8518 } | 8551 } |
8519 | 8552 |
8520 | 8553 |
8521 void TokenStream::Iterator::SetCurrentPosition(intptr_t value) { | 8554 void TokenStream::Iterator::SetCurrentPosition(intptr_t value) { |
8522 stream_.SetPosition(value); | 8555 stream_.SetPosition(value); |
8523 Advance(); | 8556 Advance(); |
8524 } | 8557 } |
8525 | 8558 |
8526 | 8559 |
| 8560 void TokenStream::Iterator::SetCurrentPosition(TokenDescriptor token_pos) { |
| 8561 SetCurrentPosition(token_pos.value()); |
| 8562 } |
| 8563 |
| 8564 |
8527 void TokenStream::Iterator::Advance() { | 8565 void TokenStream::Iterator::Advance() { |
8528 intptr_t value; | 8566 intptr_t value; |
8529 do { | 8567 do { |
8530 cur_token_pos_ = stream_.Position(); | 8568 cur_token_pos_ = stream_.Position(); |
8531 value = ReadToken(); | 8569 value = ReadToken(); |
8532 } while ((stream_type_ == kNoNewlines) && | 8570 } while ((stream_type_ == kNoNewlines) && |
8533 (static_cast<Token::Kind>(value) == Token::kNEWLINE)); | 8571 (static_cast<Token::Kind>(value) == Token::kNEWLINE)); |
8534 if (value < Token::kNumTokens) { | 8572 if (value < Token::kNumTokens) { |
8535 cur_token_kind_ = static_cast<Token::Kind>(value); | 8573 cur_token_kind_ = static_cast<Token::Kind>(value); |
8536 cur_token_obj_index_ = -1; | 8574 cur_token_obj_index_ = -1; |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8752 | 8790 |
8753 void Script::SetLocationOffset(intptr_t line_offset, | 8791 void Script::SetLocationOffset(intptr_t line_offset, |
8754 intptr_t col_offset) const { | 8792 intptr_t col_offset) const { |
8755 ASSERT(line_offset >= 0); | 8793 ASSERT(line_offset >= 0); |
8756 ASSERT(col_offset >= 0); | 8794 ASSERT(col_offset >= 0); |
8757 StoreNonPointer(&raw_ptr()->line_offset_, line_offset); | 8795 StoreNonPointer(&raw_ptr()->line_offset_, line_offset); |
8758 StoreNonPointer(&raw_ptr()->col_offset_, col_offset); | 8796 StoreNonPointer(&raw_ptr()->col_offset_, col_offset); |
8759 } | 8797 } |
8760 | 8798 |
8761 | 8799 |
8762 void Script::GetTokenLocation(intptr_t token_pos, | 8800 void Script::GetTokenLocation(TokenDescriptor token_pos, |
8763 intptr_t* line, | 8801 intptr_t* line, |
8764 intptr_t* column, | 8802 intptr_t* column, |
8765 intptr_t* token_len) const { | 8803 intptr_t* token_len) const { |
8766 ASSERT(line != NULL); | 8804 ASSERT(line != NULL); |
8767 const TokenStream& tkns = TokenStream::Handle(tokens()); | 8805 const TokenStream& tkns = TokenStream::Handle(tokens()); |
8768 if (tkns.IsNull()) { | 8806 if (tkns.IsNull()) { |
8769 ASSERT(Dart::IsRunningPrecompiledCode()); | 8807 ASSERT(Dart::IsRunningPrecompiledCode()); |
8770 *line = -1; | 8808 *line = -1; |
8771 if (column != NULL) { | 8809 if (column != NULL) { |
8772 *column = -1; | 8810 *column = -1; |
8773 } | 8811 } |
8774 if (token_len != NULL) { | 8812 if (token_len != NULL) { |
8775 *token_len = 1; | 8813 *token_len = 1; |
8776 } | 8814 } |
8777 return; | 8815 return; |
8778 } | 8816 } |
8779 if (column == NULL) { | 8817 if (column == NULL) { |
8780 TokenStream::Iterator tkit(tkns, 0, TokenStream::Iterator::kAllTokens); | 8818 TokenStream::Iterator tkit(tkns, 0, TokenStream::Iterator::kAllTokens); |
8781 intptr_t cur_line = line_offset() + 1; | 8819 intptr_t cur_line = line_offset() + 1; |
8782 while (tkit.CurrentPosition() < token_pos && | 8820 while ((tkit.CurrentPosition() < token_pos.value()) && |
8783 tkit.CurrentTokenKind() != Token::kEOS) { | 8821 (tkit.CurrentTokenKind() != Token::kEOS)) { |
8784 if (tkit.CurrentTokenKind() == Token::kNEWLINE) { | 8822 if (tkit.CurrentTokenKind() == Token::kNEWLINE) { |
8785 cur_line++; | 8823 cur_line++; |
8786 } | 8824 } |
8787 tkit.Advance(); | 8825 tkit.Advance(); |
8788 } | 8826 } |
8789 *line = cur_line; | 8827 *line = cur_line; |
8790 } else { | 8828 } else { |
8791 const String& src = String::Handle(Source()); | 8829 const String& src = String::Handle(Source()); |
8792 intptr_t src_pos = tkns.ComputeSourcePosition(token_pos); | 8830 TokenDescriptor src_pos = tkns.ComputeSourcePosition(token_pos); |
8793 Scanner scanner(src, Symbols::Empty()); | 8831 Scanner scanner(src, Symbols::Empty()); |
8794 scanner.ScanTo(src_pos); | 8832 scanner.ScanTo(src_pos); |
8795 intptr_t relative_line = scanner.CurrentPosition().line; | 8833 intptr_t relative_line = scanner.CurrentPosition().line; |
8796 *line = relative_line + line_offset(); | 8834 *line = relative_line + line_offset(); |
8797 *column = scanner.CurrentPosition().column; | 8835 *column = scanner.CurrentPosition().column; |
8798 if (token_len != NULL) { | 8836 if (token_len != NULL) { |
8799 if (scanner.current_token().literal != NULL) { | 8837 if (scanner.current_token().literal != NULL) { |
8800 *token_len = scanner.current_token().literal->Length(); | 8838 *token_len = scanner.current_token().literal->Length(); |
8801 } else { | 8839 } else { |
8802 *token_len = 1; | 8840 *token_len = 1; |
8803 } | 8841 } |
8804 } | 8842 } |
8805 // On the first line of the script we must add the column offset. | 8843 // On the first line of the script we must add the column offset. |
8806 if (relative_line == 1) { | 8844 if (relative_line == 1) { |
8807 *column += col_offset(); | 8845 *column += col_offset(); |
8808 } | 8846 } |
8809 } | 8847 } |
8810 } | 8848 } |
8811 | 8849 |
8812 | 8850 |
8813 void Script::TokenRangeAtLine(intptr_t line_number, | 8851 void Script::TokenRangeAtLine(intptr_t line_number, |
8814 intptr_t* first_token_index, | 8852 TokenDescriptor* first_token_index, |
8815 intptr_t* last_token_index) const { | 8853 TokenDescriptor* last_token_index) const { |
8816 ASSERT(first_token_index != NULL && last_token_index != NULL); | 8854 ASSERT(first_token_index != NULL && last_token_index != NULL); |
8817 ASSERT(line_number > 0); | 8855 ASSERT(line_number > 0); |
8818 *first_token_index = -1; | 8856 *first_token_index = TokenDescriptor::kNoSource; |
8819 *last_token_index = -1; | 8857 *last_token_index = TokenDescriptor::kNoSource; |
8820 const TokenStream& tkns = TokenStream::Handle(tokens()); | 8858 const TokenStream& tkns = TokenStream::Handle(tokens()); |
8821 line_number -= line_offset(); | 8859 line_number -= line_offset(); |
8822 if (line_number < 1) line_number = 1; | 8860 if (line_number < 1) line_number = 1; |
8823 TokenStream::Iterator tkit(tkns, 0, TokenStream::Iterator::kAllTokens); | 8861 TokenStream::Iterator tkit(tkns, 0, TokenStream::Iterator::kAllTokens); |
8824 // Scan through the token stream to the required line. | 8862 // Scan through the token stream to the required line. |
8825 intptr_t cur_line = 1; | 8863 intptr_t cur_line = 1; |
8826 while (cur_line < line_number && tkit.CurrentTokenKind() != Token::kEOS) { | 8864 while (cur_line < line_number && tkit.CurrentTokenKind() != Token::kEOS) { |
8827 if (tkit.CurrentTokenKind() == Token::kNEWLINE) { | 8865 if (tkit.CurrentTokenKind() == Token::kNEWLINE) { |
8828 cur_line++; | 8866 cur_line++; |
8829 } | 8867 } |
8830 tkit.Advance(); | 8868 tkit.Advance(); |
8831 } | 8869 } |
8832 if (tkit.CurrentTokenKind() == Token::kEOS) { | 8870 if (tkit.CurrentTokenKind() == Token::kEOS) { |
8833 // End of token stream before reaching required line. | 8871 // End of token stream before reaching required line. |
8834 return; | 8872 return; |
8835 } | 8873 } |
8836 if (tkit.CurrentTokenKind() == Token::kNEWLINE) { | 8874 if (tkit.CurrentTokenKind() == Token::kNEWLINE) { |
8837 // No tokens on the current line. If there is a valid token afterwards, put | 8875 // No tokens on the current line. If there is a valid token afterwards, put |
8838 // it into first_token_index. | 8876 // it into first_token_index. |
8839 while (tkit.CurrentTokenKind() == Token::kNEWLINE && | 8877 while (tkit.CurrentTokenKind() == Token::kNEWLINE && |
8840 tkit.CurrentTokenKind() != Token::kEOS) { | 8878 tkit.CurrentTokenKind() != Token::kEOS) { |
8841 tkit.Advance(); | 8879 tkit.Advance(); |
8842 } | 8880 } |
8843 if (tkit.CurrentTokenKind() != Token::kEOS) { | 8881 if (tkit.CurrentTokenKind() != Token::kEOS) { |
8844 *first_token_index = tkit.CurrentPosition(); | 8882 *first_token_index = TokenDescriptor(tkit.CurrentPosition()); |
8845 } | 8883 } |
8846 return; | 8884 return; |
8847 } | 8885 } |
8848 *first_token_index = tkit.CurrentPosition(); | 8886 *first_token_index = TokenDescriptor(tkit.CurrentPosition()); |
8849 // We cannot do "CurrentPosition() - 1" for the last token, because we do not | 8887 // 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. | 8888 // know whether the previous token is a simple one or not. |
8851 intptr_t end_pos = *first_token_index; | 8889 TokenDescriptor end_pos = *first_token_index; |
8852 while (tkit.CurrentTokenKind() != Token::kNEWLINE && | 8890 while (tkit.CurrentTokenKind() != Token::kNEWLINE && |
8853 tkit.CurrentTokenKind() != Token::kEOS) { | 8891 tkit.CurrentTokenKind() != Token::kEOS) { |
8854 end_pos = tkit.CurrentPosition(); | 8892 end_pos = TokenDescriptor(tkit.CurrentPosition()); |
8855 tkit.Advance(); | 8893 tkit.Advance(); |
8856 } | 8894 } |
8857 *last_token_index = end_pos; | 8895 *last_token_index = end_pos; |
8858 } | 8896 } |
8859 | 8897 |
8860 | 8898 |
8861 RawString* Script::GetLine(intptr_t line_number, Heap::Space space) const { | 8899 RawString* Script::GetLine(intptr_t line_number, Heap::Space space) const { |
8862 const String& src = String::Handle(Source()); | 8900 const String& src = String::Handle(Source()); |
8863 intptr_t relative_line_number = line_number - line_offset(); | 8901 intptr_t relative_line_number = line_number - line_offset(); |
8864 intptr_t current_line = 1; | 8902 intptr_t current_line = 1; |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9144 next_ix_++; | 9182 next_ix_++; |
9145 obj = array_.At(next_ix_); | 9183 obj = array_.At(next_ix_); |
9146 } | 9184 } |
9147 } | 9185 } |
9148 | 9186 |
9149 | 9187 |
9150 static void ReportTooManyImports(const Library& lib) { | 9188 static void ReportTooManyImports(const Library& lib) { |
9151 const String& url = String::Handle(lib.url()); | 9189 const String& url = String::Handle(lib.url()); |
9152 Report::MessageF(Report::kError, | 9190 Report::MessageF(Report::kError, |
9153 Script::Handle(lib.LookupScript(url)), | 9191 Script::Handle(lib.LookupScript(url)), |
9154 Token::kNoSourcePos, | 9192 TokenDescriptor::kNoSource, |
9155 Report::AtLocation, | 9193 Report::AtLocation, |
9156 "too many imports in library '%s'", | 9194 "too many imports in library '%s'", |
9157 url.ToCString()); | 9195 url.ToCString()); |
9158 UNREACHABLE(); | 9196 UNREACHABLE(); |
9159 } | 9197 } |
9160 | 9198 |
9161 | 9199 |
9162 void Library::set_num_imports(intptr_t value) const { | 9200 void Library::set_num_imports(intptr_t value) const { |
9163 if (!Utils::IsUint(16, value)) { | 9201 if (!Utils::IsUint(16, value)) { |
9164 ReportTooManyImports(*this); | 9202 ReportTooManyImports(*this); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9331 GrowableHandlePtrArray<const String> pieces(Thread::Current()->zone(), 3); | 9369 GrowableHandlePtrArray<const String> pieces(Thread::Current()->zone(), 3); |
9332 pieces.Add(cname); | 9370 pieces.Add(cname); |
9333 pieces.Add(Symbols::At()); | 9371 pieces.Add(Symbols::At()); |
9334 pieces.Add(String::Handle(param.name())); | 9372 pieces.Add(String::Handle(param.name())); |
9335 return Symbols::FromConcatAll(pieces); | 9373 return Symbols::FromConcatAll(pieces); |
9336 } | 9374 } |
9337 | 9375 |
9338 | 9376 |
9339 void Library::AddMetadata(const Object& owner, | 9377 void Library::AddMetadata(const Object& owner, |
9340 const String& name, | 9378 const String& name, |
9341 intptr_t token_pos) const { | 9379 TokenDescriptor token_pos) const { |
9342 const String& metaname = String::Handle(Symbols::New(name)); | 9380 const String& metaname = String::Handle(Symbols::New(name)); |
9343 const Field& field = Field::Handle( | 9381 const Field& field = Field::Handle( |
9344 Field::NewTopLevel(metaname, | 9382 Field::NewTopLevel(metaname, |
9345 false, // is_final | 9383 false, // is_final |
9346 false, // is_const | 9384 false, // is_const |
9347 owner, | 9385 owner, |
9348 token_pos)); | 9386 token_pos)); |
9349 field.SetFieldType(Object::dynamic_type()); | 9387 field.SetFieldType(Object::dynamic_type()); |
9350 field.set_is_reflectable(false); | 9388 field.set_is_reflectable(false); |
9351 field.SetStaticValue(Array::empty_array(), true); | 9389 field.SetStaticValue(Array::empty_array(), true); |
9352 GrowableObjectArray& metadata = | 9390 GrowableObjectArray& metadata = |
9353 GrowableObjectArray::Handle(this->metadata()); | 9391 GrowableObjectArray::Handle(this->metadata()); |
9354 metadata.Add(field, Heap::kOld); | 9392 metadata.Add(field, Heap::kOld); |
9355 } | 9393 } |
9356 | 9394 |
9357 | 9395 |
9358 void Library::AddClassMetadata(const Class& cls, | 9396 void Library::AddClassMetadata(const Class& cls, |
9359 const Object& tl_owner, | 9397 const Object& tl_owner, |
9360 intptr_t token_pos) const { | 9398 TokenDescriptor token_pos) const { |
9361 // We use the toplevel class as the owner of a class's metadata field because | 9399 // 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. | 9400 // a class's metadata is in scope of the library, not the class. |
9363 AddMetadata(tl_owner, | 9401 AddMetadata(tl_owner, |
9364 String::Handle(MakeClassMetaName(cls)), | 9402 String::Handle(MakeClassMetaName(cls)), |
9365 token_pos); | 9403 token_pos); |
9366 } | 9404 } |
9367 | 9405 |
9368 | 9406 |
9369 void Library::AddFieldMetadata(const Field& field, | 9407 void Library::AddFieldMetadata(const Field& field, |
9370 intptr_t token_pos) const { | 9408 TokenDescriptor token_pos) const { |
9371 AddMetadata(Object::Handle(field.RawOwner()), | 9409 AddMetadata(Object::Handle(field.RawOwner()), |
9372 String::Handle(MakeFieldMetaName(field)), | 9410 String::Handle(MakeFieldMetaName(field)), |
9373 token_pos); | 9411 token_pos); |
9374 } | 9412 } |
9375 | 9413 |
9376 | 9414 |
9377 void Library::AddFunctionMetadata(const Function& func, | 9415 void Library::AddFunctionMetadata(const Function& func, |
9378 intptr_t token_pos) const { | 9416 TokenDescriptor token_pos) const { |
9379 AddMetadata(Object::Handle(func.RawOwner()), | 9417 AddMetadata(Object::Handle(func.RawOwner()), |
9380 String::Handle(MakeFunctionMetaName(func)), | 9418 String::Handle(MakeFunctionMetaName(func)), |
9381 token_pos); | 9419 token_pos); |
9382 } | 9420 } |
9383 | 9421 |
9384 | 9422 |
9385 void Library::AddTypeParameterMetadata(const TypeParameter& param, | 9423 void Library::AddTypeParameterMetadata(const TypeParameter& param, |
9386 intptr_t token_pos) const { | 9424 TokenDescriptor token_pos) const { |
9387 AddMetadata(Class::Handle(param.parameterized_class()), | 9425 AddMetadata(Class::Handle(param.parameterized_class()), |
9388 String::Handle(MakeTypeParameterMetaName(param)), | 9426 String::Handle(MakeTypeParameterMetaName(param)), |
9389 token_pos); | 9427 token_pos); |
9390 } | 9428 } |
9391 | 9429 |
9392 | 9430 |
9393 void Library::AddLibraryMetadata(const Object& tl_owner, | 9431 void Library::AddLibraryMetadata(const Object& tl_owner, |
9394 intptr_t token_pos) const { | 9432 TokenDescriptor token_pos) const { |
9395 AddMetadata(tl_owner, Symbols::TopLevel(), token_pos); | 9433 AddMetadata(tl_owner, Symbols::TopLevel(), token_pos); |
9396 } | 9434 } |
9397 | 9435 |
9398 | 9436 |
9399 RawString* Library::MakeMetadataName(const Object& obj) const { | 9437 RawString* Library::MakeMetadataName(const Object& obj) const { |
9400 if (obj.IsClass()) { | 9438 if (obj.IsClass()) { |
9401 return MakeClassMetaName(Class::Cast(obj)); | 9439 return MakeClassMetaName(Class::Cast(obj)); |
9402 } else if (obj.IsField()) { | 9440 } else if (obj.IsField()) { |
9403 return MakeFieldMetaName(Field::Cast(obj)); | 9441 return MakeFieldMetaName(Field::Cast(obj)); |
9404 } else if (obj.IsFunction()) { | 9442 } else if (obj.IsFunction()) { |
(...skipping 1428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10833 void LibraryPrefix::PrintJSONImpl(JSONStream* stream, bool ref) const { | 10871 void LibraryPrefix::PrintJSONImpl(JSONStream* stream, bool ref) const { |
10834 Object::PrintJSONImpl(stream, ref); | 10872 Object::PrintJSONImpl(stream, ref); |
10835 } | 10873 } |
10836 | 10874 |
10837 | 10875 |
10838 void Namespace::set_metadata_field(const Field& value) const { | 10876 void Namespace::set_metadata_field(const Field& value) const { |
10839 StorePointer(&raw_ptr()->metadata_field_, value.raw()); | 10877 StorePointer(&raw_ptr()->metadata_field_, value.raw()); |
10840 } | 10878 } |
10841 | 10879 |
10842 | 10880 |
10843 void Namespace::AddMetadata(const Object& owner, intptr_t token_pos) { | 10881 void Namespace::AddMetadata(const Object& owner, TokenDescriptor token_pos) { |
10844 ASSERT(Field::Handle(metadata_field()).IsNull()); | 10882 ASSERT(Field::Handle(metadata_field()).IsNull()); |
10845 Field& field = Field::Handle(Field::NewTopLevel(Symbols::TopLevel(), | 10883 Field& field = Field::Handle(Field::NewTopLevel(Symbols::TopLevel(), |
10846 false, // is_final | 10884 false, // is_final |
10847 false, // is_const | 10885 false, // is_const |
10848 owner, | 10886 owner, |
10849 token_pos)); | 10887 token_pos)); |
10850 field.set_is_reflectable(false); | 10888 field.set_is_reflectable(false); |
10851 field.SetFieldType(Object::dynamic_type()); | 10889 field.SetFieldType(Object::dynamic_type()); |
10852 field.SetStaticValue(Array::empty_array(), true); | 10890 field.SetStaticValue(Array::empty_array(), true); |
10853 set_metadata_field(field); | 10891 set_metadata_field(field); |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11417 const int addr_width = kBitsPerWord / 4; | 11455 const int addr_width = kBitsPerWord / 4; |
11418 // First compute the buffer size required. | 11456 // First compute the buffer size required. |
11419 intptr_t len = 1; // Trailing '\0'. | 11457 intptr_t len = 1; // Trailing '\0'. |
11420 { | 11458 { |
11421 Iterator iter(*this, RawPcDescriptors::kAnyKind); | 11459 Iterator iter(*this, RawPcDescriptors::kAnyKind); |
11422 while (iter.MoveNext()) { | 11460 while (iter.MoveNext()) { |
11423 len += OS::SNPrint(NULL, 0, FORMAT, addr_width, | 11461 len += OS::SNPrint(NULL, 0, FORMAT, addr_width, |
11424 iter.PcOffset(), | 11462 iter.PcOffset(), |
11425 KindAsStr(iter.Kind()), | 11463 KindAsStr(iter.Kind()), |
11426 iter.DeoptId(), | 11464 iter.DeoptId(), |
11427 iter.TokenPos(), | 11465 iter.TokenPos().value(), |
11428 iter.TryIndex()); | 11466 iter.TryIndex()); |
11429 } | 11467 } |
11430 } | 11468 } |
11431 // Allocate the buffer. | 11469 // Allocate the buffer. |
11432 char* buffer = Thread::Current()->zone()->Alloc<char>(len); | 11470 char* buffer = Thread::Current()->zone()->Alloc<char>(len); |
11433 // Layout the fields in the buffer. | 11471 // Layout the fields in the buffer. |
11434 intptr_t index = 0; | 11472 intptr_t index = 0; |
11435 Iterator iter(*this, RawPcDescriptors::kAnyKind); | 11473 Iterator iter(*this, RawPcDescriptors::kAnyKind); |
11436 while (iter.MoveNext()) { | 11474 while (iter.MoveNext()) { |
11437 index += OS::SNPrint((buffer + index), (len - index), FORMAT, addr_width, | 11475 index += OS::SNPrint((buffer + index), (len - index), FORMAT, addr_width, |
11438 iter.PcOffset(), | 11476 iter.PcOffset(), |
11439 KindAsStr(iter.Kind()), | 11477 KindAsStr(iter.Kind()), |
11440 iter.DeoptId(), | 11478 iter.DeoptId(), |
11441 iter.TokenPos(), | 11479 iter.TokenPos().value(), |
11442 iter.TryIndex()); | 11480 iter.TryIndex()); |
11443 } | 11481 } |
11444 return buffer; | 11482 return buffer; |
11445 #undef FORMAT | 11483 #undef FORMAT |
11446 } | 11484 } |
11447 | 11485 |
11448 | 11486 |
11449 void PcDescriptors::PrintToJSONObject(JSONObject* jsobj, bool ref) const { | 11487 void PcDescriptors::PrintToJSONObject(JSONObject* jsobj, bool ref) const { |
11450 AddCommonObjectProperties(jsobj, "Object", ref); | 11488 AddCommonObjectProperties(jsobj, "Object", ref); |
11451 // TODO(johnmccutchan): Generate a stable id. PcDescriptors hang off a Code | 11489 // TODO(johnmccutchan): Generate a stable id. PcDescriptors hang off a Code |
11452 // object but do not have a back reference to generate an ID. | 11490 // object but do not have a back reference to generate an ID. |
11453 jsobj->AddServiceId(*this); | 11491 jsobj->AddServiceId(*this); |
11454 if (ref) { | 11492 if (ref) { |
11455 return; | 11493 return; |
11456 } | 11494 } |
11457 JSONArray members(jsobj, "members"); | 11495 JSONArray members(jsobj, "members"); |
11458 Iterator iter(*this, RawPcDescriptors::kAnyKind); | 11496 Iterator iter(*this, RawPcDescriptors::kAnyKind); |
11459 while (iter.MoveNext()) { | 11497 while (iter.MoveNext()) { |
11460 JSONObject descriptor(&members); | 11498 JSONObject descriptor(&members); |
11461 descriptor.AddPropertyF("pcOffset", "%" Px "", iter.PcOffset()); | 11499 descriptor.AddPropertyF("pcOffset", "%" Px "", iter.PcOffset()); |
11462 descriptor.AddProperty("kind", KindAsStr(iter.Kind())); | 11500 descriptor.AddProperty("kind", KindAsStr(iter.Kind())); |
11463 descriptor.AddProperty("deoptId", iter.DeoptId()); | 11501 descriptor.AddProperty("deoptId", iter.DeoptId()); |
11464 // TODO(turnidge): Use AddLocation instead. | 11502 // TODO(turnidge): Use AddLocation instead. |
11465 descriptor.AddProperty("tokenPos", iter.TokenPos()); | 11503 descriptor.AddProperty("tokenPos", iter.TokenPos().value()); |
11466 descriptor.AddProperty("tryIndex", iter.TryIndex()); | 11504 descriptor.AddProperty("tryIndex", iter.TryIndex()); |
11467 } | 11505 } |
11468 } | 11506 } |
11469 | 11507 |
11470 | 11508 |
11471 void PcDescriptors::PrintJSONImpl(JSONStream* stream, bool ref) const { | 11509 void PcDescriptors::PrintJSONImpl(JSONStream* stream, bool ref) const { |
11472 JSONObject jsobj(stream); | 11510 JSONObject jsobj(stream); |
11473 PrintToJSONObject(&jsobj, ref); | 11511 PrintToJSONObject(&jsobj, ref); |
11474 } | 11512 } |
11475 | 11513 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11586 } | 11624 } |
11587 // 4 bits per hex digit. | 11625 // 4 bits per hex digit. |
11588 const int addr_width = kBitsPerWord / 4; | 11626 const int addr_width = kBitsPerWord / 4; |
11589 // First compute the buffer size required. | 11627 // First compute the buffer size required. |
11590 intptr_t len = 1; // Trailing '\0'. | 11628 intptr_t len = 1; // Trailing '\0'. |
11591 { | 11629 { |
11592 Iterator iter(*this); | 11630 Iterator iter(*this); |
11593 while (iter.MoveNext()) { | 11631 while (iter.MoveNext()) { |
11594 len += OS::SNPrint(NULL, 0, FORMAT, addr_width, | 11632 len += OS::SNPrint(NULL, 0, FORMAT, addr_width, |
11595 iter.PcOffset(), | 11633 iter.PcOffset(), |
11596 iter.TokenPos()); | 11634 iter.TokenPos().value()); |
11597 } | 11635 } |
11598 } | 11636 } |
11599 // Allocate the buffer. | 11637 // Allocate the buffer. |
11600 char* buffer = Thread::Current()->zone()->Alloc<char>(len); | 11638 char* buffer = Thread::Current()->zone()->Alloc<char>(len); |
11601 // Layout the fields in the buffer. | 11639 // Layout the fields in the buffer. |
11602 intptr_t index = 0; | 11640 intptr_t index = 0; |
11603 Iterator iter(*this); | 11641 Iterator iter(*this); |
11604 while (iter.MoveNext()) { | 11642 while (iter.MoveNext()) { |
11605 index += OS::SNPrint((buffer + index), (len - index), FORMAT, addr_width, | 11643 index += OS::SNPrint((buffer + index), (len - index), FORMAT, addr_width, |
11606 iter.PcOffset(), | 11644 iter.PcOffset(), |
11607 iter.TokenPos()); | 11645 iter.TokenPos().value()); |
11608 } | 11646 } |
11609 return buffer; | 11647 return buffer; |
11610 #undef FORMAT | 11648 #undef FORMAT |
11611 } | 11649 } |
11612 | 11650 |
11613 | 11651 |
11614 // Encode integer in SLEB128 format. | 11652 // Encode integer in SLEB128 format. |
11615 void CodeSourceMap::EncodeInteger(GrowableArray<uint8_t>* data, | 11653 void CodeSourceMap::EncodeInteger(GrowableArray<uint8_t>* data, |
11616 intptr_t value) { | 11654 intptr_t value) { |
11617 return EncodeSLEB128(data, value); | 11655 return EncodeSLEB128(data, value); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11787 const RawLocalVarDescriptors::VarInfoKind kind = info.kind(); | 11825 const RawLocalVarDescriptors::VarInfoKind kind = info.kind(); |
11788 const int32_t index = info.index(); | 11826 const int32_t index = info.index(); |
11789 if (kind == RawLocalVarDescriptors::kContextLevel) { | 11827 if (kind == RawLocalVarDescriptors::kContextLevel) { |
11790 return OS::SNPrint(buffer, len, | 11828 return OS::SNPrint(buffer, len, |
11791 "%2" Pd " %-13s level=%-3d scope=%-3d" | 11829 "%2" Pd " %-13s level=%-3d scope=%-3d" |
11792 " begin=%-3d end=%d\n", | 11830 " begin=%-3d end=%d\n", |
11793 i, | 11831 i, |
11794 LocalVarDescriptors::KindToCString(kind), | 11832 LocalVarDescriptors::KindToCString(kind), |
11795 index, | 11833 index, |
11796 info.scope_id, | 11834 info.scope_id, |
11797 info.begin_pos, | 11835 static_cast<int>(info.begin_pos.value()), |
11798 info.end_pos); | 11836 static_cast<int>(info.end_pos.value())); |
11799 } else if (kind == RawLocalVarDescriptors::kContextVar) { | 11837 } else if (kind == RawLocalVarDescriptors::kContextVar) { |
11800 return OS::SNPrint(buffer, len, | 11838 return OS::SNPrint(buffer, len, |
11801 "%2" Pd " %-13s level=%-3d index=%-3d" | 11839 "%2" Pd " %-13s level=%-3d index=%-3d" |
11802 " begin=%-3d end=%-3d name=%s\n", | 11840 " begin=%-3d end=%-3d name=%s\n", |
11803 i, | 11841 i, |
11804 LocalVarDescriptors::KindToCString(kind), | 11842 LocalVarDescriptors::KindToCString(kind), |
11805 info.scope_id, | 11843 info.scope_id, |
11806 index, | 11844 index, |
11807 info.begin_pos, | 11845 static_cast<int>(info.begin_pos.value()), |
11808 info.end_pos, | 11846 static_cast<int>(info.end_pos.value()), |
11809 var_name.ToCString()); | 11847 var_name.ToCString()); |
11810 } else { | 11848 } else { |
11811 return OS::SNPrint(buffer, len, | 11849 return OS::SNPrint(buffer, len, |
11812 "%2" Pd " %-13s scope=%-3d index=%-3d" | 11850 "%2" Pd " %-13s scope=%-3d index=%-3d" |
11813 " begin=%-3d end=%-3d name=%s\n", | 11851 " begin=%-3d end=%-3d name=%s\n", |
11814 i, | 11852 i, |
11815 LocalVarDescriptors::KindToCString(kind), | 11853 LocalVarDescriptors::KindToCString(kind), |
11816 info.scope_id, | 11854 info.scope_id, |
11817 index, | 11855 index, |
11818 info.begin_pos, | 11856 static_cast<int>(info.begin_pos.value()), |
11819 info.end_pos, | 11857 static_cast<int>(info.end_pos.value()), |
11820 var_name.ToCString()); | 11858 var_name.ToCString()); |
11821 } | 11859 } |
11822 } | 11860 } |
11823 | 11861 |
11824 | 11862 |
11825 const char* LocalVarDescriptors::ToCString() const { | 11863 const char* LocalVarDescriptors::ToCString() const { |
11826 if (IsNull()) { | 11864 if (IsNull()) { |
11827 return "LocalVarDescriptors(NULL)"; | 11865 return "LocalVarDescriptors(NULL)"; |
11828 } | 11866 } |
11829 if (Length() == 0) { | 11867 if (Length() == 0) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11864 } | 11902 } |
11865 JSONArray members(&jsobj, "members"); | 11903 JSONArray members(&jsobj, "members"); |
11866 String& var_name = String::Handle(); | 11904 String& var_name = String::Handle(); |
11867 for (intptr_t i = 0; i < Length(); i++) { | 11905 for (intptr_t i = 0; i < Length(); i++) { |
11868 RawLocalVarDescriptors::VarInfo info; | 11906 RawLocalVarDescriptors::VarInfo info; |
11869 var_name = GetName(i); | 11907 var_name = GetName(i); |
11870 GetInfo(i, &info); | 11908 GetInfo(i, &info); |
11871 JSONObject var(&members); | 11909 JSONObject var(&members); |
11872 var.AddProperty("name", var_name.ToCString()); | 11910 var.AddProperty("name", var_name.ToCString()); |
11873 var.AddProperty("index", static_cast<intptr_t>(info.index())); | 11911 var.AddProperty("index", static_cast<intptr_t>(info.index())); |
11874 var.AddProperty("beginPos", static_cast<intptr_t>(info.begin_pos)); | 11912 var.AddProperty("beginPos", info.begin_pos.value()); |
11875 var.AddProperty("endPos", static_cast<intptr_t>(info.end_pos)); | 11913 var.AddProperty("endPos", info.end_pos.value()); |
11876 var.AddProperty("scopeId", static_cast<intptr_t>(info.scope_id)); | 11914 var.AddProperty("scopeId", static_cast<intptr_t>(info.scope_id)); |
11877 var.AddProperty("kind", KindToCString(info.kind())); | 11915 var.AddProperty("kind", KindToCString(info.kind())); |
11878 } | 11916 } |
11879 } | 11917 } |
11880 | 11918 |
11881 | 11919 |
11882 const char* LocalVarDescriptors::KindToCString( | 11920 const char* LocalVarDescriptors::KindToCString( |
11883 RawLocalVarDescriptors::VarInfoKind kind) { | 11921 RawLocalVarDescriptors::VarInfoKind kind) { |
11884 switch (kind) { | 11922 switch (kind) { |
11885 case RawLocalVarDescriptors::kStackVar: | 11923 case RawLocalVarDescriptors::kStackVar: |
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12942 if (ref) { | 12980 if (ref) { |
12943 return; | 12981 return; |
12944 } | 12982 } |
12945 jsobj.AddProperty("_argumentsDescriptor", | 12983 jsobj.AddProperty("_argumentsDescriptor", |
12946 Object::Handle(arguments_descriptor())); | 12984 Object::Handle(arguments_descriptor())); |
12947 jsobj.AddProperty("_entries", Object::Handle(ic_data())); | 12985 jsobj.AddProperty("_entries", Object::Handle(ic_data())); |
12948 } | 12986 } |
12949 | 12987 |
12950 | 12988 |
12951 void ICData::PrintToJSONArray(const JSONArray& jsarray, | 12989 void ICData::PrintToJSONArray(const JSONArray& jsarray, |
12952 intptr_t token_pos, | 12990 TokenDescriptor token_pos, |
12953 bool is_static_call) const { | 12991 bool is_static_call) const { |
12954 Isolate* isolate = Isolate::Current(); | 12992 Isolate* isolate = Isolate::Current(); |
12955 Class& cls = Class::Handle(); | 12993 Class& cls = Class::Handle(); |
12956 Function& func = Function::Handle(); | 12994 Function& func = Function::Handle(); |
12957 | 12995 |
12958 JSONObject jsobj(&jsarray); | 12996 JSONObject jsobj(&jsarray); |
12959 jsobj.AddProperty("name", String::Handle(target_name()).ToCString()); | 12997 jsobj.AddProperty("name", String::Handle(target_name()).ToCString()); |
12960 jsobj.AddProperty("tokenPos", token_pos); | 12998 jsobj.AddProperty("tokenPos", token_pos.value()); |
12961 // TODO(rmacnak): Figure out how to stringify DeoptReasons(). | 12999 // TODO(rmacnak): Figure out how to stringify DeoptReasons(). |
12962 // jsobj.AddProperty("deoptReasons", ...); | 13000 // jsobj.AddProperty("deoptReasons", ...); |
12963 | 13001 |
12964 JSONArray cache_entries(&jsobj, "cacheEntries"); | 13002 JSONArray cache_entries(&jsobj, "cacheEntries"); |
12965 for (intptr_t i = 0; i < NumberOfChecks(); i++) { | 13003 for (intptr_t i = 0; i < NumberOfChecks(); i++) { |
12966 func = GetTargetAt(i); | 13004 func = GetTargetAt(i); |
12967 if (is_static_call) { | 13005 if (is_static_call) { |
12968 cls ^= func.Owner(); | 13006 cls ^= func.Owner(); |
12969 } else { | 13007 } else { |
12970 intptr_t cid = GetReceiverClassIdAt(i); | 13008 intptr_t cid = GetReceiverClassIdAt(i); |
12971 cls ^= isolate->class_table()->At(cid); | 13009 cls ^= isolate->class_table()->At(cid); |
12972 } | 13010 } |
12973 intptr_t count = GetCountAt(i); | 13011 intptr_t count = GetCountAt(i); |
12974 JSONObject cache_entry(&cache_entries); | 13012 JSONObject cache_entry(&cache_entries); |
12975 if (cls.IsTopLevel()) { | 13013 if (cls.IsTopLevel()) { |
12976 cache_entry.AddProperty("receiverContainer", | 13014 cache_entry.AddProperty("receiverContainer", |
12977 Library::Handle(cls.library())); | 13015 Library::Handle(cls.library())); |
12978 } else { | 13016 } else { |
12979 cache_entry.AddProperty("receiverContainer", cls); | 13017 cache_entry.AddProperty("receiverContainer", cls); |
12980 } | 13018 } |
12981 cache_entry.AddProperty("count", count); | 13019 cache_entry.AddProperty("count", count); |
12982 cache_entry.AddProperty("target", func); | 13020 cache_entry.AddProperty("target", func); |
12983 } | 13021 } |
12984 } | 13022 } |
12985 | 13023 |
12986 | 13024 |
12987 void ICData::PrintToJSONArrayNew(const JSONArray& jsarray, | 13025 void ICData::PrintToJSONArrayNew(const JSONArray& jsarray, |
12988 intptr_t token_pos, | 13026 TokenDescriptor token_pos, |
12989 bool is_static_call) const { | 13027 bool is_static_call) const { |
12990 Isolate* isolate = Isolate::Current(); | 13028 Isolate* isolate = Isolate::Current(); |
12991 Class& cls = Class::Handle(); | 13029 Class& cls = Class::Handle(); |
12992 Function& func = Function::Handle(); | 13030 Function& func = Function::Handle(); |
12993 | 13031 |
12994 JSONObject jsobj(&jsarray); | 13032 JSONObject jsobj(&jsarray); |
12995 jsobj.AddProperty("name", String::Handle(target_name()).ToCString()); | 13033 jsobj.AddProperty("name", String::Handle(target_name()).ToCString()); |
12996 jsobj.AddProperty("tokenPos", token_pos); | 13034 jsobj.AddProperty("tokenPos", token_pos.value()); |
12997 // TODO(rmacnak): Figure out how to stringify DeoptReasons(). | 13035 // TODO(rmacnak): Figure out how to stringify DeoptReasons(). |
12998 // jsobj.AddProperty("deoptReasons", ...); | 13036 // jsobj.AddProperty("deoptReasons", ...); |
12999 | 13037 |
13000 JSONArray cache_entries(&jsobj, "cacheEntries"); | 13038 JSONArray cache_entries(&jsobj, "cacheEntries"); |
13001 for (intptr_t i = 0; i < NumberOfChecks(); i++) { | 13039 for (intptr_t i = 0; i < NumberOfChecks(); i++) { |
13002 JSONObject cache_entry(&cache_entries); | 13040 JSONObject cache_entry(&cache_entries); |
13003 func = GetTargetAt(i); | 13041 func = GetTargetAt(i); |
13004 intptr_t count = GetCountAt(i); | 13042 intptr_t count = GetCountAt(i); |
13005 if (!is_static_call) { | 13043 if (!is_static_call) { |
13006 intptr_t cid = GetReceiverClassIdAt(i); | 13044 intptr_t cid = GetReceiverClassIdAt(i); |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13606 code ^= Code::LookupCodeInVmIsolate(pc); | 13644 code ^= Code::LookupCodeInVmIsolate(pc); |
13607 if (!code.IsNull() && (code.compile_timestamp() == timestamp) && | 13645 if (!code.IsNull() && (code.compile_timestamp() == timestamp) && |
13608 (code.EntryPoint() == pc)) { | 13646 (code.EntryPoint() == pc)) { |
13609 // Found code in VM isolate. | 13647 // Found code in VM isolate. |
13610 return code.raw(); | 13648 return code.raw(); |
13611 } | 13649 } |
13612 return Code::null(); | 13650 return Code::null(); |
13613 } | 13651 } |
13614 | 13652 |
13615 | 13653 |
13616 intptr_t Code::GetTokenIndexOfPC(uword pc) const { | 13654 TokenDescriptor Code::GetTokenIndexOfPC(uword pc) const { |
13617 uword pc_offset = pc - EntryPoint(); | 13655 uword pc_offset = pc - EntryPoint(); |
13618 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); | 13656 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); |
13619 PcDescriptors::Iterator iter(descriptors, RawPcDescriptors::kAnyKind); | 13657 PcDescriptors::Iterator iter(descriptors, RawPcDescriptors::kAnyKind); |
13620 while (iter.MoveNext()) { | 13658 while (iter.MoveNext()) { |
13621 if (iter.PcOffset() == pc_offset) { | 13659 if (iter.PcOffset() == pc_offset) { |
13622 return iter.TokenPos(); | 13660 return iter.TokenPos(); |
13623 } | 13661 } |
13624 } | 13662 } |
13625 return -1; | 13663 return TokenDescriptor::kNoSource; |
13626 } | 13664 } |
13627 | 13665 |
13628 | 13666 |
13629 uword Code::GetPcForDeoptId(intptr_t deopt_id, | 13667 uword Code::GetPcForDeoptId(intptr_t deopt_id, |
13630 RawPcDescriptors::Kind kind) const { | 13668 RawPcDescriptors::Kind kind) const { |
13631 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); | 13669 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); |
13632 PcDescriptors::Iterator iter(descriptors, kind); | 13670 PcDescriptors::Iterator iter(descriptors, kind); |
13633 while (iter.MoveNext()) { | 13671 while (iter.MoveNext()) { |
13634 if (iter.DeoptId() == deopt_id) { | 13672 if (iter.DeoptId() == deopt_id) { |
13635 uword pc_offset = iter.PcOffset(); | 13673 uword pc_offset = iter.PcOffset(); |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14113 Heap::kOld); | 14151 Heap::kOld); |
14114 NoSafepointScope no_safepoint; | 14152 NoSafepointScope no_safepoint; |
14115 result ^= raw; | 14153 result ^= raw; |
14116 result.set_num_variables(num_variables); | 14154 result.set_num_variables(num_variables); |
14117 result.set_is_implicit(is_implicit); | 14155 result.set_is_implicit(is_implicit); |
14118 } | 14156 } |
14119 return result.raw(); | 14157 return result.raw(); |
14120 } | 14158 } |
14121 | 14159 |
14122 | 14160 |
14123 intptr_t ContextScope::TokenIndexAt(intptr_t scope_index) const { | 14161 TokenDescriptor ContextScope::TokenIndexAt(intptr_t scope_index) const { |
14124 return Smi::Value(VariableDescAddr(scope_index)->token_pos); | 14162 return TokenDescriptor(Smi::Value(VariableDescAddr(scope_index)->token_pos)); |
14125 } | 14163 } |
14126 | 14164 |
14127 | 14165 |
14128 void ContextScope::SetTokenIndexAt(intptr_t scope_index, | 14166 void ContextScope::SetTokenIndexAt(intptr_t scope_index, |
14129 intptr_t token_pos) const { | 14167 TokenDescriptor token_pos) const { |
14130 StoreSmi(&VariableDescAddr(scope_index)->token_pos, | 14168 StoreSmi(&VariableDescAddr(scope_index)->token_pos, |
14131 Smi::New(token_pos)); | 14169 Smi::New(token_pos.value())); |
14132 } | 14170 } |
14133 | 14171 |
14134 | 14172 |
14135 RawString* ContextScope::NameAt(intptr_t scope_index) const { | 14173 RawString* ContextScope::NameAt(intptr_t scope_index) const { |
14136 return VariableDescAddr(scope_index)->name; | 14174 return VariableDescAddr(scope_index)->name; |
14137 } | 14175 } |
14138 | 14176 |
14139 | 14177 |
14140 void ContextScope::SetNameAt(intptr_t scope_index, const String& name) const { | 14178 void ContextScope::SetNameAt(intptr_t scope_index, const String& name) const { |
14141 StorePointer(&(VariableDescAddr(scope_index)->name), name.raw()); | 14179 StorePointer(&(VariableDescAddr(scope_index)->name), name.raw()); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14212 Smi::New(context_level)); | 14250 Smi::New(context_level)); |
14213 } | 14251 } |
14214 | 14252 |
14215 | 14253 |
14216 const char* ContextScope::ToCString() const { | 14254 const char* ContextScope::ToCString() const { |
14217 const char* prev_cstr = "ContextScope:"; | 14255 const char* prev_cstr = "ContextScope:"; |
14218 String& name = String::Handle(); | 14256 String& name = String::Handle(); |
14219 for (int i = 0; i < num_variables(); i++) { | 14257 for (int i = 0; i < num_variables(); i++) { |
14220 name = NameAt(i); | 14258 name = NameAt(i); |
14221 const char* cname = name.ToCString(); | 14259 const char* cname = name.ToCString(); |
14222 intptr_t pos = TokenIndexAt(i); | 14260 TokenDescriptor pos = TokenIndexAt(i); |
14223 intptr_t idx = ContextIndexAt(i); | 14261 intptr_t idx = ContextIndexAt(i); |
14224 intptr_t lvl = ContextLevelAt(i); | 14262 intptr_t lvl = ContextLevelAt(i); |
14225 char* chars = OS::SCreate(Thread::Current()->zone(), | 14263 char* chars = OS::SCreate(Thread::Current()->zone(), |
14226 "%s\nvar %s token-pos %" Pd " ctx lvl %" Pd " index %" Pd "", | 14264 "%s\nvar %s token-pos %" Pd " ctx lvl %" Pd " index %" Pd "", |
14227 prev_cstr, cname, pos, lvl, idx); | 14265 prev_cstr, cname, pos.value(), lvl, idx); |
14228 prev_cstr = chars; | 14266 prev_cstr = chars; |
14229 } | 14267 } |
14230 return prev_cstr; | 14268 return prev_cstr; |
14231 } | 14269 } |
14232 | 14270 |
14233 | 14271 |
14234 void ContextScope::PrintJSONImpl(JSONStream* stream, bool ref) const { | 14272 void ContextScope::PrintJSONImpl(JSONStream* stream, bool ref) const { |
14235 Object::PrintJSONImpl(stream, ref); | 14273 Object::PrintJSONImpl(stream, ref); |
14236 } | 14274 } |
14237 | 14275 |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14538 ASSERT(Object::language_error_class() != Class::null()); | 14576 ASSERT(Object::language_error_class() != Class::null()); |
14539 RawObject* raw = Object::Allocate(LanguageError::kClassId, | 14577 RawObject* raw = Object::Allocate(LanguageError::kClassId, |
14540 LanguageError::InstanceSize(), | 14578 LanguageError::InstanceSize(), |
14541 Heap::kOld); | 14579 Heap::kOld); |
14542 return reinterpret_cast<RawLanguageError*>(raw); | 14580 return reinterpret_cast<RawLanguageError*>(raw); |
14543 } | 14581 } |
14544 | 14582 |
14545 | 14583 |
14546 RawLanguageError* LanguageError::NewFormattedV(const Error& prev_error, | 14584 RawLanguageError* LanguageError::NewFormattedV(const Error& prev_error, |
14547 const Script& script, | 14585 const Script& script, |
14548 intptr_t token_pos, | 14586 TokenDescriptor token_pos, |
14549 bool report_after_token, | 14587 bool report_after_token, |
14550 Report::Kind kind, | 14588 Report::Kind kind, |
14551 Heap::Space space, | 14589 Heap::Space space, |
14552 const char* format, | 14590 const char* format, |
14553 va_list args) { | 14591 va_list args) { |
14554 ASSERT(Object::language_error_class() != Class::null()); | 14592 ASSERT(Object::language_error_class() != Class::null()); |
14555 LanguageError& result = LanguageError::Handle(); | 14593 LanguageError& result = LanguageError::Handle(); |
14556 { | 14594 { |
14557 RawObject* raw = Object::Allocate(LanguageError::kClassId, | 14595 RawObject* raw = Object::Allocate(LanguageError::kClassId, |
14558 LanguageError::InstanceSize(), | 14596 LanguageError::InstanceSize(), |
14559 space); | 14597 space); |
14560 NoSafepointScope no_safepoint; | 14598 NoSafepointScope no_safepoint; |
14561 result ^= raw; | 14599 result ^= raw; |
14562 } | 14600 } |
14563 result.set_previous_error(prev_error); | 14601 result.set_previous_error(prev_error); |
14564 result.set_script(script); | 14602 result.set_script(script); |
14565 result.set_token_pos(token_pos); | 14603 result.set_token_pos(token_pos); |
14566 result.set_report_after_token(report_after_token); | 14604 result.set_report_after_token(report_after_token); |
14567 result.set_kind(kind); | 14605 result.set_kind(kind); |
14568 result.set_message(String::Handle( | 14606 result.set_message(String::Handle( |
14569 String::NewFormattedV(format, args, space))); | 14607 String::NewFormattedV(format, args, space))); |
14570 return result.raw(); | 14608 return result.raw(); |
14571 } | 14609 } |
14572 | 14610 |
14573 | 14611 |
14574 RawLanguageError* LanguageError::NewFormatted(const Error& prev_error, | 14612 RawLanguageError* LanguageError::NewFormatted(const Error& prev_error, |
14575 const Script& script, | 14613 const Script& script, |
14576 intptr_t token_pos, | 14614 TokenDescriptor token_pos, |
14577 bool report_after_token, | 14615 bool report_after_token, |
14578 Report::Kind kind, | 14616 Report::Kind kind, |
14579 Heap::Space space, | 14617 Heap::Space space, |
14580 const char* format, ...) { | 14618 const char* format, ...) { |
14581 va_list args; | 14619 va_list args; |
14582 va_start(args, format); | 14620 va_start(args, format); |
14583 RawLanguageError* result = LanguageError::NewFormattedV( | 14621 RawLanguageError* result = LanguageError::NewFormattedV( |
14584 prev_error, script, token_pos, report_after_token, | 14622 prev_error, script, token_pos, report_after_token, |
14585 kind, space, format, args); | 14623 kind, space, format, args); |
14586 NoSafepointScope no_safepoint; | 14624 NoSafepointScope no_safepoint; |
(...skipping 23 matching lines...) Expand all Loading... |
14610 void LanguageError::set_previous_error(const Error& value) const { | 14648 void LanguageError::set_previous_error(const Error& value) const { |
14611 StorePointer(&raw_ptr()->previous_error_, value.raw()); | 14649 StorePointer(&raw_ptr()->previous_error_, value.raw()); |
14612 } | 14650 } |
14613 | 14651 |
14614 | 14652 |
14615 void LanguageError::set_script(const Script& value) const { | 14653 void LanguageError::set_script(const Script& value) const { |
14616 StorePointer(&raw_ptr()->script_, value.raw()); | 14654 StorePointer(&raw_ptr()->script_, value.raw()); |
14617 } | 14655 } |
14618 | 14656 |
14619 | 14657 |
14620 void LanguageError::set_token_pos(intptr_t token_pos) const { | 14658 void LanguageError::set_token_pos(TokenDescriptor token_pos) const { |
14621 ASSERT(!Token::IsClassifying(token_pos)); | 14659 ASSERT(!TokenDescriptor(token_pos).IsClassifying()); |
14622 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); | 14660 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); |
14623 } | 14661 } |
14624 | 14662 |
14625 | 14663 |
14626 void LanguageError::set_report_after_token(bool value) { | 14664 void LanguageError::set_report_after_token(bool value) { |
14627 StoreNonPointer(&raw_ptr()->report_after_token_, value); | 14665 StoreNonPointer(&raw_ptr()->report_after_token_, value); |
14628 } | 14666 } |
14629 | 14667 |
14630 | 14668 |
14631 void LanguageError::set_kind(uint8_t value) const { | 14669 void LanguageError::set_kind(uint8_t value) const { |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15022 if (!type.IsCanonical()) { | 15060 if (!type.IsCanonical()) { |
15023 type ^= type.Canonicalize(); | 15061 type ^= type.Canonicalize(); |
15024 signature.SetSignatureType(type); | 15062 signature.SetSignatureType(type); |
15025 } | 15063 } |
15026 return type.raw(); | 15064 return type.raw(); |
15027 } | 15065 } |
15028 const Class& scope_cls = Class::Handle(type.scope_class()); | 15066 const Class& scope_cls = Class::Handle(type.scope_class()); |
15029 ASSERT(scope_cls.NumTypeArguments() > 0); | 15067 ASSERT(scope_cls.NumTypeArguments() > 0); |
15030 TypeArguments& type_arguments = TypeArguments::Handle(GetTypeArguments()); | 15068 TypeArguments& type_arguments = TypeArguments::Handle(GetTypeArguments()); |
15031 type = FunctionType::New( | 15069 type = FunctionType::New( |
15032 scope_cls, type_arguments, signature, Token::kNoSourcePos); | 15070 scope_cls, type_arguments, signature, TokenDescriptor::kNoSource); |
15033 type.SetIsFinalized(); | 15071 type.SetIsFinalized(); |
15034 type ^= type.Canonicalize(); | 15072 type ^= type.Canonicalize(); |
15035 return type.raw(); | 15073 return type.raw(); |
15036 } | 15074 } |
15037 Type& type = Type::Handle(); | 15075 Type& type = Type::Handle(); |
15038 if (!cls.IsGeneric()) { | 15076 if (!cls.IsGeneric()) { |
15039 type = cls.CanonicalType(); | 15077 type = cls.CanonicalType(); |
15040 } | 15078 } |
15041 if (type.IsNull()) { | 15079 if (type.IsNull()) { |
15042 TypeArguments& type_arguments = TypeArguments::Handle(); | 15080 TypeArguments& type_arguments = TypeArguments::Handle(); |
15043 if (cls.NumTypeArguments() > 0) { | 15081 if (cls.NumTypeArguments() > 0) { |
15044 type_arguments = GetTypeArguments(); | 15082 type_arguments = GetTypeArguments(); |
15045 } | 15083 } |
15046 type = Type::New(cls, type_arguments, Token::kNoSourcePos); | 15084 type = Type::New(cls, type_arguments, TokenDescriptor::kNoSource); |
15047 type.SetIsFinalized(); | 15085 type.SetIsFinalized(); |
15048 type ^= type.Canonicalize(); | 15086 type ^= type.Canonicalize(); |
15049 } | 15087 } |
15050 return type.raw(); | 15088 return type.raw(); |
15051 } | 15089 } |
15052 | 15090 |
15053 | 15091 |
15054 RawTypeArguments* Instance::GetTypeArguments() const { | 15092 RawTypeArguments* Instance::GetTypeArguments() const { |
15055 const Class& cls = Class::Handle(clazz()); | 15093 const Class& cls = Class::Handle(clazz()); |
15056 intptr_t field_offset = cls.type_arguments_field_offset(); | 15094 intptr_t field_offset = cls.type_arguments_field_offset(); |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15363 } else { | 15401 } else { |
15364 if (IsClosure()) { | 15402 if (IsClosure()) { |
15365 return Closure::Cast(*this).ToCString(); | 15403 return Closure::Cast(*this).ToCString(); |
15366 } | 15404 } |
15367 const Class& cls = Class::Handle(clazz()); | 15405 const Class& cls = Class::Handle(clazz()); |
15368 TypeArguments& type_arguments = TypeArguments::Handle(); | 15406 TypeArguments& type_arguments = TypeArguments::Handle(); |
15369 const intptr_t num_type_arguments = cls.NumTypeArguments(); | 15407 const intptr_t num_type_arguments = cls.NumTypeArguments(); |
15370 if (num_type_arguments > 0) { | 15408 if (num_type_arguments > 0) { |
15371 type_arguments = GetTypeArguments(); | 15409 type_arguments = GetTypeArguments(); |
15372 } | 15410 } |
15373 const Type& type = | 15411 const Type& type = Type::Handle( |
15374 Type::Handle(Type::New(cls, type_arguments, Token::kNoSourcePos)); | 15412 Type::New(cls, type_arguments, TokenDescriptor::kNoSource)); |
15375 const String& type_name = String::Handle(type.UserVisibleName()); | 15413 const String& type_name = String::Handle(type.UserVisibleName()); |
15376 return OS::SCreate(Thread::Current()->zone(), | 15414 return OS::SCreate(Thread::Current()->zone(), |
15377 "Instance of '%s'", type_name.ToCString()); | 15415 "Instance of '%s'", type_name.ToCString()); |
15378 } | 15416 } |
15379 } | 15417 } |
15380 | 15418 |
15381 | 15419 |
15382 void Instance::PrintSharedInstanceJSON(JSONObject* jsobj, | 15420 void Instance::PrintSharedInstanceJSON(JSONObject* jsobj, |
15383 bool ref) const { | 15421 bool ref) const { |
15384 AddCommonObjectProperties(jsobj, "Instance", ref); | 15422 AddCommonObjectProperties(jsobj, "Instance", ref); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15503 UNREACHABLE(); | 15541 UNREACHABLE(); |
15504 return NULL; | 15542 return NULL; |
15505 } | 15543 } |
15506 | 15544 |
15507 | 15545 |
15508 void AbstractType::set_arguments(const TypeArguments& value) const { | 15546 void AbstractType::set_arguments(const TypeArguments& value) const { |
15509 // AbstractType is an abstract class. | 15547 // AbstractType is an abstract class. |
15510 UNREACHABLE(); | 15548 UNREACHABLE(); |
15511 } | 15549 } |
15512 | 15550 |
15513 intptr_t AbstractType::token_pos() const { | 15551 TokenDescriptor AbstractType::token_pos() const { |
15514 // AbstractType is an abstract class. | 15552 // AbstractType is an abstract class. |
15515 UNREACHABLE(); | 15553 UNREACHABLE(); |
15516 return -1; | 15554 return TokenDescriptor::kNoSource; |
15517 } | 15555 } |
15518 | 15556 |
15519 | 15557 |
15520 bool AbstractType::IsInstantiated(TrailPtr trail) const { | 15558 bool AbstractType::IsInstantiated(TrailPtr trail) const { |
15521 // AbstractType is an abstract class. | 15559 // AbstractType is an abstract class. |
15522 UNREACHABLE(); | 15560 UNREACHABLE(); |
15523 return false; | 15561 return false; |
15524 } | 15562 } |
15525 | 15563 |
15526 | 15564 |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16099 } | 16137 } |
16100 | 16138 |
16101 | 16139 |
16102 RawType* Type::NewNonParameterizedType(const Class& type_class) { | 16140 RawType* Type::NewNonParameterizedType(const Class& type_class) { |
16103 ASSERT(type_class.NumTypeArguments() == 0); | 16141 ASSERT(type_class.NumTypeArguments() == 0); |
16104 Type& type = Type::Handle(type_class.CanonicalType()); | 16142 Type& type = Type::Handle(type_class.CanonicalType()); |
16105 if (type.IsNull()) { | 16143 if (type.IsNull()) { |
16106 const TypeArguments& no_type_arguments = TypeArguments::Handle(); | 16144 const TypeArguments& no_type_arguments = TypeArguments::Handle(); |
16107 type ^= Type::New(Object::Handle(type_class.raw()), | 16145 type ^= Type::New(Object::Handle(type_class.raw()), |
16108 no_type_arguments, | 16146 no_type_arguments, |
16109 Token::kNoSourcePos); | 16147 TokenDescriptor::kNoSource); |
16110 type.SetIsFinalized(); | 16148 type.SetIsFinalized(); |
16111 type ^= type.Canonicalize(); | 16149 type ^= type.Canonicalize(); |
16112 } | 16150 } |
16113 ASSERT(type.IsFinalized()); | 16151 ASSERT(type.IsFinalized()); |
16114 return type.raw(); | 16152 return type.raw(); |
16115 } | 16153 } |
16116 | 16154 |
16117 | 16155 |
16118 void Type::SetIsFinalized() const { | 16156 void Type::SetIsFinalized() const { |
16119 ASSERT(!IsFinalized()); | 16157 ASSERT(!IsFinalized()); |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16557 RawType* Type::New(Heap::Space space) { | 16595 RawType* Type::New(Heap::Space space) { |
16558 RawObject* raw = Object::Allocate(Type::kClassId, | 16596 RawObject* raw = Object::Allocate(Type::kClassId, |
16559 Type::InstanceSize(), | 16597 Type::InstanceSize(), |
16560 space); | 16598 space); |
16561 return reinterpret_cast<RawType*>(raw); | 16599 return reinterpret_cast<RawType*>(raw); |
16562 } | 16600 } |
16563 | 16601 |
16564 | 16602 |
16565 RawType* Type::New(const Object& clazz, | 16603 RawType* Type::New(const Object& clazz, |
16566 const TypeArguments& arguments, | 16604 const TypeArguments& arguments, |
16567 intptr_t token_pos, | 16605 TokenDescriptor token_pos, |
16568 Heap::Space space) { | 16606 Heap::Space space) { |
16569 const Type& result = Type::Handle(Type::New(space)); | 16607 const Type& result = Type::Handle(Type::New(space)); |
16570 result.set_type_class(clazz); | 16608 result.set_type_class(clazz); |
16571 result.set_arguments(arguments); | 16609 result.set_arguments(arguments); |
16572 result.set_token_pos(token_pos); | 16610 result.set_token_pos(token_pos); |
16573 result.StoreNonPointer(&result.raw_ptr()->type_state_, RawType::kAllocated); | 16611 result.StoreNonPointer(&result.raw_ptr()->type_state_, RawType::kAllocated); |
16574 return result.raw(); | 16612 return result.raw(); |
16575 } | 16613 } |
16576 | 16614 |
16577 | 16615 |
16578 void Type::set_token_pos(intptr_t token_pos) const { | 16616 void Type::set_token_pos(TokenDescriptor token_pos) const { |
16579 ASSERT(!Token::IsClassifying(token_pos)); | 16617 ASSERT(!TokenDescriptor(token_pos).IsClassifying()); |
16580 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); | 16618 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); |
16581 } | 16619 } |
16582 | 16620 |
16583 | 16621 |
16584 void Type::set_type_state(int8_t state) const { | 16622 void Type::set_type_state(int8_t state) const { |
16585 ASSERT((state >= RawType::kAllocated) && | 16623 ASSERT((state >= RawType::kAllocated) && |
16586 (state <= RawType::kFinalizedUninstantiated)); | 16624 (state <= RawType::kFinalizedUninstantiated)); |
16587 StoreNonPointer(&raw_ptr()->type_state_, state); | 16625 StoreNonPointer(&raw_ptr()->type_state_, state); |
16588 } | 16626 } |
16589 | 16627 |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16987 // In case the type is first canonicalized at runtime, its type argument | 17025 // In case the type is first canonicalized at runtime, its type argument |
16988 // vector may be longer than necessary. This is not an issue. | 17026 // vector may be longer than necessary. This is not an issue. |
16989 ASSERT(type_args.IsNull() || | 17027 ASSERT(type_args.IsNull() || |
16990 (type_args.Length() >= scope_cls.NumTypeArguments())); | 17028 (type_args.Length() >= scope_cls.NumTypeArguments())); |
16991 type_args = type_args.Canonicalize(trail); | 17029 type_args = type_args.Canonicalize(trail); |
16992 set_arguments(type_args); | 17030 set_arguments(type_args); |
16993 | 17031 |
16994 // Replace the actual function by a signature function. | 17032 // Replace the actual function by a signature function. |
16995 const Function& fun = Function::Handle(zone, signature()); | 17033 const Function& fun = Function::Handle(zone, signature()); |
16996 if (!fun.IsSignatureFunction()) { | 17034 if (!fun.IsSignatureFunction()) { |
16997 Function& sig_fun = | 17035 Function& sig_fun = Function::Handle(zone, |
16998 Function::Handle(zone, | 17036 Function::NewSignatureFunction(scope_cls, TokenDescriptor::kNoSource)); |
16999 Function::NewSignatureFunction(scope_cls, | |
17000 Token::kNoSourcePos)); | |
17001 type = fun.result_type(); | 17037 type = fun.result_type(); |
17002 type = type.Canonicalize(trail); | 17038 type = type.Canonicalize(trail); |
17003 sig_fun.set_result_type(type); | 17039 sig_fun.set_result_type(type); |
17004 const intptr_t num_params = fun.NumParameters(); | 17040 const intptr_t num_params = fun.NumParameters(); |
17005 sig_fun.set_num_fixed_parameters(fun.num_fixed_parameters()); | 17041 sig_fun.set_num_fixed_parameters(fun.num_fixed_parameters()); |
17006 sig_fun.SetNumOptionalParameters(fun.NumOptionalParameters(), | 17042 sig_fun.SetNumOptionalParameters(fun.NumOptionalParameters(), |
17007 fun.HasOptionalPositionalParameters()); | 17043 fun.HasOptionalPositionalParameters()); |
17008 sig_fun.set_parameter_types(Array::Handle(Array::New(num_params, | 17044 sig_fun.set_parameter_types(Array::Handle(Array::New(num_params, |
17009 Heap::kOld))); | 17045 Heap::kOld))); |
17010 for (intptr_t i = 0; i < num_params; i++) { | 17046 for (intptr_t i = 0; i < num_params; i++) { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17101 RawObject* raw = Object::Allocate(FunctionType::kClassId, | 17137 RawObject* raw = Object::Allocate(FunctionType::kClassId, |
17102 FunctionType::InstanceSize(), | 17138 FunctionType::InstanceSize(), |
17103 space); | 17139 space); |
17104 return reinterpret_cast<RawFunctionType*>(raw); | 17140 return reinterpret_cast<RawFunctionType*>(raw); |
17105 } | 17141 } |
17106 | 17142 |
17107 | 17143 |
17108 RawFunctionType* FunctionType::New(const Class& clazz, | 17144 RawFunctionType* FunctionType::New(const Class& clazz, |
17109 const TypeArguments& arguments, | 17145 const TypeArguments& arguments, |
17110 const Function& signature, | 17146 const Function& signature, |
17111 intptr_t token_pos, | 17147 TokenDescriptor token_pos, |
17112 Heap::Space space) { | 17148 Heap::Space space) { |
17113 const FunctionType& result = FunctionType::Handle(FunctionType::New(space)); | 17149 const FunctionType& result = FunctionType::Handle(FunctionType::New(space)); |
17114 result.set_scope_class(clazz); | 17150 result.set_scope_class(clazz); |
17115 result.set_arguments(arguments); | 17151 result.set_arguments(arguments); |
17116 result.set_signature(signature); | 17152 result.set_signature(signature); |
17117 result.set_token_pos(token_pos); | 17153 result.set_token_pos(token_pos); |
17118 result.StoreNonPointer(&result.raw_ptr()->type_state_, | 17154 result.StoreNonPointer(&result.raw_ptr()->type_state_, |
17119 RawFunctionType::kAllocated); | 17155 RawFunctionType::kAllocated); |
17120 return result.raw(); | 17156 return result.raw(); |
17121 } | 17157 } |
17122 | 17158 |
17123 | 17159 |
17124 void FunctionType::set_token_pos(intptr_t token_pos) const { | 17160 void FunctionType::set_token_pos(TokenDescriptor token_pos) const { |
17125 ASSERT(!Token::IsClassifying(token_pos)); | 17161 ASSERT(!TokenDescriptor(token_pos).IsClassifying()); |
17126 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); | 17162 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); |
17127 } | 17163 } |
17128 | 17164 |
17129 | 17165 |
17130 void FunctionType::set_type_state(int8_t state) const { | 17166 void FunctionType::set_type_state(int8_t state) const { |
17131 ASSERT((state >= RawFunctionType::kAllocated) && | 17167 ASSERT((state >= RawFunctionType::kAllocated) && |
17132 (state <= RawFunctionType::kFinalizedUninstantiated)); | 17168 (state <= RawFunctionType::kFinalizedUninstantiated)); |
17133 StoreNonPointer(&raw_ptr()->type_state_, state); | 17169 StoreNonPointer(&raw_ptr()->type_state_, state); |
17134 } | 17170 } |
17135 | 17171 |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17533 TypeParameter::InstanceSize(), | 17569 TypeParameter::InstanceSize(), |
17534 Heap::kOld); | 17570 Heap::kOld); |
17535 return reinterpret_cast<RawTypeParameter*>(raw); | 17571 return reinterpret_cast<RawTypeParameter*>(raw); |
17536 } | 17572 } |
17537 | 17573 |
17538 | 17574 |
17539 RawTypeParameter* TypeParameter::New(const Class& parameterized_class, | 17575 RawTypeParameter* TypeParameter::New(const Class& parameterized_class, |
17540 intptr_t index, | 17576 intptr_t index, |
17541 const String& name, | 17577 const String& name, |
17542 const AbstractType& bound, | 17578 const AbstractType& bound, |
17543 intptr_t token_pos) { | 17579 TokenDescriptor token_pos) { |
17544 const TypeParameter& result = TypeParameter::Handle(TypeParameter::New()); | 17580 const TypeParameter& result = TypeParameter::Handle(TypeParameter::New()); |
17545 result.set_parameterized_class(parameterized_class); | 17581 result.set_parameterized_class(parameterized_class); |
17546 result.set_index(index); | 17582 result.set_index(index); |
17547 result.set_name(name); | 17583 result.set_name(name); |
17548 result.set_bound(bound); | 17584 result.set_bound(bound); |
17549 result.set_token_pos(token_pos); | 17585 result.set_token_pos(token_pos); |
17550 result.StoreNonPointer(&result.raw_ptr()->type_state_, | 17586 result.StoreNonPointer(&result.raw_ptr()->type_state_, |
17551 RawTypeParameter::kAllocated); | 17587 RawTypeParameter::kAllocated); |
17552 return result.raw(); | 17588 return result.raw(); |
17553 } | 17589 } |
17554 | 17590 |
17555 | 17591 |
17556 void TypeParameter::set_token_pos(intptr_t token_pos) const { | 17592 void TypeParameter::set_token_pos(TokenDescriptor token_pos) const { |
17557 ASSERT(!Token::IsClassifying(token_pos)); | 17593 ASSERT(!TokenDescriptor(token_pos).IsClassifying()); |
17558 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); | 17594 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); |
17559 } | 17595 } |
17560 | 17596 |
17561 | 17597 |
17562 void TypeParameter::set_type_state(int8_t state) const { | 17598 void TypeParameter::set_type_state(int8_t state) const { |
17563 ASSERT((state == RawTypeParameter::kAllocated) || | 17599 ASSERT((state == RawTypeParameter::kAllocated) || |
17564 (state == RawTypeParameter::kBeingFinalized) || | 17600 (state == RawTypeParameter::kBeingFinalized) || |
17565 (state == RawTypeParameter::kFinalizedUninstantiated)); | 17601 (state == RawTypeParameter::kFinalizedUninstantiated)); |
17566 StoreNonPointer(&raw_ptr()->type_state_, state); | 17602 StoreNonPointer(&raw_ptr()->type_state_, state); |
17567 } | 17603 } |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17824 const String& vm_name = String::Handle(Name()); | 17860 const String& vm_name = String::Handle(Name()); |
17825 AddNameProperties(&jsobj, user_name, vm_name); | 17861 AddNameProperties(&jsobj, user_name, vm_name); |
17826 if (ref) { | 17862 if (ref) { |
17827 return; | 17863 return; |
17828 } | 17864 } |
17829 jsobj.AddProperty("targetType", AbstractType::Handle(type())); | 17865 jsobj.AddProperty("targetType", AbstractType::Handle(type())); |
17830 jsobj.AddProperty("bound", AbstractType::Handle(bound())); | 17866 jsobj.AddProperty("bound", AbstractType::Handle(bound())); |
17831 } | 17867 } |
17832 | 17868 |
17833 | 17869 |
17834 intptr_t MixinAppType::token_pos() const { | 17870 TokenDescriptor MixinAppType::token_pos() const { |
17835 return AbstractType::Handle(MixinTypeAt(0)).token_pos(); | 17871 return AbstractType::Handle(MixinTypeAt(0)).token_pos(); |
17836 } | 17872 } |
17837 | 17873 |
17838 | 17874 |
17839 intptr_t MixinAppType::Depth() const { | 17875 intptr_t MixinAppType::Depth() const { |
17840 return Array::Handle(mixin_types()).Length(); | 17876 return Array::Handle(mixin_types()).Length(); |
17841 } | 17877 } |
17842 | 17878 |
17843 | 17879 |
17844 RawString* MixinAppType::Name() const { | 17880 RawString* MixinAppType::Name() const { |
(...skipping 4477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22322 jsobj.AddProperty("valueAsString", ToCStringInternal(&idx)); | 22358 jsobj.AddProperty("valueAsString", ToCStringInternal(&idx)); |
22323 } | 22359 } |
22324 | 22360 |
22325 | 22361 |
22326 static intptr_t PrintOneStacktrace(Zone* zone, | 22362 static intptr_t PrintOneStacktrace(Zone* zone, |
22327 GrowableArray<char*>* frame_strings, | 22363 GrowableArray<char*>* frame_strings, |
22328 uword pc, | 22364 uword pc, |
22329 const Function& function, | 22365 const Function& function, |
22330 const Code& code, | 22366 const Code& code, |
22331 intptr_t frame_index) { | 22367 intptr_t frame_index) { |
22332 const intptr_t token_pos = code.GetTokenIndexOfPC(pc); | 22368 const TokenDescriptor token_pos = code.GetTokenIndexOfPC(pc); |
22333 const Script& script = Script::Handle(zone, function.script()); | 22369 const Script& script = Script::Handle(zone, function.script()); |
22334 const String& function_name = | 22370 const String& function_name = |
22335 String::Handle(zone, function.QualifiedUserVisibleName()); | 22371 String::Handle(zone, function.QualifiedUserVisibleName()); |
22336 const String& url = String::Handle(zone, script.url()); | 22372 const String& url = String::Handle(zone, script.url()); |
22337 intptr_t line = -1; | 22373 intptr_t line = -1; |
22338 intptr_t column = -1; | 22374 intptr_t column = -1; |
22339 if (token_pos >= 0) { | 22375 if (token_pos.IsReal()) { |
22340 if (script.HasSource()) { | 22376 if (script.HasSource()) { |
22341 script.GetTokenLocation(token_pos, &line, &column); | 22377 script.GetTokenLocation(token_pos, &line, &column); |
22342 } else { | 22378 } else { |
22343 script.GetTokenLocation(token_pos, &line, NULL); | 22379 script.GetTokenLocation(token_pos, &line, NULL); |
22344 } | 22380 } |
22345 } | 22381 } |
22346 char* chars = NULL; | 22382 char* chars = NULL; |
22347 if (column >= 0) { | 22383 if (column >= 0) { |
22348 chars = OS::SCreate(zone, | 22384 chars = OS::SCreate(zone, |
22349 "#%-6" Pd " %s (%s:%" Pd ":%" Pd ")\n", | 22385 "#%-6" Pd " %s (%s:%" Pd ":%" Pd ")\n", |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22837 return tag_label.ToCString(); | 22873 return tag_label.ToCString(); |
22838 } | 22874 } |
22839 | 22875 |
22840 | 22876 |
22841 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 22877 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
22842 Instance::PrintJSONImpl(stream, ref); | 22878 Instance::PrintJSONImpl(stream, ref); |
22843 } | 22879 } |
22844 | 22880 |
22845 | 22881 |
22846 } // namespace dart | 22882 } // namespace dart |
OLD | NEW |