| 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 "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/compiler_stats.h" | 10 #include "vm/compiler_stats.h" |
| 11 #include "vm/dart_api_impl.h" | 11 #include "vm/dart_api_impl.h" |
| 12 #include "vm/dart_entry.h" | 12 #include "vm/dart_entry.h" |
| 13 #include "vm/flags.h" | 13 #include "vm/flags.h" |
| 14 #include "vm/growable_array.h" | 14 #include "vm/growable_array.h" |
| 15 #include "vm/longjump.h" | 15 #include "vm/longjump.h" |
| 16 #include "vm/native_entry.h" | 16 #include "vm/native_entry.h" |
| 17 #include "vm/object.h" | 17 #include "vm/object.h" |
| 18 #include "vm/object_store.h" | 18 #include "vm/object_store.h" |
| 19 #include "vm/resolver.h" | 19 #include "vm/resolver.h" |
| 20 #include "vm/scopes.h" | 20 #include "vm/scopes.h" |
| 21 #include "vm/symbols.h" | 21 #include "vm/symbols.h" |
| 22 | 22 |
| 23 namespace dart { | 23 namespace dart { |
| 24 | 24 |
| 25 DEFINE_FLAG(bool, constructor_name_check, false, | |
| 26 "Named constructors may not clash with other members"); | |
| 27 DEFINE_FLAG(bool, enable_asserts, false, "Enable assert statements."); | 25 DEFINE_FLAG(bool, enable_asserts, false, "Enable assert statements."); |
| 28 DEFINE_FLAG(bool, enable_type_checks, false, "Enable type checks."); | 26 DEFINE_FLAG(bool, enable_type_checks, false, "Enable type checks."); |
| 29 DEFINE_FLAG(bool, trace_parser, false, "Trace parser operations."); | 27 DEFINE_FLAG(bool, trace_parser, false, "Trace parser operations."); |
| 30 DEFINE_FLAG(bool, warning_as_error, false, "Treat warnings as errors."); | 28 DEFINE_FLAG(bool, warning_as_error, false, "Treat warnings as errors."); |
| 31 DEFINE_FLAG(bool, silent_warnings, false, "Silence warnings."); | 29 DEFINE_FLAG(bool, silent_warnings, false, "Silence warnings."); |
| 32 DEFINE_FLAG(bool, warn_legacy_map_literal, false, | 30 DEFINE_FLAG(bool, warn_legacy_map_literal, false, |
| 33 "Warning on legacy map literal syntax (single type argument)"); | 31 "Warning on legacy map literal syntax (single type argument)"); |
| 34 DEFINE_FLAG(bool, warn_legacy_dynamic, false, | 32 DEFINE_FLAG(bool, warn_legacy_dynamic, false, |
| 35 "Warning on legacy type Dynamic)"); | 33 "Warning on legacy type Dynamic)"); |
| 36 DEFINE_FLAG(bool, warn_legacy_getters, false, | 34 DEFINE_FLAG(bool, warn_legacy_getters, false, |
| (...skipping 3209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3246 | 3244 |
| 3247 | 3245 |
| 3248 // Check for cycles in constructor redirection. Also check whether a | 3246 // Check for cycles in constructor redirection. Also check whether a |
| 3249 // named constructor collides with the name of another class member. | 3247 // named constructor collides with the name of another class member. |
| 3250 void Parser::CheckConstructors(ClassDesc* class_desc) { | 3248 void Parser::CheckConstructors(ClassDesc* class_desc) { |
| 3251 // Check for cycles in constructor redirection. | 3249 // Check for cycles in constructor redirection. |
| 3252 const GrowableArray<MemberDesc>& members = class_desc->members(); | 3250 const GrowableArray<MemberDesc>& members = class_desc->members(); |
| 3253 for (int i = 0; i < members.length(); i++) { | 3251 for (int i = 0; i < members.length(); i++) { |
| 3254 MemberDesc* member = &members[i]; | 3252 MemberDesc* member = &members[i]; |
| 3255 | 3253 |
| 3256 if (FLAG_constructor_name_check && member->constructor_name != NULL) { | 3254 if (member->constructor_name != NULL) { |
| 3255 // Check whether constructor name conflicts with a member name. |
| 3257 if (class_desc->FunctionNameExists( | 3256 if (class_desc->FunctionNameExists( |
| 3258 *member->constructor_name, member->kind)) { | 3257 *member->constructor_name, member->kind)) { |
| 3259 ErrorMsg(member->name_pos, | 3258 ErrorMsg(member->name_pos, |
| 3260 "Named constructor '%s' conflicts with method or field '%s'", | 3259 "Named constructor '%s' conflicts with method or field '%s'", |
| 3261 member->name->ToCString(), | 3260 member->name->ToCString(), |
| 3262 member->constructor_name->ToCString()); | 3261 member->constructor_name->ToCString()); |
| 3263 } | 3262 } |
| 3264 } | 3263 } |
| 3265 | 3264 |
| 3266 GrowableArray<MemberDesc*> ctors; | 3265 GrowableArray<MemberDesc*> ctors; |
| (...skipping 6474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9741 void Parser::SkipQualIdent() { | 9740 void Parser::SkipQualIdent() { |
| 9742 ASSERT(IsIdentifier()); | 9741 ASSERT(IsIdentifier()); |
| 9743 ConsumeToken(); | 9742 ConsumeToken(); |
| 9744 if (CurrentToken() == Token::kPERIOD) { | 9743 if (CurrentToken() == Token::kPERIOD) { |
| 9745 ConsumeToken(); // Consume the kPERIOD token. | 9744 ConsumeToken(); // Consume the kPERIOD token. |
| 9746 ExpectIdentifier("identifier expected after '.'"); | 9745 ExpectIdentifier("identifier expected after '.'"); |
| 9747 } | 9746 } |
| 9748 } | 9747 } |
| 9749 | 9748 |
| 9750 } // namespace dart | 9749 } // namespace dart |
| OLD | NEW |