| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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/exceptions.h" | 5 #include "vm/exceptions.h" |
| 6 | 6 |
| 7 #include "vm/dart_api_impl.h" | 7 #include "vm/dart_api_impl.h" |
| 8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
| 9 #include "vm/debugger.h" | 9 #include "vm/debugger.h" |
| 10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
| (...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 const String& msg_str = String::Handle(String::New(msg)); | 743 const String& msg_str = String::Handle(String::New(msg)); |
| 744 exc_args.SetAt(0, msg_str); | 744 exc_args.SetAt(0, msg_str); |
| 745 Exceptions::ThrowByType(Exceptions::kJavascriptCompatibilityError, exc_args); | 745 Exceptions::ThrowByType(Exceptions::kJavascriptCompatibilityError, exc_args); |
| 746 } | 746 } |
| 747 | 747 |
| 748 | 748 |
| 749 void Exceptions::JSWarning(StackFrame* caller_frame, const char* format, ...) { | 749 void Exceptions::JSWarning(StackFrame* caller_frame, const char* format, ...) { |
| 750 ASSERT(caller_frame != NULL); | 750 ASSERT(caller_frame != NULL); |
| 751 ASSERT(FLAG_warn_on_javascript_compatibility); | 751 ASSERT(FLAG_warn_on_javascript_compatibility); |
| 752 if (FLAG_silent_warnings) return; | 752 if (FLAG_silent_warnings) return; |
| 753 const Code& caller_code = Code::Handle(caller_frame->LookupDartCode()); | 753 Isolate* isolate = Isolate::Current(); |
| 754 const Code& caller_code = Code::Handle(isolate, |
| 755 caller_frame->LookupDartCode()); |
| 754 ASSERT(!caller_code.IsNull()); | 756 ASSERT(!caller_code.IsNull()); |
| 755 const uword caller_pc = caller_frame->pc(); | 757 const uword caller_pc = caller_frame->pc(); |
| 756 const intptr_t token_pos = caller_code.GetTokenIndexOfPC(caller_pc); | 758 const intptr_t token_pos = caller_code.GetTokenIndexOfPC(caller_pc); |
| 757 const Function& caller = Function::Handle(caller_code.function()); | 759 const Function& caller = Function::Handle(isolate, caller_code.function()); |
| 758 const Script& script = Script::Handle(caller.script()); | 760 const Script& script = Script::Handle(isolate, caller.script()); |
| 759 va_list args; | 761 va_list args; |
| 760 va_start(args, format); | 762 va_start(args, format); |
| 761 const Error& error = Error::Handle( | 763 const Error& error = Error::Handle(isolate, |
| 762 LanguageError::NewFormattedV(Error::Handle(), // No previous error. | 764 LanguageError::NewFormattedV(Error::Handle(isolate), // No prev error. |
| 763 script, token_pos, LanguageError::kWarning, | 765 script, token_pos, LanguageError::kWarning, |
| 764 Heap::kNew, format, args)); | 766 Heap::kNew, format, args)); |
| 765 va_end(args); | 767 va_end(args); |
| 766 if (FLAG_warning_as_error) { | 768 if (FLAG_warning_as_error) { |
| 767 ThrowJavascriptCompatibilityError(error.ToErrorCString()); | 769 ThrowJavascriptCompatibilityError(error.ToErrorCString()); |
| 768 } else { | 770 } else { |
| 769 OS::Print("javascript compatibility warning: %s", error.ToErrorCString()); | 771 OS::Print("javascript compatibility warning: %s", error.ToErrorCString()); |
| 772 va_start(args, format); |
| 773 TraceBuffer::TraceWarningV(isolate, script, token_pos, format, args); |
| 774 va_end(args); |
| 770 } | 775 } |
| 771 const Stacktrace& stacktrace = | 776 const Stacktrace& stacktrace = |
| 772 Stacktrace::Handle(Exceptions::CurrentStacktrace()); | 777 Stacktrace::Handle(isolate, Exceptions::CurrentStacktrace()); |
| 773 intptr_t idx = 0; | 778 intptr_t idx = 0; |
| 774 OS::Print("%s", | 779 OS::Print("%s", |
| 775 stacktrace.ToCStringInternal(&idx, | 780 stacktrace.ToCStringInternal(&idx, |
| 776 FLAG_stacktrace_depth_on_warning)); | 781 FLAG_stacktrace_depth_on_warning)); |
| 777 } | 782 } |
| 778 | 783 |
| 779 } // namespace dart | 784 } // namespace dart |
| OLD | NEW |