// ECMA 262 - 15.9.5.5
function DateToLocaleString() {
- return DateToString.call(this);
+ return %_CallFunction(this, DateToString);
}
// do that either. Instead, we create a new function whose name
// property will return toGMTString.
function DateToGMTString() {
- return DateToUTCString.call(this);
+ return %_CallFunction(this, DateToUTCString);
}
}
} else {
for (var p in val) {
- if (ObjectHasOwnProperty.call(val, p)) {
+ if (%_CallFunction(val, p, ObjectHasOwnProperty)) {
var newElement = Revive(val, p, reviver);
if (IS_UNDEFINED(newElement)) {
delete val[p];
if (IS_ARRAY(replacer)) {
var length = replacer.length;
for (var i = 0; i < length; i++) {
- if (ObjectHasOwnProperty.call(replacer, i)) {
+ if (%_CallFunction(replacer, i, ObjectHasOwnProperty)) {
var p = replacer[i];
var strP = JSONSerialize(p, value, replacer, stack, indent, gap);
if (!IS_UNDEFINED(strP)) {
}
} else {
for (var p in value) {
- if (ObjectHasOwnProperty.call(value, p)) {
+ if (%_CallFunction(value, p, ObjectHasOwnProperty)) {
var strP = JSONSerialize(p, value, replacer, stack, indent, gap);
if (!IS_UNDEFINED(strP)) {
var member = %QuoteJSONString(p) + ":";
// message on access.
var kAddMessageAccessorsMarker = { };
-
-function GetInstanceName(cons) {
- if (cons.length == 0) {
- return "";
- }
- var first = %StringToLowerCase(StringCharAt.call(cons, 0));
- if (kVowelSounds === 0) {
- kVowelSounds = {a: true, e: true, i: true, o: true, u: true, y: true};
- kCapitalVowelSounds = {a: true, e: true, i: true, o: true, u: true, h: true,
- f: true, l: true, m: true, n: true, r: true, s: true, x: true, y: true};
- }
- var vowel_mapping = kVowelSounds;
- if (cons.length > 1 && (StringCharAt.call(cons, 0) != first)) {
- // First char is upper case
- var second = %StringToLowerCase(StringCharAt.call(cons, 1));
- // Second char is upper case
- if (StringCharAt.call(cons, 1) != second) {
- vowel_mapping = kCapitalVowelSounds;
- }
- }
- var s = vowel_mapping[first] ? "an " : "a ";
- return s + cons;
-}
-
-
var kMessages = 0;
+var kReplacementMarkers =
+ [ "%0", "%1", "%2", "%3", "%4", "%5", "%6", "%7", "%8", "%9", "%10" ];
function FormatString(format, args) {
var result = format;
} catch (e) {
str = "#<error>";
}
- result = ArrayJoin.call(StringSplit.call(result, "%" + i), str);
+ var replacement_marker = kReplacementMarkers[i];
+ var split = %_CallFunction(result, replacement_marker, StringSplit);
+ result = %_CallFunction(split, str, ArrayJoin);
}
return result;
}
if (!constructorName || !IS_STRING(constructorName)) {
return ToStringCheckErrorObject(obj);
}
- return "#<" + GetInstanceName(constructorName) + ">";
+ return "#<" + constructorName + ">";
} else {
return ToStringCheckErrorObject(obj);
}
var line_ends = this.line_ends;
var start = line == 0 ? 0 : line_ends[line - 1] + 1;
var end = line_ends[line];
- if (end > 0 && StringCharAt.call(this.source, end - 1) == '\r') end--;
+ if (end > 0 && %_CallFunction(this.source, end - 1, StringCharAt) == '\r') end--;
var column = position - start;
// Adjust according to the offset within the resource.
var line_ends = this.line_ends;
var start = line == 0 ? 0 : line_ends[line - 1] + 1;
var end = line_ends[line];
- return StringSubstring.call(this.source, start, end);
+ return %_CallFunction(this.source, start, end, StringSubstring);
}
* Source text for this location.
*/
SourceLocation.prototype.sourceText = function () {
- return StringSubstring.call(this.script.source, this.start, this.end);
+ return %_CallFunction(this.script.source, this.start, this.end, StringSubstring);
};
* the line terminating characters (if any)
*/
SourceSlice.prototype.sourceText = function () {
- return StringSubstring.call(this.script.source, this.from_position, this.to_position);
+ return %_CallFunction(this.script.source,
+ this.from_position,
+ this.to_position,
+ StringSubstring);
};
CallSite.prototype.getTypeName = function () {
var constructor = this.receiver.constructor;
if (!constructor)
- return $Object.prototype.toString.call(this.receiver);
+ return %_CallFunction(this.receiver, ObjectToString);
var constructorName = constructor.name;
if (!constructorName)
- return $Object.prototype.toString.call(this.receiver);
+ return %_CallFunction(this.receiver, ObjectToString);
return constructorName;
};
// this function.
var ownName = this.fun.name;
if (ownName && this.receiver &&
- (ObjectLookupGetter.call(this.receiver, ownName) === this.fun ||
- ObjectLookupSetter.call(this.receiver, ownName) === this.fun ||
+ (%_CallFunction(this.receiver, ownName, ObjectLookupGetter) === this.fun ||
+ %_CallFunction(this.receiver, ownName, ObjectLookupSetter) === this.fun ||
this.receiver[ownName] === this.fun)) {
// To handle DontEnum properties we guess that the method has
// the same name as the function.
Mirror.prototype.toText = function() {
// Simpel to text which is used when on specialization in subclass.
- return "#<" + builtins.GetInstanceName(this.constructor.name) + ">";
+ return "#<" + this.constructor.name + ">";
}
* @extends Mirror
*/
function ValueMirror(type, value, transient) {
- Mirror.call(this, type);
+ %_CallFunction(this, type, Mirror);
this.value_ = value;
if (!transient) {
this.allocateHandle_();
* @extends ValueMirror
*/
function UndefinedMirror() {
- ValueMirror.call(this, UNDEFINED_TYPE, void 0);
+ %_CallFunction(this, UNDEFINED_TYPE, void 0, ValueMirror);
}
inherits(UndefinedMirror, ValueMirror);
* @extends ValueMirror
*/
function NullMirror() {
- ValueMirror.call(this, NULL_TYPE, null);
+ %_CallFunction(this, NULL_TYPE, null, ValueMirror);
}
inherits(NullMirror, ValueMirror);
* @extends ValueMirror
*/
function BooleanMirror(value) {
- ValueMirror.call(this, BOOLEAN_TYPE, value);
+ %_CallFunction(this, BOOLEAN_TYPE, value, ValueMirror);
}
inherits(BooleanMirror, ValueMirror);
* @extends ValueMirror
*/
function NumberMirror(value) {
- ValueMirror.call(this, NUMBER_TYPE, value);
+ %_CallFunction(this, NUMBER_TYPE, value, ValueMirror);
}
inherits(NumberMirror, ValueMirror);
* @extends ValueMirror
*/
function StringMirror(value) {
- ValueMirror.call(this, STRING_TYPE, value);
+ %_CallFunction(this, STRING_TYPE, value, ValueMirror);
}
inherits(StringMirror, ValueMirror);
* @extends ValueMirror
*/
function ObjectMirror(value, type, transient) {
- ValueMirror.call(this, type || OBJECT_TYPE, value, transient);
+ %_CallFunction(this, type || OBJECT_TYPE, value, transient, ValueMirror);
}
inherits(ObjectMirror, ValueMirror);
name = this.className();
}
}
- return '#<' + builtins.GetInstanceName(name) + '>';
+ return '#<' + name + '>';
};
* @extends ObjectMirror
*/
function FunctionMirror(value) {
- ObjectMirror.call(this, value, FUNCTION_TYPE);
+ %_CallFunction(this, value, FUNCTION_TYPE, ObjectMirror);
this.resolved_ = true;
}
inherits(FunctionMirror, ObjectMirror);
function UnresolvedFunctionMirror(value) {
// Construct this using the ValueMirror as an unresolved function is not a
// real object but just a string.
- ValueMirror.call(this, FUNCTION_TYPE, value);
+ %_CallFunction(this, FUNCTION_TYPE, value, ValueMirror);
this.propertyCount_ = 0;
this.elementCount_ = 0;
this.resolved_ = false;
* @extends ObjectMirror
*/
function ArrayMirror(value) {
- ObjectMirror.call(this, value);
+ %_CallFunction(this, value, ObjectMirror);
}
inherits(ArrayMirror, ObjectMirror);
* @extends ObjectMirror
*/
function DateMirror(value) {
- ObjectMirror.call(this, value);
+ %_CallFunction(this, value, ObjectMirror);
}
inherits(DateMirror, ObjectMirror);
* @extends ObjectMirror
*/
function RegExpMirror(value) {
- ObjectMirror.call(this, value, REGEXP_TYPE);
+ %_CallFunction(this, value, REGEXP_TYPE, ObjectMirror);
}
inherits(RegExpMirror, ObjectMirror);
* @extends ObjectMirror
*/
function ErrorMirror(value) {
- ObjectMirror.call(this, value, ERROR_TYPE);
+ %_CallFunction(this, value, ERROR_TYPE, ObjectMirror);
}
inherits(ErrorMirror, ObjectMirror);
* @extends Mirror
*/
function PropertyMirror(mirror, name, details) {
- Mirror.call(this, PROPERTY_TYPE);
+ %_CallFunction(this, PROPERTY_TYPE, Mirror);
this.mirror_ = mirror;
this.name_ = name;
this.value_ = details[0];
* @extends Mirror
*/
function FrameMirror(break_id, index) {
- Mirror.call(this, FRAME_TYPE);
+ %_CallFunction(this, FRAME_TYPE, Mirror);
this.break_id_ = break_id;
this.index_ = index;
this.details_ = new FrameDetails(break_id, index);
* @extends Mirror
*/
function ScopeMirror(frame, index) {
- Mirror.call(this, SCOPE_TYPE);
+ %_CallFunction(this, SCOPE_TYPE, Mirror);
this.frame_index_ = frame.index_;
this.scope_index_ = index;
this.details_ = new ScopeDetails(frame, index);
* @extends Mirror
*/
function ScriptMirror(script) {
- Mirror.call(this, SCRIPT_TYPE);
+ %_CallFunction(this, SCRIPT_TYPE, Mirror);
this.script_ = script;
this.context_ = new ContextMirror(script.context_data);
this.allocateHandle_();
* @extends Mirror
*/
function ContextMirror(data) {
- Mirror.call(this, CONTEXT_TYPE);
+ %_CallFunction(this, CONTEXT_TYPE, Mirror);
this.data_ = data;
this.allocateHandle_();
}
var multiline = false;
for (var i = 0; i < flags.length; i++) {
- var c = StringCharAt.call(flags, i);
+ var c = %_CallFunction(flags, i, StringCharAt);
switch (c) {
case 'g':
// Allow duplicate flags to be consistent with JSC and others.
v8::HandleScope scope;
v8::V8::AddMessageListener(check_reference_error_message);
LocalContext context;
+ CompileRun("Number.prototype.toString = function f() { return 'Yikes'; }");
+ CompileRun("String.prototype.toString = function f() { return 'Yikes'; }");
CompileRun("ReferenceError.prototype.toString ="
" function() { return 'Whoops' }");
CompileRun("asdf;");
" var str = String(e);"
" if (str.indexOf('TypeError') == -1) return 1;"
" if (str.indexOf('[object Fun]') != -1) return 2;"
- " if (str.indexOf('#<a Fun>') == -1) return 3;"
+ " if (str.indexOf('#<Fun>') == -1) return 3;"
" return 0;"
" }"
" return 4;"
// 1: Call distance on Point where distance is a direct property
// 2: Call on function an array element 2
// 3: [anonymous]
- assertEquals("#<a Point>.distanceTo(p=#<a Point>)", exec_state.frame(0).invocationText());
- assertEquals("#<a Point>.distanceTo(p=#<a Point>)", exec_state.frame(1).invocationText());
- assertEquals("#<an Array>[2](aka distance)(p=#<a Point>, q=#<a Point>)", exec_state.frame(2).invocationText());
+ assertEquals("#<Point>.distanceTo(p=#<Point>)", exec_state.frame(0).invocationText());
+ assertEquals("#<Point>.distanceTo(p=#<Point>)", exec_state.frame(1).invocationText());
+ assertEquals("#<Array>[2](aka distance)(p=#<Point>, q=#<Point>)", exec_state.frame(2).invocationText());
assertEquals("[anonymous]()", exec_state.frame(3).invocationText());
listenerCalled = true;
} else {