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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pending-compilation-error-handler.h ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pending-compilation-error-handler.cc
diff --git a/src/pending-compilation-error-handler.cc b/src/pending-compilation-error-handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..230b8767924d37ecb2034c294b843da2fb9efc14
--- /dev/null
+++ b/src/pending-compilation-error-handler.cc
@@ -0,0 +1,62 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/pending-compilation-error-handler.h"
+
+#include "src/debug.h"
+#include "src/handles.h"
+#include "src/isolate.h"
+#include "src/messages.h"
+
+namespace v8 {
+namespace internal {
+
+void PendingCompilationErrorHandler::ThrowPendingError(Isolate* isolate,
+ Handle<Script> script) {
+ if (!has_pending_error_) return;
+ MessageLocation location(script, start_position_, end_position_);
+ Factory* factory = isolate->factory();
+ bool has_arg = arg_ != NULL || char_arg_ != NULL;
+ Handle<FixedArray> elements = factory->NewFixedArray(has_arg ? 1 : 0);
+ if (arg_ != NULL) {
+ Handle<String> arg_string = arg_->string();
+ elements->set(0, *arg_string);
+ } else if (char_arg_ != NULL) {
+ Handle<String> arg_string =
+ factory->NewStringFromUtf8(CStrVector(char_arg_)).ToHandleChecked();
+ elements->set(0, *arg_string);
+ }
+ isolate->debug()->OnCompileError(script);
+
+ Handle<JSArray> array = factory->NewJSArrayWithElements(elements);
+ Handle<Object> error;
+
+ switch (error_type_) {
+ case kReferenceError:
+ error = factory->NewReferenceError(message_, array);
+ break;
+ case kSyntaxError:
+ error = factory->NewSyntaxError(message_, array);
+ break;
+ }
+
+ Handle<JSObject> jserror = Handle<JSObject>::cast(error);
+
+ Handle<Name> key_start_pos = factory->error_start_pos_symbol();
+ JSObject::SetProperty(jserror, key_start_pos,
+ handle(Smi::FromInt(location.start_pos()), isolate),
+ SLOPPY).Check();
+
+ Handle<Name> key_end_pos = factory->error_end_pos_symbol();
+ JSObject::SetProperty(jserror, key_end_pos,
+ handle(Smi::FromInt(location.end_pos()), isolate),
+ SLOPPY).Check();
+
+ Handle<Name> key_script = factory->error_script_symbol();
+ JSObject::SetProperty(jserror, key_script, script, SLOPPY).Check();
+
+ isolate->Throw(*error, &location);
+}
+}
+} // namespace v8::internal
« 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