Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: runtime/vm/parser.cc

Issue 312693008: Add javascript compatibility warnings for strings that are not identical, but (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/bootstrap.h" 9 #include "vm/bootstrap.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 24 matching lines...) Expand all
35 namespace dart { 35 namespace dart {
36 36
37 DEFINE_FLAG(bool, enable_asserts, false, "Enable assert statements."); 37 DEFINE_FLAG(bool, enable_asserts, false, "Enable assert statements.");
38 DEFINE_FLAG(bool, enable_type_checks, false, "Enable type checks."); 38 DEFINE_FLAG(bool, enable_type_checks, false, "Enable type checks.");
39 DEFINE_FLAG(bool, trace_parser, false, "Trace parser operations."); 39 DEFINE_FLAG(bool, trace_parser, false, "Trace parser operations.");
40 DEFINE_FLAG(bool, warning_as_error, false, "Treat warnings as errors."); 40 DEFINE_FLAG(bool, warning_as_error, false, "Treat warnings as errors.");
41 DEFINE_FLAG(bool, silent_warnings, false, "Silence warnings."); 41 DEFINE_FLAG(bool, silent_warnings, false, "Silence warnings.");
42 DEFINE_FLAG(bool, warn_mixin_typedef, true, "Warning on legacy mixin typedef."); 42 DEFINE_FLAG(bool, warn_mixin_typedef, true, "Warning on legacy mixin typedef.");
43 DECLARE_FLAG(bool, error_on_bad_type); 43 DECLARE_FLAG(bool, error_on_bad_type);
44 DECLARE_FLAG(bool, throw_on_javascript_int_overflow); 44 DECLARE_FLAG(bool, throw_on_javascript_int_overflow);
45 DECLARE_FLAG(bool, warn_on_javascript_compatibility);
45 46
46 static void CheckedModeHandler(bool value) { 47 static void CheckedModeHandler(bool value) {
47 FLAG_enable_asserts = value; 48 FLAG_enable_asserts = value;
48 FLAG_enable_type_checks = value; 49 FLAG_enable_type_checks = value;
49 } 50 }
50 51
51 // --enable-checked-mode and --checked both enable checked mode which is 52 // --enable-checked-mode and --checked both enable checked mode which is
52 // equivalent to setting --enable-asserts and --enable-type-checks. 53 // equivalent to setting --enable-asserts and --enable-type-checks.
53 DEFINE_FLAG_HANDLER(CheckedModeHandler, 54 DEFINE_FLAG_HANDLER(CheckedModeHandler,
54 enable_checked_mode, 55 enable_checked_mode,
(...skipping 8316 matching lines...) Expand 10 before | Expand all | Expand 10 after
8371 return ThrowNoSuchMethodError(ident_pos, 8372 return ThrowNoSuchMethodError(ident_pos,
8372 cls, 8373 cls,
8373 func_name, 8374 func_name,
8374 arguments, 8375 arguments,
8375 InvocationMirror::kStatic, 8376 InvocationMirror::kStatic,
8376 InvocationMirror::kMethod, 8377 InvocationMirror::kMethod,
8377 NULL); // No existing function. 8378 NULL); // No existing function.
8378 } else if (cls.IsTopLevel() && 8379 } else if (cls.IsTopLevel() &&
8379 (cls.library() == Library::CoreLibrary()) && 8380 (cls.library() == Library::CoreLibrary()) &&
8380 (func.name() == Symbols::Identical().raw())) { 8381 (func.name() == Symbols::Identical().raw())) {
8381 // This is the predefined toplevel function identical(a,b). Create 8382 // This is the predefined toplevel function identical(a,b).
8382 // a comparison node instead. 8383 // Create a comparison node instead of a static call to the function, unless
8383 ASSERT(num_arguments == 2); 8384 // javascript warnings are desired and identical is not invoked from a patch
8384 return new(isolate()) ComparisonNode(ident_pos, 8385 // source.
8385 Token::kEQ_STRICT, 8386 if (!FLAG_warn_on_javascript_compatibility || is_patch_source()) {
8386 arguments->NodeAt(0), 8387 ASSERT(num_arguments == 2);
8387 arguments->NodeAt(1)); 8388 return new(isolate()) ComparisonNode(ident_pos,
8389 Token::kEQ_STRICT,
8390 arguments->NodeAt(0),
8391 arguments->NodeAt(1));
8392 }
8388 } 8393 }
8389 return new(isolate()) StaticCallNode(call_pos, func, arguments); 8394 return new(isolate()) StaticCallNode(call_pos, func, arguments);
8390 } 8395 }
8391 8396
8392 8397
8393 AstNode* Parser::ParseInstanceCall(AstNode* receiver, const String& func_name) { 8398 AstNode* Parser::ParseInstanceCall(AstNode* receiver, const String& func_name) {
8394 TRACE_PARSER("ParseInstanceCall"); 8399 TRACE_PARSER("ParseInstanceCall");
8395 const intptr_t call_pos = TokenPos(); 8400 const intptr_t call_pos = TokenPos();
8396 CheckToken(Token::kLPAREN); 8401 CheckToken(Token::kLPAREN);
8397 ArgumentListNode* arguments = ParseActualParameters(NULL, kAllowConst); 8402 ArgumentListNode* arguments = ParseActualParameters(NULL, kAllowConst);
(...skipping 2629 matching lines...) Expand 10 before | Expand all | Expand 10 after
11027 void Parser::SkipQualIdent() { 11032 void Parser::SkipQualIdent() {
11028 ASSERT(IsIdentifier()); 11033 ASSERT(IsIdentifier());
11029 ConsumeToken(); 11034 ConsumeToken();
11030 if (CurrentToken() == Token::kPERIOD) { 11035 if (CurrentToken() == Token::kPERIOD) {
11031 ConsumeToken(); // Consume the kPERIOD token. 11036 ConsumeToken(); // Consume the kPERIOD token.
11032 ExpectIdentifier("identifier expected after '.'"); 11037 ExpectIdentifier("identifier expected after '.'");
11033 } 11038 }
11034 } 11039 }
11035 11040
11036 } // namespace dart 11041 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | tests/standalone/javascript_compatibility_errors_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698