| 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 "vm/bigint_operations.h" | 8 #include "vm/bigint_operations.h" |
| 8 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
| 9 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| 10 #include "vm/compiler_stats.h" | 11 #include "vm/compiler_stats.h" |
| 11 #include "vm/dart_api_impl.h" | 12 #include "vm/dart_api_impl.h" |
| 12 #include "vm/dart_entry.h" | 13 #include "vm/dart_entry.h" |
| 13 #include "vm/flags.h" | 14 #include "vm/flags.h" |
| 14 #include "vm/growable_array.h" | 15 #include "vm/growable_array.h" |
| 15 #include "vm/longjump.h" | 16 #include "vm/longjump.h" |
| 16 #include "vm/native_entry.h" | 17 #include "vm/native_entry.h" |
| (...skipping 2370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2387 ASSERT(expr != NULL); | 2388 ASSERT(expr != NULL); |
| 2388 current_block_->statements->Add(new ReturnNode(expr_pos, expr)); | 2389 current_block_->statements->Add(new ReturnNode(expr_pos, expr)); |
| 2389 } else if (IsLiteral("native")) { | 2390 } else if (IsLiteral("native")) { |
| 2390 ParseNativeFunctionBlock(¶ms, func); | 2391 ParseNativeFunctionBlock(¶ms, func); |
| 2391 } else if (func.is_external()) { | 2392 } else if (func.is_external()) { |
| 2392 // Body of an external method contains a single throw. | 2393 // Body of an external method contains a single throw. |
| 2393 const String& function_name = String::ZoneHandle(func.name()); | 2394 const String& function_name = String::ZoneHandle(func.name()); |
| 2394 // TODO(regis): For an instance function, pass the receiver to | 2395 // TODO(regis): For an instance function, pass the receiver to |
| 2395 // NoSuchMethodError. | 2396 // NoSuchMethodError. |
| 2396 current_block_->statements->Add( | 2397 current_block_->statements->Add( |
| 2397 ThrowNoSuchMethodError(TokenPos(), current_class(), function_name)); | 2398 ThrowNoSuchMethodError(TokenPos(), |
| 2399 current_class(), |
| 2400 function_name, |
| 2401 func.is_static() ? |
| 2402 InvocationMirror::kStatic : |
| 2403 InvocationMirror::kDynamic, |
| 2404 InvocationMirror::kMethod)); |
| 2398 } else { | 2405 } else { |
| 2399 UnexpectedToken(); | 2406 UnexpectedToken(); |
| 2400 } | 2407 } |
| 2401 SequenceNode* body = CloseBlock(); | 2408 SequenceNode* body = CloseBlock(); |
| 2402 current_block_->statements->Add(body); | 2409 current_block_->statements->Add(body); |
| 2403 innermost_function_ = saved_innermost_function.raw(); | 2410 innermost_function_ = saved_innermost_function.raw(); |
| 2404 return CloseBlock(); | 2411 return CloseBlock(); |
| 2405 } | 2412 } |
| 2406 | 2413 |
| 2407 | 2414 |
| (...skipping 4434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6842 arguments); | 6849 arguments); |
| 6843 } | 6850 } |
| 6844 | 6851 |
| 6845 | 6852 |
| 6846 // TODO(regis): Providing the argument values is not always feasible, since | 6853 // TODO(regis): Providing the argument values is not always feasible, since |
| 6847 // evaluating them could throw an error. | 6854 // evaluating them could throw an error. |
| 6848 // Should NoSuchMethodError reflect the argument count and names instead of | 6855 // Should NoSuchMethodError reflect the argument count and names instead of |
| 6849 // argument values? Or should the spec specify a different evaluation order? | 6856 // argument values? Or should the spec specify a different evaluation order? |
| 6850 AstNode* Parser::ThrowNoSuchMethodError(intptr_t call_pos, | 6857 AstNode* Parser::ThrowNoSuchMethodError(intptr_t call_pos, |
| 6851 const Class& cls, | 6858 const Class& cls, |
| 6852 const String& function_name) { | 6859 const String& function_name, |
| 6860 InvocationMirror::Call im_call, |
| 6861 InvocationMirror::Type im_type) { |
| 6853 ArgumentListNode* arguments = new ArgumentListNode(call_pos); | 6862 ArgumentListNode* arguments = new ArgumentListNode(call_pos); |
| 6854 // Object receiver. | 6863 // Object receiver. |
| 6855 // TODO(regis): For now, we pass a class literal of the unresolved | 6864 // TODO(regis): For now, we pass a class literal of the unresolved |
| 6856 // method's owner, but this is not specified and will probably change. | 6865 // method's owner, but this is not specified and will probably change. |
| 6857 Type& type = Type::ZoneHandle( | 6866 Type& type = Type::ZoneHandle( |
| 6858 Type::New(cls, TypeArguments::Handle(), call_pos, Heap::kOld)); | 6867 Type::New(cls, TypeArguments::Handle(), call_pos, Heap::kOld)); |
| 6859 type ^= ClassFinalizer::FinalizeType( | 6868 type ^= ClassFinalizer::FinalizeType( |
| 6860 current_class(), type, ClassFinalizer::kCanonicalize); | 6869 current_class(), type, ClassFinalizer::kCanonicalize); |
| 6861 arguments->Add(new LiteralNode(call_pos, type)); | 6870 arguments->Add(new LiteralNode(call_pos, type)); |
| 6862 // String memberName. | 6871 // String memberName. |
| 6863 arguments->Add(new LiteralNode( | 6872 arguments->Add(new LiteralNode( |
| 6864 call_pos, String::ZoneHandle(Symbols::New(function_name)))); | 6873 call_pos, String::ZoneHandle(Symbols::New(function_name)))); |
| 6874 // Smi invocation_type. |
| 6875 if (cls.IsTopLevel()) { |
| 6876 ASSERT(im_call == InvocationMirror::kStatic || |
| 6877 im_call == InvocationMirror::kTopLevel); |
| 6878 im_call = InvocationMirror::kTopLevel; |
| 6879 } |
| 6880 arguments->Add(new LiteralNode(call_pos, Smi::ZoneHandle( |
| 6881 Smi::New(InvocationMirror::EncodeType(im_call, im_type))))); |
| 6865 // List arguments. | 6882 // List arguments. |
| 6866 arguments->Add(new LiteralNode(call_pos, Array::ZoneHandle())); | 6883 arguments->Add(new LiteralNode(call_pos, Array::ZoneHandle())); |
| 6867 // List argumentNames. | 6884 // List argumentNames. |
| 6868 arguments->Add(new LiteralNode(call_pos, Array::ZoneHandle())); | 6885 arguments->Add(new LiteralNode(call_pos, Array::ZoneHandle())); |
| 6869 // List existingArgumentNames. | 6886 // List existingArgumentNames. |
| 6870 arguments->Add(new LiteralNode(call_pos, Array::ZoneHandle())); | 6887 arguments->Add(new LiteralNode(call_pos, Array::ZoneHandle())); |
| 6871 return MakeStaticCall(Symbols::NoSuchMethodError(), | 6888 return MakeStaticCall(Symbols::NoSuchMethodError(), |
| 6872 PrivateCoreLibName(Symbols::ThrowNew()), | 6889 PrivateCoreLibName(Symbols::ThrowNew()), |
| 6873 arguments); | 6890 arguments); |
| 6874 } | 6891 } |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7166 | 7183 |
| 7167 // Ensure that the expression temp is allocated for nodes that may need it. | 7184 // Ensure that the expression temp is allocated for nodes that may need it. |
| 7168 AstNode* Parser::CreateAssignmentNode(AstNode* original, AstNode* rhs) { | 7185 AstNode* Parser::CreateAssignmentNode(AstNode* original, AstNode* rhs) { |
| 7169 AstNode* result = original->MakeAssignmentNode(rhs); | 7186 AstNode* result = original->MakeAssignmentNode(rhs); |
| 7170 if ((result == NULL) && original->IsTypeNode()) { | 7187 if ((result == NULL) && original->IsTypeNode()) { |
| 7171 const String& type_name = String::ZoneHandle( | 7188 const String& type_name = String::ZoneHandle( |
| 7172 original->AsTypeNode()->type().ClassName()); | 7189 original->AsTypeNode()->type().ClassName()); |
| 7173 // TODO(tball): determine whether NoSuchMethod should be called instead. | 7190 // TODO(tball): determine whether NoSuchMethod should be called instead. |
| 7174 result = ThrowNoSuchMethodError(original->token_pos(), | 7191 result = ThrowNoSuchMethodError(original->token_pos(), |
| 7175 current_class(), | 7192 current_class(), |
| 7176 type_name); | 7193 type_name, |
| 7194 InvocationMirror::kStatic, |
| 7195 InvocationMirror::kSetter); |
| 7177 } | 7196 } |
| 7178 if ((result != NULL) && | 7197 if ((result != NULL) && |
| 7179 (result->IsStoreIndexedNode() || | 7198 (result->IsStoreIndexedNode() || |
| 7180 result->IsInstanceSetterNode() || | 7199 result->IsInstanceSetterNode() || |
| 7181 result->IsStaticSetterNode() || | 7200 result->IsStaticSetterNode() || |
| 7182 result->IsStoreStaticFieldNode() || | 7201 result->IsStoreStaticFieldNode() || |
| 7183 result->IsStoreLocalNode())) { | 7202 result->IsStoreLocalNode())) { |
| 7184 EnsureExpressionTemp(); | 7203 EnsureExpressionTemp(); |
| 7185 } | 7204 } |
| 7186 return result; | 7205 return result; |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7451 Class::ZoneHandle(cls.raw()), | 7470 Class::ZoneHandle(cls.raw()), |
| 7452 func_name); | 7471 func_name); |
| 7453 return new ClosureCallNode(call_pos, closure, arguments); | 7472 return new ClosureCallNode(call_pos, closure, arguments); |
| 7454 } | 7473 } |
| 7455 } else { | 7474 } else { |
| 7456 EnsureSavedCurrentContext(); | 7475 EnsureSavedCurrentContext(); |
| 7457 closure = GenerateStaticFieldLookup(field, call_pos); | 7476 closure = GenerateStaticFieldLookup(field, call_pos); |
| 7458 return new ClosureCallNode(call_pos, closure, arguments); | 7477 return new ClosureCallNode(call_pos, closure, arguments); |
| 7459 } | 7478 } |
| 7460 // Could not resolve static method: throw a NoSuchMethodError. | 7479 // Could not resolve static method: throw a NoSuchMethodError. |
| 7461 return ThrowNoSuchMethodError(ident_pos, cls, func_name); | 7480 return ThrowNoSuchMethodError(ident_pos, |
| 7481 cls, |
| 7482 func_name, |
| 7483 InvocationMirror::kStatic, |
| 7484 InvocationMirror::kMethod); |
| 7462 } | 7485 } |
| 7463 return new StaticCallNode(call_pos, func, arguments); | 7486 return new StaticCallNode(call_pos, func, arguments); |
| 7464 } | 7487 } |
| 7465 | 7488 |
| 7466 | 7489 |
| 7467 AstNode* Parser::ParseInstanceCall(AstNode* receiver, const String& func_name) { | 7490 AstNode* Parser::ParseInstanceCall(AstNode* receiver, const String& func_name) { |
| 7468 TRACE_PARSER("ParseInstanceCall"); | 7491 TRACE_PARSER("ParseInstanceCall"); |
| 7469 const intptr_t call_pos = TokenPos(); | 7492 const intptr_t call_pos = TokenPos(); |
| 7470 if (CurrentToken() != Token::kLPAREN) { | 7493 if (CurrentToken() != Token::kLPAREN) { |
| 7471 ErrorMsg(call_pos, "left parenthesis expected"); | 7494 ErrorMsg(call_pos, "left parenthesis expected"); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7522 const String& setter_name = | 7545 const String& setter_name = |
| 7523 String::ZoneHandle(Field::SetterName(field_name)); | 7546 String::ZoneHandle(Field::SetterName(field_name)); |
| 7524 const int kNumArguments = 1; // value. | 7547 const int kNumArguments = 1; // value. |
| 7525 func = Resolver::ResolveStatic(cls, | 7548 func = Resolver::ResolveStatic(cls, |
| 7526 setter_name, | 7549 setter_name, |
| 7527 kNumArguments, | 7550 kNumArguments, |
| 7528 Object::empty_array(), | 7551 Object::empty_array(), |
| 7529 Resolver::kIsQualified); | 7552 Resolver::kIsQualified); |
| 7530 if (func.IsNull()) { | 7553 if (func.IsNull()) { |
| 7531 // No field or explicit setter function, throw a NoSuchMethodError. | 7554 // No field or explicit setter function, throw a NoSuchMethodError. |
| 7532 return ThrowNoSuchMethodError(ident_pos, cls, field_name); | 7555 return ThrowNoSuchMethodError(ident_pos, |
| 7556 cls, |
| 7557 field_name, |
| 7558 InvocationMirror::kStatic, |
| 7559 InvocationMirror::kField); |
| 7533 } | 7560 } |
| 7534 | 7561 |
| 7535 // Explicit setter function for the field found, field does not exist. | 7562 // Explicit setter function for the field found, field does not exist. |
| 7536 // Create a getter node first in case it is needed. If getter node | 7563 // Create a getter node first in case it is needed. If getter node |
| 7537 // is used as part of, e.g., "+=", and the explicit getter does not | 7564 // is used as part of, e.g., "+=", and the explicit getter does not |
| 7538 // exist, and error will be reported by the code generator. | 7565 // exist, and error will be reported by the code generator. |
| 7539 access = new StaticGetterNode(call_pos, | 7566 access = new StaticGetterNode(call_pos, |
| 7540 NULL, | 7567 NULL, |
| 7541 false, | 7568 false, |
| 7542 Class::ZoneHandle(cls.raw()), | 7569 Class::ZoneHandle(cls.raw()), |
| (...skipping 19 matching lines...) Expand all Loading... |
| 7562 getter_name, | 7589 getter_name, |
| 7563 kNumArguments, | 7590 kNumArguments, |
| 7564 Object::empty_array(), | 7591 Object::empty_array(), |
| 7565 Resolver::kIsQualified); | 7592 Resolver::kIsQualified); |
| 7566 if (func.IsNull()) { | 7593 if (func.IsNull()) { |
| 7567 // We might be referring to an implicit closure, check to see if | 7594 // We might be referring to an implicit closure, check to see if |
| 7568 // there is a function of the same name. | 7595 // there is a function of the same name. |
| 7569 func = cls.LookupStaticFunction(field_name); | 7596 func = cls.LookupStaticFunction(field_name); |
| 7570 if (func.IsNull()) { | 7597 if (func.IsNull()) { |
| 7571 // No field or explicit getter function, throw a NoSuchMethodError. | 7598 // No field or explicit getter function, throw a NoSuchMethodError. |
| 7572 return ThrowNoSuchMethodError(ident_pos, cls, field_name); | 7599 return ThrowNoSuchMethodError(ident_pos, |
| 7600 cls, |
| 7601 field_name, |
| 7602 InvocationMirror::kStatic, |
| 7603 InvocationMirror::kGetter); |
| 7573 } | 7604 } |
| 7574 access = CreateImplicitClosureNode(func, call_pos, NULL); | 7605 access = CreateImplicitClosureNode(func, call_pos, NULL); |
| 7575 } else { | 7606 } else { |
| 7576 ASSERT(func.kind() != RawFunction::kConstImplicitGetter); | 7607 ASSERT(func.kind() != RawFunction::kConstImplicitGetter); |
| 7577 access = new StaticGetterNode(call_pos, | 7608 access = new StaticGetterNode(call_pos, |
| 7578 NULL, | 7609 NULL, |
| 7579 false, | 7610 false, |
| 7580 Class::ZoneHandle(cls.raw()), | 7611 Class::ZoneHandle(cls.raw()), |
| 7581 field_name); | 7612 field_name); |
| 7582 } | 7613 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 7599 } | 7630 } |
| 7600 // In a static method, evaluation of an unresolved identifier causes a | 7631 // In a static method, evaluation of an unresolved identifier causes a |
| 7601 // NoSuchMethodError to be thrown. | 7632 // NoSuchMethodError to be thrown. |
| 7602 // In an instance method, we convert this into a getter call | 7633 // In an instance method, we convert this into a getter call |
| 7603 // for a field (which may be defined in a subclass.) | 7634 // for a field (which may be defined in a subclass.) |
| 7604 String& name = String::CheckedZoneHandle(primary->primary().raw()); | 7635 String& name = String::CheckedZoneHandle(primary->primary().raw()); |
| 7605 if (current_function().is_static() || | 7636 if (current_function().is_static() || |
| 7606 current_function().IsInFactoryScope()) { | 7637 current_function().IsInFactoryScope()) { |
| 7607 return ThrowNoSuchMethodError(primary->token_pos(), | 7638 return ThrowNoSuchMethodError(primary->token_pos(), |
| 7608 current_class(), | 7639 current_class(), |
| 7609 name); | 7640 name, |
| 7641 InvocationMirror::kStatic, |
| 7642 InvocationMirror::kField); |
| 7610 } else { | 7643 } else { |
| 7611 AstNode* receiver = LoadReceiver(primary->token_pos()); | 7644 AstNode* receiver = LoadReceiver(primary->token_pos()); |
| 7612 return CallGetter(node->token_pos(), receiver, name); | 7645 return CallGetter(node->token_pos(), receiver, name); |
| 7613 } | 7646 } |
| 7614 } | 7647 } |
| 7615 return primary; | 7648 return primary; |
| 7616 } | 7649 } |
| 7617 | 7650 |
| 7618 | 7651 |
| 7619 AstNode* Parser::LoadClosure(PrimaryNode* primary) { | 7652 AstNode* Parser::LoadClosure(PrimaryNode* primary) { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7737 } | 7770 } |
| 7738 } else if (primary->primary().IsString()) { | 7771 } else if (primary->primary().IsString()) { |
| 7739 // Primary is an unresolved name. | 7772 // Primary is an unresolved name. |
| 7740 if (primary->IsSuper()) { | 7773 if (primary->IsSuper()) { |
| 7741 ErrorMsg(primary->token_pos(), "illegal use of super"); | 7774 ErrorMsg(primary->token_pos(), "illegal use of super"); |
| 7742 } | 7775 } |
| 7743 String& name = String::CheckedZoneHandle(primary->primary().raw()); | 7776 String& name = String::CheckedZoneHandle(primary->primary().raw()); |
| 7744 if (current_function().is_static()) { | 7777 if (current_function().is_static()) { |
| 7745 selector = ThrowNoSuchMethodError(primary->token_pos(), | 7778 selector = ThrowNoSuchMethodError(primary->token_pos(), |
| 7746 current_class(), | 7779 current_class(), |
| 7747 name); | 7780 name, |
| 7781 InvocationMirror::kStatic, |
| 7782 InvocationMirror::kMethod); |
| 7748 } else { | 7783 } else { |
| 7749 // Treat as call to unresolved (instance) method. | 7784 // Treat as call to unresolved (instance) method. |
| 7750 AstNode* receiver = LoadReceiver(primary->token_pos()); | 7785 AstNode* receiver = LoadReceiver(primary->token_pos()); |
| 7751 selector = ParseInstanceCall(receiver, name); | 7786 selector = ParseInstanceCall(receiver, name); |
| 7752 } | 7787 } |
| 7753 } else if (primary->primary().IsClass()) { | 7788 } else if (primary->primary().IsClass()) { |
| 7754 ErrorMsg(left->token_pos(), | 7789 ErrorMsg(left->token_pos(), |
| 7755 "must use 'new' or 'const' to construct new instance"); | 7790 "must use 'new' or 'const' to construct new instance"); |
| 7756 } else { | 7791 } else { |
| 7757 UNREACHABLE(); // Internal parser error. | 7792 UNREACHABLE(); // Internal parser error. |
| (...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8656 } | 8691 } |
| 8657 if (resolved->IsPrimaryNode()) { | 8692 if (resolved->IsPrimaryNode()) { |
| 8658 PrimaryNode* primary = resolved->AsPrimaryNode(); | 8693 PrimaryNode* primary = resolved->AsPrimaryNode(); |
| 8659 if (primary->primary().IsString()) { | 8694 if (primary->primary().IsString()) { |
| 8660 // We got an unresolved name. If we are compiling a static | 8695 // We got an unresolved name. If we are compiling a static |
| 8661 // method, evaluation of an unresolved identifier causes a | 8696 // method, evaluation of an unresolved identifier causes a |
| 8662 // NoSuchMethodError to be thrown. In an instance method, we convert | 8697 // NoSuchMethodError to be thrown. In an instance method, we convert |
| 8663 // the unresolved name to an instance field access, since a | 8698 // the unresolved name to an instance field access, since a |
| 8664 // subclass might define a field with this name. | 8699 // subclass might define a field with this name. |
| 8665 if (current_function().is_static()) { | 8700 if (current_function().is_static()) { |
| 8666 resolved = ThrowNoSuchMethodError(ident_pos, current_class(), ident); | 8701 resolved = ThrowNoSuchMethodError(ident_pos, |
| 8702 current_class(), |
| 8703 ident, |
| 8704 InvocationMirror::kStatic, |
| 8705 InvocationMirror::kField); |
| 8667 } else { | 8706 } else { |
| 8668 // Treat as call to unresolved instance field. | 8707 // Treat as call to unresolved instance field. |
| 8669 resolved = CallGetter(ident_pos, LoadReceiver(ident_pos), ident); | 8708 resolved = CallGetter(ident_pos, LoadReceiver(ident_pos), ident); |
| 8670 } | 8709 } |
| 8671 } else if (primary->primary().IsFunction()) { | 8710 } else if (primary->primary().IsFunction()) { |
| 8672 if (allow_closure_names) { | 8711 if (allow_closure_names) { |
| 8673 resolved = LoadClosure(primary); | 8712 resolved = LoadClosure(primary); |
| 8674 } else { | 8713 } else { |
| 8675 ErrorMsg(ident_pos, "illegal reference to method '%s'", | 8714 ErrorMsg(ident_pos, "illegal reference to method '%s'", |
| 8676 ident.ToCString()); | 8715 ident.ToCString()); |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9256 call_pos, | 9295 call_pos, |
| 9257 ClassFinalizer::kTryResolve, // No compile-time error. | 9296 ClassFinalizer::kTryResolve, // No compile-time error. |
| 9258 "class '%s' has no constructor or factory named '%s'", | 9297 "class '%s' has no constructor or factory named '%s'", |
| 9259 String::Handle(type_class.Name()).ToCString(), | 9298 String::Handle(type_class.Name()).ToCString(), |
| 9260 external_constructor_name.ToCString()); | 9299 external_constructor_name.ToCString()); |
| 9261 const Error& error = Error::Handle(type.malformed_error()); | 9300 const Error& error = Error::Handle(type.malformed_error()); |
| 9262 ErrorMsg(error); | 9301 ErrorMsg(error); |
| 9263 } | 9302 } |
| 9264 return ThrowNoSuchMethodError(call_pos, | 9303 return ThrowNoSuchMethodError(call_pos, |
| 9265 type_class, | 9304 type_class, |
| 9266 external_constructor_name); | 9305 external_constructor_name, |
| 9306 InvocationMirror::kConstructor, |
| 9307 InvocationMirror::kMethod); |
| 9267 } else if (constructor.IsRedirectingFactory()) { | 9308 } else if (constructor.IsRedirectingFactory()) { |
| 9268 Type& redirect_type = Type::Handle(constructor.RedirectionType()); | 9309 Type& redirect_type = Type::Handle(constructor.RedirectionType()); |
| 9269 if (!redirect_type.IsMalformed() && !redirect_type.IsInstantiated()) { | 9310 if (!redirect_type.IsMalformed() && !redirect_type.IsInstantiated()) { |
| 9270 // The type arguments of the redirection type are instantiated from the | 9311 // The type arguments of the redirection type are instantiated from the |
| 9271 // type arguments of the parsed type of the 'new' or 'const' expression. | 9312 // type arguments of the parsed type of the 'new' or 'const' expression. |
| 9272 redirect_type ^= redirect_type.InstantiateFrom(type_arguments); | 9313 redirect_type ^= redirect_type.InstantiateFrom(type_arguments); |
| 9273 } | 9314 } |
| 9274 if (redirect_type.IsMalformed()) { | 9315 if (redirect_type.IsMalformed()) { |
| 9275 if (is_const) { | 9316 if (is_const) { |
| 9276 const Error& error = Error::Handle(redirect_type.malformed_error()); | 9317 const Error& error = Error::Handle(redirect_type.malformed_error()); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9316 if (is_const) { | 9357 if (is_const) { |
| 9317 ErrorMsg(call_pos, | 9358 ErrorMsg(call_pos, |
| 9318 "invalid arguments passed to constructor '%s' " | 9359 "invalid arguments passed to constructor '%s' " |
| 9319 "for class '%s': %s", | 9360 "for class '%s': %s", |
| 9320 external_constructor_name.ToCString(), | 9361 external_constructor_name.ToCString(), |
| 9321 String::Handle(type_class.Name()).ToCString(), | 9362 String::Handle(type_class.Name()).ToCString(), |
| 9322 error_message.ToCString()); | 9363 error_message.ToCString()); |
| 9323 } | 9364 } |
| 9324 return ThrowNoSuchMethodError(call_pos, | 9365 return ThrowNoSuchMethodError(call_pos, |
| 9325 type_class, | 9366 type_class, |
| 9326 external_constructor_name); | 9367 external_constructor_name, |
| 9368 InvocationMirror::kConstructor, |
| 9369 InvocationMirror::kMethod); |
| 9327 } | 9370 } |
| 9328 | 9371 |
| 9329 // Return a throw in case of a malformed type or report a compile-time error | 9372 // Return a throw in case of a malformed type or report a compile-time error |
| 9330 // if the constructor is const. | 9373 // if the constructor is const. |
| 9331 if (type.IsMalformed()) { | 9374 if (type.IsMalformed()) { |
| 9332 if (is_const) { | 9375 if (is_const) { |
| 9333 const Error& error = Error::Handle(type.malformed_error()); | 9376 const Error& error = Error::Handle(type.malformed_error()); |
| 9334 ErrorMsg(error); | 9377 ErrorMsg(error); |
| 9335 } | 9378 } |
| 9336 return ThrowTypeError(type_pos, type); | 9379 return ThrowTypeError(type_pos, type); |
| (...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9999 void Parser::SkipQualIdent() { | 10042 void Parser::SkipQualIdent() { |
| 10000 ASSERT(IsIdentifier()); | 10043 ASSERT(IsIdentifier()); |
| 10001 ConsumeToken(); | 10044 ConsumeToken(); |
| 10002 if (CurrentToken() == Token::kPERIOD) { | 10045 if (CurrentToken() == Token::kPERIOD) { |
| 10003 ConsumeToken(); // Consume the kPERIOD token. | 10046 ConsumeToken(); // Consume the kPERIOD token. |
| 10004 ExpectIdentifier("identifier expected after '.'"); | 10047 ExpectIdentifier("identifier expected after '.'"); |
| 10005 } | 10048 } |
| 10006 } | 10049 } |
| 10007 | 10050 |
| 10008 } // namespace dart | 10051 } // namespace dart |
| OLD | NEW |