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

Side by Side Diff: runtime/lib/errors.cc

Issue 2468093007: clang-format runtime/lib (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « runtime/lib/double.cc ('k') | runtime/lib/function.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/bootstrap_natives.h" 5 #include "vm/bootstrap_natives.h"
6 #include "vm/exceptions.h" 6 #include "vm/exceptions.h"
7 #include "vm/object_store.h" 7 #include "vm/object_store.h"
8 #include "vm/runtime_entry.h" 8 #include "vm/runtime_entry.h"
9 #include "vm/stack_frame.h" 9 #include "vm/stack_frame.h"
10 #include "vm/symbols.h" 10 #include "vm/symbols.h"
11 11
12 namespace dart { 12 namespace dart {
13 13
14 // Scan the stack until we hit the first function in the _AssertionError 14 // Scan the stack until we hit the first function in the _AssertionError
15 // class. We then return the next frame's script taking inlining into account. 15 // class. We then return the next frame's script taking inlining into account.
16 static RawScript* FindScript(DartFrameIterator* iterator) { 16 static RawScript* FindScript(DartFrameIterator* iterator) {
17 if (FLAG_precompiled_runtime) { 17 if (FLAG_precompiled_runtime) {
18 // The precompiled runtime faces two issues in recovering the correct 18 // The precompiled runtime faces two issues in recovering the correct
19 // assertion text. First, the precompiled runtime does not include 19 // assertion text. First, the precompiled runtime does not include
20 // the inlining meta-data so we cannot walk the inline-aware stack trace. 20 // the inlining meta-data so we cannot walk the inline-aware stack trace.
21 // Second, the script text itself is missing so whatever script is returned 21 // Second, the script text itself is missing so whatever script is returned
22 // from here will be missing the assertion expression text. 22 // from here will be missing the assertion expression text.
23 iterator->NextFrame(); // Skip _AssertionError._checkAssertion frame 23 iterator->NextFrame(); // Skip _AssertionError._checkAssertion frame
24 return Exceptions::GetCallerScript(iterator); 24 return Exceptions::GetCallerScript(iterator);
25 } 25 }
26 StackFrame* stack_frame = iterator->NextFrame(); 26 StackFrame* stack_frame = iterator->NextFrame();
27 Code& code = Code::Handle(); 27 Code& code = Code::Handle();
28 Function& func = Function::Handle(); 28 Function& func = Function::Handle();
29 const Class& assert_error_class = Class::Handle( 29 const Class& assert_error_class =
30 Library::LookupCoreClass(Symbols::AssertionError())); 30 Class::Handle(Library::LookupCoreClass(Symbols::AssertionError()));
31 ASSERT(!assert_error_class.IsNull()); 31 ASSERT(!assert_error_class.IsNull());
32 bool hit_assertion_error = false; 32 bool hit_assertion_error = false;
33 while (stack_frame != NULL) { 33 while (stack_frame != NULL) {
34 code ^= stack_frame->LookupDartCode(); 34 code ^= stack_frame->LookupDartCode();
35 if (code.is_optimized()) { 35 if (code.is_optimized()) {
36 InlinedFunctionsIterator inlined_iterator(code, stack_frame->pc()); 36 InlinedFunctionsIterator inlined_iterator(code, stack_frame->pc());
37 while (!inlined_iterator.Done()) { 37 while (!inlined_iterator.Done()) {
38 func ^= inlined_iterator.function(); 38 func ^= inlined_iterator.function();
39 if (hit_assertion_error) { 39 if (hit_assertion_error) {
40 return func.script(); 40 return func.script();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 iterator.NextFrame(); // Skip native call. 77 iterator.NextFrame(); // Skip native call.
78 const Script& script = Script::Handle(FindScript(&iterator)); 78 const Script& script = Script::Handle(FindScript(&iterator));
79 79
80 // Initialize argument 'failed_assertion' with source snippet. 80 // Initialize argument 'failed_assertion' with source snippet.
81 intptr_t from_line, from_column; 81 intptr_t from_line, from_column;
82 script.GetTokenLocation(assertion_start, &from_line, &from_column); 82 script.GetTokenLocation(assertion_start, &from_line, &from_column);
83 intptr_t to_line, to_column; 83 intptr_t to_line, to_column;
84 script.GetTokenLocation(assertion_end, &to_line, &to_column); 84 script.GetTokenLocation(assertion_end, &to_line, &to_column);
85 // The snippet will extract the correct assertion code even if the source 85 // The snippet will extract the correct assertion code even if the source
86 // is generated. 86 // is generated.
87 args.SetAt(0, String::Handle( 87 args.SetAt(0, String::Handle(script.GetSnippet(from_line, from_column,
88 script.GetSnippet(from_line, from_column, to_line, to_column))); 88 to_line, to_column)));
89 89
90 // Initialize location arguments starting at position 1. 90 // Initialize location arguments starting at position 1.
91 // Do not set a column if the source has been generated as it will be wrong. 91 // Do not set a column if the source has been generated as it will be wrong.
92 args.SetAt(1, String::Handle(script.url())); 92 args.SetAt(1, String::Handle(script.url()));
93 args.SetAt(2, Smi::Handle(Smi::New(from_line))); 93 args.SetAt(2, Smi::Handle(Smi::New(from_line)));
94 args.SetAt(3, Smi::Handle(Smi::New(script.HasSource() ? from_column : -1))); 94 args.SetAt(3, Smi::Handle(Smi::New(script.HasSource() ? from_column : -1)));
95 95
96 Exceptions::ThrowByType(Exceptions::kAssertion, args); 96 Exceptions::ThrowByType(Exceptions::kAssertion, args);
97 UNREACHABLE(); 97 UNREACHABLE();
98 return Object::null(); 98 return Object::null();
(...skipping 12 matching lines...) Expand all
111 // internally from the VM. 111 // internally from the VM.
112 const TokenPosition location = 112 const TokenPosition location =
113 TokenPosition(Smi::CheckedHandle(arguments->NativeArgAt(0)).Value()); 113 TokenPosition(Smi::CheckedHandle(arguments->NativeArgAt(0)).Value());
114 const Instance& src_value = 114 const Instance& src_value =
115 Instance::CheckedHandle(arguments->NativeArgAt(1)); 115 Instance::CheckedHandle(arguments->NativeArgAt(1));
116 const AbstractType& dst_type = 116 const AbstractType& dst_type =
117 AbstractType::CheckedHandle(arguments->NativeArgAt(2)); 117 AbstractType::CheckedHandle(arguments->NativeArgAt(2));
118 const String& dst_name = String::CheckedHandle(arguments->NativeArgAt(3)); 118 const String& dst_name = String::CheckedHandle(arguments->NativeArgAt(3));
119 const String& error_msg = String::CheckedHandle(arguments->NativeArgAt(4)); 119 const String& error_msg = String::CheckedHandle(arguments->NativeArgAt(4));
120 const AbstractType& src_type = AbstractType::Handle(src_value.GetType()); 120 const AbstractType& src_type = AbstractType::Handle(src_value.GetType());
121 Exceptions::CreateAndThrowTypeError( 121 Exceptions::CreateAndThrowTypeError(location, src_type, dst_type, dst_name,
122 location, src_type, dst_type, dst_name, error_msg); 122 error_msg);
123 UNREACHABLE(); 123 UNREACHABLE();
124 return Object::null(); 124 return Object::null();
125 } 125 }
126 126
127 127
128 // Allocate and throw a new FallThroughError. 128 // Allocate and throw a new FallThroughError.
129 // Arg0: index of the case clause token into which we fall through. 129 // Arg0: index of the case clause token into which we fall through.
130 // Return value: none, throws an exception. 130 // Return value: none, throws an exception.
131 DEFINE_NATIVE_ENTRY(FallThroughError_throwNew, 1) { 131 DEFINE_NATIVE_ENTRY(FallThroughError_throwNew, 1) {
132 GET_NON_NULL_NATIVE_ARGUMENT(Smi, smi_pos, arguments->NativeArgAt(0)); 132 GET_NON_NULL_NATIVE_ARGUMENT(Smi, smi_pos, arguments->NativeArgAt(0));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 177
178 // Rethrow an error with a stacktrace. 178 // Rethrow an error with a stacktrace.
179 DEFINE_NATIVE_ENTRY(Async_rethrow, 2) { 179 DEFINE_NATIVE_ENTRY(Async_rethrow, 2) {
180 GET_NON_NULL_NATIVE_ARGUMENT(Instance, error, arguments->NativeArgAt(0)); 180 GET_NON_NULL_NATIVE_ARGUMENT(Instance, error, arguments->NativeArgAt(0));
181 GET_NON_NULL_NATIVE_ARGUMENT(Instance, stacktrace, arguments->NativeArgAt(1)); 181 GET_NON_NULL_NATIVE_ARGUMENT(Instance, stacktrace, arguments->NativeArgAt(1));
182 Exceptions::ReThrow(thread, error, stacktrace); 182 Exceptions::ReThrow(thread, error, stacktrace);
183 return Object::null(); 183 return Object::null();
184 } 184 }
185 185
186 } // namespace dart 186 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/double.cc ('k') | runtime/lib/function.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698