OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/pending-compilation-error-handler.h" | 5 #include "src/pending-compilation-error-handler.h" |
6 | 6 |
7 #include "src/debug.h" | 7 #include "src/debug.h" |
8 #include "src/handles.h" | 8 #include "src/handles.h" |
9 #include "src/isolate.h" | 9 #include "src/isolate.h" |
10 #include "src/messages.h" | 10 #include "src/messages.h" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
15 void PendingCompilationErrorHandler::ThrowPendingError(Isolate* isolate, | 15 void PendingCompilationErrorHandler::ThrowPendingError(Isolate* isolate, |
16 Handle<Script> script) { | 16 Handle<Script> script) { |
17 if (!has_pending_error_) return; | 17 if (!has_pending_error_) return; |
18 MessageLocation location(script, start_position_, end_position_); | 18 MessageLocation location(script, start_position_, end_position_); |
19 Factory* factory = isolate->factory(); | 19 Factory* factory = isolate->factory(); |
20 bool has_arg = arg_ != NULL || char_arg_ != NULL; | 20 bool has_arg = arg_ != NULL || char_arg_ != NULL || !handle_arg_.is_null(); |
21 Handle<FixedArray> elements = factory->NewFixedArray(has_arg ? 1 : 0); | 21 Handle<FixedArray> elements = factory->NewFixedArray(has_arg ? 1 : 0); |
22 if (arg_ != NULL) { | 22 if (arg_ != NULL) { |
23 Handle<String> arg_string = arg_->string(); | 23 Handle<String> arg_string = arg_->string(); |
24 elements->set(0, *arg_string); | 24 elements->set(0, *arg_string); |
25 } else if (char_arg_ != NULL) { | 25 } else if (char_arg_ != NULL) { |
26 Handle<String> arg_string = | 26 Handle<String> arg_string = |
27 factory->NewStringFromUtf8(CStrVector(char_arg_)).ToHandleChecked(); | 27 factory->NewStringFromUtf8(CStrVector(char_arg_)).ToHandleChecked(); |
28 elements->set(0, *arg_string); | 28 elements->set(0, *arg_string); |
| 29 } else if (!handle_arg_.is_null()) { |
| 30 elements->set(0, *handle_arg_); |
29 } | 31 } |
30 isolate->debug()->OnCompileError(script); | 32 isolate->debug()->OnCompileError(script); |
31 | 33 |
32 Handle<JSArray> array = factory->NewJSArrayWithElements(elements); | 34 Handle<JSArray> array = factory->NewJSArrayWithElements(elements); |
33 Handle<Object> error; | 35 Handle<Object> error; |
34 | 36 |
35 switch (error_type_) { | 37 switch (error_type_) { |
36 case kReferenceError: | 38 case kReferenceError: |
37 error = factory->NewReferenceError(message_, array); | 39 error = factory->NewReferenceError(message_, array); |
38 break; | 40 break; |
(...skipping 14 matching lines...) Expand all Loading... |
53 handle(Smi::FromInt(location.end_pos()), isolate), | 55 handle(Smi::FromInt(location.end_pos()), isolate), |
54 SLOPPY).Check(); | 56 SLOPPY).Check(); |
55 | 57 |
56 Handle<Name> key_script = factory->error_script_symbol(); | 58 Handle<Name> key_script = factory->error_script_symbol(); |
57 JSObject::SetProperty(jserror, key_script, script, SLOPPY).Check(); | 59 JSObject::SetProperty(jserror, key_script, script, SLOPPY).Check(); |
58 | 60 |
59 isolate->Throw(*error, &location); | 61 isolate->Throw(*error, &location); |
60 } | 62 } |
61 } | 63 } |
62 } // namespace v8::internal | 64 } // namespace v8::internal |
OLD | NEW |