summaryrefslogtreecommitdiff
path: root/deps/v8/src/messages.js
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2011-01-28 01:56:31 -0800
committerRyan Dahl <ry@tinyclouds.org>2011-01-28 01:57:00 -0800
commit7eaa956baee9070f8a073aa5c1bff01b1b8f2f5d (patch)
treef23f0a06b77cfd983640ff0fcf9e5d4714e4d108 /deps/v8/src/messages.js
parent97375c475e17562a016aa4d13f94030bd0f3ae37 (diff)
downloadnode-7eaa956baee9070f8a073aa5c1bff01b1b8f2f5d.tar.gz
Upgrade V8 to 3.0.12
Diffstat (limited to 'deps/v8/src/messages.js')
-rw-r--r--deps/v8/src/messages.js36
1 files changed, 32 insertions, 4 deletions
diff --git a/deps/v8/src/messages.js b/deps/v8/src/messages.js
index 932d64d2e..a072d3b47 100644
--- a/deps/v8/src/messages.js
+++ b/deps/v8/src/messages.js
@@ -82,20 +82,39 @@ function FormatString(format, args) {
var result = format;
for (var i = 0; i < args.length; i++) {
var str;
- try { str = ToDetailString(args[i]); }
- catch (e) { str = "#<error>"; }
+ try {
+ str = ToDetailString(args[i]);
+ } catch (e) {
+ str = "#<error>";
+ }
result = ArrayJoin.call(StringSplit.call(result, "%" + i), str);
}
return result;
}
+// To check if something is a native error we need to check the
+// concrete native error types. It is not enough to check "obj
+// instanceof $Error" because user code can replace
+// NativeError.prototype.__proto__. User code cannot replace
+// NativeError.prototype though and therefore this is a safe test.
+function IsNativeErrorObject(obj) {
+ return (obj instanceof $Error) ||
+ (obj instanceof $EvalError) ||
+ (obj instanceof $RangeError) ||
+ (obj instanceof $ReferenceError) ||
+ (obj instanceof $SyntaxError) ||
+ (obj instanceof $TypeError) ||
+ (obj instanceof $URIError);
+}
+
+
// When formatting internally created error messages, do not
// invoke overwritten error toString methods but explicitly use
// the error to string method. This is to avoid leaking error
// objects between script tags in a browser setting.
function ToStringCheckErrorObject(obj) {
- if (obj instanceof $Error) {
+ if (IsNativeErrorObject(obj)) {
return %_CallFunction(obj, errorToString);
} else {
return ToString(obj);
@@ -108,7 +127,9 @@ function ToDetailString(obj) {
var constructor = obj.constructor;
if (!constructor) return ToStringCheckErrorObject(obj);
var constructorName = constructor.name;
- if (!constructorName) return ToStringCheckErrorObject(obj);
+ if (!constructorName || !IS_STRING(constructorName)) {
+ return ToStringCheckErrorObject(obj);
+ }
return "#<" + GetInstanceName(constructorName) + ">";
} else {
return ToStringCheckErrorObject(obj);
@@ -216,6 +237,13 @@ function FormatMessage(message) {
strict_param_dupe: "Strict mode function may not have duplicate parameter names",
strict_var_name: "Variable name may not be eval or arguments in strict mode",
strict_function_name: "Function name may not be eval or arguments in strict mode",
+ strict_octal_literal: "Octal literals are not allowed in strict mode.",
+ strict_duplicate_property: "Duplicate data property in object literal not allowed in strict mode",
+ accessor_data_property: "Object literal may not have data and accessor property with the same name",
+ accessor_get_set: "Object literal may not have multiple get/set accessors with the same name",
+ strict_lhs_eval_assignment: "Assignment to eval or arguments is not allowed in strict mode",
+ strict_lhs_postfix: "Postfix increment/decrement may not have eval or arguments operand in strict mode",
+ strict_lhs_prefix: "Prefix increment/decrement may not have eval or arguments operand in strict mode",
};
}
var format = kMessages[message.type];