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/parser.h" | 5 #include "vm/parser.h" |
6 #include "vm/flags.h" | 6 #include "vm/flags.h" |
7 | 7 |
8 #ifndef DART_PRECOMPILED_RUNTIME | 8 #ifndef DART_PRECOMPILED_RUNTIME |
9 | 9 |
10 #include "lib/invocation_mirror.h" | 10 #include "lib/invocation_mirror.h" |
(...skipping 12485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12496 } | 12496 } |
12497 } | 12497 } |
12498 } | 12498 } |
12499 | 12499 |
12500 | 12500 |
12501 RawAbstractType* Parser::CanonicalizeType(const AbstractType& type) { | 12501 RawAbstractType* Parser::CanonicalizeType(const AbstractType& type) { |
12502 // If the current class is the result of a mixin application, we must | 12502 // If the current class is the result of a mixin application, we must |
12503 // use the class scope of the class from which the function originates. | 12503 // use the class scope of the class from which the function originates. |
12504 if (current_class().IsMixinApplication()) { | 12504 if (current_class().IsMixinApplication()) { |
12505 return ClassFinalizer::FinalizeType( | 12505 return ClassFinalizer::FinalizeType( |
12506 Class::Handle(Z, parsed_function()->function().origin()), type, | 12506 Class::Handle(Z, parsed_function()->function().origin()), type); |
12507 ClassFinalizer::kCanonicalize); | |
12508 } | 12507 } |
12509 return ClassFinalizer::FinalizeType(current_class(), type, | 12508 return ClassFinalizer::FinalizeType(current_class(), type); |
12510 ClassFinalizer::kCanonicalize); | |
12511 } | 12509 } |
12512 | 12510 |
12513 | 12511 |
12514 LocalVariable* Parser::LookupLocalScope(const String& ident) { | 12512 LocalVariable* Parser::LookupLocalScope(const String& ident) { |
12515 if (current_block_ == NULL) { | 12513 if (current_block_ == NULL) { |
12516 return NULL; | 12514 return NULL; |
12517 } | 12515 } |
12518 // A found name is treated as accessed and possibly marked as captured. | 12516 // A found name is treated as accessed and possibly marked as captured. |
12519 const bool kTestOnly = false; | 12517 const bool kTestOnly = false; |
12520 return current_block_->scope->LookupVariable(ident, kTestOnly); | 12518 return current_block_->scope->LookupVariable(ident, kTestOnly); |
(...skipping 28 matching lines...) Expand all Loading... |
12549 ASSERT(!cls.IsTypedefClass()); | 12547 ASSERT(!cls.IsTypedefClass()); |
12550 // Note that if cls is _Closure, the returned type will be _Closure, | 12548 // Note that if cls is _Closure, the returned type will be _Closure, |
12551 // and not the signature type. | 12549 // and not the signature type. |
12552 Type& type = Type::ZoneHandle(Z, cls.CanonicalType()); | 12550 Type& type = Type::ZoneHandle(Z, cls.CanonicalType()); |
12553 if (!type.IsNull()) { | 12551 if (!type.IsNull()) { |
12554 return &type; | 12552 return &type; |
12555 } | 12553 } |
12556 type = Type::New(cls, TypeArguments::Handle(Z, cls.type_parameters()), | 12554 type = Type::New(cls, TypeArguments::Handle(Z, cls.type_parameters()), |
12557 cls.token_pos(), Heap::kOld); | 12555 cls.token_pos(), Heap::kOld); |
12558 if (cls.is_type_finalized()) { | 12556 if (cls.is_type_finalized()) { |
12559 type ^= ClassFinalizer::FinalizeType( | 12557 type ^= ClassFinalizer::FinalizeType(cls, type); |
12560 cls, type, ClassFinalizer::kCanonicalizeWellFormed); | |
12561 // Note that the receiver type may now be a malbounded type. | 12558 // Note that the receiver type may now be a malbounded type. |
12562 cls.SetCanonicalType(type); | 12559 cls.SetCanonicalType(type); |
12563 } | 12560 } |
12564 return &type; | 12561 return &type; |
12565 } | 12562 } |
12566 | 12563 |
12567 | 12564 |
12568 bool Parser::IsInstantiatorRequired() const { | 12565 bool Parser::IsInstantiatorRequired() const { |
12569 ASSERT(!current_function().IsNull()); | 12566 ASSERT(!current_function().IsNull()); |
12570 if (current_function().is_static() && | 12567 if (current_function().is_static() && |
(...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13948 // and the constructor is known to exist. | 13945 // and the constructor is known to exist. |
13949 void Parser::ParseConstructorClosurization(Function* constructor, | 13946 void Parser::ParseConstructorClosurization(Function* constructor, |
13950 TypeArguments* type_arguments) { | 13947 TypeArguments* type_arguments) { |
13951 *constructor = Function::null(); | 13948 *constructor = Function::null(); |
13952 *type_arguments = TypeArguments::null(); | 13949 *type_arguments = TypeArguments::null(); |
13953 const Token::Kind la3 = LookaheadToken(3); | 13950 const Token::Kind la3 = LookaheadToken(3); |
13954 const bool consume_unresolved_prefix = | 13951 const bool consume_unresolved_prefix = |
13955 (la3 == Token::kLT) || (la3 == Token::kPERIOD) || (la3 == Token::kHASH); | 13952 (la3 == Token::kLT) || (la3 == Token::kPERIOD) || (la3 == Token::kHASH); |
13956 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle(Z); | 13953 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle(Z); |
13957 AbstractType& type = | 13954 AbstractType& type = |
13958 AbstractType::Handle(Z, ParseType(ClassFinalizer::kCanonicalizeWellFormed, | 13955 AbstractType::Handle(Z, ParseType(ClassFinalizer::kCanonicalize, |
13959 true, // allow deferred type | 13956 true, // allow deferred type |
13960 consume_unresolved_prefix, &prefix)); | 13957 consume_unresolved_prefix, &prefix)); |
13961 // A constructor tear-off closure can only have been created for a | 13958 // A constructor tear-off closure can only have been created for a |
13962 // type that is loaded. | 13959 // type that is loaded. |
13963 ASSERT(prefix.IsNull() || prefix.is_loaded()); | 13960 ASSERT(prefix.IsNull() || prefix.is_loaded()); |
13964 ASSERT(!type.IsMalformed() && !type.IsTypeParameter()); | 13961 ASSERT(!type.IsMalformed() && !type.IsTypeParameter()); |
13965 if (!FLAG_support_deprecated_tearoff_syntax) { | 13962 if (!FLAG_support_deprecated_tearoff_syntax) { |
13966 ReportError("tear-off using the x#id syntax is a deprecated feature"); | 13963 ReportError("tear-off using the x#id syntax is a deprecated feature"); |
13967 return; | 13964 return; |
13968 } | 13965 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14011 } | 14008 } |
14012 TokenPosition type_pos = TokenPos(); | 14009 TokenPosition type_pos = TokenPos(); |
14013 // Can't allocate const objects of a deferred type. | 14010 // Can't allocate const objects of a deferred type. |
14014 const bool allow_deferred_type = !is_const; | 14011 const bool allow_deferred_type = !is_const; |
14015 const Token::Kind la3 = LookaheadToken(3); | 14012 const Token::Kind la3 = LookaheadToken(3); |
14016 const bool consume_unresolved_prefix = | 14013 const bool consume_unresolved_prefix = |
14017 (la3 == Token::kLT) || (la3 == Token::kPERIOD) || (la3 == Token::kHASH); | 14014 (la3 == Token::kLT) || (la3 == Token::kPERIOD) || (la3 == Token::kHASH); |
14018 | 14015 |
14019 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle(Z); | 14016 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle(Z); |
14020 AbstractType& type = AbstractType::ZoneHandle( | 14017 AbstractType& type = AbstractType::ZoneHandle( |
14021 Z, ParseType(ClassFinalizer::kCanonicalizeWellFormed, allow_deferred_type, | 14018 Z, ParseType(ClassFinalizer::kCanonicalize, allow_deferred_type, |
14022 consume_unresolved_prefix, &prefix)); | 14019 consume_unresolved_prefix, &prefix)); |
14023 | 14020 |
14024 if (FLAG_load_deferred_eagerly && !prefix.IsNull() && | 14021 if (FLAG_load_deferred_eagerly && !prefix.IsNull() && |
14025 prefix.is_deferred_load() && !prefix.is_loaded()) { | 14022 prefix.is_deferred_load() && !prefix.is_loaded()) { |
14026 // Add runtime check. | 14023 // Add runtime check. |
14027 Type& malformed_type = Type::ZoneHandle(Z); | 14024 Type& malformed_type = Type::ZoneHandle(Z); |
14028 malformed_type = ClassFinalizer::NewFinalizedMalformedType( | 14025 malformed_type = ClassFinalizer::NewFinalizedMalformedType( |
14029 Error::Handle(Z), // No previous error. | 14026 Error::Handle(Z), // No previous error. |
14030 script_, type_pos, "deferred type '%s.%s' is not yet loaded", | 14027 script_, type_pos, "deferred type '%s.%s' is not yet loaded", |
14031 String::Handle(Z, prefix.name()).ToCString(), | 14028 String::Handle(Z, prefix.name()).ToCString(), |
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15206 const ArgumentListNode& function_args, | 15203 const ArgumentListNode& function_args, |
15207 const LocalVariable* temp_for_last_arg, | 15204 const LocalVariable* temp_for_last_arg, |
15208 bool is_super_invocation) { | 15205 bool is_super_invocation) { |
15209 UNREACHABLE(); | 15206 UNREACHABLE(); |
15210 return NULL; | 15207 return NULL; |
15211 } | 15208 } |
15212 | 15209 |
15213 } // namespace dart | 15210 } // namespace dart |
15214 | 15211 |
15215 #endif // DART_PRECOMPILED_RUNTIME | 15212 #endif // DART_PRECOMPILED_RUNTIME |
OLD | NEW |