| 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 | 6 |
| 7 #include "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
| 8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
| 9 #include "vm/bootstrap.h" | 9 #include "vm/bootstrap.h" |
| 10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 9302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9313 AbstractTypeArguments::ZoneHandle(type_arguments.raw()); | 9313 AbstractTypeArguments::ZoneHandle(type_arguments.raw()); |
| 9314 // If no type argument vector is provided, leave it as null, which is | 9314 // If no type argument vector is provided, leave it as null, which is |
| 9315 // equivalent to using dynamic as the type argument for the element type. | 9315 // equivalent to using dynamic as the type argument for the element type. |
| 9316 if (!list_type_arguments.IsNull()) { | 9316 if (!list_type_arguments.IsNull()) { |
| 9317 ASSERT(list_type_arguments.Length() > 0); | 9317 ASSERT(list_type_arguments.Length() > 0); |
| 9318 // List literals take a single type argument. | 9318 // List literals take a single type argument. |
| 9319 if (list_type_arguments.Length() == 1) { | 9319 if (list_type_arguments.Length() == 1) { |
| 9320 element_type = list_type_arguments.TypeAt(0); | 9320 element_type = list_type_arguments.TypeAt(0); |
| 9321 ASSERT(!element_type.IsMalformed()); // Would be mapped to dynamic. | 9321 ASSERT(!element_type.IsMalformed()); // Would be mapped to dynamic. |
| 9322 ASSERT(!element_type.IsMalbounded()); // No declared bound in List. | 9322 ASSERT(!element_type.IsMalbounded()); // No declared bound in List. |
| 9323 if (is_const && !element_type.IsInstantiated()) { | 9323 if (element_type.IsDynamicType()) { |
| 9324 list_type_arguments = AbstractTypeArguments::null(); |
| 9325 } else if (is_const && !element_type.IsInstantiated()) { |
| 9324 ErrorMsg(type_pos, | 9326 ErrorMsg(type_pos, |
| 9325 "the type argument of a constant list literal cannot include " | 9327 "the type argument of a constant list literal cannot include " |
| 9326 "a type variable"); | 9328 "a type variable"); |
| 9327 } | 9329 } |
| 9328 } else { | 9330 } else { |
| 9329 if (FLAG_error_on_bad_type) { | 9331 if (FLAG_error_on_bad_type) { |
| 9330 ErrorMsg(type_pos, | 9332 ErrorMsg(type_pos, |
| 9331 "a list literal takes one type argument specifying " | 9333 "a list literal takes one type argument specifying " |
| 9332 "the element type"); | 9334 "the element type"); |
| 9333 } | 9335 } |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9509 if (!map_type_arguments.IsNull()) { | 9511 if (!map_type_arguments.IsNull()) { |
| 9510 ASSERT(map_type_arguments.Length() > 0); | 9512 ASSERT(map_type_arguments.Length() > 0); |
| 9511 // Map literals take two type arguments. | 9513 // Map literals take two type arguments. |
| 9512 if (map_type_arguments.Length() == 2) { | 9514 if (map_type_arguments.Length() == 2) { |
| 9513 key_type = map_type_arguments.TypeAt(0); | 9515 key_type = map_type_arguments.TypeAt(0); |
| 9514 value_type = map_type_arguments.TypeAt(1); | 9516 value_type = map_type_arguments.TypeAt(1); |
| 9515 // Malformed type arguments are mapped to dynamic. | 9517 // Malformed type arguments are mapped to dynamic. |
| 9516 ASSERT(!key_type.IsMalformed() && !value_type.IsMalformed()); | 9518 ASSERT(!key_type.IsMalformed() && !value_type.IsMalformed()); |
| 9517 // No declared bounds in Map. | 9519 // No declared bounds in Map. |
| 9518 ASSERT(!key_type.IsMalbounded() && !value_type.IsMalbounded()); | 9520 ASSERT(!key_type.IsMalbounded() && !value_type.IsMalbounded()); |
| 9519 if (is_const && !type_arguments.IsInstantiated()) { | 9521 if (key_type.IsDynamicType() && value_type.IsDynamicType()) { |
| 9522 map_type_arguments = AbstractTypeArguments::null(); |
| 9523 } else if (is_const && !type_arguments.IsInstantiated()) { |
| 9520 ErrorMsg(type_pos, | 9524 ErrorMsg(type_pos, |
| 9521 "the type arguments of a constant map literal cannot include " | 9525 "the type arguments of a constant map literal cannot include " |
| 9522 "a type variable"); | 9526 "a type variable"); |
| 9523 } | 9527 } |
| 9524 } else { | 9528 } else { |
| 9525 if (FLAG_error_on_bad_type) { | 9529 if (FLAG_error_on_bad_type) { |
| 9526 ErrorMsg(type_pos, | 9530 ErrorMsg(type_pos, |
| 9527 "a map literal takes two type arguments specifying " | 9531 "a map literal takes two type arguments specifying " |
| 9528 "the key type and the value type"); | 9532 "the key type and the value type"); |
| 9529 } | 9533 } |
| (...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10695 void Parser::SkipQualIdent() { | 10699 void Parser::SkipQualIdent() { |
| 10696 ASSERT(IsIdentifier()); | 10700 ASSERT(IsIdentifier()); |
| 10697 ConsumeToken(); | 10701 ConsumeToken(); |
| 10698 if (CurrentToken() == Token::kPERIOD) { | 10702 if (CurrentToken() == Token::kPERIOD) { |
| 10699 ConsumeToken(); // Consume the kPERIOD token. | 10703 ConsumeToken(); // Consume the kPERIOD token. |
| 10700 ExpectIdentifier("identifier expected after '.'"); | 10704 ExpectIdentifier("identifier expected after '.'"); |
| 10701 } | 10705 } |
| 10702 } | 10706 } |
| 10703 | 10707 |
| 10704 } // namespace dart | 10708 } // namespace dart |
| OLD | NEW |