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

Side by Side Diff: src/pending-compilation-error-handler.cc

Issue 960543002: Move compilation error handling into a separate class. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 months 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 | « src/pending-compilation-error-handler.h ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "src/pending-compilation-error-handler.h"
6
7 #include "src/debug.h"
8 #include "src/handles.h"
9 #include "src/isolate.h"
10 #include "src/messages.h"
11
12 namespace v8 {
13 namespace internal {
14
15 void PendingCompilationErrorHandler::ThrowPendingError(Isolate* isolate,
16 Handle<Script> script) {
17 if (!has_pending_error_) return;
18 MessageLocation location(script, start_position_, end_position_);
19 Factory* factory = isolate->factory();
20 bool has_arg = arg_ != NULL || char_arg_ != NULL;
21 Handle<FixedArray> elements = factory->NewFixedArray(has_arg ? 1 : 0);
22 if (arg_ != NULL) {
23 Handle<String> arg_string = arg_->string();
24 elements->set(0, *arg_string);
25 } else if (char_arg_ != NULL) {
26 Handle<String> arg_string =
27 factory->NewStringFromUtf8(CStrVector(char_arg_)).ToHandleChecked();
28 elements->set(0, *arg_string);
29 }
30 isolate->debug()->OnCompileError(script);
31
32 Handle<JSArray> array = factory->NewJSArrayWithElements(elements);
33 Handle<Object> error;
34
35 switch (error_type_) {
36 case kReferenceError:
37 error = factory->NewReferenceError(message_, array);
38 break;
39 case kSyntaxError:
40 error = factory->NewSyntaxError(message_, array);
41 break;
42 }
43
44 Handle<JSObject> jserror = Handle<JSObject>::cast(error);
45
46 Handle<Name> key_start_pos = factory->error_start_pos_symbol();
47 JSObject::SetProperty(jserror, key_start_pos,
48 handle(Smi::FromInt(location.start_pos()), isolate),
49 SLOPPY).Check();
50
51 Handle<Name> key_end_pos = factory->error_end_pos_symbol();
52 JSObject::SetProperty(jserror, key_end_pos,
53 handle(Smi::FromInt(location.end_pos()), isolate),
54 SLOPPY).Check();
55
56 Handle<Name> key_script = factory->error_script_symbol();
57 JSObject::SetProperty(jserror, key_script, script, SLOPPY).Check();
58
59 isolate->Throw(*error, &location);
60 }
61 }
62 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/pending-compilation-error-handler.h ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698