Chromium Code Reviews| 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/ast/ast-value-factory.h" | 7 #include "src/ast/ast-value-factory.h" |
| 8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.h" |
| 9 #include "src/handles.h" | 9 #include "src/handles.h" |
| 10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
| 11 #include "src/messages.h" | 11 #include "src/messages.h" |
| 12 | 12 |
| 13 namespace v8 { | 13 namespace v8 { |
| 14 namespace internal { | 14 namespace internal { |
| 15 | 15 |
| 16 Handle<String> PendingCompilationErrorHandler::ArgumentString( | |
| 17 Isolate* isolate) { | |
| 18 if (arg_ != NULL) return arg_->string(); | |
| 19 if (char_arg_ != NULL) { | |
| 20 return isolate->factory() | |
| 21 ->NewStringFromUtf8(CStrVector(char_arg_)) | |
| 22 .ToHandleChecked(); | |
| 23 } | |
| 24 if (!handle_arg_.is_null()) return handle_arg_; | |
| 25 return isolate->factory()->undefined_string(); | |
| 26 } | |
| 27 | |
| 28 Handle<String> PendingCompilationErrorHandler::FormatMessage(Isolate* isolate) { | |
|
vogelheim
2016/11/15 08:43:42
Who calls this? Is it only for testing?
Toon Verwaest
2016/11/15 10:12:24
Yeah just testing. It seems small enough that it d
| |
| 29 return MessageTemplate::FormatMessage(isolate, message_, | |
| 30 ArgumentString(isolate)); | |
| 31 } | |
| 32 | |
| 16 void PendingCompilationErrorHandler::ThrowPendingError(Isolate* isolate, | 33 void PendingCompilationErrorHandler::ThrowPendingError(Isolate* isolate, |
| 17 Handle<Script> script) { | 34 Handle<Script> script) { |
| 18 if (!has_pending_error_) return; | 35 if (!has_pending_error_) return; |
| 19 MessageLocation location(script, start_position_, end_position_); | 36 MessageLocation location(script, start_position_, end_position_); |
| 20 Factory* factory = isolate->factory(); | 37 Factory* factory = isolate->factory(); |
| 21 Handle<String> argument; | 38 Handle<String> argument = ArgumentString(isolate); |
| 22 if (arg_ != NULL) { | |
| 23 argument = arg_->string(); | |
| 24 } else if (char_arg_ != NULL) { | |
| 25 argument = | |
| 26 factory->NewStringFromUtf8(CStrVector(char_arg_)).ToHandleChecked(); | |
| 27 } else if (!handle_arg_.is_null()) { | |
| 28 argument = handle_arg_; | |
| 29 } | |
| 30 isolate->debug()->OnCompileError(script); | 39 isolate->debug()->OnCompileError(script); |
| 31 | 40 |
| 32 Handle<Object> error; | 41 Handle<Object> error; |
| 33 switch (error_type_) { | 42 switch (error_type_) { |
| 34 case kReferenceError: | 43 case kReferenceError: |
| 35 error = factory->NewReferenceError(message_, argument); | 44 error = factory->NewReferenceError(message_, argument); |
| 36 break; | 45 break; |
| 37 case kSyntaxError: | 46 case kSyntaxError: |
| 38 error = factory->NewSyntaxError(message_, argument); | 47 error = factory->NewSyntaxError(message_, argument); |
| 39 break; | 48 break; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 59 handle(Smi::FromInt(location.end_pos()), isolate), | 68 handle(Smi::FromInt(location.end_pos()), isolate), |
| 60 SLOPPY).Check(); | 69 SLOPPY).Check(); |
| 61 | 70 |
| 62 Handle<Name> key_script = factory->error_script_symbol(); | 71 Handle<Name> key_script = factory->error_script_symbol(); |
| 63 JSObject::SetProperty(jserror, key_script, script, SLOPPY).Check(); | 72 JSObject::SetProperty(jserror, key_script, script, SLOPPY).Check(); |
| 64 | 73 |
| 65 isolate->Throw(*error, &location); | 74 isolate->Throw(*error, &location); |
| 66 } | 75 } |
| 67 } // namespace internal | 76 } // namespace internal |
| 68 } // namespace v8 | 77 } // namespace v8 |
| OLD | NEW |