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

Unified Diff: src/messages.js

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/messages.cc ('k') | src/runtime/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/messages.js
diff --git a/src/messages.js b/src/messages.js
index 5900ed18e2a24cc3ecbf91f943de22f7bd1ba6ba..9c8c075e9ee503a8217ddfe453d6c31c82343754 100644
--- a/src/messages.js
+++ b/src/messages.js
@@ -39,7 +39,6 @@ var kMessages = {
stack_trace: ["Stack Trace:\n", "%0"],
called_non_callable: ["%0", " is not a function"],
undefined_method: ["Object ", "%1", " has no method '", "%0", "'"],
- property_not_function: ["Property '", "%0", "' of object ", "%1", " is not a function"],
cannot_convert_to_primitive: ["Cannot convert object to primitive value"],
not_constructor: ["%0", " is not a constructor"],
not_defined: ["%0", " is not defined"],
@@ -47,7 +46,6 @@ var kMessages = {
unsupported_super: ["Unsupported reference to 'super'"],
non_object_property_load: ["Cannot read property '", "%0", "' of ", "%1"],
non_object_property_store: ["Cannot set property '", "%0", "' of ", "%1"],
- with_expression: ["%0", " has no properties"],
illegal_invocation: ["Illegal invocation"],
no_setter_in_callback: ["Cannot set property ", "%0", " of ", "%1", " which has only a getter"],
apply_non_function: ["Function.prototype.apply was called on ", "%0", ", which is a ", "%1", " and not a function"],
@@ -325,6 +323,11 @@ function MakeGenericError(constructor, type, args) {
}
+function MakeGenericError2(constructor, type, arg0, arg1, arg2) {
+ return new constructor(FormatMessage(type, arg0, arg1, arg2));
+}
+
+
/**
* Set up the Script function and constructor.
*/
@@ -338,10 +341,21 @@ function MakeGenericError(constructor, type, args) {
// Helper functions; called from the runtime system.
-function FormatMessage(type, args) {
+function FormatMessage(type, arg0, arg1, arg2) {
+ if (IS_NUMBER(type)) {
+ var arg0 = NoSideEffectToString(arg0);
+ var arg1 = NoSideEffectToString(arg1);
+ var arg2 = NoSideEffectToString(arg2);
+ try {
+ return %FormatMessageString(type, arg0, arg1, arg2);
+ } catch (e) {
+ return "";
+ }
+ }
+ // TODO(yangguo): remove this code path once we migrated all messages.
var format = kMessages[type];
if (!format) return "<unknown message " + type + ">";
- return FormatString(format, args);
+ return FormatString(format, arg0);
}
@@ -371,6 +385,12 @@ function MakeTypeError(type, args) {
}
+// TODO(yangguo): rename this once we migrated all messages.
+function MakeTypeError2(type, arg0, arg1, arg2) {
+ return MakeGenericError2($TypeError, type, arg0, arg1, arg2);
+}
+
+
function MakeRangeError(type, args) {
return MakeGenericError($RangeError, type, args);
}
« no previous file with comments | « src/messages.cc ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698