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

Unified Diff: src/factory.cc

Issue 1087633005: Start migrating error message templates to the runtime. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix windows build Created 5 years, 8 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/factory.h ('k') | src/messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index a33f288ccbe7dfd2457f4350e2815930c5784a0e..57e5da77bd2b500b272ad18fb53ba196d9468026 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -1080,6 +1080,13 @@ Handle<Object> Factory::NewTypeError(const char* message,
}
+Handle<Object> Factory::NewTypeError(MessageTemplate::Template template_index,
+ Handle<Object> arg0, Handle<Object> arg1,
+ Handle<Object> arg2) {
+ return NewError("MakeTypeError2", template_index, arg0, arg1, arg2);
+}
+
+
Handle<Object> Factory::NewTypeError(Handle<String> message) {
return NewError("$TypeError", message);
}
@@ -1138,6 +1145,39 @@ Handle<Object> Factory::NewError(const char* maker, const char* message,
}
+Handle<Object> Factory::NewError(const char* maker,
+ MessageTemplate::Template template_index,
+ Handle<Object> arg0, Handle<Object> arg1,
+ Handle<Object> arg2) {
+ HandleScope scope(isolate());
+ Handle<String> error_maker = InternalizeUtf8String(maker);
+ Handle<Object> fun_obj = Object::GetProperty(isolate()->js_builtins_object(),
+ error_maker).ToHandleChecked();
+
+ Handle<JSFunction> fun = Handle<JSFunction>::cast(fun_obj);
+ Handle<Object> message_type(Smi::FromInt(template_index), isolate());
+ if (arg0.is_null()) arg0 = undefined_value();
+ if (arg1.is_null()) arg1 = undefined_value();
+ if (arg2.is_null()) arg2 = undefined_value();
+ Handle<Object> argv[] = {message_type, arg0, arg1, arg2};
+
+ // Invoke the JavaScript factory method. If an exception is thrown while
+ // running the factory method, use the exception as the result.
+ Handle<Object> result;
+ MaybeHandle<Object> exception;
+ if (!Execution::TryCall(fun, isolate()->js_builtins_object(), arraysize(argv),
+ argv, &exception).ToHandle(&result)) {
+ Handle<Object> exception_obj;
+ if (exception.ToHandle(&exception_obj)) {
+ result = exception_obj;
+ } else {
+ result = undefined_value();
+ }
+ }
+ return scope.CloseAndEscape(result);
+}
+
+
Handle<Object> Factory::NewEvalError(const char* message,
Vector<Handle<Object> > args) {
return NewError("MakeEvalError", message, args);
« no previous file with comments | « src/factory.h ('k') | src/messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698