| 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/ast_transformer.h" | 9 #include "vm/ast_transformer.h" |
| 10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
| (...skipping 3112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3123 ParamDesc& param = (*params.parameters)[i]; | 3123 ParamDesc& param = (*params.parameters)[i]; |
| 3124 if (param.is_field_initializer) { | 3124 if (param.is_field_initializer) { |
| 3125 ReportError(param.name_pos, | 3125 ReportError(param.name_pos, |
| 3126 "field initializer only allowed in constructors"); | 3126 "field initializer only allowed in constructors"); |
| 3127 } | 3127 } |
| 3128 } | 3128 } |
| 3129 } | 3129 } |
| 3130 // Populate function scope with the formal parameters. | 3130 // Populate function scope with the formal parameters. |
| 3131 AddFormalParamsToScope(¶ms, current_block_->scope); | 3131 AddFormalParamsToScope(¶ms, current_block_->scope); |
| 3132 | 3132 |
| 3133 if (FLAG_enable_type_checks && | 3133 if (I->TypeChecksEnabled() && |
| 3134 (current_block_->scope->function_level() > 0)) { | 3134 (current_block_->scope->function_level() > 0)) { |
| 3135 // We are parsing, but not compiling, a local function. | 3135 // We are parsing, but not compiling, a local function. |
| 3136 // The instantiator may be required at run time for generic type checks. | 3136 // The instantiator may be required at run time for generic type checks. |
| 3137 if (IsInstantiatorRequired()) { | 3137 if (IsInstantiatorRequired()) { |
| 3138 // Make sure that the receiver of the enclosing instance function | 3138 // Make sure that the receiver of the enclosing instance function |
| 3139 // (or implicit first parameter of an enclosing factory) is marked as | 3139 // (or implicit first parameter of an enclosing factory) is marked as |
| 3140 // captured if type checks are enabled, because they may access it to | 3140 // captured if type checks are enabled, because they may access it to |
| 3141 // instantiate types. | 3141 // instantiate types. |
| 3142 CaptureInstantiator(); | 3142 CaptureInstantiator(); |
| 3143 } | 3143 } |
| (...skipping 3420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6564 | 6564 |
| 6565 // Returns ast nodes of the variable initialization. Variables without an | 6565 // Returns ast nodes of the variable initialization. Variables without an |
| 6566 // explicit initializer are initialized to null. If several variables are | 6566 // explicit initializer are initialized to null. If several variables are |
| 6567 // declared, the individual initializers are collected in a sequence node. | 6567 // declared, the individual initializers are collected in a sequence node. |
| 6568 AstNode* Parser::ParseVariableDeclarationList() { | 6568 AstNode* Parser::ParseVariableDeclarationList() { |
| 6569 TRACE_PARSER("ParseVariableDeclarationList"); | 6569 TRACE_PARSER("ParseVariableDeclarationList"); |
| 6570 SkipMetadata(); | 6570 SkipMetadata(); |
| 6571 bool is_final = (CurrentToken() == Token::kFINAL); | 6571 bool is_final = (CurrentToken() == Token::kFINAL); |
| 6572 bool is_const = (CurrentToken() == Token::kCONST); | 6572 bool is_const = (CurrentToken() == Token::kCONST); |
| 6573 const AbstractType& type = AbstractType::ZoneHandle(Z, | 6573 const AbstractType& type = AbstractType::ZoneHandle(Z, |
| 6574 ParseConstFinalVarOrType(FLAG_enable_type_checks ? | 6574 ParseConstFinalVarOrType(I->TypeChecksEnabled() ? |
| 6575 ClassFinalizer::kCanonicalize : ClassFinalizer::kIgnore)); | 6575 ClassFinalizer::kCanonicalize : ClassFinalizer::kIgnore)); |
| 6576 if (!IsIdentifier()) { | 6576 if (!IsIdentifier()) { |
| 6577 ReportError("identifier expected"); | 6577 ReportError("identifier expected"); |
| 6578 } | 6578 } |
| 6579 | 6579 |
| 6580 SequenceNode* preamble = NULL; | 6580 SequenceNode* preamble = NULL; |
| 6581 AstNode* initializers = | 6581 AstNode* initializers = |
| 6582 ParseVariableDeclaration(type, is_final, is_const, &preamble); | 6582 ParseVariableDeclaration(type, is_final, is_const, &preamble); |
| 6583 ASSERT(initializers != NULL); | 6583 ASSERT(initializers != NULL); |
| 6584 if (preamble != NULL) { | 6584 if (preamble != NULL) { |
| (...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7552 ReportError("Loop variable cannot be 'const'"); | 7552 ReportError("Loop variable cannot be 'const'"); |
| 7553 } | 7553 } |
| 7554 bool new_loop_var = false; | 7554 bool new_loop_var = false; |
| 7555 AbstractType& loop_var_type = AbstractType::ZoneHandle(Z); | 7555 AbstractType& loop_var_type = AbstractType::ZoneHandle(Z); |
| 7556 if (LookaheadToken(1) != Token::kIN) { | 7556 if (LookaheadToken(1) != Token::kIN) { |
| 7557 // Declaration of a new loop variable. | 7557 // Declaration of a new loop variable. |
| 7558 // Delay creation of the local variable until we know its actual | 7558 // Delay creation of the local variable until we know its actual |
| 7559 // position, which is inside the loop body. | 7559 // position, which is inside the loop body. |
| 7560 new_loop_var = true; | 7560 new_loop_var = true; |
| 7561 loop_var_type = ParseConstFinalVarOrType( | 7561 loop_var_type = ParseConstFinalVarOrType( |
| 7562 FLAG_enable_type_checks ? ClassFinalizer::kCanonicalize : | 7562 I->TypeChecksEnabled() ? ClassFinalizer::kCanonicalize : |
| 7563 ClassFinalizer::kIgnore); | 7563 ClassFinalizer::kIgnore); |
| 7564 } | 7564 } |
| 7565 intptr_t loop_var_pos = TokenPos(); | 7565 intptr_t loop_var_pos = TokenPos(); |
| 7566 const String* loop_var_name = ExpectIdentifier("variable name expected"); | 7566 const String* loop_var_name = ExpectIdentifier("variable name expected"); |
| 7567 | 7567 |
| 7568 // Parse stream expression. | 7568 // Parse stream expression. |
| 7569 ExpectToken(Token::kIN); | 7569 ExpectToken(Token::kIN); |
| 7570 const intptr_t stream_pos = TokenPos(); | 7570 const intptr_t stream_pos = TokenPos(); |
| 7571 AstNode* stream_expr = | 7571 AstNode* stream_expr = |
| 7572 ParseAwaitableExpr(kAllowConst, kConsumeCascades, NULL); | 7572 ParseAwaitableExpr(kAllowConst, kConsumeCascades, NULL); |
| 7573 ExpectToken(Token::kRPAREN); | 7573 ExpectToken(Token::kRPAREN); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7695 AbstractType& loop_var_type = AbstractType::ZoneHandle(Z); | 7695 AbstractType& loop_var_type = AbstractType::ZoneHandle(Z); |
| 7696 if (LookaheadToken(1) == Token::kIN) { | 7696 if (LookaheadToken(1) == Token::kIN) { |
| 7697 loop_var_pos = TokenPos(); | 7697 loop_var_pos = TokenPos(); |
| 7698 loop_var_name = ExpectIdentifier("variable name expected"); | 7698 loop_var_name = ExpectIdentifier("variable name expected"); |
| 7699 } else { | 7699 } else { |
| 7700 // The case without a type is handled above, so require a type here. | 7700 // The case without a type is handled above, so require a type here. |
| 7701 // Delay creation of the local variable until we know its actual | 7701 // Delay creation of the local variable until we know its actual |
| 7702 // position, which is inside the loop body. | 7702 // position, which is inside the loop body. |
| 7703 new_loop_var = true; | 7703 new_loop_var = true; |
| 7704 loop_var_type = ParseConstFinalVarOrType( | 7704 loop_var_type = ParseConstFinalVarOrType( |
| 7705 FLAG_enable_type_checks ? ClassFinalizer::kCanonicalize : | 7705 I->TypeChecksEnabled() ? ClassFinalizer::kCanonicalize : |
| 7706 ClassFinalizer::kIgnore); | 7706 ClassFinalizer::kIgnore); |
| 7707 loop_var_name = ExpectIdentifier("variable name expected"); | 7707 loop_var_name = ExpectIdentifier("variable name expected"); |
| 7708 } | 7708 } |
| 7709 ExpectToken(Token::kIN); | 7709 ExpectToken(Token::kIN); |
| 7710 const intptr_t collection_pos = TokenPos(); | 7710 const intptr_t collection_pos = TokenPos(); |
| 7711 AstNode* collection_expr = | 7711 AstNode* collection_expr = |
| 7712 ParseAwaitableExpr(kAllowConst, kConsumeCascades, NULL); | 7712 ParseAwaitableExpr(kAllowConst, kConsumeCascades, NULL); |
| 7713 ExpectToken(Token::kRPAREN); | 7713 ExpectToken(Token::kRPAREN); |
| 7714 | 7714 |
| 7715 OpenBlock(); // Implicit block around while loop. | 7715 OpenBlock(); // Implicit block around while loop. |
| 7716 | 7716 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7914 } | 7914 } |
| 7915 return condition; | 7915 return condition; |
| 7916 } | 7916 } |
| 7917 | 7917 |
| 7918 | 7918 |
| 7919 AstNode* Parser::ParseAssertStatement() { | 7919 AstNode* Parser::ParseAssertStatement() { |
| 7920 TRACE_PARSER("ParseAssertStatement"); | 7920 TRACE_PARSER("ParseAssertStatement"); |
| 7921 ConsumeToken(); // Consume assert keyword. | 7921 ConsumeToken(); // Consume assert keyword. |
| 7922 ExpectToken(Token::kLPAREN); | 7922 ExpectToken(Token::kLPAREN); |
| 7923 const intptr_t condition_pos = TokenPos(); | 7923 const intptr_t condition_pos = TokenPos(); |
| 7924 if (!FLAG_enable_asserts && !FLAG_enable_type_checks) { | 7924 if (!I->AssertsEnabled() && !I->TypeChecksEnabled()) { |
| 7925 SkipExpr(); | 7925 SkipExpr(); |
| 7926 ExpectToken(Token::kRPAREN); | 7926 ExpectToken(Token::kRPAREN); |
| 7927 return NULL; | 7927 return NULL; |
| 7928 } | 7928 } |
| 7929 AstNode* condition = ParseExpr(kAllowConst, kConsumeCascades); | 7929 AstNode* condition = ParseExpr(kAllowConst, kConsumeCascades); |
| 7930 const intptr_t condition_end = TokenPos(); | 7930 const intptr_t condition_end = TokenPos(); |
| 7931 ExpectToken(Token::kRPAREN); | 7931 ExpectToken(Token::kRPAREN); |
| 7932 condition = InsertClosureCallNodes(condition); | 7932 condition = InsertClosureCallNodes(condition); |
| 7933 condition = new(Z) UnaryOpNode(condition_pos, Token::kNOT, condition); | 7933 condition = new(Z) UnaryOpNode(condition_pos, Token::kNOT, condition); |
| 7934 AstNode* assert_throw = MakeAssertCall(condition_pos, condition_end); | 7934 AstNode* assert_throw = MakeAssertCall(condition_pos, condition_end); |
| (...skipping 2889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10824 ASSERT(!element_type.IsMalformed()); // Would be mapped to dynamic. | 10824 ASSERT(!element_type.IsMalformed()); // Would be mapped to dynamic. |
| 10825 ASSERT(!element_type.IsMalbounded()); // No declared bound in List. | 10825 ASSERT(!element_type.IsMalbounded()); // No declared bound in List. |
| 10826 if (element_type.IsDynamicType()) { | 10826 if (element_type.IsDynamicType()) { |
| 10827 list_type_arguments = TypeArguments::null(); | 10827 list_type_arguments = TypeArguments::null(); |
| 10828 } else if (is_const && !element_type.IsInstantiated()) { | 10828 } else if (is_const && !element_type.IsInstantiated()) { |
| 10829 ReportError(type_pos, | 10829 ReportError(type_pos, |
| 10830 "the type argument of a constant list literal cannot " | 10830 "the type argument of a constant list literal cannot " |
| 10831 "include a type variable"); | 10831 "include a type variable"); |
| 10832 } | 10832 } |
| 10833 } else { | 10833 } else { |
| 10834 if (FLAG_error_on_bad_type) { | 10834 if (I->ErrorOnBadTypeEnabled()) { |
| 10835 ReportError(type_pos, | 10835 ReportError(type_pos, |
| 10836 "a list literal takes one type argument specifying " | 10836 "a list literal takes one type argument specifying " |
| 10837 "the element type"); | 10837 "the element type"); |
| 10838 } | 10838 } |
| 10839 // Ignore type arguments. | 10839 // Ignore type arguments. |
| 10840 list_type_arguments = TypeArguments::null(); | 10840 list_type_arguments = TypeArguments::null(); |
| 10841 } | 10841 } |
| 10842 } | 10842 } |
| 10843 ASSERT(list_type_arguments.IsNull() || (list_type_arguments.Length() == 1)); | 10843 ASSERT(list_type_arguments.IsNull() || (list_type_arguments.Length() == 1)); |
| 10844 const Class& array_class = Class::Handle(Z, I->object_store()->array_class()); | 10844 const Class& array_class = Class::Handle(Z, I->object_store()->array_class()); |
| 10845 Type& type = Type::ZoneHandle(Z, | 10845 Type& type = Type::ZoneHandle(Z, |
| 10846 Type::New(array_class, list_type_arguments, type_pos)); | 10846 Type::New(array_class, list_type_arguments, type_pos)); |
| 10847 type ^= ClassFinalizer::FinalizeType( | 10847 type ^= ClassFinalizer::FinalizeType( |
| 10848 current_class(), type, ClassFinalizer::kCanonicalize); | 10848 current_class(), type, ClassFinalizer::kCanonicalize); |
| 10849 GrowableArray<AstNode*> element_list; | 10849 GrowableArray<AstNode*> element_list; |
| 10850 // Parse the list elements. Note: there may be an optional extra | 10850 // Parse the list elements. Note: there may be an optional extra |
| 10851 // comma after the last element. | 10851 // comma after the last element. |
| 10852 if (!is_empty_literal) { | 10852 if (!is_empty_literal) { |
| 10853 const bool saved_mode = SetAllowFunctionLiterals(true); | 10853 const bool saved_mode = SetAllowFunctionLiterals(true); |
| 10854 while (CurrentToken() != Token::kRBRACK) { | 10854 while (CurrentToken() != Token::kRBRACK) { |
| 10855 const intptr_t element_pos = TokenPos(); | 10855 const intptr_t element_pos = TokenPos(); |
| 10856 AstNode* element = ParseExpr(is_const, kConsumeCascades); | 10856 AstNode* element = ParseExpr(is_const, kConsumeCascades); |
| 10857 if (FLAG_enable_type_checks && | 10857 if (I->TypeChecksEnabled() && |
| 10858 !is_const && | 10858 !is_const && |
| 10859 !element_type.IsDynamicType()) { | 10859 !element_type.IsDynamicType()) { |
| 10860 element = new(Z) AssignableNode(element_pos, | 10860 element = new(Z) AssignableNode(element_pos, |
| 10861 element, | 10861 element, |
| 10862 element_type, | 10862 element_type, |
| 10863 Symbols::ListLiteralElement()); | 10863 Symbols::ListLiteralElement()); |
| 10864 } | 10864 } |
| 10865 element_list.Add(element); | 10865 element_list.Add(element); |
| 10866 if (CurrentToken() == Token::kCOMMA) { | 10866 if (CurrentToken() == Token::kCOMMA) { |
| 10867 ConsumeToken(); | 10867 ConsumeToken(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 10878 Array& const_list = | 10878 Array& const_list = |
| 10879 Array::ZoneHandle(Z, Array::New(element_list.length(), Heap::kOld)); | 10879 Array::ZoneHandle(Z, Array::New(element_list.length(), Heap::kOld)); |
| 10880 const_list.SetTypeArguments( | 10880 const_list.SetTypeArguments( |
| 10881 TypeArguments::Handle(Z, list_type_arguments.Canonicalize())); | 10881 TypeArguments::Handle(Z, list_type_arguments.Canonicalize())); |
| 10882 Error& malformed_error = Error::Handle(Z); | 10882 Error& malformed_error = Error::Handle(Z); |
| 10883 for (int i = 0; i < element_list.length(); i++) { | 10883 for (int i = 0; i < element_list.length(); i++) { |
| 10884 AstNode* elem = element_list[i]; | 10884 AstNode* elem = element_list[i]; |
| 10885 // Arguments have been evaluated to a literal value already. | 10885 // Arguments have been evaluated to a literal value already. |
| 10886 ASSERT(elem->IsLiteralNode()); | 10886 ASSERT(elem->IsLiteralNode()); |
| 10887 ASSERT(!is_top_level_); // We cannot check unresolved types. | 10887 ASSERT(!is_top_level_); // We cannot check unresolved types. |
| 10888 if (FLAG_enable_type_checks && | 10888 if (I->TypeChecksEnabled() && |
| 10889 !element_type.IsDynamicType() && | 10889 !element_type.IsDynamicType() && |
| 10890 (!elem->AsLiteralNode()->literal().IsNull() && | 10890 (!elem->AsLiteralNode()->literal().IsNull() && |
| 10891 !elem->AsLiteralNode()->literal().IsInstanceOf( | 10891 !elem->AsLiteralNode()->literal().IsInstanceOf( |
| 10892 element_type, | 10892 element_type, |
| 10893 TypeArguments::Handle(Z), | 10893 TypeArguments::Handle(Z), |
| 10894 &malformed_error))) { | 10894 &malformed_error))) { |
| 10895 // If the failure is due to a malformed type error, display it instead. | 10895 // If the failure is due to a malformed type error, display it instead. |
| 10896 if (!malformed_error.IsNull()) { | 10896 if (!malformed_error.IsNull()) { |
| 10897 ReportError(malformed_error); | 10897 ReportError(malformed_error); |
| 10898 } else { | 10898 } else { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11021 // No declared bounds in Map. | 11021 // No declared bounds in Map. |
| 11022 ASSERT(!key_type.IsMalbounded() && !value_type.IsMalbounded()); | 11022 ASSERT(!key_type.IsMalbounded() && !value_type.IsMalbounded()); |
| 11023 if (key_type.IsDynamicType() && value_type.IsDynamicType()) { | 11023 if (key_type.IsDynamicType() && value_type.IsDynamicType()) { |
| 11024 map_type_arguments = TypeArguments::null(); | 11024 map_type_arguments = TypeArguments::null(); |
| 11025 } else if (is_const && !type_arguments.IsInstantiated()) { | 11025 } else if (is_const && !type_arguments.IsInstantiated()) { |
| 11026 ReportError(type_pos, | 11026 ReportError(type_pos, |
| 11027 "the type arguments of a constant map literal cannot " | 11027 "the type arguments of a constant map literal cannot " |
| 11028 "include a type variable"); | 11028 "include a type variable"); |
| 11029 } | 11029 } |
| 11030 } else { | 11030 } else { |
| 11031 if (FLAG_error_on_bad_type) { | 11031 if (I->ErrorOnBadTypeEnabled()) { |
| 11032 ReportError(type_pos, | 11032 ReportError(type_pos, |
| 11033 "a map literal takes two type arguments specifying " | 11033 "a map literal takes two type arguments specifying " |
| 11034 "the key type and the value type"); | 11034 "the key type and the value type"); |
| 11035 } | 11035 } |
| 11036 // Ignore type arguments. | 11036 // Ignore type arguments. |
| 11037 map_type_arguments = TypeArguments::null(); | 11037 map_type_arguments = TypeArguments::null(); |
| 11038 } | 11038 } |
| 11039 } | 11039 } |
| 11040 ASSERT(map_type_arguments.IsNull() || (map_type_arguments.Length() == 2)); | 11040 ASSERT(map_type_arguments.IsNull() || (map_type_arguments.Length() == 2)); |
| 11041 map_type_arguments ^= map_type_arguments.Canonicalize(); | 11041 map_type_arguments ^= map_type_arguments.Canonicalize(); |
| 11042 | 11042 |
| 11043 GrowableArray<AstNode*> kv_pairs_list; | 11043 GrowableArray<AstNode*> kv_pairs_list; |
| 11044 // Parse the map entries. Note: there may be an optional extra | 11044 // Parse the map entries. Note: there may be an optional extra |
| 11045 // comma after the last entry. | 11045 // comma after the last entry. |
| 11046 while (CurrentToken() != Token::kRBRACE) { | 11046 while (CurrentToken() != Token::kRBRACE) { |
| 11047 const bool saved_mode = SetAllowFunctionLiterals(true); | 11047 const bool saved_mode = SetAllowFunctionLiterals(true); |
| 11048 const intptr_t key_pos = TokenPos(); | 11048 const intptr_t key_pos = TokenPos(); |
| 11049 AstNode* key = ParseExpr(is_const, kConsumeCascades); | 11049 AstNode* key = ParseExpr(is_const, kConsumeCascades); |
| 11050 if (FLAG_enable_type_checks && | 11050 if (I->TypeChecksEnabled() && |
| 11051 !is_const && | 11051 !is_const && |
| 11052 !key_type.IsDynamicType()) { | 11052 !key_type.IsDynamicType()) { |
| 11053 key = new(Z) AssignableNode( | 11053 key = new(Z) AssignableNode( |
| 11054 key_pos, key, key_type, Symbols::ListLiteralElement()); | 11054 key_pos, key, key_type, Symbols::ListLiteralElement()); |
| 11055 } | 11055 } |
| 11056 if (is_const) { | 11056 if (is_const) { |
| 11057 ASSERT(key->IsLiteralNode()); | 11057 ASSERT(key->IsLiteralNode()); |
| 11058 const Instance& key_value = key->AsLiteralNode()->literal(); | 11058 const Instance& key_value = key->AsLiteralNode()->literal(); |
| 11059 if (key_value.IsDouble()) { | 11059 if (key_value.IsDouble()) { |
| 11060 ReportError(key_pos, "key value must not be of type double"); | 11060 ReportError(key_pos, "key value must not be of type double"); |
| 11061 } | 11061 } |
| 11062 if (!key_value.IsInteger() && | 11062 if (!key_value.IsInteger() && |
| 11063 !key_value.IsString() && | 11063 !key_value.IsString() && |
| 11064 (key_value.clazz() != I->object_store()->symbol_class()) && | 11064 (key_value.clazz() != I->object_store()->symbol_class()) && |
| 11065 ImplementsEqualOperator(key_value)) { | 11065 ImplementsEqualOperator(key_value)) { |
| 11066 ReportError(key_pos, "key value must not implement operator =="); | 11066 ReportError(key_pos, "key value must not implement operator =="); |
| 11067 } | 11067 } |
| 11068 } | 11068 } |
| 11069 ExpectToken(Token::kCOLON); | 11069 ExpectToken(Token::kCOLON); |
| 11070 const intptr_t value_pos = TokenPos(); | 11070 const intptr_t value_pos = TokenPos(); |
| 11071 AstNode* value = ParseExpr(is_const, kConsumeCascades); | 11071 AstNode* value = ParseExpr(is_const, kConsumeCascades); |
| 11072 SetAllowFunctionLiterals(saved_mode); | 11072 SetAllowFunctionLiterals(saved_mode); |
| 11073 if (FLAG_enable_type_checks && | 11073 if (I->TypeChecksEnabled() && |
| 11074 !is_const && | 11074 !is_const && |
| 11075 !value_type.IsDynamicType()) { | 11075 !value_type.IsDynamicType()) { |
| 11076 value = new(Z) AssignableNode( | 11076 value = new(Z) AssignableNode( |
| 11077 value_pos, value, value_type, Symbols::ListLiteralElement()); | 11077 value_pos, value, value_type, Symbols::ListLiteralElement()); |
| 11078 } | 11078 } |
| 11079 AddKeyValuePair(&kv_pairs_list, is_const, key, value); | 11079 AddKeyValuePair(&kv_pairs_list, is_const, key, value); |
| 11080 | 11080 |
| 11081 if (CurrentToken() == Token::kCOMMA) { | 11081 if (CurrentToken() == Token::kCOMMA) { |
| 11082 ConsumeToken(); | 11082 ConsumeToken(); |
| 11083 } else if (CurrentToken() != Token::kRBRACE) { | 11083 } else if (CurrentToken() != Token::kRBRACE) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 11095 // First, create the canonicalized key-value pair array. | 11095 // First, create the canonicalized key-value pair array. |
| 11096 Array& key_value_array = | 11096 Array& key_value_array = |
| 11097 Array::ZoneHandle(Z, Array::New(kv_pairs_list.length(), Heap::kOld)); | 11097 Array::ZoneHandle(Z, Array::New(kv_pairs_list.length(), Heap::kOld)); |
| 11098 AbstractType& arg_type = Type::Handle(Z); | 11098 AbstractType& arg_type = Type::Handle(Z); |
| 11099 Error& malformed_error = Error::Handle(Z); | 11099 Error& malformed_error = Error::Handle(Z); |
| 11100 for (int i = 0; i < kv_pairs_list.length(); i++) { | 11100 for (int i = 0; i < kv_pairs_list.length(); i++) { |
| 11101 AstNode* arg = kv_pairs_list[i]; | 11101 AstNode* arg = kv_pairs_list[i]; |
| 11102 // Arguments have been evaluated to a literal value already. | 11102 // Arguments have been evaluated to a literal value already. |
| 11103 ASSERT(arg->IsLiteralNode()); | 11103 ASSERT(arg->IsLiteralNode()); |
| 11104 ASSERT(!is_top_level_); // We cannot check unresolved types. | 11104 ASSERT(!is_top_level_); // We cannot check unresolved types. |
| 11105 if (FLAG_enable_type_checks) { | 11105 if (I->TypeChecksEnabled()) { |
| 11106 if ((i % 2) == 0) { | 11106 if ((i % 2) == 0) { |
| 11107 // Check key type. | 11107 // Check key type. |
| 11108 arg_type = key_type.raw(); | 11108 arg_type = key_type.raw(); |
| 11109 } else { | 11109 } else { |
| 11110 // Check value type. | 11110 // Check value type. |
| 11111 arg_type = value_type.raw(); | 11111 arg_type = value_type.raw(); |
| 11112 } | 11112 } |
| 11113 if (!arg_type.IsDynamicType() && | 11113 if (!arg_type.IsDynamicType() && |
| 11114 (!arg->AsLiteralNode()->literal().IsNull() && | 11114 (!arg->AsLiteralNode()->literal().IsNull() && |
| 11115 !arg->AsLiteralNode()->literal().IsInstanceOf( | 11115 !arg->AsLiteralNode()->literal().IsInstanceOf( |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11420 "redirecting factory type '%s' cannot be instantiated", | 11420 "redirecting factory type '%s' cannot be instantiated", |
| 11421 String::Handle(Z, redirect_type.UserVisibleName()).ToCString()); | 11421 String::Handle(Z, redirect_type.UserVisibleName()).ToCString()); |
| 11422 } | 11422 } |
| 11423 } | 11423 } |
| 11424 if (redirect_type.IsMalformedOrMalbounded()) { | 11424 if (redirect_type.IsMalformedOrMalbounded()) { |
| 11425 if (is_const) { | 11425 if (is_const) { |
| 11426 ReportError(Error::Handle(Z, redirect_type.error())); | 11426 ReportError(Error::Handle(Z, redirect_type.error())); |
| 11427 } | 11427 } |
| 11428 return ThrowTypeError(redirect_type.token_pos(), redirect_type); | 11428 return ThrowTypeError(redirect_type.token_pos(), redirect_type); |
| 11429 } | 11429 } |
| 11430 if (FLAG_enable_type_checks && !redirect_type.IsSubtypeOf(type, NULL)) { | 11430 if (I->TypeChecksEnabled() && !redirect_type.IsSubtypeOf(type, NULL)) { |
| 11431 // Additional type checking of the result is necessary. | 11431 // Additional type checking of the result is necessary. |
| 11432 type_bound = type.raw(); | 11432 type_bound = type.raw(); |
| 11433 } | 11433 } |
| 11434 type = redirect_type.raw(); | 11434 type = redirect_type.raw(); |
| 11435 type_class = type.type_class(); | 11435 type_class = type.type_class(); |
| 11436 type_class_name = type_class.Name(); | 11436 type_class_name = type_class.Name(); |
| 11437 type_arguments = type.arguments(); | 11437 type_arguments = type.arguments(); |
| 11438 constructor = constructor.RedirectionTarget(); | 11438 constructor = constructor.RedirectionTarget(); |
| 11439 constructor_name = constructor.name(); | 11439 constructor_name = constructor.name(); |
| 11440 ASSERT(!constructor.IsNull()); | 11440 ASSERT(!constructor.IsNull()); |
| (...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12242 void Parser::SkipQualIdent() { | 12242 void Parser::SkipQualIdent() { |
| 12243 ASSERT(IsIdentifier()); | 12243 ASSERT(IsIdentifier()); |
| 12244 ConsumeToken(); | 12244 ConsumeToken(); |
| 12245 if (CurrentToken() == Token::kPERIOD) { | 12245 if (CurrentToken() == Token::kPERIOD) { |
| 12246 ConsumeToken(); // Consume the kPERIOD token. | 12246 ConsumeToken(); // Consume the kPERIOD token. |
| 12247 ExpectIdentifier("identifier expected after '.'"); | 12247 ExpectIdentifier("identifier expected after '.'"); |
| 12248 } | 12248 } |
| 12249 } | 12249 } |
| 12250 | 12250 |
| 12251 } // namespace dart | 12251 } // namespace dart |
| OLD | NEW |