| 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 "vm/bigint_operations.h" | 8 #include "vm/bigint_operations.h" |
| 9 #include "vm/bootstrap.h" | 9 #include "vm/bootstrap.h" |
| 10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 9809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9820 if (constructor.IsFactory()) { | 9820 if (constructor.IsFactory()) { |
| 9821 // A factory does not have the implicit 'phase' parameter. | 9821 // A factory does not have the implicit 'phase' parameter. |
| 9822 arguments_length -= 1; | 9822 arguments_length -= 1; |
| 9823 } | 9823 } |
| 9824 } | 9824 } |
| 9825 | 9825 |
| 9826 // It is ok to call a factory method of an abstract class, but it is | 9826 // It is ok to call a factory method of an abstract class, but it is |
| 9827 // a dynamic error to instantiate an abstract class. | 9827 // a dynamic error to instantiate an abstract class. |
| 9828 ASSERT(!constructor.IsNull()); | 9828 ASSERT(!constructor.IsNull()); |
| 9829 if (type_class.is_abstract() && !constructor.IsFactory()) { | 9829 if (type_class.is_abstract() && !constructor.IsFactory()) { |
| 9830 ArgumentListNode* arguments = new ArgumentListNode(type_pos); | 9830 // Evaluate arguments before throwing. |
| 9831 arguments->Add(new LiteralNode( | 9831 LetNode* result = new LetNode(call_pos); |
| 9832 for (intptr_t i = 0; i < arguments->length(); ++i) { |
| 9833 result->AddNode(arguments->NodeAt(i)); |
| 9834 } |
| 9835 ArgumentListNode* error_arguments = new ArgumentListNode(type_pos); |
| 9836 error_arguments->Add(new LiteralNode( |
| 9832 TokenPos(), Integer::ZoneHandle(Integer::New(type_pos)))); | 9837 TokenPos(), Integer::ZoneHandle(Integer::New(type_pos)))); |
| 9833 arguments->Add(new LiteralNode( | 9838 error_arguments->Add(new LiteralNode( |
| 9834 TokenPos(), String::ZoneHandle(type_class_name.raw()))); | 9839 TokenPos(), String::ZoneHandle(type_class_name.raw()))); |
| 9835 return MakeStaticCall(Symbols::AbstractClassInstantiationError(), | 9840 result->AddNode( |
| 9836 Library::PrivateCoreLibName(Symbols::ThrowNew()), | 9841 MakeStaticCall(Symbols::AbstractClassInstantiationError(), |
| 9837 arguments); | 9842 Library::PrivateCoreLibName(Symbols::ThrowNew()), |
| 9843 error_arguments)); |
| 9844 return result; |
| 9838 } | 9845 } |
| 9839 String& error_message = String::Handle(); | 9846 String& error_message = String::Handle(); |
| 9840 if (!constructor.AreValidArguments(arguments_length, | 9847 if (!constructor.AreValidArguments(arguments_length, |
| 9841 arguments->names(), | 9848 arguments->names(), |
| 9842 &error_message)) { | 9849 &error_message)) { |
| 9843 const String& external_constructor_name = | 9850 const String& external_constructor_name = |
| 9844 (named_constructor ? constructor_name : type_class_name); | 9851 (named_constructor ? constructor_name : type_class_name); |
| 9845 if (is_const) { | 9852 if (is_const) { |
| 9846 ErrorMsg(call_pos, | 9853 ErrorMsg(call_pos, |
| 9847 "invalid arguments passed to constructor '%s' " | 9854 "invalid arguments passed to constructor '%s' " |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10573 void Parser::SkipQualIdent() { | 10580 void Parser::SkipQualIdent() { |
| 10574 ASSERT(IsIdentifier()); | 10581 ASSERT(IsIdentifier()); |
| 10575 ConsumeToken(); | 10582 ConsumeToken(); |
| 10576 if (CurrentToken() == Token::kPERIOD) { | 10583 if (CurrentToken() == Token::kPERIOD) { |
| 10577 ConsumeToken(); // Consume the kPERIOD token. | 10584 ConsumeToken(); // Consume the kPERIOD token. |
| 10578 ExpectIdentifier("identifier expected after '.'"); | 10585 ExpectIdentifier("identifier expected after '.'"); |
| 10579 } | 10586 } |
| 10580 } | 10587 } |
| 10581 | 10588 |
| 10582 } // namespace dart | 10589 } // namespace dart |
| OLD | NEW |