Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(480)

Side by Side Diff: runtime/vm/parser.cc

Issue 883263004: Allows turning on checked mode on a per-isolate basis (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 3107 matching lines...) Expand 10 before | Expand all | Expand 10 after
3118 ParamDesc& param = (*params.parameters)[i]; 3118 ParamDesc& param = (*params.parameters)[i];
3119 if (param.is_field_initializer) { 3119 if (param.is_field_initializer) {
3120 ReportError(param.name_pos, 3120 ReportError(param.name_pos,
3121 "field initializer only allowed in constructors"); 3121 "field initializer only allowed in constructors");
3122 } 3122 }
3123 } 3123 }
3124 } 3124 }
3125 // Populate function scope with the formal parameters. 3125 // Populate function scope with the formal parameters.
3126 AddFormalParamsToScope(&params, current_block_->scope); 3126 AddFormalParamsToScope(&params, current_block_->scope);
3127 3127
3128 if (FLAG_enable_type_checks && 3128 if (I->TypeChecksEnabled() &&
3129 (current_block_->scope->function_level() > 0)) { 3129 (current_block_->scope->function_level() > 0)) {
3130 // We are parsing, but not compiling, a local function. 3130 // We are parsing, but not compiling, a local function.
3131 // The instantiator may be required at run time for generic type checks. 3131 // The instantiator may be required at run time for generic type checks.
3132 if (IsInstantiatorRequired()) { 3132 if (IsInstantiatorRequired()) {
3133 // Make sure that the receiver of the enclosing instance function 3133 // Make sure that the receiver of the enclosing instance function
3134 // (or implicit first parameter of an enclosing factory) is marked as 3134 // (or implicit first parameter of an enclosing factory) is marked as
3135 // captured if type checks are enabled, because they may access it to 3135 // captured if type checks are enabled, because they may access it to
3136 // instantiate types. 3136 // instantiate types.
3137 CaptureInstantiator(); 3137 CaptureInstantiator();
3138 } 3138 }
(...skipping 3415 matching lines...) Expand 10 before | Expand all | Expand 10 after
6554 6554
6555 // Returns ast nodes of the variable initialization. Variables without an 6555 // Returns ast nodes of the variable initialization. Variables without an
6556 // explicit initializer are initialized to null. If several variables are 6556 // explicit initializer are initialized to null. If several variables are
6557 // declared, the individual initializers are collected in a sequence node. 6557 // declared, the individual initializers are collected in a sequence node.
6558 AstNode* Parser::ParseVariableDeclarationList() { 6558 AstNode* Parser::ParseVariableDeclarationList() {
6559 TRACE_PARSER("ParseVariableDeclarationList"); 6559 TRACE_PARSER("ParseVariableDeclarationList");
6560 SkipMetadata(); 6560 SkipMetadata();
6561 bool is_final = (CurrentToken() == Token::kFINAL); 6561 bool is_final = (CurrentToken() == Token::kFINAL);
6562 bool is_const = (CurrentToken() == Token::kCONST); 6562 bool is_const = (CurrentToken() == Token::kCONST);
6563 const AbstractType& type = AbstractType::ZoneHandle(Z, 6563 const AbstractType& type = AbstractType::ZoneHandle(Z,
6564 ParseConstFinalVarOrType(FLAG_enable_type_checks ? 6564 ParseConstFinalVarOrType(I->TypeChecksEnabled() ?
6565 ClassFinalizer::kCanonicalize : ClassFinalizer::kIgnore)); 6565 ClassFinalizer::kCanonicalize : ClassFinalizer::kIgnore));
6566 if (!IsIdentifier()) { 6566 if (!IsIdentifier()) {
6567 ReportError("identifier expected"); 6567 ReportError("identifier expected");
6568 } 6568 }
6569 6569
6570 SequenceNode* preamble = NULL; 6570 SequenceNode* preamble = NULL;
6571 AstNode* initializers = 6571 AstNode* initializers =
6572 ParseVariableDeclaration(type, is_final, is_const, &preamble); 6572 ParseVariableDeclaration(type, is_final, is_const, &preamble);
6573 ASSERT(initializers != NULL); 6573 ASSERT(initializers != NULL);
6574 if (preamble != NULL) { 6574 if (preamble != NULL) {
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after
7542 ReportError("Loop variable cannot be 'const'"); 7542 ReportError("Loop variable cannot be 'const'");
7543 } 7543 }
7544 bool new_loop_var = false; 7544 bool new_loop_var = false;
7545 AbstractType& loop_var_type = AbstractType::ZoneHandle(Z); 7545 AbstractType& loop_var_type = AbstractType::ZoneHandle(Z);
7546 if (LookaheadToken(1) != Token::kIN) { 7546 if (LookaheadToken(1) != Token::kIN) {
7547 // Declaration of a new loop variable. 7547 // Declaration of a new loop variable.
7548 // Delay creation of the local variable until we know its actual 7548 // Delay creation of the local variable until we know its actual
7549 // position, which is inside the loop body. 7549 // position, which is inside the loop body.
7550 new_loop_var = true; 7550 new_loop_var = true;
7551 loop_var_type = ParseConstFinalVarOrType( 7551 loop_var_type = ParseConstFinalVarOrType(
7552 FLAG_enable_type_checks ? ClassFinalizer::kCanonicalize : 7552 I->TypeChecksEnabled() ? ClassFinalizer::kCanonicalize :
7553 ClassFinalizer::kIgnore); 7553 ClassFinalizer::kIgnore);
7554 } 7554 }
7555 intptr_t loop_var_pos = TokenPos(); 7555 intptr_t loop_var_pos = TokenPos();
7556 const String* loop_var_name = ExpectIdentifier("variable name expected"); 7556 const String* loop_var_name = ExpectIdentifier("variable name expected");
7557 7557
7558 // Parse stream expression. 7558 // Parse stream expression.
7559 ExpectToken(Token::kIN); 7559 ExpectToken(Token::kIN);
7560 const intptr_t stream_pos = TokenPos(); 7560 const intptr_t stream_pos = TokenPos();
7561 AstNode* stream_expr = 7561 AstNode* stream_expr =
7562 ParseAwaitableExpr(kAllowConst, kConsumeCascades, NULL); 7562 ParseAwaitableExpr(kAllowConst, kConsumeCascades, NULL);
7563 ExpectToken(Token::kRPAREN); 7563 ExpectToken(Token::kRPAREN);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
7685 AbstractType& loop_var_type = AbstractType::ZoneHandle(Z); 7685 AbstractType& loop_var_type = AbstractType::ZoneHandle(Z);
7686 if (LookaheadToken(1) == Token::kIN) { 7686 if (LookaheadToken(1) == Token::kIN) {
7687 loop_var_pos = TokenPos(); 7687 loop_var_pos = TokenPos();
7688 loop_var_name = ExpectIdentifier("variable name expected"); 7688 loop_var_name = ExpectIdentifier("variable name expected");
7689 } else { 7689 } else {
7690 // The case without a type is handled above, so require a type here. 7690 // The case without a type is handled above, so require a type here.
7691 // Delay creation of the local variable until we know its actual 7691 // Delay creation of the local variable until we know its actual
7692 // position, which is inside the loop body. 7692 // position, which is inside the loop body.
7693 new_loop_var = true; 7693 new_loop_var = true;
7694 loop_var_type = ParseConstFinalVarOrType( 7694 loop_var_type = ParseConstFinalVarOrType(
7695 FLAG_enable_type_checks ? ClassFinalizer::kCanonicalize : 7695 I->TypeChecksEnabled() ? ClassFinalizer::kCanonicalize :
7696 ClassFinalizer::kIgnore); 7696 ClassFinalizer::kIgnore);
7697 loop_var_name = ExpectIdentifier("variable name expected"); 7697 loop_var_name = ExpectIdentifier("variable name expected");
7698 } 7698 }
7699 ExpectToken(Token::kIN); 7699 ExpectToken(Token::kIN);
7700 const intptr_t collection_pos = TokenPos(); 7700 const intptr_t collection_pos = TokenPos();
7701 AstNode* collection_expr = 7701 AstNode* collection_expr =
7702 ParseAwaitableExpr(kAllowConst, kConsumeCascades, NULL); 7702 ParseAwaitableExpr(kAllowConst, kConsumeCascades, NULL);
7703 ExpectToken(Token::kRPAREN); 7703 ExpectToken(Token::kRPAREN);
7704 7704
7705 OpenBlock(); // Implicit block around while loop. 7705 OpenBlock(); // Implicit block around while loop.
7706 7706
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
7904 } 7904 }
7905 return condition; 7905 return condition;
7906 } 7906 }
7907 7907
7908 7908
7909 AstNode* Parser::ParseAssertStatement() { 7909 AstNode* Parser::ParseAssertStatement() {
7910 TRACE_PARSER("ParseAssertStatement"); 7910 TRACE_PARSER("ParseAssertStatement");
7911 ConsumeToken(); // Consume assert keyword. 7911 ConsumeToken(); // Consume assert keyword.
7912 ExpectToken(Token::kLPAREN); 7912 ExpectToken(Token::kLPAREN);
7913 const intptr_t condition_pos = TokenPos(); 7913 const intptr_t condition_pos = TokenPos();
7914 if (!FLAG_enable_asserts && !FLAG_enable_type_checks) { 7914 if (!I->AssertsEnabled() && !I->TypeChecksEnabled()) {
7915 SkipExpr(); 7915 SkipExpr();
7916 ExpectToken(Token::kRPAREN); 7916 ExpectToken(Token::kRPAREN);
7917 return NULL; 7917 return NULL;
7918 } 7918 }
7919 AstNode* condition = ParseExpr(kAllowConst, kConsumeCascades); 7919 AstNode* condition = ParseExpr(kAllowConst, kConsumeCascades);
7920 const intptr_t condition_end = TokenPos(); 7920 const intptr_t condition_end = TokenPos();
7921 ExpectToken(Token::kRPAREN); 7921 ExpectToken(Token::kRPAREN);
7922 condition = InsertClosureCallNodes(condition); 7922 condition = InsertClosureCallNodes(condition);
7923 condition = new(Z) UnaryOpNode(condition_pos, Token::kNOT, condition); 7923 condition = new(Z) UnaryOpNode(condition_pos, Token::kNOT, condition);
7924 AstNode* assert_throw = MakeAssertCall(condition_pos, condition_end); 7924 AstNode* assert_throw = MakeAssertCall(condition_pos, condition_end);
(...skipping 2889 matching lines...) Expand 10 before | Expand all | Expand 10 after
10814 ASSERT(!element_type.IsMalformed()); // Would be mapped to dynamic. 10814 ASSERT(!element_type.IsMalformed()); // Would be mapped to dynamic.
10815 ASSERT(!element_type.IsMalbounded()); // No declared bound in List. 10815 ASSERT(!element_type.IsMalbounded()); // No declared bound in List.
10816 if (element_type.IsDynamicType()) { 10816 if (element_type.IsDynamicType()) {
10817 list_type_arguments = TypeArguments::null(); 10817 list_type_arguments = TypeArguments::null();
10818 } else if (is_const && !element_type.IsInstantiated()) { 10818 } else if (is_const && !element_type.IsInstantiated()) {
10819 ReportError(type_pos, 10819 ReportError(type_pos,
10820 "the type argument of a constant list literal cannot " 10820 "the type argument of a constant list literal cannot "
10821 "include a type variable"); 10821 "include a type variable");
10822 } 10822 }
10823 } else { 10823 } else {
10824 if (FLAG_error_on_bad_type) { 10824 if (I->ErrorOnBadTypeEnabled()) {
10825 ReportError(type_pos, 10825 ReportError(type_pos,
10826 "a list literal takes one type argument specifying " 10826 "a list literal takes one type argument specifying "
10827 "the element type"); 10827 "the element type");
10828 } 10828 }
10829 // Ignore type arguments. 10829 // Ignore type arguments.
10830 list_type_arguments = TypeArguments::null(); 10830 list_type_arguments = TypeArguments::null();
10831 } 10831 }
10832 } 10832 }
10833 ASSERT(list_type_arguments.IsNull() || (list_type_arguments.Length() == 1)); 10833 ASSERT(list_type_arguments.IsNull() || (list_type_arguments.Length() == 1));
10834 const Class& array_class = Class::Handle(Z, I->object_store()->array_class()); 10834 const Class& array_class = Class::Handle(Z, I->object_store()->array_class());
10835 Type& type = Type::ZoneHandle(Z, 10835 Type& type = Type::ZoneHandle(Z,
10836 Type::New(array_class, list_type_arguments, type_pos)); 10836 Type::New(array_class, list_type_arguments, type_pos));
10837 type ^= ClassFinalizer::FinalizeType( 10837 type ^= ClassFinalizer::FinalizeType(
10838 current_class(), type, ClassFinalizer::kCanonicalize); 10838 current_class(), type, ClassFinalizer::kCanonicalize);
10839 GrowableArray<AstNode*> element_list; 10839 GrowableArray<AstNode*> element_list;
10840 // Parse the list elements. Note: there may be an optional extra 10840 // Parse the list elements. Note: there may be an optional extra
10841 // comma after the last element. 10841 // comma after the last element.
10842 if (!is_empty_literal) { 10842 if (!is_empty_literal) {
10843 const bool saved_mode = SetAllowFunctionLiterals(true); 10843 const bool saved_mode = SetAllowFunctionLiterals(true);
10844 while (CurrentToken() != Token::kRBRACK) { 10844 while (CurrentToken() != Token::kRBRACK) {
10845 const intptr_t element_pos = TokenPos(); 10845 const intptr_t element_pos = TokenPos();
10846 AstNode* element = ParseExpr(is_const, kConsumeCascades); 10846 AstNode* element = ParseExpr(is_const, kConsumeCascades);
10847 if (FLAG_enable_type_checks && 10847 if (I->TypeChecksEnabled() &&
10848 !is_const && 10848 !is_const &&
10849 !element_type.IsDynamicType()) { 10849 !element_type.IsDynamicType()) {
10850 element = new(Z) AssignableNode(element_pos, 10850 element = new(Z) AssignableNode(element_pos,
10851 element, 10851 element,
10852 element_type, 10852 element_type,
10853 Symbols::ListLiteralElement()); 10853 Symbols::ListLiteralElement());
10854 } 10854 }
10855 element_list.Add(element); 10855 element_list.Add(element);
10856 if (CurrentToken() == Token::kCOMMA) { 10856 if (CurrentToken() == Token::kCOMMA) {
10857 ConsumeToken(); 10857 ConsumeToken();
(...skipping 10 matching lines...) Expand all
10868 Array& const_list = 10868 Array& const_list =
10869 Array::ZoneHandle(Z, Array::New(element_list.length(), Heap::kOld)); 10869 Array::ZoneHandle(Z, Array::New(element_list.length(), Heap::kOld));
10870 const_list.SetTypeArguments( 10870 const_list.SetTypeArguments(
10871 TypeArguments::Handle(Z, list_type_arguments.Canonicalize())); 10871 TypeArguments::Handle(Z, list_type_arguments.Canonicalize()));
10872 Error& malformed_error = Error::Handle(Z); 10872 Error& malformed_error = Error::Handle(Z);
10873 for (int i = 0; i < element_list.length(); i++) { 10873 for (int i = 0; i < element_list.length(); i++) {
10874 AstNode* elem = element_list[i]; 10874 AstNode* elem = element_list[i];
10875 // Arguments have been evaluated to a literal value already. 10875 // Arguments have been evaluated to a literal value already.
10876 ASSERT(elem->IsLiteralNode()); 10876 ASSERT(elem->IsLiteralNode());
10877 ASSERT(!is_top_level_); // We cannot check unresolved types. 10877 ASSERT(!is_top_level_); // We cannot check unresolved types.
10878 if (FLAG_enable_type_checks && 10878 if (I->TypeChecksEnabled() &&
10879 !element_type.IsDynamicType() && 10879 !element_type.IsDynamicType() &&
10880 (!elem->AsLiteralNode()->literal().IsNull() && 10880 (!elem->AsLiteralNode()->literal().IsNull() &&
10881 !elem->AsLiteralNode()->literal().IsInstanceOf( 10881 !elem->AsLiteralNode()->literal().IsInstanceOf(
10882 element_type, 10882 element_type,
10883 TypeArguments::Handle(Z), 10883 TypeArguments::Handle(Z),
10884 &malformed_error))) { 10884 &malformed_error))) {
10885 // If the failure is due to a malformed type error, display it instead. 10885 // If the failure is due to a malformed type error, display it instead.
10886 if (!malformed_error.IsNull()) { 10886 if (!malformed_error.IsNull()) {
10887 ReportError(malformed_error); 10887 ReportError(malformed_error);
10888 } else { 10888 } else {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
11011 // No declared bounds in Map. 11011 // No declared bounds in Map.
11012 ASSERT(!key_type.IsMalbounded() && !value_type.IsMalbounded()); 11012 ASSERT(!key_type.IsMalbounded() && !value_type.IsMalbounded());
11013 if (key_type.IsDynamicType() && value_type.IsDynamicType()) { 11013 if (key_type.IsDynamicType() && value_type.IsDynamicType()) {
11014 map_type_arguments = TypeArguments::null(); 11014 map_type_arguments = TypeArguments::null();
11015 } else if (is_const && !type_arguments.IsInstantiated()) { 11015 } else if (is_const && !type_arguments.IsInstantiated()) {
11016 ReportError(type_pos, 11016 ReportError(type_pos,
11017 "the type arguments of a constant map literal cannot " 11017 "the type arguments of a constant map literal cannot "
11018 "include a type variable"); 11018 "include a type variable");
11019 } 11019 }
11020 } else { 11020 } else {
11021 if (FLAG_error_on_bad_type) { 11021 if (I->ErrorOnBadTypeEnabled()) {
11022 ReportError(type_pos, 11022 ReportError(type_pos,
11023 "a map literal takes two type arguments specifying " 11023 "a map literal takes two type arguments specifying "
11024 "the key type and the value type"); 11024 "the key type and the value type");
11025 } 11025 }
11026 // Ignore type arguments. 11026 // Ignore type arguments.
11027 map_type_arguments = TypeArguments::null(); 11027 map_type_arguments = TypeArguments::null();
11028 } 11028 }
11029 } 11029 }
11030 ASSERT(map_type_arguments.IsNull() || (map_type_arguments.Length() == 2)); 11030 ASSERT(map_type_arguments.IsNull() || (map_type_arguments.Length() == 2));
11031 map_type_arguments ^= map_type_arguments.Canonicalize(); 11031 map_type_arguments ^= map_type_arguments.Canonicalize();
11032 11032
11033 GrowableArray<AstNode*> kv_pairs_list; 11033 GrowableArray<AstNode*> kv_pairs_list;
11034 // Parse the map entries. Note: there may be an optional extra 11034 // Parse the map entries. Note: there may be an optional extra
11035 // comma after the last entry. 11035 // comma after the last entry.
11036 while (CurrentToken() != Token::kRBRACE) { 11036 while (CurrentToken() != Token::kRBRACE) {
11037 const bool saved_mode = SetAllowFunctionLiterals(true); 11037 const bool saved_mode = SetAllowFunctionLiterals(true);
11038 const intptr_t key_pos = TokenPos(); 11038 const intptr_t key_pos = TokenPos();
11039 AstNode* key = ParseExpr(is_const, kConsumeCascades); 11039 AstNode* key = ParseExpr(is_const, kConsumeCascades);
11040 if (FLAG_enable_type_checks && 11040 if (I->TypeChecksEnabled() &&
11041 !is_const && 11041 !is_const &&
11042 !key_type.IsDynamicType()) { 11042 !key_type.IsDynamicType()) {
11043 key = new(Z) AssignableNode( 11043 key = new(Z) AssignableNode(
11044 key_pos, key, key_type, Symbols::ListLiteralElement()); 11044 key_pos, key, key_type, Symbols::ListLiteralElement());
11045 } 11045 }
11046 if (is_const) { 11046 if (is_const) {
11047 ASSERT(key->IsLiteralNode()); 11047 ASSERT(key->IsLiteralNode());
11048 const Instance& key_value = key->AsLiteralNode()->literal(); 11048 const Instance& key_value = key->AsLiteralNode()->literal();
11049 if (key_value.IsDouble()) { 11049 if (key_value.IsDouble()) {
11050 ReportError(key_pos, "key value must not be of type double"); 11050 ReportError(key_pos, "key value must not be of type double");
11051 } 11051 }
11052 if (!key_value.IsInteger() && 11052 if (!key_value.IsInteger() &&
11053 !key_value.IsString() && 11053 !key_value.IsString() &&
11054 (key_value.clazz() != I->object_store()->symbol_class()) && 11054 (key_value.clazz() != I->object_store()->symbol_class()) &&
11055 ImplementsEqualOperator(key_value)) { 11055 ImplementsEqualOperator(key_value)) {
11056 ReportError(key_pos, "key value must not implement operator =="); 11056 ReportError(key_pos, "key value must not implement operator ==");
11057 } 11057 }
11058 } 11058 }
11059 ExpectToken(Token::kCOLON); 11059 ExpectToken(Token::kCOLON);
11060 const intptr_t value_pos = TokenPos(); 11060 const intptr_t value_pos = TokenPos();
11061 AstNode* value = ParseExpr(is_const, kConsumeCascades); 11061 AstNode* value = ParseExpr(is_const, kConsumeCascades);
11062 SetAllowFunctionLiterals(saved_mode); 11062 SetAllowFunctionLiterals(saved_mode);
11063 if (FLAG_enable_type_checks && 11063 if (I->TypeChecksEnabled() &&
11064 !is_const && 11064 !is_const &&
11065 !value_type.IsDynamicType()) { 11065 !value_type.IsDynamicType()) {
11066 value = new(Z) AssignableNode( 11066 value = new(Z) AssignableNode(
11067 value_pos, value, value_type, Symbols::ListLiteralElement()); 11067 value_pos, value, value_type, Symbols::ListLiteralElement());
11068 } 11068 }
11069 AddKeyValuePair(&kv_pairs_list, is_const, key, value); 11069 AddKeyValuePair(&kv_pairs_list, is_const, key, value);
11070 11070
11071 if (CurrentToken() == Token::kCOMMA) { 11071 if (CurrentToken() == Token::kCOMMA) {
11072 ConsumeToken(); 11072 ConsumeToken();
11073 } else if (CurrentToken() != Token::kRBRACE) { 11073 } else if (CurrentToken() != Token::kRBRACE) {
(...skipping 11 matching lines...) Expand all
11085 // First, create the canonicalized key-value pair array. 11085 // First, create the canonicalized key-value pair array.
11086 Array& key_value_array = 11086 Array& key_value_array =
11087 Array::ZoneHandle(Z, Array::New(kv_pairs_list.length(), Heap::kOld)); 11087 Array::ZoneHandle(Z, Array::New(kv_pairs_list.length(), Heap::kOld));
11088 AbstractType& arg_type = Type::Handle(Z); 11088 AbstractType& arg_type = Type::Handle(Z);
11089 Error& malformed_error = Error::Handle(Z); 11089 Error& malformed_error = Error::Handle(Z);
11090 for (int i = 0; i < kv_pairs_list.length(); i++) { 11090 for (int i = 0; i < kv_pairs_list.length(); i++) {
11091 AstNode* arg = kv_pairs_list[i]; 11091 AstNode* arg = kv_pairs_list[i];
11092 // Arguments have been evaluated to a literal value already. 11092 // Arguments have been evaluated to a literal value already.
11093 ASSERT(arg->IsLiteralNode()); 11093 ASSERT(arg->IsLiteralNode());
11094 ASSERT(!is_top_level_); // We cannot check unresolved types. 11094 ASSERT(!is_top_level_); // We cannot check unresolved types.
11095 if (FLAG_enable_type_checks) { 11095 if (I->TypeChecksEnabled()) {
11096 if ((i % 2) == 0) { 11096 if ((i % 2) == 0) {
11097 // Check key type. 11097 // Check key type.
11098 arg_type = key_type.raw(); 11098 arg_type = key_type.raw();
11099 } else { 11099 } else {
11100 // Check value type. 11100 // Check value type.
11101 arg_type = value_type.raw(); 11101 arg_type = value_type.raw();
11102 } 11102 }
11103 if (!arg_type.IsDynamicType() && 11103 if (!arg_type.IsDynamicType() &&
11104 (!arg->AsLiteralNode()->literal().IsNull() && 11104 (!arg->AsLiteralNode()->literal().IsNull() &&
11105 !arg->AsLiteralNode()->literal().IsInstanceOf( 11105 !arg->AsLiteralNode()->literal().IsInstanceOf(
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
11410 "redirecting factory type '%s' cannot be instantiated", 11410 "redirecting factory type '%s' cannot be instantiated",
11411 String::Handle(Z, redirect_type.UserVisibleName()).ToCString()); 11411 String::Handle(Z, redirect_type.UserVisibleName()).ToCString());
11412 } 11412 }
11413 } 11413 }
11414 if (redirect_type.IsMalformedOrMalbounded()) { 11414 if (redirect_type.IsMalformedOrMalbounded()) {
11415 if (is_const) { 11415 if (is_const) {
11416 ReportError(Error::Handle(Z, redirect_type.error())); 11416 ReportError(Error::Handle(Z, redirect_type.error()));
11417 } 11417 }
11418 return ThrowTypeError(redirect_type.token_pos(), redirect_type); 11418 return ThrowTypeError(redirect_type.token_pos(), redirect_type);
11419 } 11419 }
11420 if (FLAG_enable_type_checks && !redirect_type.IsSubtypeOf(type, NULL)) { 11420 if (I->TypeChecksEnabled() && !redirect_type.IsSubtypeOf(type, NULL)) {
11421 // Additional type checking of the result is necessary. 11421 // Additional type checking of the result is necessary.
11422 type_bound = type.raw(); 11422 type_bound = type.raw();
11423 } 11423 }
11424 type = redirect_type.raw(); 11424 type = redirect_type.raw();
11425 type_class = type.type_class(); 11425 type_class = type.type_class();
11426 type_class_name = type_class.Name(); 11426 type_class_name = type_class.Name();
11427 type_arguments = type.arguments(); 11427 type_arguments = type.arguments();
11428 constructor = constructor.RedirectionTarget(); 11428 constructor = constructor.RedirectionTarget();
11429 constructor_name = constructor.name(); 11429 constructor_name = constructor.name();
11430 ASSERT(!constructor.IsNull()); 11430 ASSERT(!constructor.IsNull());
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
12232 void Parser::SkipQualIdent() { 12232 void Parser::SkipQualIdent() {
12233 ASSERT(IsIdentifier()); 12233 ASSERT(IsIdentifier());
12234 ConsumeToken(); 12234 ConsumeToken();
12235 if (CurrentToken() == Token::kPERIOD) { 12235 if (CurrentToken() == Token::kPERIOD) {
12236 ConsumeToken(); // Consume the kPERIOD token. 12236 ConsumeToken(); // Consume the kPERIOD token.
12237 ExpectIdentifier("identifier expected after '.'"); 12237 ExpectIdentifier("identifier expected after '.'");
12238 } 12238 }
12239 } 12239 }
12240 12240
12241 } // namespace dart 12241 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698