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 "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/compiler_stats.h" | 10 #include "vm/compiler_stats.h" |
(...skipping 5171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5182 bool no_check = type.IsDynamicType(); | 5182 bool no_check = type.IsDynamicType(); |
5183 if ((CurrentToken() == Token::kINTEGER) && | 5183 if ((CurrentToken() == Token::kINTEGER) && |
5184 (no_check || type.IsIntType() || type.IsNumberType())) { | 5184 (no_check || type.IsIntType() || type.IsNumberType())) { |
5185 *value = CurrentIntegerLiteral(); | 5185 *value = CurrentIntegerLiteral(); |
5186 return true; | 5186 return true; |
5187 } else if ((CurrentToken() == Token::kDOUBLE) && | 5187 } else if ((CurrentToken() == Token::kDOUBLE) && |
5188 (no_check || type.IsDoubleType() || type.IsNumberType())) { | 5188 (no_check || type.IsDoubleType() || type.IsNumberType())) { |
5189 *value = CurrentDoubleLiteral(); | 5189 *value = CurrentDoubleLiteral(); |
5190 return true; | 5190 return true; |
5191 } else if ((CurrentToken() == Token::kSTRING) && | 5191 } else if ((CurrentToken() == Token::kSTRING) && |
5192 (no_check || type.IsStringInterface())) { | 5192 (no_check || type.IsStringType())) { |
5193 *value = CurrentLiteral()->raw(); | 5193 *value = CurrentLiteral()->raw(); |
5194 return true; | 5194 return true; |
5195 } else if ((CurrentToken() == Token::kTRUE) && | 5195 } else if ((CurrentToken() == Token::kTRUE) && |
5196 (no_check || type.IsBoolType())) { | 5196 (no_check || type.IsBoolType())) { |
5197 *value = Bool::True(); | 5197 *value = Bool::True(); |
5198 return true; | 5198 return true; |
5199 } else if ((CurrentToken() == Token::kFALSE) && | 5199 } else if ((CurrentToken() == Token::kFALSE) && |
5200 (no_check || type.IsBoolType())) { | 5200 (no_check || type.IsBoolType())) { |
5201 *value = Bool::False(); | 5201 *value = Bool::False(); |
5202 return true; | 5202 return true; |
(...skipping 3651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8854 // Map literals take two type arguments. | 8854 // Map literals take two type arguments. |
8855 if (map_type_arguments.Length() < 2) { | 8855 if (map_type_arguments.Length() < 2) { |
8856 // TODO(hausner): Remove legacy syntax support. | 8856 // TODO(hausner): Remove legacy syntax support. |
8857 // We temporarily accept a single type argument. | 8857 // We temporarily accept a single type argument. |
8858 if (FLAG_warn_legacy_map_literal) { | 8858 if (FLAG_warn_legacy_map_literal) { |
8859 Warning(type_pos, | 8859 Warning(type_pos, |
8860 "a map literal takes two type arguments specifying " | 8860 "a map literal takes two type arguments specifying " |
8861 "the key type and the value type"); | 8861 "the key type and the value type"); |
8862 } | 8862 } |
8863 TypeArguments& type_array = TypeArguments::Handle(TypeArguments::New(2)); | 8863 TypeArguments& type_array = TypeArguments::Handle(TypeArguments::New(2)); |
8864 type_array.SetTypeAt(0, Type::Handle(Type::StringInterface())); | 8864 type_array.SetTypeAt(0, Type::Handle(Type::StringType())); |
8865 type_array.SetTypeAt(1, value_type); | 8865 type_array.SetTypeAt(1, value_type); |
8866 map_type_arguments = type_array.raw(); | 8866 map_type_arguments = type_array.raw(); |
8867 } else if (map_type_arguments.Length() > 2) { | 8867 } else if (map_type_arguments.Length() > 2) { |
8868 ErrorMsg(type_pos, | 8868 ErrorMsg(type_pos, |
8869 "a map literal takes two type arguments specifying " | 8869 "a map literal takes two type arguments specifying " |
8870 "the key type and the value type"); | 8870 "the key type and the value type"); |
8871 } else { | 8871 } else { |
8872 const AbstractType& key_type = | 8872 const AbstractType& key_type = |
8873 AbstractType::Handle(map_type_arguments.TypeAt(0)); | 8873 AbstractType::Handle(map_type_arguments.TypeAt(0)); |
8874 value_type = map_type_arguments.TypeAt(1); | 8874 value_type = map_type_arguments.TypeAt(1); |
8875 if (!key_type.IsStringInterface()) { | 8875 if (!key_type.IsStringType()) { |
8876 ErrorMsg(type_pos, "the key type of a map literal must be 'String'"); | 8876 ErrorMsg(type_pos, "the key type of a map literal must be 'String'"); |
8877 } | 8877 } |
8878 } | 8878 } |
8879 if (is_const && !value_type.IsInstantiated()) { | 8879 if (is_const && !value_type.IsInstantiated()) { |
8880 ErrorMsg(type_pos, | 8880 ErrorMsg(type_pos, |
8881 "the type argument of a constant map literal cannot include " | 8881 "the type argument of a constant map literal cannot include " |
8882 "a type variable"); | 8882 "a type variable"); |
8883 } | 8883 } |
8884 } | 8884 } |
8885 ASSERT(map_type_arguments.IsNull() || (map_type_arguments.Length() == 2)); | 8885 ASSERT(map_type_arguments.IsNull() || (map_type_arguments.Length() == 2)); |
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9969 void Parser::SkipQualIdent() { | 9969 void Parser::SkipQualIdent() { |
9970 ASSERT(IsIdentifier()); | 9970 ASSERT(IsIdentifier()); |
9971 ConsumeToken(); | 9971 ConsumeToken(); |
9972 if (CurrentToken() == Token::kPERIOD) { | 9972 if (CurrentToken() == Token::kPERIOD) { |
9973 ConsumeToken(); // Consume the kPERIOD token. | 9973 ConsumeToken(); // Consume the kPERIOD token. |
9974 ExpectIdentifier("identifier expected after '.'"); | 9974 ExpectIdentifier("identifier expected after '.'"); |
9975 } | 9975 } |
9976 } | 9976 } |
9977 | 9977 |
9978 } // namespace dart | 9978 } // namespace dart |
OLD | NEW |