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 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
974 ParsedFunction* parsed_function = new ParsedFunction( | 974 ParsedFunction* parsed_function = new ParsedFunction( |
975 thread, Function::ZoneHandle(zone, func.raw())); | 975 thread, Function::ZoneHandle(zone, func.raw())); |
976 Parser parser(script, parsed_function, func.token_pos()); | 976 Parser parser(script, parsed_function, func.token_pos()); |
977 parser.SkipFunctionPreamble(); | 977 parser.SkipFunctionPreamble(); |
978 ParamList params; | 978 ParamList params; |
979 parser.ParseFormalParameterList(true, true, ¶ms); | 979 parser.ParseFormalParameterList(true, true, ¶ms); |
980 ParamDesc* param = params.parameters->data(); | 980 ParamDesc* param = params.parameters->data(); |
981 const int param_cnt = params.num_fixed_parameters + | 981 const int param_cnt = params.num_fixed_parameters + |
982 params.num_optional_parameters; | 982 params.num_optional_parameters; |
983 const Array& param_descriptor = | 983 const Array& param_descriptor = |
984 Array::Handle(Array::New(param_cnt * kParameterEntrySize)); | 984 Array::Handle(Array::New(param_cnt * kParameterEntrySize, Heap::kOld)); |
985 for (int i = 0, j = 0; i < param_cnt; i++, j += kParameterEntrySize) { | 985 for (int i = 0, j = 0; i < param_cnt; i++, j += kParameterEntrySize) { |
986 param_descriptor.SetAt(j + kParameterIsFinalOffset, | 986 param_descriptor.SetAt(j + kParameterIsFinalOffset, |
987 param[i].is_final ? Bool::True() : Bool::False()); | 987 param[i].is_final ? Bool::True() : Bool::False()); |
988 param_descriptor.SetAt(j + kParameterDefaultValueOffset, | 988 param_descriptor.SetAt(j + kParameterDefaultValueOffset, |
989 (param[i].default_value == NULL) ? Object::null_instance() : | 989 (param[i].default_value == NULL) ? Object::null_instance() : |
990 *(param[i].default_value)); | 990 *(param[i].default_value)); |
991 const Object* metadata = param[i].metadata; | 991 const Object* metadata = param[i].metadata; |
992 if ((metadata != NULL) && (*metadata).IsError()) { | 992 if ((metadata != NULL) && (*metadata).IsError()) { |
993 return metadata->raw(); // Error evaluating the metadata. | 993 return metadata->raw(); // Error evaluating the metadata. |
994 } | 994 } |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1511 AddFormalParamsToScope(¶ms, scope); | 1511 AddFormalParamsToScope(¶ms, scope); |
1512 | 1512 |
1513 ArgumentListNode* ctor_args = new ArgumentListNode(token_pos); | 1513 ArgumentListNode* ctor_args = new ArgumentListNode(token_pos); |
1514 // Skip implicit closure parameter at 0. | 1514 // Skip implicit closure parameter at 0. |
1515 for (intptr_t i = 1; i < func.NumParameters(); i++) { | 1515 for (intptr_t i = 1; i < func.NumParameters(); i++) { |
1516 ctor_args->Add(new LoadLocalNode(token_pos, scope->VariableAt(i))); | 1516 ctor_args->Add(new LoadLocalNode(token_pos, scope->VariableAt(i))); |
1517 } | 1517 } |
1518 | 1518 |
1519 if (func.HasOptionalNamedParameters()) { | 1519 if (func.HasOptionalNamedParameters()) { |
1520 const Array& arg_names = | 1520 const Array& arg_names = |
1521 Array::ZoneHandle(Array::New(func.NumOptionalParameters())); | 1521 Array::ZoneHandle(Array::New(func.NumOptionalParameters(), Heap::kOld)); |
1522 for (intptr_t i = 0; i < arg_names.Length(); i++) { | 1522 for (intptr_t i = 0; i < arg_names.Length(); i++) { |
1523 intptr_t index = func.num_fixed_parameters() + i; | 1523 intptr_t index = func.num_fixed_parameters() + i; |
1524 arg_names.SetAt(i, String::Handle(func.ParameterNameAt(index))); | 1524 arg_names.SetAt(i, String::Handle(func.ParameterNameAt(index))); |
1525 } | 1525 } |
1526 ctor_args->set_names(arg_names); | 1526 ctor_args->set_names(arg_names); |
1527 } | 1527 } |
1528 | 1528 |
1529 AstNode* new_object = | 1529 AstNode* new_object = |
1530 CreateConstructorCallNode(token_pos, type_args, constructor, ctor_args); | 1530 CreateConstructorCallNode(token_pos, type_args, constructor, ctor_args); |
1531 ReturnNode* return_node = new ReturnNode(token_pos, new_object); | 1531 ReturnNode* return_node = new ReturnNode(token_pos, new_object); |
(...skipping 3801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5333 } | 5333 } |
5334 return TypeArguments::null(); | 5334 return TypeArguments::null(); |
5335 } | 5335 } |
5336 | 5336 |
5337 | 5337 |
5338 // Parse interface list and add to class cls. | 5338 // Parse interface list and add to class cls. |
5339 void Parser::ParseInterfaceList(const Class& cls) { | 5339 void Parser::ParseInterfaceList(const Class& cls) { |
5340 TRACE_PARSER("ParseInterfaceList"); | 5340 TRACE_PARSER("ParseInterfaceList"); |
5341 ASSERT(CurrentToken() == Token::kIMPLEMENTS); | 5341 ASSERT(CurrentToken() == Token::kIMPLEMENTS); |
5342 const GrowableObjectArray& all_interfaces = | 5342 const GrowableObjectArray& all_interfaces = |
5343 GrowableObjectArray::Handle(Z, GrowableObjectArray::New()); | 5343 GrowableObjectArray::Handle(Z, GrowableObjectArray::New(Heap::kOld)); |
5344 AbstractType& interface = AbstractType::Handle(Z); | 5344 AbstractType& interface = AbstractType::Handle(Z); |
5345 // First get all the interfaces already implemented by class. | 5345 // First get all the interfaces already implemented by class. |
5346 Array& cls_interfaces = Array::Handle(Z, cls.interfaces()); | 5346 Array& cls_interfaces = Array::Handle(Z, cls.interfaces()); |
5347 for (intptr_t i = 0; i < cls_interfaces.Length(); i++) { | 5347 for (intptr_t i = 0; i < cls_interfaces.Length(); i++) { |
5348 interface ^= cls_interfaces.At(i); | 5348 interface ^= cls_interfaces.At(i); |
5349 all_interfaces.Add(interface); | 5349 all_interfaces.Add(interface); |
5350 } | 5350 } |
5351 // Now parse and add the new interfaces. | 5351 // Now parse and add the new interfaces. |
5352 do { | 5352 do { |
5353 ConsumeToken(); | 5353 ConsumeToken(); |
5354 TokenPosition interface_pos = TokenPos(); | 5354 TokenPosition interface_pos = TokenPos(); |
5355 interface = ParseType(ClassFinalizer::kResolveTypeParameters); | 5355 interface = ParseType(ClassFinalizer::kResolveTypeParameters); |
5356 if (interface.IsTypeParameter()) { | 5356 if (interface.IsTypeParameter()) { |
5357 ReportError(interface_pos, | 5357 ReportError(interface_pos, |
5358 "type parameter '%s' may not be used in interface list", | 5358 "type parameter '%s' may not be used in interface list", |
5359 String::Handle(Z, interface.UserVisibleName()).ToCString()); | 5359 String::Handle(Z, interface.UserVisibleName()).ToCString()); |
5360 } | 5360 } |
5361 all_interfaces.Add(interface); | 5361 all_interfaces.Add(interface); |
5362 } while (CurrentToken() == Token::kCOMMA); | 5362 } while (CurrentToken() == Token::kCOMMA); |
5363 cls_interfaces = Array::MakeArray(all_interfaces); | 5363 cls_interfaces = Array::MakeArray(all_interfaces); |
5364 cls.set_interfaces(cls_interfaces); | 5364 cls.set_interfaces(cls_interfaces); |
5365 } | 5365 } |
5366 | 5366 |
5367 | 5367 |
5368 RawAbstractType* Parser::ParseMixins(const AbstractType& super_type) { | 5368 RawAbstractType* Parser::ParseMixins(const AbstractType& super_type) { |
5369 TRACE_PARSER("ParseMixins"); | 5369 TRACE_PARSER("ParseMixins"); |
5370 ASSERT(CurrentToken() == Token::kWITH); | 5370 ASSERT(CurrentToken() == Token::kWITH); |
5371 const GrowableObjectArray& mixin_types = | 5371 const GrowableObjectArray& mixin_types = |
5372 GrowableObjectArray::Handle(Z, GrowableObjectArray::New()); | 5372 GrowableObjectArray::Handle(Z, GrowableObjectArray::New(Heap::kOld)); |
5373 AbstractType& mixin_type = AbstractType::Handle(Z); | 5373 AbstractType& mixin_type = AbstractType::Handle(Z); |
5374 do { | 5374 do { |
5375 ConsumeToken(); | 5375 ConsumeToken(); |
5376 mixin_type = ParseType(ClassFinalizer::kResolveTypeParameters); | 5376 mixin_type = ParseType(ClassFinalizer::kResolveTypeParameters); |
5377 if (mixin_type.IsDynamicType()) { | 5377 if (mixin_type.IsDynamicType()) { |
5378 // The string 'dynamic' is not resolved yet at this point, but a malformed | 5378 // The string 'dynamic' is not resolved yet at this point, but a malformed |
5379 // type mapped to dynamic can be encountered here. | 5379 // type mapped to dynamic can be encountered here. |
5380 ReportError(mixin_type.token_pos(), "illegal mixin of a malformed type"); | 5380 ReportError(mixin_type.token_pos(), "illegal mixin of a malformed type"); |
5381 } | 5381 } |
5382 if (mixin_type.IsTypeParameter()) { | 5382 if (mixin_type.IsTypeParameter()) { |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5867 if (CurrentToken() != Token::kCOMMA) { | 5867 if (CurrentToken() != Token::kCOMMA) { |
5868 return; | 5868 return; |
5869 } | 5869 } |
5870 ConsumeToken(); // Comma. | 5870 ConsumeToken(); // Comma. |
5871 } | 5871 } |
5872 } | 5872 } |
5873 | 5873 |
5874 | 5874 |
5875 void Parser::ParseLibraryImportExport(const Object& tl_owner, | 5875 void Parser::ParseLibraryImportExport(const Object& tl_owner, |
5876 TokenPosition metadata_pos) { | 5876 TokenPosition metadata_pos) { |
5877 ASSERT(Thread::Current()->IsMutatorThread()); | |
5877 bool is_import = (CurrentToken() == Token::kIMPORT); | 5878 bool is_import = (CurrentToken() == Token::kIMPORT); |
5878 bool is_export = (CurrentToken() == Token::kEXPORT); | 5879 bool is_export = (CurrentToken() == Token::kEXPORT); |
5879 ASSERT(is_import || is_export); | 5880 ASSERT(is_import || is_export); |
5880 const TokenPosition import_pos = TokenPos(); | 5881 const TokenPosition import_pos = TokenPos(); |
5881 ConsumeToken(); | 5882 ConsumeToken(); |
5882 CheckToken(Token::kSTRING, "library url expected"); | 5883 CheckToken(Token::kSTRING, "library url expected"); |
5883 AstNode* url_literal = ParseStringLiteral(false); | 5884 AstNode* url_literal = ParseStringLiteral(false); |
5884 if (FLAG_conditional_directives) { | 5885 if (FLAG_conditional_directives) { |
5885 bool condition_triggered = false; | 5886 bool condition_triggered = false; |
5886 while (CurrentToken() == Token::kIF) { | 5887 while (CurrentToken() == Token::kIF) { |
(...skipping 2491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8378 // End of switch statement. | 8379 // End of switch statement. |
8379 break; | 8380 break; |
8380 } | 8381 } |
8381 if ((next_token == Token::kCASE) || (next_token == Token::kDEFAULT)) { | 8382 if ((next_token == Token::kCASE) || (next_token == Token::kDEFAULT)) { |
8382 // End of this case clause. If there is a possible fall-through to | 8383 // End of this case clause. If there is a possible fall-through to |
8383 // the next case clause, throw an implicit FallThroughError. | 8384 // the next case clause, throw an implicit FallThroughError. |
8384 if (!abrupt_completing_seen) { | 8385 if (!abrupt_completing_seen) { |
8385 ArgumentListNode* arguments = new(Z) ArgumentListNode(TokenPos()); | 8386 ArgumentListNode* arguments = new(Z) ArgumentListNode(TokenPos()); |
8386 arguments->Add(new(Z) LiteralNode( | 8387 arguments->Add(new(Z) LiteralNode( |
8387 TokenPos(), | 8388 TokenPos(), |
8388 Integer::ZoneHandle(Z, Integer::New(TokenPos().value())))); | 8389 Integer::ZoneHandle(Z, Integer::New(TokenPos().value(), |
8390 Heap::kOld)))); | |
8389 current_block_->statements->Add( | 8391 current_block_->statements->Add( |
8390 MakeStaticCall(Symbols::FallThroughError(), | 8392 MakeStaticCall(Symbols::FallThroughError(), |
8391 Library::PrivateCoreLibName(Symbols::ThrowNew()), | 8393 Library::PrivateCoreLibName(Symbols::ThrowNew()), |
8392 arguments)); | 8394 arguments)); |
8393 } | 8395 } |
8394 break; | 8396 break; |
8395 } | 8397 } |
8396 // The next statement still belongs to this case. | 8398 // The next statement still belongs to this case. |
8397 AstNode* statement = ParseStatement(); | 8399 AstNode* statement = ParseStatement(); |
8398 if (statement != NULL) { | 8400 if (statement != NULL) { |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9157 arguments->length(), | 9159 arguments->length(), |
9158 arguments->names())); | 9160 arguments->names())); |
9159 ASSERT(!func.IsNull()); | 9161 ASSERT(!func.IsNull()); |
9160 return new(Z) StaticCallNode(arguments->token_pos(), func, arguments); | 9162 return new(Z) StaticCallNode(arguments->token_pos(), func, arguments); |
9161 } | 9163 } |
9162 | 9164 |
9163 | 9165 |
9164 AstNode* Parser::MakeAssertCall(TokenPosition begin, TokenPosition end) { | 9166 AstNode* Parser::MakeAssertCall(TokenPosition begin, TokenPosition end) { |
9165 ArgumentListNode* arguments = new(Z) ArgumentListNode(begin); | 9167 ArgumentListNode* arguments = new(Z) ArgumentListNode(begin); |
9166 arguments->Add(new(Z) LiteralNode(begin, | 9168 arguments->Add(new(Z) LiteralNode(begin, |
9167 Integer::ZoneHandle(Z, Integer::New(begin.value())))); | 9169 Integer::ZoneHandle(Z, Integer::New(begin.value(), Heap::kOld)))); |
9168 arguments->Add(new(Z) LiteralNode(end, | 9170 arguments->Add(new(Z) LiteralNode(end, |
9169 Integer::ZoneHandle(Z, Integer::New(end.value())))); | 9171 Integer::ZoneHandle(Z, Integer::New(end.value(), Heap::kOld)))); |
9170 return MakeStaticCall(Symbols::AssertionError(), | 9172 return MakeStaticCall(Symbols::AssertionError(), |
9171 Library::PrivateCoreLibName(Symbols::ThrowNew()), | 9173 Library::PrivateCoreLibName(Symbols::ThrowNew()), |
9172 arguments); | 9174 arguments); |
9173 } | 9175 } |
9174 | 9176 |
9175 | 9177 |
9176 AstNode* Parser::InsertClosureCallNodes(AstNode* condition) { | 9178 AstNode* Parser::InsertClosureCallNodes(AstNode* condition) { |
9177 if (condition->IsClosureNode() || | 9179 if (condition->IsClosureNode() || |
9178 (condition->IsStoreLocalNode() && | 9180 (condition->IsStoreLocalNode() && |
9179 condition->AsStoreLocalNode()->value()->IsClosureNode())) { | 9181 condition->AsStoreLocalNode()->value()->IsClosureNode())) { |
(...skipping 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10462 String& method_name = String::Handle(Z); | 10464 String& method_name = String::Handle(Z); |
10463 if (prefix == NULL) { | 10465 if (prefix == NULL) { |
10464 method_name = Library::PrivateCoreLibName(Symbols::ThrowNew()).raw(); | 10466 method_name = Library::PrivateCoreLibName(Symbols::ThrowNew()).raw(); |
10465 } else { | 10467 } else { |
10466 arguments->Add(new(Z) LiteralNode(type_pos, *prefix)); | 10468 arguments->Add(new(Z) LiteralNode(type_pos, *prefix)); |
10467 method_name = Library::PrivateCoreLibName( | 10469 method_name = Library::PrivateCoreLibName( |
10468 Symbols::ThrowNewIfNotLoaded()).raw(); | 10470 Symbols::ThrowNewIfNotLoaded()).raw(); |
10469 } | 10471 } |
10470 // Location argument. | 10472 // Location argument. |
10471 arguments->Add(new(Z) LiteralNode( | 10473 arguments->Add(new(Z) LiteralNode( |
10472 type_pos, Integer::ZoneHandle(Z, Integer::New(type_pos.value())))); | 10474 type_pos, Integer::ZoneHandle(Z, Integer::New(type_pos.value(), |
10475 Heap::kOld)))); | |
10473 // Src value argument. | 10476 // Src value argument. |
10474 arguments->Add(new(Z) LiteralNode(type_pos, Object::null_instance())); | 10477 arguments->Add(new(Z) LiteralNode(type_pos, Object::null_instance())); |
10475 // Dst type argument. | 10478 // Dst type argument. |
10476 arguments->Add(new(Z) LiteralNode(type_pos, type)); | 10479 arguments->Add(new(Z) LiteralNode(type_pos, type)); |
10477 // Dst name argument. | 10480 // Dst name argument. |
10478 arguments->Add(new(Z) LiteralNode(type_pos, Symbols::Empty())); | 10481 arguments->Add(new(Z) LiteralNode(type_pos, Symbols::Empty())); |
10479 // Bound error msg argument. | 10482 // Bound error msg argument. |
10480 arguments->Add(new(Z) LiteralNode(type_pos, Object::null_instance())); | 10483 arguments->Add(new(Z) LiteralNode(type_pos, Object::null_instance())); |
10481 return MakeStaticCall(Symbols::TypeError(), method_name, arguments); | 10484 return MakeStaticCall(Symbols::TypeError(), method_name, arguments); |
10482 } | 10485 } |
(...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11690 } else { | 11693 } else { |
11691 // Treat as call to unresolved (instance) method. | 11694 // Treat as call to unresolved (instance) method. |
11692 selector = ParseInstanceCall(LoadReceiver(primary_pos), | 11695 selector = ParseInstanceCall(LoadReceiver(primary_pos), |
11693 name, | 11696 name, |
11694 primary_pos, | 11697 primary_pos, |
11695 false /* is_conditional */); | 11698 false /* is_conditional */); |
11696 } | 11699 } |
11697 } else if (primary_node->primary().IsClass()) { | 11700 } else if (primary_node->primary().IsClass()) { |
11698 const Class& type_class = Class::Cast(primary_node->primary()); | 11701 const Class& type_class = Class::Cast(primary_node->primary()); |
11699 AbstractType& type = Type::ZoneHandle(Z, Type::New( | 11702 AbstractType& type = Type::ZoneHandle(Z, Type::New( |
11700 type_class, TypeArguments::Handle(Z), primary_pos)); | 11703 type_class, TypeArguments::Handle(Z), primary_pos, Heap::kOld)); |
siva
2016/06/09 20:51:41
Type::New by default allocates in the kOld, but th
| |
11701 type ^= ClassFinalizer::FinalizeType( | 11704 type ^= ClassFinalizer::FinalizeType( |
11702 current_class(), type, ClassFinalizer::kCanonicalize); | 11705 current_class(), type, ClassFinalizer::kCanonicalize); |
11703 // Type may be malbounded, but not malformed. | 11706 // Type may be malbounded, but not malformed. |
11704 ASSERT(!type.IsMalformed()); | 11707 ASSERT(!type.IsMalformed()); |
11705 selector = new(Z) TypeNode(primary_pos, type); | 11708 selector = new(Z) TypeNode(primary_pos, type); |
11706 } else { | 11709 } else { |
11707 UNREACHABLE(); // Internal parser error. | 11710 UNREACHABLE(); // Internal parser error. |
11708 } | 11711 } |
11709 } else { | 11712 } else { |
11710 // Left is not a primary node; this must be a closure call. | 11713 // Left is not a primary node; this must be a closure call. |
11711 AstNode* closure = left; | 11714 AstNode* closure = left; |
11712 selector = ParseClosureCall(closure); | 11715 selector = ParseClosureCall(closure); |
11713 } | 11716 } |
11714 } else { | 11717 } else { |
11715 // No (more) selectors to parse. | 11718 // No (more) selectors to parse. |
11716 left = LoadFieldIfUnresolved(left); | 11719 left = LoadFieldIfUnresolved(left); |
11717 if (left->IsPrimaryNode()) { | 11720 if (left->IsPrimaryNode()) { |
11718 PrimaryNode* primary_node = left->AsPrimaryNode(); | 11721 PrimaryNode* primary_node = left->AsPrimaryNode(); |
11719 const TokenPosition primary_pos = primary->token_pos(); | 11722 const TokenPosition primary_pos = primary->token_pos(); |
11720 if (primary_node->primary().IsFunction()) { | 11723 if (primary_node->primary().IsFunction()) { |
11721 // Treat as implicit closure. | 11724 // Treat as implicit closure. |
11722 left = LoadClosure(primary_node); | 11725 left = LoadClosure(primary_node); |
11723 } else if (primary_node->primary().IsClass()) { | 11726 } else if (primary_node->primary().IsClass()) { |
11724 const Class& type_class = Class::Cast(primary_node->primary()); | 11727 const Class& type_class = Class::Cast(primary_node->primary()); |
11725 AbstractType& type = Type::ZoneHandle(Z, Type::New( | 11728 AbstractType& type = Type::ZoneHandle(Z, Type::New( |
11726 type_class, TypeArguments::Handle(Z), primary_pos)); | 11729 type_class, TypeArguments::Handle(Z), primary_pos, Heap::kOld)); |
11727 type = ClassFinalizer::FinalizeType( | 11730 type = ClassFinalizer::FinalizeType( |
11728 current_class(), type, ClassFinalizer::kCanonicalize); | 11731 current_class(), type, ClassFinalizer::kCanonicalize); |
11729 // Type may be malbounded, but not malformed. | 11732 // Type may be malbounded, but not malformed. |
11730 ASSERT(!type.IsMalformed()); | 11733 ASSERT(!type.IsMalformed()); |
11731 left = new(Z) TypeNode(primary_pos, type); | 11734 left = new(Z) TypeNode(primary_pos, type); |
11732 } else if (primary_node->primary().IsTypeParameter()) { | 11735 } else if (primary_node->primary().IsTypeParameter()) { |
11733 if (ParsingStaticMember()) { | 11736 if (ParsingStaticMember()) { |
11734 const String& name = String::ZoneHandle(Z, | 11737 const String& name = String::ZoneHandle(Z, |
11735 TypeParameter::Cast(primary_node->primary()).name()); | 11738 TypeParameter::Cast(primary_node->primary()).name()); |
11736 ReportError(primary_pos, | 11739 ReportError(primary_pos, |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12089 | 12092 |
12090 const AbstractType* Parser::ReceiverType(const Class& cls) { | 12093 const AbstractType* Parser::ReceiverType(const Class& cls) { |
12091 ASSERT(!cls.IsNull()); | 12094 ASSERT(!cls.IsNull()); |
12092 ASSERT(!cls.IsTypedefClass()); | 12095 ASSERT(!cls.IsTypedefClass()); |
12093 // Note that if cls is _Closure, the returned type will be _Closure, | 12096 // Note that if cls is _Closure, the returned type will be _Closure, |
12094 // and not the signature type. | 12097 // and not the signature type. |
12095 Type& type = Type::ZoneHandle(Z, cls.CanonicalType()); | 12098 Type& type = Type::ZoneHandle(Z, cls.CanonicalType()); |
12096 if (!type.IsNull()) { | 12099 if (!type.IsNull()) { |
12097 return &type; | 12100 return &type; |
12098 } | 12101 } |
12099 type = Type::New(cls, | 12102 type = Type::New(cls, TypeArguments::Handle(Z, cls.type_parameters()), |
12100 TypeArguments::Handle(Z, cls.type_parameters()), cls.token_pos()); | 12103 cls.token_pos(), Heap::kOld); |
12101 if (cls.is_type_finalized()) { | 12104 if (cls.is_type_finalized()) { |
12102 type ^= ClassFinalizer::FinalizeType( | 12105 type ^= ClassFinalizer::FinalizeType( |
12103 cls, type, ClassFinalizer::kCanonicalizeWellFormed); | 12106 cls, type, ClassFinalizer::kCanonicalizeWellFormed); |
12104 // Note that the receiver type may now be a malbounded type. | 12107 // Note that the receiver type may now be a malbounded type. |
12105 cls.SetCanonicalType(type); | 12108 cls.SetCanonicalType(type); |
12106 } | 12109 } |
12107 return &type; | 12110 return &type; |
12108 } | 12111 } |
12109 | 12112 |
12110 | 12113 |
12111 bool Parser::IsInstantiatorRequired() const { | 12114 bool Parser::IsInstantiatorRequired() const { |
12112 ASSERT(!current_function().IsNull()); | 12115 ASSERT(!current_function().IsNull()); |
12113 if (current_function().is_static() && | 12116 if (current_function().is_static() && |
12114 !current_function().IsInFactoryScope()) { | 12117 !current_function().IsInFactoryScope()) { |
12115 return false; | 12118 return false; |
12116 } | 12119 } |
12117 return current_class().IsGeneric(); | 12120 return current_class().IsGeneric(); |
12118 } | 12121 } |
12119 | 12122 |
12120 | 12123 |
12121 void Parser::InsertCachedConstantValue(const String& url, | 12124 void Parser::InsertCachedConstantValue(const String& url, |
12122 TokenPosition token_pos, | 12125 TokenPosition token_pos, |
12123 const Instance& value) { | 12126 const Instance& value) { |
12127 ASSERT(Thread::Current()->IsMutatorThread()); | |
12124 Isolate* isolate = Isolate::Current(); | 12128 Isolate* isolate = Isolate::Current(); |
12125 ConstantPosKey key(url, token_pos); | 12129 ConstantPosKey key(url, token_pos); |
12126 if (isolate->object_store()->compile_time_constants() == Array::null()) { | 12130 if (isolate->object_store()->compile_time_constants() == Array::null()) { |
12127 const intptr_t kInitialConstMapSize = 16; | 12131 const intptr_t kInitialConstMapSize = 16; |
12128 isolate->object_store()->set_compile_time_constants( | 12132 isolate->object_store()->set_compile_time_constants( |
12129 Array::Handle(HashTables::New<ConstantsMap>(kInitialConstMapSize, | 12133 Array::Handle(HashTables::New<ConstantsMap>(kInitialConstMapSize, |
12130 Heap::kNew))); | 12134 Heap::kNew))); |
12131 } | 12135 } |
12132 ConstantsMap constants(isolate->object_store()->compile_time_constants()); | 12136 ConstantsMap constants(isolate->object_store()->compile_time_constants()); |
12133 constants.InsertNewOrGetValue(key, value); | 12137 constants.InsertNewOrGetValue(key, value); |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12610 } else if (primary->primary().IsFunction()) { | 12614 } else if (primary->primary().IsFunction()) { |
12611 if (allow_closure_names) { | 12615 if (allow_closure_names) { |
12612 resolved = LoadClosure(primary); | 12616 resolved = LoadClosure(primary); |
12613 } else { | 12617 } else { |
12614 ReportError(ident_pos, "illegal reference to method '%s'", | 12618 ReportError(ident_pos, "illegal reference to method '%s'", |
12615 ident.ToCString()); | 12619 ident.ToCString()); |
12616 } | 12620 } |
12617 } else if (primary->primary().IsClass()) { | 12621 } else if (primary->primary().IsClass()) { |
12618 const Class& type_class = Class::Cast(primary->primary()); | 12622 const Class& type_class = Class::Cast(primary->primary()); |
12619 AbstractType& type = Type::ZoneHandle(Z, | 12623 AbstractType& type = Type::ZoneHandle(Z, |
12620 Type::New(type_class, TypeArguments::Handle(Z), primary_pos)); | 12624 Type::New(type_class, TypeArguments::Handle(Z), primary_pos, |
12625 Heap::kOld)); | |
12621 type ^= ClassFinalizer::FinalizeType( | 12626 type ^= ClassFinalizer::FinalizeType( |
12622 current_class(), type, ClassFinalizer::kCanonicalize); | 12627 current_class(), type, ClassFinalizer::kCanonicalize); |
12623 // Type may be malbounded, but not malformed. | 12628 // Type may be malbounded, but not malformed. |
12624 ASSERT(!type.IsMalformed()); | 12629 ASSERT(!type.IsMalformed()); |
12625 resolved = new(Z) TypeNode(primary_pos, type); | 12630 resolved = new(Z) TypeNode(primary_pos, type); |
12626 } | 12631 } |
12627 } | 12632 } |
12628 return resolved; | 12633 return resolved; |
12629 } | 12634 } |
12630 | 12635 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12741 // Leave type_class as null if type finalization mode is kIgnore. | 12746 // Leave type_class as null if type finalization mode is kIgnore. |
12742 if (finalization != ClassFinalizer::kIgnore) { | 12747 if (finalization != ClassFinalizer::kIgnore) { |
12743 type_class = UnresolvedClass::New(*prefix, type_name, ident_pos); | 12748 type_class = UnresolvedClass::New(*prefix, type_name, ident_pos); |
12744 } | 12749 } |
12745 TypeArguments& type_arguments = TypeArguments::Handle( | 12750 TypeArguments& type_arguments = TypeArguments::Handle( |
12746 Z, ParseTypeArguments(finalization)); | 12751 Z, ParseTypeArguments(finalization)); |
12747 if (finalization == ClassFinalizer::kIgnore) { | 12752 if (finalization == ClassFinalizer::kIgnore) { |
12748 return Type::DynamicType(); | 12753 return Type::DynamicType(); |
12749 } | 12754 } |
12750 AbstractType& type = AbstractType::Handle( | 12755 AbstractType& type = AbstractType::Handle( |
12751 Z, Type::New(type_class, type_arguments, ident_pos)); | 12756 Z, Type::New(type_class, type_arguments, ident_pos, Heap::kOld)); |
12752 if (finalization >= ClassFinalizer::kResolveTypeParameters) { | 12757 if (finalization >= ClassFinalizer::kResolveTypeParameters) { |
12753 ResolveTypeFromClass(current_class(), finalization, &type); | 12758 ResolveTypeFromClass(current_class(), finalization, &type); |
12754 if (finalization >= ClassFinalizer::kCanonicalize) { | 12759 if (finalization >= ClassFinalizer::kCanonicalize) { |
12755 type ^= ClassFinalizer::FinalizeType(current_class(), type, finalization); | 12760 type ^= ClassFinalizer::FinalizeType(current_class(), type, finalization); |
12756 } | 12761 } |
12757 } | 12762 } |
12758 return type.raw(); | 12763 return type.raw(); |
12759 } | 12764 } |
12760 | 12765 |
12761 | 12766 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12824 "a list literal takes one type argument specifying " | 12829 "a list literal takes one type argument specifying " |
12825 "the element type"); | 12830 "the element type"); |
12826 } | 12831 } |
12827 // Ignore type arguments. | 12832 // Ignore type arguments. |
12828 list_type_arguments = TypeArguments::null(); | 12833 list_type_arguments = TypeArguments::null(); |
12829 } | 12834 } |
12830 } | 12835 } |
12831 ASSERT(list_type_arguments.IsNull() || (list_type_arguments.Length() == 1)); | 12836 ASSERT(list_type_arguments.IsNull() || (list_type_arguments.Length() == 1)); |
12832 const Class& array_class = Class::Handle(Z, I->object_store()->array_class()); | 12837 const Class& array_class = Class::Handle(Z, I->object_store()->array_class()); |
12833 Type& type = Type::ZoneHandle(Z, | 12838 Type& type = Type::ZoneHandle(Z, |
12834 Type::New(array_class, list_type_arguments, type_pos)); | 12839 Type::New(array_class, list_type_arguments, type_pos, Heap::kOld)); |
12835 type ^= ClassFinalizer::FinalizeType( | 12840 type ^= ClassFinalizer::FinalizeType( |
12836 current_class(), type, ClassFinalizer::kCanonicalize); | 12841 current_class(), type, ClassFinalizer::kCanonicalize); |
12837 GrowableArray<AstNode*> element_list; | 12842 GrowableArray<AstNode*> element_list; |
12838 // Parse the list elements. Note: there may be an optional extra | 12843 // Parse the list elements. Note: there may be an optional extra |
12839 // comma after the last element. | 12844 // comma after the last element. |
12840 if (!is_empty_literal) { | 12845 if (!is_empty_literal) { |
12841 const bool saved_mode = SetAllowFunctionLiterals(true); | 12846 const bool saved_mode = SetAllowFunctionLiterals(true); |
12842 while (CurrentToken() != Token::kRBRACK) { | 12847 while (CurrentToken() != Token::kRBRACK) { |
12843 const TokenPosition element_pos = TokenPos(); | 12848 const TokenPosition element_pos = TokenPos(); |
12844 AstNode* element = ParseExpr(is_const, kConsumeCascades); | 12849 AstNode* element = ParseExpr(is_const, kConsumeCascades); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12916 // Make sure that the instantiator is captured. | 12921 // Make sure that the instantiator is captured. |
12917 CaptureInstantiator(); | 12922 CaptureInstantiator(); |
12918 } | 12923 } |
12919 TypeArguments& factory_type_args = | 12924 TypeArguments& factory_type_args = |
12920 TypeArguments::ZoneHandle(Z, list_type_arguments.raw()); | 12925 TypeArguments::ZoneHandle(Z, list_type_arguments.raw()); |
12921 // If the factory class extends other parameterized classes, adjust the | 12926 // If the factory class extends other parameterized classes, adjust the |
12922 // type argument vector. | 12927 // type argument vector. |
12923 if (!factory_type_args.IsNull() && (factory_class.NumTypeArguments() > 1)) { | 12928 if (!factory_type_args.IsNull() && (factory_class.NumTypeArguments() > 1)) { |
12924 ASSERT(factory_type_args.Length() == 1); | 12929 ASSERT(factory_type_args.Length() == 1); |
12925 Type& factory_type = Type::Handle(Z, Type::New( | 12930 Type& factory_type = Type::Handle(Z, Type::New( |
12926 factory_class, factory_type_args, type_pos, Heap::kNew)); | 12931 factory_class, factory_type_args, type_pos, Heap::kOld)); |
12927 factory_type ^= ClassFinalizer::FinalizeType( | 12932 factory_type ^= ClassFinalizer::FinalizeType( |
12928 current_class(), factory_type, ClassFinalizer::kFinalize); | 12933 current_class(), factory_type, ClassFinalizer::kFinalize); |
12929 factory_type_args = factory_type.arguments(); | 12934 factory_type_args = factory_type.arguments(); |
12930 ASSERT(factory_type_args.Length() == factory_class.NumTypeArguments()); | 12935 ASSERT(factory_type_args.Length() == factory_class.NumTypeArguments()); |
12931 } | 12936 } |
12932 factory_type_args = factory_type_args.Canonicalize(); | 12937 factory_type_args = factory_type_args.Canonicalize(); |
12933 ArgumentListNode* factory_param = new(Z) ArgumentListNode( | 12938 ArgumentListNode* factory_param = new(Z) ArgumentListNode( |
12934 literal_pos); | 12939 literal_pos); |
12935 if (element_list.length() == 0) { | 12940 if (element_list.length() == 0) { |
12936 LiteralNode* empty_array_literal = | 12941 LiteralNode* empty_array_literal = |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13178 // Make sure that the instantiator is captured. | 13183 // Make sure that the instantiator is captured. |
13179 CaptureInstantiator(); | 13184 CaptureInstantiator(); |
13180 } | 13185 } |
13181 TypeArguments& factory_type_args = | 13186 TypeArguments& factory_type_args = |
13182 TypeArguments::ZoneHandle(Z, map_type_arguments.raw()); | 13187 TypeArguments::ZoneHandle(Z, map_type_arguments.raw()); |
13183 // If the factory class extends other parameterized classes, adjust the | 13188 // If the factory class extends other parameterized classes, adjust the |
13184 // type argument vector. | 13189 // type argument vector. |
13185 if (!factory_type_args.IsNull() && (factory_class.NumTypeArguments() > 2)) { | 13190 if (!factory_type_args.IsNull() && (factory_class.NumTypeArguments() > 2)) { |
13186 ASSERT(factory_type_args.Length() == 2); | 13191 ASSERT(factory_type_args.Length() == 2); |
13187 Type& factory_type = Type::Handle(Z, Type::New( | 13192 Type& factory_type = Type::Handle(Z, Type::New( |
13188 factory_class, factory_type_args, type_pos, Heap::kNew)); | 13193 factory_class, factory_type_args, type_pos, Heap::kOld)); |
13189 factory_type ^= ClassFinalizer::FinalizeType( | 13194 factory_type ^= ClassFinalizer::FinalizeType( |
13190 current_class(), factory_type, ClassFinalizer::kFinalize); | 13195 current_class(), factory_type, ClassFinalizer::kFinalize); |
13191 factory_type_args = factory_type.arguments(); | 13196 factory_type_args = factory_type.arguments(); |
13192 ASSERT(factory_type_args.Length() == factory_class.NumTypeArguments()); | 13197 ASSERT(factory_type_args.Length() == factory_class.NumTypeArguments()); |
13193 } | 13198 } |
13194 factory_type_args = factory_type_args.Canonicalize(); | 13199 factory_type_args = factory_type_args.Canonicalize(); |
13195 ArgumentListNode* factory_param = new(Z) ArgumentListNode(literal_pos); | 13200 ArgumentListNode* factory_param = new(Z) ArgumentListNode(literal_pos); |
13196 // The kv_pair array is temporary and of element type dynamic. It is passed | 13201 // The kv_pair array is temporary and of element type dynamic. It is passed |
13197 // to the factory to initialize a properly typed map. Pass a pre-allocated | 13202 // to the factory to initialize a properly typed map. Pass a pre-allocated |
13198 // array for the common empty map literal case. | 13203 // array for the common empty map literal case. |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13632 // It is ok to call a factory method of an abstract class, but it is | 13637 // It is ok to call a factory method of an abstract class, but it is |
13633 // a dynamic error to instantiate an abstract class. | 13638 // a dynamic error to instantiate an abstract class. |
13634 if (type_class.is_abstract() && !constructor.IsFactory()) { | 13639 if (type_class.is_abstract() && !constructor.IsFactory()) { |
13635 // Evaluate arguments before throwing. | 13640 // Evaluate arguments before throwing. |
13636 LetNode* result = new(Z) LetNode(call_pos); | 13641 LetNode* result = new(Z) LetNode(call_pos); |
13637 for (intptr_t i = 0; i < arguments->length(); ++i) { | 13642 for (intptr_t i = 0; i < arguments->length(); ++i) { |
13638 result->AddNode(arguments->NodeAt(i)); | 13643 result->AddNode(arguments->NodeAt(i)); |
13639 } | 13644 } |
13640 ArgumentListNode* error_arguments = new(Z) ArgumentListNode(type_pos); | 13645 ArgumentListNode* error_arguments = new(Z) ArgumentListNode(type_pos); |
13641 error_arguments->Add(new(Z) LiteralNode( | 13646 error_arguments->Add(new(Z) LiteralNode( |
13642 TokenPos(), Integer::ZoneHandle(Z, Integer::New(type_pos.value())))); | 13647 TokenPos(), Integer::ZoneHandle(Z, Integer::New(type_pos.value(), |
13648 Heap::kOld)))); | |
13643 error_arguments->Add(new(Z) LiteralNode( | 13649 error_arguments->Add(new(Z) LiteralNode( |
13644 TokenPos(), String::ZoneHandle(Z, type_class_name.raw()))); | 13650 TokenPos(), String::ZoneHandle(Z, type_class_name.raw()))); |
13645 result->AddNode( | 13651 result->AddNode( |
13646 MakeStaticCall(Symbols::AbstractClassInstantiationError(), | 13652 MakeStaticCall(Symbols::AbstractClassInstantiationError(), |
13647 Library::PrivateCoreLibName(Symbols::ThrowNew()), | 13653 Library::PrivateCoreLibName(Symbols::ThrowNew()), |
13648 error_arguments)); | 13654 error_arguments)); |
13649 return result; | 13655 return result; |
13650 } | 13656 } |
13651 | 13657 |
13652 type_arguments ^= type_arguments.Canonicalize(); | 13658 type_arguments ^= type_arguments.Canonicalize(); |
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
14611 const ArgumentListNode& function_args, | 14617 const ArgumentListNode& function_args, |
14612 const LocalVariable* temp_for_last_arg, | 14618 const LocalVariable* temp_for_last_arg, |
14613 bool is_super_invocation) { | 14619 bool is_super_invocation) { |
14614 UNREACHABLE(); | 14620 UNREACHABLE(); |
14615 return NULL; | 14621 return NULL; |
14616 } | 14622 } |
14617 | 14623 |
14618 } // namespace dart | 14624 } // namespace dart |
14619 | 14625 |
14620 #endif // DART_PRECOMPILED_RUNTIME | 14626 #endif // DART_PRECOMPILED_RUNTIME |
OLD | NEW |