| 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/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "vm/stack_frame.h" | 22 #include "vm/stack_frame.h" |
| 23 #include "vm/symbols.h" | 23 #include "vm/symbols.h" |
| 24 | 24 |
| 25 namespace dart { | 25 namespace dart { |
| 26 | 26 |
| 27 DEFINE_FLAG(bool, enable_asserts, false, "Enable assert statements."); | 27 DEFINE_FLAG(bool, enable_asserts, false, "Enable assert statements."); |
| 28 DEFINE_FLAG(bool, enable_type_checks, false, "Enable type checks."); | 28 DEFINE_FLAG(bool, enable_type_checks, false, "Enable type checks."); |
| 29 DEFINE_FLAG(bool, trace_parser, false, "Trace parser operations."); | 29 DEFINE_FLAG(bool, trace_parser, false, "Trace parser operations."); |
| 30 DEFINE_FLAG(bool, warning_as_error, false, "Treat warnings as errors."); | 30 DEFINE_FLAG(bool, warning_as_error, false, "Treat warnings as errors."); |
| 31 DEFINE_FLAG(bool, silent_warnings, false, "Silence warnings."); | 31 DEFINE_FLAG(bool, silent_warnings, false, "Silence warnings."); |
| 32 DECLARE_FLAG(bool, throw_on_javascript_int_overflow); |
| 32 | 33 |
| 33 static void CheckedModeHandler(bool value) { | 34 static void CheckedModeHandler(bool value) { |
| 34 FLAG_enable_asserts = value; | 35 FLAG_enable_asserts = value; |
| 35 FLAG_enable_type_checks = value; | 36 FLAG_enable_type_checks = value; |
| 36 } | 37 } |
| 37 | 38 |
| 38 // --enable-checked-mode and --checked both enable checked mode which is | 39 // --enable-checked-mode and --checked both enable checked mode which is |
| 39 // equivalent to setting --enable-asserts and --enable-type-checks. | 40 // equivalent to setting --enable-asserts and --enable-type-checks. |
| 40 DEFINE_FLAG_HANDLER(CheckedModeHandler, | 41 DEFINE_FLAG_HANDLER(CheckedModeHandler, |
| 41 enable_checked_mode, | 42 enable_checked_mode, |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 RawDouble* Parser::CurrentDoubleLiteral() const { | 396 RawDouble* Parser::CurrentDoubleLiteral() const { |
| 396 literal_token_ ^= tokens_iterator_.CurrentToken(); | 397 literal_token_ ^= tokens_iterator_.CurrentToken(); |
| 397 ASSERT(literal_token_.kind() == Token::kDOUBLE); | 398 ASSERT(literal_token_.kind() == Token::kDOUBLE); |
| 398 return Double::RawCast(literal_token_.value()); | 399 return Double::RawCast(literal_token_.value()); |
| 399 } | 400 } |
| 400 | 401 |
| 401 | 402 |
| 402 RawInteger* Parser::CurrentIntegerLiteral() const { | 403 RawInteger* Parser::CurrentIntegerLiteral() const { |
| 403 literal_token_ ^= tokens_iterator_.CurrentToken(); | 404 literal_token_ ^= tokens_iterator_.CurrentToken(); |
| 404 ASSERT(literal_token_.kind() == Token::kINTEGER); | 405 ASSERT(literal_token_.kind() == Token::kINTEGER); |
| 405 return Integer::RawCast(literal_token_.value()); | 406 RawInteger* ri = Integer::RawCast(literal_token_.value()); |
| 407 if (FLAG_throw_on_javascript_int_overflow) { |
| 408 const Integer& i = Integer::Handle(ri); |
| 409 if (i.CheckFiftyThreeBitOverflow()) { |
| 410 ErrorMsg(TokenPos(), "Integer literal does not fit in 53 bits: %s.", |
| 411 i.ToCString()); |
| 412 } |
| 413 } |
| 414 return ri; |
| 406 } | 415 } |
| 407 | 416 |
| 408 | 417 |
| 409 // A QualIdent is an optionally qualified identifier. | 418 // A QualIdent is an optionally qualified identifier. |
| 410 struct QualIdent { | 419 struct QualIdent { |
| 411 QualIdent() { | 420 QualIdent() { |
| 412 Clear(); | 421 Clear(); |
| 413 } | 422 } |
| 414 void Clear() { | 423 void Clear() { |
| 415 lib_prefix = NULL; | 424 lib_prefix = NULL; |
| (...skipping 6148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6564 const char* format, ...) { | 6573 const char* format, ...) { |
| 6565 va_list args; | 6574 va_list args; |
| 6566 va_start(args, format); | 6575 va_start(args, format); |
| 6567 const String& buf = String::Handle( | 6576 const String& buf = String::Handle( |
| 6568 FormatMessage(script, token_pos, message_header, format, args)); | 6577 FormatMessage(script, token_pos, message_header, format, args)); |
| 6569 va_end(args); | 6578 va_end(args); |
| 6570 OS::Print("%s", buf.ToCString()); | 6579 OS::Print("%s", buf.ToCString()); |
| 6571 } | 6580 } |
| 6572 | 6581 |
| 6573 | 6582 |
| 6574 void Parser::ErrorMsg(intptr_t token_pos, const char* format, ...) { | 6583 void Parser::ErrorMsg(intptr_t token_pos, const char* format, ...) const { |
| 6575 va_list args; | 6584 va_list args; |
| 6576 va_start(args, format); | 6585 va_start(args, format); |
| 6577 const Error& error = Error::Handle( | 6586 const Error& error = Error::Handle( |
| 6578 FormatError(script_, token_pos, "Error", format, args)); | 6587 FormatError(script_, token_pos, "Error", format, args)); |
| 6579 va_end(args); | 6588 va_end(args); |
| 6580 isolate()->long_jump_base()->Jump(1, error); | 6589 isolate()->long_jump_base()->Jump(1, error); |
| 6581 UNREACHABLE(); | 6590 UNREACHABLE(); |
| 6582 } | 6591 } |
| 6583 | 6592 |
| 6584 | 6593 |
| (...skipping 3386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9971 void Parser::SkipQualIdent() { | 9980 void Parser::SkipQualIdent() { |
| 9972 ASSERT(IsIdentifier()); | 9981 ASSERT(IsIdentifier()); |
| 9973 ConsumeToken(); | 9982 ConsumeToken(); |
| 9974 if (CurrentToken() == Token::kPERIOD) { | 9983 if (CurrentToken() == Token::kPERIOD) { |
| 9975 ConsumeToken(); // Consume the kPERIOD token. | 9984 ConsumeToken(); // Consume the kPERIOD token. |
| 9976 ExpectIdentifier("identifier expected after '.'"); | 9985 ExpectIdentifier("identifier expected after '.'"); |
| 9977 } | 9986 } |
| 9978 } | 9987 } |
| 9979 | 9988 |
| 9980 } // namespace dart | 9989 } // namespace dart |
| OLD | NEW |