summaryrefslogtreecommitdiff
path: root/src/3rdparty/v8/src/messages.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/v8/src/messages.js')
-rw-r--r--src/3rdparty/v8/src/messages.js440
1 files changed, 223 insertions, 217 deletions
diff --git a/src/3rdparty/v8/src/messages.js b/src/3rdparty/v8/src/messages.js
index ab71936..f04bed9 100644
--- a/src/3rdparty/v8/src/messages.js
+++ b/src/3rdparty/v8/src/messages.js
@@ -26,18 +26,137 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// -------------------------------------------------------------------
-//
-// If this object gets passed to an error constructor the error will
-// get an accessor for .message that constructs a descriptive error
-// message on access.
-var kAddMessageAccessorsMarker = { };
-
-// This will be lazily initialized when first needed (and forcibly
-// overwritten even though it's const).
-var kMessages = 0;
-function FormatString(format, message) {
- var args = %MessageGetArguments(message);
+var kMessages = {
+ // Error
+ cyclic_proto: ["Cyclic __proto__ value"],
+ code_gen_from_strings: ["%0"],
+ // TypeError
+ unexpected_token: ["Unexpected token ", "%0"],
+ unexpected_token_number: ["Unexpected number"],
+ unexpected_token_string: ["Unexpected string"],
+ unexpected_token_identifier: ["Unexpected identifier"],
+ unexpected_reserved: ["Unexpected reserved word"],
+ unexpected_strict_reserved: ["Unexpected strict mode reserved word"],
+ unexpected_eos: ["Unexpected end of input"],
+ malformed_regexp: ["Invalid regular expression: /", "%0", "/: ", "%1"],
+ unterminated_regexp: ["Invalid regular expression: missing /"],
+ regexp_flags: ["Cannot supply flags when constructing one RegExp from another"],
+ incompatible_method_receiver: ["Method ", "%0", " called on incompatible receiver ", "%1"],
+ invalid_lhs_in_assignment: ["Invalid left-hand side in assignment"],
+ invalid_lhs_in_for_in: ["Invalid left-hand side in for-in"],
+ invalid_lhs_in_postfix_op: ["Invalid left-hand side expression in postfix operation"],
+ invalid_lhs_in_prefix_op: ["Invalid left-hand side expression in prefix operation"],
+ multiple_defaults_in_switch: ["More than one default clause in switch statement"],
+ newline_after_throw: ["Illegal newline after throw"],
+ redeclaration: ["%0", " '", "%1", "' has already been declared"],
+ no_catch_or_finally: ["Missing catch or finally after try"],
+ unknown_label: ["Undefined label '", "%0", "'"],
+ uncaught_exception: ["Uncaught ", "%0"],
+ 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"],
+ non_object_property_load: ["Cannot read property '", "%0", "' of ", "%1"],
+ non_object_property_store: ["Cannot set property '", "%0", "' of ", "%1"],
+ non_object_property_call: ["Cannot call method '", "%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"],
+ apply_wrong_args: ["Function.prototype.apply: Arguments list has wrong type"],
+ invalid_in_operator_use: ["Cannot use 'in' operator to search for '", "%0", "' in ", "%1"],
+ instanceof_function_expected: ["Expecting a function in instanceof check, but got ", "%0"],
+ instanceof_nonobject_proto: ["Function has non-object prototype '", "%0", "' in instanceof check"],
+ null_to_object: ["Cannot convert null to object"],
+ reduce_no_initial: ["Reduce of empty array with no initial value"],
+ getter_must_be_callable: ["Getter must be a function: ", "%0"],
+ setter_must_be_callable: ["Setter must be a function: ", "%0"],
+ value_and_accessor: ["Invalid property. A property cannot both have accessors and be writable or have a value, ", "%0"],
+ proto_object_or_null: ["Object prototype may only be an Object or null"],
+ property_desc_object: ["Property description must be an object: ", "%0"],
+ redefine_disallowed: ["Cannot redefine property: ", "%0"],
+ define_disallowed: ["Cannot define property:", "%0", ", object is not extensible."],
+ non_extensible_proto: ["%0", " is not extensible"],
+ handler_non_object: ["Proxy.", "%0", " called with non-object as handler"],
+ proto_non_object: ["Proxy.", "%0", " called with non-object as prototype"],
+ trap_function_expected: ["Proxy.", "%0", " called with non-function for '", "%1", "' trap"],
+ handler_trap_missing: ["Proxy handler ", "%0", " has no '", "%1", "' trap"],
+ handler_trap_must_be_callable: ["Proxy handler ", "%0", " has non-callable '", "%1", "' trap"],
+ handler_returned_false: ["Proxy handler ", "%0", " returned false from '", "%1", "' trap"],
+ handler_returned_undefined: ["Proxy handler ", "%0", " returned undefined from '", "%1", "' trap"],
+ proxy_prop_not_configurable: ["Proxy handler ", "%0", " returned non-configurable descriptor for property '", "%2", "' from '", "%1", "' trap"],
+ proxy_non_object_prop_names: ["Trap '", "%1", "' returned non-object ", "%0"],
+ proxy_repeated_prop_name: ["Trap '", "%1", "' returned repeated property name '", "%2", "'"],
+ invalid_weakmap_key: ["Invalid value used as weak map key"],
+ not_date_object: ["this is not a Date object."],
+ observe_non_object: ["Object.", "%0", " cannot ", "%0", " non-object"],
+ observe_non_function: ["Object.", "%0", " cannot deliver to non-function"],
+ observe_callback_frozen: ["Object.observe cannot deliver to a frozen function object"],
+ observe_type_non_string: ["Invalid changeRecord with non-string 'type' property"],
+ observe_notify_non_notifier: ["notify called on non-notifier object"],
+ // RangeError
+ invalid_array_length: ["Invalid array length"],
+ stack_overflow: ["Maximum call stack size exceeded"],
+ invalid_time_value: ["Invalid time value"],
+ // SyntaxError
+ unable_to_parse: ["Parse error"],
+ invalid_regexp_flags: ["Invalid flags supplied to RegExp constructor '", "%0", "'"],
+ invalid_regexp: ["Invalid RegExp pattern /", "%0", "/"],
+ illegal_break: ["Illegal break statement"],
+ illegal_continue: ["Illegal continue statement"],
+ illegal_return: ["Illegal return statement"],
+ illegal_let: ["Illegal let declaration outside extended mode"],
+ error_loading_debugger: ["Error loading debugger"],
+ no_input_to_regexp: ["No input to ", "%0"],
+ invalid_json: ["String '", "%0", "' is not valid JSON"],
+ circular_structure: ["Converting circular structure to JSON"],
+ called_on_non_object: ["%0", " called on non-object"],
+ called_on_null_or_undefined: ["%0", " called on null or undefined"],
+ array_indexof_not_defined: ["Array.getIndexOf: Argument undefined"],
+ object_not_extensible: ["Can't add property ", "%0", ", object is not extensible"],
+ illegal_access: ["Illegal access"],
+ invalid_preparser_data: ["Invalid preparser data for function ", "%0"],
+ strict_mode_with: ["Strict mode code may not include a with statement"],
+ strict_catch_variable: ["Catch variable may not be eval or arguments in strict mode"],
+ too_many_arguments: ["Too many arguments in function call (only 32766 allowed)"],
+ too_many_parameters: ["Too many parameters in function definition (only 32766 allowed)"],
+ too_many_variables: ["Too many variables declared (only 131071 allowed)"],
+ strict_param_name: ["Parameter name eval or arguments is not allowed in strict mode"],
+ 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_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"],
+ strict_reserved_word: ["Use of future reserved word in strict mode"],
+ strict_delete: ["Delete of an unqualified identifier in strict mode."],
+ strict_delete_property: ["Cannot delete property '", "%0", "' of ", "%1"],
+ strict_const: ["Use of const in strict mode."],
+ strict_function: ["In strict mode code, functions can only be declared at top level or immediately within another function." ],
+ strict_read_only_property: ["Cannot assign to read only property '", "%0", "' of ", "%1"],
+ strict_cannot_assign: ["Cannot assign to read only '", "%0", "' in strict mode"],
+ strict_poison_pill: ["'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them"],
+ strict_caller: ["Illegal access to a strict mode caller function."],
+ unprotected_let: ["Illegal let declaration in unprotected statement context."],
+ unprotected_const: ["Illegal const declaration in unprotected statement context."],
+ cant_prevent_ext_external_array_elements: ["Cannot prevent extension of an object with external array elements"],
+ redef_external_array_element: ["Cannot redefine a property of an object with external array elements"],
+ harmony_const_assign: ["Assignment to constant variable."],
+ invalid_module_path: ["Module does not export '", "%0", "', or export is not itself a module"],
+ module_type_error: ["Module '", "%0", "' used improperly"],
+ module_export_undefined: ["Export '", "%0", "' is not defined in module"],
+};
+
+
+function FormatString(format, args) {
var result = "";
var arg_num = 0;
for (var i = 0; i < format.length; i++) {
@@ -48,9 +167,14 @@ function FormatString(format, message) {
if (arg_num < 4) {
// str is one of %0, %1, %2 or %3.
try {
- str = ToDetailString(args[arg_num]);
+ str = NoSideEffectToString(args[arg_num]);
} catch (e) {
- str = "#<error>";
+ if (%IsJSModule(args[arg_num]))
+ str = "module";
+ else if (IS_SPEC_OBJECT(args[arg_num]))
+ str = "object";
+ else
+ str = "#<error>";
}
}
}
@@ -60,6 +184,26 @@ function FormatString(format, message) {
}
+function NoSideEffectToString(obj) {
+ if (IS_STRING(obj)) return obj;
+ if (IS_NUMBER(obj)) return %_NumberToString(obj);
+ if (IS_BOOLEAN(obj)) return x ? 'true' : 'false';
+ if (IS_UNDEFINED(obj)) return 'undefined';
+ if (IS_NULL(obj)) return 'null';
+ if (IS_OBJECT(obj) && %GetDataProperty(obj, "toString") === ObjectToString) {
+ var constructor = obj.constructor;
+ if (typeof constructor == "function") {
+ var constructorName = constructor.name;
+ if (IS_STRING(constructorName) && constructorName !== "") {
+ return "#<" + constructorName + ">";
+ }
+ }
+ }
+ if (IsNativeErrorObject(obj)) return %_CallFunction(obj, ErrorToString);
+ return %_CallFunction(obj, ObjectToString);
+}
+
+
// To check if something is a native error we need to check the
// concrete native error types. It is not sufficient to use instanceof
// since it possible to create an object that has Error.prototype on
@@ -110,7 +254,7 @@ function MakeGenericError(constructor, type, args) {
if (IS_UNDEFINED(args)) {
args = [];
}
- var e = new constructor(kAddMessageAccessorsMarker);
+ var e = new constructor(FormatMessage(type, args));
e.type = type;
e.arguments = args;
return e;
@@ -130,154 +274,10 @@ function MakeGenericError(constructor, type, args) {
// Helper functions; called from the runtime system.
-function FormatMessage(message) {
- if (kMessages === 0) {
- var messagesDictionary = [
- // Error
- "cyclic_proto", ["Cyclic __proto__ value"],
- "code_gen_from_strings", ["Code generation from strings disallowed for this context"],
- // TypeError
- "unexpected_token", ["Unexpected token ", "%0"],
- "unexpected_token_number", ["Unexpected number"],
- "unexpected_token_string", ["Unexpected string"],
- "unexpected_token_identifier", ["Unexpected identifier"],
- "unexpected_reserved", ["Unexpected reserved word"],
- "unexpected_strict_reserved", ["Unexpected strict mode reserved word"],
- "unexpected_eos", ["Unexpected end of input"],
- "malformed_regexp", ["Invalid regular expression: /", "%0", "/: ", "%1"],
- "unterminated_regexp", ["Invalid regular expression: missing /"],
- "regexp_flags", ["Cannot supply flags when constructing one RegExp from another"],
- "incompatible_method_receiver", ["Method ", "%0", " called on incompatible receiver ", "%1"],
- "invalid_lhs_in_assignment", ["Invalid left-hand side in assignment"],
- "invalid_lhs_in_for_in", ["Invalid left-hand side in for-in"],
- "invalid_lhs_in_postfix_op", ["Invalid left-hand side expression in postfix operation"],
- "invalid_lhs_in_prefix_op", ["Invalid left-hand side expression in prefix operation"],
- "multiple_defaults_in_switch", ["More than one default clause in switch statement"],
- "newline_after_throw", ["Illegal newline after throw"],
- "redeclaration", ["%0", " '", "%1", "' has already been declared"],
- "no_catch_or_finally", ["Missing catch or finally after try"],
- "unknown_label", ["Undefined label '", "%0", "'"],
- "uncaught_exception", ["Uncaught ", "%0"],
- "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"],
- "non_object_property_load", ["Cannot read property '", "%0", "' of ", "%1"],
- "non_object_property_store", ["Cannot set property '", "%0", "' of ", "%1"],
- "non_object_property_call", ["Cannot call method '", "%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"],
- "apply_wrong_args", ["Function.prototype.apply: Arguments list has wrong type"],
- "invalid_in_operator_use", ["Cannot use 'in' operator to search for '", "%0", "' in ", "%1"],
- "instanceof_function_expected", ["Expecting a function in instanceof check, but got ", "%0"],
- "instanceof_nonobject_proto", ["Function has non-object prototype '", "%0", "' in instanceof check"],
- "null_to_object", ["Cannot convert null to object"],
- "reduce_no_initial", ["Reduce of empty array with no initial value"],
- "getter_must_be_callable", ["Getter must be a function: ", "%0"],
- "setter_must_be_callable", ["Setter must be a function: ", "%0"],
- "value_and_accessor", ["Invalid property. A property cannot both have accessors and be writable or have a value, ", "%0"],
- "proto_object_or_null", ["Object prototype may only be an Object or null"],
- "property_desc_object", ["Property description must be an object: ", "%0"],
- "redefine_disallowed", ["Cannot redefine property: ", "%0"],
- "define_disallowed", ["Cannot define property:", "%0", ", object is not extensible."],
- "non_extensible_proto", ["%0", " is not extensible"],
- "handler_non_object", ["Proxy.", "%0", " called with non-object as handler"],
- "proto_non_object", ["Proxy.", "%0", " called with non-object as prototype"],
- "trap_function_expected", ["Proxy.", "%0", " called with non-function for '", "%1", "' trap"],
- "handler_trap_missing", ["Proxy handler ", "%0", " has no '", "%1", "' trap"],
- "handler_trap_must_be_callable", ["Proxy handler ", "%0", " has non-callable '", "%1", "' trap"],
- "handler_returned_false", ["Proxy handler ", "%0", " returned false from '", "%1", "' trap"],
- "handler_returned_undefined", ["Proxy handler ", "%0", " returned undefined from '", "%1", "' trap"],
- "proxy_prop_not_configurable", ["Proxy handler ", "%0", " returned non-configurable descriptor for property '", "%2", "' from '", "%1", "' trap"],
- "proxy_non_object_prop_names", ["Trap '", "%1", "' returned non-object ", "%0"],
- "proxy_repeated_prop_name", ["Trap '", "%1", "' returned repeated property name '", "%2", "'"],
- "invalid_weakmap_key", ["Invalid value used as weak map key"],
- // RangeError
- "invalid_array_length", ["Invalid array length"],
- "stack_overflow", ["Maximum call stack size exceeded"],
- "invalid_time_value", ["Invalid time value"],
- // SyntaxError
- "unable_to_parse", ["Parse error"],
- "invalid_regexp_flags", ["Invalid flags supplied to RegExp constructor '", "%0", "'"],
- "invalid_regexp", ["Invalid RegExp pattern /", "%0", "/"],
- "illegal_break", ["Illegal break statement"],
- "illegal_continue", ["Illegal continue statement"],
- "illegal_return", ["Illegal return statement"],
- "illegal_let", ["Illegal let declaration outside extended mode"],
- "error_loading_debugger", ["Error loading debugger"],
- "no_input_to_regexp", ["No input to ", "%0"],
- "invalid_json", ["String '", "%0", "' is not valid JSON"],
- "circular_structure", ["Converting circular structure to JSON"],
- "called_on_non_object", ["%0", " called on non-object"],
- "called_on_null_or_undefined", ["%0", " called on null or undefined"],
- "array_indexof_not_defined", ["Array.getIndexOf: Argument undefined"],
- "object_not_extensible", ["Can't add property ", "%0", ", object is not extensible"],
- "illegal_access", ["Illegal access"],
- "invalid_preparser_data", ["Invalid preparser data for function ", "%0"],
- "strict_mode_with", ["Strict mode code may not include a with statement"],
- "strict_catch_variable", ["Catch variable may not be eval or arguments in strict mode"],
- "too_many_arguments", ["Too many arguments in function call (only 32766 allowed)"],
- "too_many_parameters", ["Too many parameters in function definition (only 32766 allowed)"],
- "too_many_variables", ["Too many variables declared (only 32767 allowed)"],
- "strict_param_name", ["Parameter name eval or arguments is not allowed in strict mode"],
- "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_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"],
- "strict_reserved_word", ["Use of future reserved word in strict mode"],
- "strict_delete", ["Delete of an unqualified identifier in strict mode."],
- "strict_delete_property", ["Cannot delete property '", "%0", "' of ", "%1"],
- "strict_const", ["Use of const in strict mode."],
- "strict_function", ["In strict mode code, functions can only be declared at top level or immediately within another function." ],
- "strict_read_only_property", ["Cannot assign to read only property '", "%0", "' of ", "%1"],
- "strict_cannot_assign", ["Cannot assign to read only '", "%0", "' in strict mode"],
- "strict_poison_pill", ["'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them"],
- "strict_caller", ["Illegal access to a strict mode caller function."],
- "unprotected_let", ["Illegal let declaration in unprotected statement context."],
- "unprotected_const", ["Illegal const declaration in unprotected statement context."],
- "cant_prevent_ext_external_array_elements", ["Cannot prevent extension of an object with external array elements"],
- "redef_external_array_element", ["Cannot redefine a property of an object with external array elements"],
- "harmony_const_assign", ["Assignment to constant variable."],
- "invalid_module_path", ["Module does not export '", "%0", "', or export is not itself a module"],
- "module_type_error", ["Module '", "%0", "' used improperly"],
- ];
- var messages = { __proto__ : null };
- for (var i = 0; i < messagesDictionary.length; i += 2) {
- var key = messagesDictionary[i];
- var format = messagesDictionary[i + 1];
-
- for (var j = 0; j < format.length; j++) {
- %IgnoreAttributesAndSetProperty(format, %_NumberToString(j), format[j],
- DONT_DELETE | READ_ONLY | DONT_ENUM);
- }
- %IgnoreAttributesAndSetProperty(format, 'length', format.length,
- DONT_DELETE | READ_ONLY | DONT_ENUM);
- %PreventExtensions(format);
- %IgnoreAttributesAndSetProperty(messages,
- key,
- format,
- DONT_DELETE | DONT_ENUM | READ_ONLY);
- }
- %PreventExtensions(messages);
- %IgnoreAttributesAndSetProperty(builtins, "kMessages",
- messages,
- DONT_DELETE | DONT_ENUM | READ_ONLY);
- }
- var message_type = %MessageGetType(message);
- var format = kMessages[message_type];
- if (!format) return "<unknown message " + message_type + ">";
- return FormatString(format, message);
+function FormatMessage(type, args) {
+ var format = kMessages[type];
+ if (!format) return "<unknown message " + type + ">";
+ return FormatString(format, args);
}
@@ -525,8 +525,8 @@ function ScriptLineCount() {
/**
- * Returns the name of script if available, contents of sourceURL comment
- * otherwise. See
+ * If sourceURL comment is available and script starts at zero returns sourceURL
+ * comment contents. Otherwise, script name is returned. See
* http://fbug.googlecode.com/svn/branches/firebug1.1/docs/ReleaseNotes_1.1.txt
* for details on using //@ sourceURL comment to identify scritps that don't
* have name.
@@ -535,14 +535,15 @@ function ScriptLineCount() {
* otherwise.
*/
function ScriptNameOrSourceURL() {
- if (this.name) {
+ if (this.line_offset > 0 || this.column_offset > 0) {
return this.name;
}
// The result is cached as on long scripts it takes noticable time to search
// for the sourceURL.
- if (this.hasCachedNameOrSourceURL)
- return this.cachedNameOrSourceURL;
+ if (this.hasCachedNameOrSourceURL) {
+ return this.cachedNameOrSourceURL;
+ }
this.hasCachedNameOrSourceURL = true;
// TODO(608): the spaces in a regexp below had to be escaped as \040
@@ -760,18 +761,18 @@ function DefineOneShotAccessor(obj, name, fun) {
// Note that the accessors consistently operate on 'obj', not 'this'.
// Since the object may occur in someone else's prototype chain we
// can't rely on 'this' being the same as 'obj'.
- var hasBeenSet = false;
var value;
+ var value_factory = fun;
var getter = function() {
- if (hasBeenSet) {
+ if (value_factory == null) {
return value;
}
- hasBeenSet = true;
- value = fun(obj);
+ value = value_factory(obj);
+ value_factory = null;
return value;
};
var setter = function(v) {
- hasBeenSet = true;
+ value_factory = null;
value = v;
};
%DefineOrRedefineAccessorProperty(obj, name, getter, setter, DONT_ENUM);
@@ -788,15 +789,7 @@ function CallSiteGetThis() {
}
function CallSiteGetTypeName() {
- var constructor = this.receiver.constructor;
- if (!constructor) {
- return %_CallFunction(this.receiver, ObjectToString);
- }
- var constructorName = constructor.name;
- if (!constructorName) {
- return %_CallFunction(this.receiver, ObjectToString);
- }
- return constructorName;
+ return GetTypeName(this, false);
}
function CallSiteIsToplevel() {
@@ -830,8 +823,10 @@ function CallSiteGetFunctionName() {
var name = this.fun.name;
if (name) {
return name;
- } else {
- return %FunctionGetInferredName(this.fun);
+ }
+ name = %FunctionGetInferredName(this.fun);
+ if (name) {
+ return name;
}
// Maybe this is an evaluation?
var script = %FunctionGetScript(this.fun);
@@ -859,9 +854,9 @@ function CallSiteGetMethodName() {
}
var name = null;
for (var prop in this.receiver) {
- if (this.receiver.__lookupGetter__(prop) === this.fun ||
- this.receiver.__lookupSetter__(prop) === this.fun ||
- (!this.receiver.__lookupGetter__(prop) &&
+ if (%_CallFunction(this.receiver, prop, ObjectLookupGetter) === this.fun ||
+ %_CallFunction(this.receiver, prop, ObjectLookupSetter) === this.fun ||
+ (!%_CallFunction(this.receiver, prop, ObjectLookupGetter) &&
this.receiver[prop] === this.fun)) {
// If we find more than one match bail out to avoid confusion.
if (name) {
@@ -927,17 +922,25 @@ function CallSiteToString() {
var fileLocation = "";
if (this.isNative()) {
fileLocation = "native";
- } else if (this.isEval()) {
- fileName = this.getScriptNameOrSourceURL();
- if (!fileName) {
- fileLocation = this.getEvalOrigin();
- }
} else {
- fileName = this.getFileName();
- }
+ if (this.isEval()) {
+ fileName = this.getScriptNameOrSourceURL();
+ if (!fileName) {
+ fileLocation = this.getEvalOrigin();
+ fileLocation += ", "; // Expecting source position to follow.
+ }
+ } else {
+ fileName = this.getFileName();
+ }
- if (fileName) {
- fileLocation += fileName;
+ if (fileName) {
+ fileLocation += fileName;
+ } else {
+ // Source code does not originate from a file and is not native, but we
+ // can still get the source position inside the source string, e.g. in
+ // an eval string.
+ fileLocation += "<anonymous>";
+ }
var lineNumber = this.getLineNumber();
if (lineNumber != null) {
fileLocation += ":" + lineNumber;
@@ -948,24 +951,25 @@ function CallSiteToString() {
}
}
- if (!fileLocation) {
- fileLocation = "unknown source";
- }
var line = "";
- var functionName = this.getFunction().name;
- var addPrefix = true;
+ var functionName = this.getFunctionName();
+ var addSuffix = true;
var isConstructor = this.isConstructor();
var isMethodCall = !(this.isToplevel() || isConstructor);
if (isMethodCall) {
+ var typeName = GetTypeName(this, true);
var methodName = this.getMethodName();
- line += this.getTypeName() + ".";
if (functionName) {
+ if (typeName && functionName.indexOf(typeName) != 0) {
+ line += typeName + ".";
+ }
line += functionName;
- if (methodName && (methodName != functionName)) {
+ if (methodName && functionName.lastIndexOf("." + methodName) !=
+ functionName.length - methodName.length - 1) {
line += " [as " + methodName + "]";
}
} else {
- line += methodName || "<anonymous>";
+ line += typeName + "." + (methodName || "<anonymous>");
}
} else if (isConstructor) {
line += "new " + (functionName || "<anonymous>");
@@ -973,9 +977,9 @@ function CallSiteToString() {
line += functionName;
} else {
line += fileLocation;
- addPrefix = false;
+ addSuffix = false;
}
- if (addPrefix) {
+ if (addSuffix) {
line += " (" + fileLocation + ")";
}
return line;
@@ -1085,6 +1089,19 @@ function FormatRawStackTrace(error, raw_stack) {
}
}
+function GetTypeName(obj, requireConstructor) {
+ var constructor = obj.receiver.constructor;
+ if (!constructor) {
+ return requireConstructor ? null :
+ %_CallFunction(obj.receiver, ObjectToString);
+ }
+ var constructorName = constructor.name;
+ if (!constructorName) {
+ return requireConstructor ? null :
+ %_CallFunction(obj.receiver, ObjectToString);
+ }
+ return constructorName;
+}
function captureStackTrace(obj, cons_opt) {
var stackTraceLimit = $Error.stackTraceLimit;
@@ -1138,13 +1155,7 @@ function SetUpError() {
%IgnoreAttributesAndSetProperty(this, 'stack', void 0, DONT_ENUM);
%IgnoreAttributesAndSetProperty(this, 'arguments', void 0, DONT_ENUM);
%IgnoreAttributesAndSetProperty(this, 'type', void 0, DONT_ENUM);
- if (m === kAddMessageAccessorsMarker) {
- // DefineOneShotAccessor always inserts a message property and
- // ignores setters.
- DefineOneShotAccessor(this, 'message', function (obj) {
- return FormatMessage(%NewMessageObject(obj.type, obj.arguments));
- });
- } else if (!IS_UNDEFINED(m)) {
+ if (!IS_UNDEFINED(m)) {
%IgnoreAttributesAndSetProperty(
this, 'message', ToString(m), DONT_ENUM);
}
@@ -1207,11 +1218,6 @@ function ErrorToStringDetectCycle(error) {
var name = GetPropertyWithoutInvokingMonkeyGetters(error, "name");
name = IS_UNDEFINED(name) ? "Error" : TO_STRING_INLINE(name);
var message = GetPropertyWithoutInvokingMonkeyGetters(error, "message");
- var hasMessage = %_CallFunction(error, "message", ObjectHasOwnProperty);
- if (type && !hasMessage) {
- var args = GetPropertyWithoutInvokingMonkeyGetters(error, "arguments");
- message = FormatMessage(%NewMessageObject(type, args));
- }
message = IS_UNDEFINED(message) ? "" : TO_STRING_INLINE(message);
if (name === "") return message;
if (message === "") return name;