| 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 | 34 |
| (...skipping 3204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3241 | 3239 |
| 3242 | 3240 |
| 3243 // Check for cycles in constructor redirection. Also check whether a | 3241 // Check for cycles in constructor redirection. Also check whether a |
| 3244 // named constructor collides with the name of another class member. | 3242 // named constructor collides with the name of another class member. |
| 3245 void Parser::CheckConstructors(ClassDesc* class_desc) { | 3243 void Parser::CheckConstructors(ClassDesc* class_desc) { |
| 3246 // Check for cycles in constructor redirection. | 3244 // Check for cycles in constructor redirection. |
| 3247 const GrowableArray<MemberDesc>& members = class_desc->members(); | 3245 const GrowableArray<MemberDesc>& members = class_desc->members(); |
| 3248 for (int i = 0; i < members.length(); i++) { | 3246 for (int i = 0; i < members.length(); i++) { |
| 3249 MemberDesc* member = &members[i]; | 3247 MemberDesc* member = &members[i]; |
| 3250 | 3248 |
| 3251 if (FLAG_constructor_name_check && member->constructor_name != NULL) { | 3249 if (member->constructor_name != NULL) { |
| 3250 // Check whether constructor name conflicts with a member name. |
| 3252 if (class_desc->FunctionNameExists( | 3251 if (class_desc->FunctionNameExists( |
| 3253 *member->constructor_name, member->kind)) { | 3252 *member->constructor_name, member->kind)) { |
| 3254 ErrorMsg(member->name_pos, | 3253 ErrorMsg(member->name_pos, |
| 3255 "Named constructor '%s' conflicts with method or field '%s'", | 3254 "Named constructor '%s' conflicts with method or field '%s'", |
| 3256 member->name->ToCString(), | 3255 member->name->ToCString(), |
| 3257 member->constructor_name->ToCString()); | 3256 member->constructor_name->ToCString()); |
| 3258 } | 3257 } |
| 3259 } | 3258 } |
| 3260 | 3259 |
| 3261 GrowableArray<MemberDesc*> ctors; | 3260 GrowableArray<MemberDesc*> ctors; |
| (...skipping 6472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9734 void Parser::SkipQualIdent() { | 9733 void Parser::SkipQualIdent() { |
| 9735 ASSERT(IsIdentifier()); | 9734 ASSERT(IsIdentifier()); |
| 9736 ConsumeToken(); | 9735 ConsumeToken(); |
| 9737 if (CurrentToken() == Token::kPERIOD) { | 9736 if (CurrentToken() == Token::kPERIOD) { |
| 9738 ConsumeToken(); // Consume the kPERIOD token. | 9737 ConsumeToken(); // Consume the kPERIOD token. |
| 9739 ExpectIdentifier("identifier expected after '.'"); | 9738 ExpectIdentifier("identifier expected after '.'"); |
| 9740 } | 9739 } |
| 9741 } | 9740 } |
| 9742 | 9741 |
| 9743 } // namespace dart | 9742 } // namespace dart |
| OLD | NEW |