Chromium Code Reviews| 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 2882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2893 new StaticCallNode(call_pos, redirect_ctor, arguments)); | 2893 new StaticCallNode(call_pos, redirect_ctor, arguments)); |
| 2894 } | 2894 } |
| 2895 | 2895 |
| 2896 | 2896 |
| 2897 SequenceNode* Parser::MakeImplicitConstructor(const Function& func) { | 2897 SequenceNode* Parser::MakeImplicitConstructor(const Function& func) { |
| 2898 ASSERT(func.IsGenerativeConstructor()); | 2898 ASSERT(func.IsGenerativeConstructor()); |
| 2899 ASSERT(func.Owner() == current_class().raw()); | 2899 ASSERT(func.Owner() == current_class().raw()); |
| 2900 const TokenPosition ctor_pos = TokenPos(); | 2900 const TokenPosition ctor_pos = TokenPos(); |
| 2901 OpenFunctionBlock(func); | 2901 OpenFunctionBlock(func); |
| 2902 | 2902 |
| 2903 if ((current_class().is_mixin_app_alias() || | |
| 2904 current_class().IsMixinApplication()) && | |
| 2905 func.HasOptionalParameters()) { | |
| 2906 // At this point we don't support forwarding constructors | |
| 2907 // that have optional parameters because we don't know the default | |
| 2908 // values of the optional parameters. We would have to compile the super | |
| 2909 // constructor to get the default values. Also, the spec is not clear | |
| 2910 // whether optional parameters are even allowed in this situation. | |
| 2911 // TODO(hausner): Remove this limitation if the language spec indeed | |
| 2912 // allows optional parameters. | |
| 2913 const Class& super_class = Class::Handle(Z, current_class().SuperClass()); | |
| 2914 const String& msg = String::Handle(Symbols::NewFormatted(thread(), | |
| 2915 "cannot generate an implicit mixin application constructor " | |
| 2916 "forwarding to a super class constructor with optional " | |
| 2917 "parameters; add a constructor without optional parameters " | |
| 2918 "to class '%s' that redirects to the constructor with " | |
| 2919 "optional parameters and invoke it via super from a " | |
| 2920 "constructor of the class extending the mixin application", | |
| 2921 String::Handle(Z, super_class.Name()).ToCString())); | |
| 2922 ArgumentListNode* args = new ArgumentListNode(ST(ctor_pos)); | |
| 2923 args->Add(new LiteralNode(ctor_pos, msg)); | |
| 2924 current_block_->statements->Add(MakeStaticCall( | |
| 2925 Symbols::UnsupportedError(), Symbols::ThrowNew(), args)); | |
| 2926 return CloseBlock(); | |
|
siva
2016/04/25 23:38:31
This code has been moved from somewhere?
Ivan Posva
2016/04/26 21:17:43
From line 2951. Will be removed there once I am co
Ivan Posva
2016/05/03 21:46:40
Removed for now again.
| |
| 2927 } | |
| 2903 LocalVariable* receiver = new LocalVariable( | 2928 LocalVariable* receiver = new LocalVariable( |
| 2904 TokenPosition::kNoSource, | 2929 TokenPosition::kNoSource, |
| 2905 Symbols::This(), | 2930 Symbols::This(), |
| 2906 *ReceiverType(current_class())); | 2931 *ReceiverType(current_class())); |
| 2907 current_block_->scope->InsertParameterAt(0, receiver); | 2932 current_block_->scope->InsertParameterAt(0, receiver); |
| 2908 | 2933 |
| 2909 // Parse expressions of instance fields that have an explicit | 2934 // Parse expressions of instance fields that have an explicit |
| 2910 // initializer expression. | 2935 // initializer expression. |
| 2911 // The receiver must not be visible to field initializer expressions. | 2936 // The receiver must not be visible to field initializer expressions. |
| 2912 receiver->set_invisible(true); | 2937 receiver->set_invisible(true); |
| (...skipping 11560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 14473 const ArgumentListNode& function_args, | 14498 const ArgumentListNode& function_args, |
| 14474 const LocalVariable* temp_for_last_arg, | 14499 const LocalVariable* temp_for_last_arg, |
| 14475 bool is_super_invocation) { | 14500 bool is_super_invocation) { |
| 14476 UNREACHABLE(); | 14501 UNREACHABLE(); |
| 14477 return NULL; | 14502 return NULL; |
| 14478 } | 14503 } |
| 14479 | 14504 |
| 14480 } // namespace dart | 14505 } // namespace dart |
| 14481 | 14506 |
| 14482 #endif // DART_PRECOMPILED_RUNTIME | 14507 #endif // DART_PRECOMPILED_RUNTIME |
| OLD | NEW |