Commit 2f9411df authored by yangguo's avatar yangguo Committed by Commit bot

Revert of Revert of Wrap runtime.js in a function. (patchset #1 id:1 of...

Revert of Revert of Wrap runtime.js in a function. (patchset #1 id:1 of https://codereview.chromium.org/1123353004/)

Reason for revert:
Failing test has been fixed.

Original issue's description:
> Revert of Wrap runtime.js in a function. (patchset #2 id:20001 of https://codereview.chromium.org/1126213002/)
>
> Reason for revert:
> [Sheriff] Breaks nosnap:
> http://build.chromium.org/p/client.v8/builders/V8%20Linux%20-%20nosnap/builds/2872
>
> Original issue's description:
> > Wrap runtime.js in a function.
> >
> > R=jkummerow@chromium.org
> >
> > Committed: https://crrev.com/65c56d49b2d671ac9e379de726bff3eb03a508c1
> > Cr-Commit-Position: refs/heads/master@{#28275}
>
> TBR=jkummerow@chromium.org,yangguo@chromium.org
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
>
> Committed: https://crrev.com/62bd294f909ff448d0f876a3d745966a24cdc3f7
> Cr-Commit-Position: refs/heads/master@{#28277}

TBR=jkummerow@chromium.org,machenbach@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review URL: https://codereview.chromium.org/1131843002

Cr-Commit-Position: refs/heads/master@{#28287}
parent 47e1c276
......@@ -47,7 +47,7 @@ function ArrayIterator() {}
// 15.4.5.1 CreateArrayIterator Abstract Operation
function CreateArrayIterator(array, kind) {
var object = ToObject(array);
var object = $toObject(array);
var iterator = new ArrayIterator;
SET_PRIVATE(iterator, arrayIteratorObjectSymbol, object);
SET_PRIVATE(iterator, arrayIteratorNextIndexSymbol, 0);
......@@ -70,7 +70,7 @@ function ArrayIteratorIterator() {
// 15.4.5.2.2 ArrayIterator.prototype.next( )
function ArrayIteratorNext() {
var iterator = ToObject(this);
var iterator = $toObject(this);
if (!HAS_DEFINED_PRIVATE(iterator, arrayIteratorNextIndexSymbol)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
......
......@@ -196,7 +196,7 @@ function ConvertToString(x) {
// Assumes x is a non-string.
if (IS_NUMBER(x)) return %_NumberToString(x);
if (IS_BOOLEAN(x)) return x ? 'true' : 'false';
return (IS_NULL_OR_UNDEFINED(x)) ? '' : %ToString(%DefaultString(x));
return (IS_NULL_OR_UNDEFINED(x)) ? '' : $toString($defaultString(x));
}
......@@ -207,8 +207,8 @@ function ConvertToLocaleString(e) {
// According to ES5, section 15.4.4.3, the toLocaleString conversion
// must throw a TypeError if ToObject(e).toLocaleString isn't
// callable.
var e_obj = ToObject(e);
return %ToString(e_obj.toLocaleString());
var e_obj = $toObject(e);
return $toString(e_obj.toLocaleString());
}
}
......@@ -368,7 +368,7 @@ function ArrayToString() {
}
array = this;
} else {
array = ToObject(this);
array = $toObject(this);
func = array.join;
}
if (!IS_SPEC_FUNCTION(func)) {
......@@ -379,7 +379,7 @@ function ArrayToString() {
function ArrayToLocaleString() {
var array = ToObject(this);
var array = $toObject(this);
var arrayLen = array.length;
var len = TO_UINT32(arrayLen);
if (len === 0) return "";
......@@ -395,7 +395,7 @@ function ArrayJoin(separator) {
if (IS_UNDEFINED(separator)) {
separator = ',';
} else if (!IS_STRING(separator)) {
separator = NonStringToString(separator);
separator = $nonStringToString(separator);
}
var result = %_FastOneByteArrayJoin(array, separator);
......@@ -406,7 +406,7 @@ function ArrayJoin(separator) {
var e = array[0];
if (IS_STRING(e)) return e;
if (IS_NULL_OR_UNDEFINED(e)) return '';
return NonStringToString(e);
return $nonStringToString(e);
}
return Join(array, length, separator, ConvertToString);
......@@ -447,7 +447,7 @@ function ArrayPop() {
n--;
var value = array[n];
$delete(array, ToName(n), true);
$delete(array, $toName(n), true);
array.length = n;
return value;
}
......@@ -501,7 +501,7 @@ function ArrayPush() {
function ArrayConcatJS(arg1) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.concat");
var array = ToObject(this);
var array = $toObject(this);
var arg_count = %_ArgumentsLength();
var arrays = new InternalArray(1 + arg_count);
arrays[0] = array;
......@@ -866,8 +866,8 @@ function ArraySort(comparefn) {
if (%_IsSmi(x) && %_IsSmi(y)) {
return %SmiLexicographicCompare(x, y);
}
x = ToString(x);
y = ToString(y);
x = $toString(x);
y = $toString(y);
if (x == y) return 0;
else return x < y ? -1 : 1;
};
......@@ -1148,8 +1148,8 @@ function ArrayFilter(f, receiver) {
// Pull out the length so that modifications to the length in the
// loop will not affect the looping and side effects are visible.
var array = ToObject(this);
var length = ToUint32(array.length);
var array = $toObject(this);
var length = $toUint32(array.length);
if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f);
var needs_wrapper = false;
......@@ -1169,7 +1169,7 @@ function ArrayFilter(f, receiver) {
var element = array[i];
// Prepare break slots for debugger step in.
if (stepping) %DebugPrepareStepInIfStepping(f);
var new_receiver = needs_wrapper ? ToObject(receiver) : receiver;
var new_receiver = needs_wrapper ? $toObject(receiver) : receiver;
if (%_CallFunction(new_receiver, element, i, array, f)) {
accumulator[accumulator_length++] = element;
}
......@@ -1185,7 +1185,7 @@ function ArrayForEach(f, receiver) {
// Pull out the length so that modifications to the length in the
// loop will not affect the looping and side effects are visible.
var array = ToObject(this);
var array = $toObject(this);
var length = TO_UINT32(array.length);
if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f);
......@@ -1203,7 +1203,7 @@ function ArrayForEach(f, receiver) {
var element = array[i];
// Prepare break slots for debugger step in.
if (stepping) %DebugPrepareStepInIfStepping(f);
var new_receiver = needs_wrapper ? ToObject(receiver) : receiver;
var new_receiver = needs_wrapper ? $toObject(receiver) : receiver;
%_CallFunction(new_receiver, element, i, array, f);
}
}
......@@ -1217,7 +1217,7 @@ function ArraySome(f, receiver) {
// Pull out the length so that modifications to the length in the
// loop will not affect the looping and side effects are visible.
var array = ToObject(this);
var array = $toObject(this);
var length = TO_UINT32(array.length);
if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f);
......@@ -1235,7 +1235,7 @@ function ArraySome(f, receiver) {
var element = array[i];
// Prepare break slots for debugger step in.
if (stepping) %DebugPrepareStepInIfStepping(f);
var new_receiver = needs_wrapper ? ToObject(receiver) : receiver;
var new_receiver = needs_wrapper ? $toObject(receiver) : receiver;
if (%_CallFunction(new_receiver, element, i, array, f)) return true;
}
}
......@@ -1248,7 +1248,7 @@ function ArrayEvery(f, receiver) {
// Pull out the length so that modifications to the length in the
// loop will not affect the looping and side effects are visible.
var array = ToObject(this);
var array = $toObject(this);
var length = TO_UINT32(array.length);
if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f);
......@@ -1266,7 +1266,7 @@ function ArrayEvery(f, receiver) {
var element = array[i];
// Prepare break slots for debugger step in.
if (stepping) %DebugPrepareStepInIfStepping(f);
var new_receiver = needs_wrapper ? ToObject(receiver) : receiver;
var new_receiver = needs_wrapper ? $toObject(receiver) : receiver;
if (!%_CallFunction(new_receiver, element, i, array, f)) return false;
}
}
......@@ -1279,7 +1279,7 @@ function ArrayMap(f, receiver) {
// Pull out the length so that modifications to the length in the
// loop will not affect the looping and side effects are visible.
var array = ToObject(this);
var array = $toObject(this);
var length = TO_UINT32(array.length);
if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f);
......@@ -1299,7 +1299,7 @@ function ArrayMap(f, receiver) {
var element = array[i];
// Prepare break slots for debugger step in.
if (stepping) %DebugPrepareStepInIfStepping(f);
var new_receiver = needs_wrapper ? ToObject(receiver) : receiver;
var new_receiver = needs_wrapper ? $toObject(receiver) : receiver;
accumulator[i] = %_CallFunction(new_receiver, element, i, array, f);
}
}
......@@ -1423,8 +1423,8 @@ function ArrayReduce(callback, current) {
// Pull out the length so that modifications to the length in the
// loop will not affect the looping and side effects are visible.
var array = ToObject(this);
var length = ToUint32(array.length);
var array = $toObject(this);
var length = $toUint32(array.length);
if (!IS_SPEC_FUNCTION(callback)) {
throw MakeTypeError(kCalledNonCallable, callback);
......@@ -1460,8 +1460,8 @@ function ArrayReduceRight(callback, current) {
// Pull out the length so that side effects are visible before the
// callback function is checked.
var array = ToObject(this);
var length = ToUint32(array.length);
var array = $toObject(this);
var length = $toUint32(array.length);
if (!IS_SPEC_FUNCTION(callback)) {
throw MakeTypeError(kCalledNonCallable, callback);
......
......@@ -15,7 +15,7 @@ var GlobalObject = global.Object;
function ArrayBufferConstructor(length) { // length = 1
if (%_IsConstructCall()) {
var byteLength = ToPositiveInteger(length, kInvalidArrayBufferLength);
var byteLength = $toPositiveInteger(length, kInvalidArrayBufferLength);
%ArrayBufferInitialize(this, byteLength);
} else {
throw MakeTypeError(kConstructorNotFunction, "ArrayBuffer");
......
......@@ -264,7 +264,7 @@ class AstValue : public ZoneObject {
F(spread_iterable, "$spreadIterable") \
F(this, "this") \
F(throw_iterator_result_not_an_object, "ThrowIteratorResultNotAnObject") \
F(to_string, "ToString") \
F(to_string, "$toString") \
F(undefined, "undefined") \
F(use_asm, "use asm") \
F(use_strong, "use strong") \
......
......@@ -1564,14 +1564,14 @@ void Genesis::InstallNativeFunctions() {
HandleScope scope(isolate());
INSTALL_NATIVE(JSFunction, "$createDate", create_date_fun);
INSTALL_NATIVE(JSFunction, "ToNumber", to_number_fun);
INSTALL_NATIVE(JSFunction, "ToString", to_string_fun);
INSTALL_NATIVE(JSFunction, "$toNumber", to_number_fun);
INSTALL_NATIVE(JSFunction, "$toString", to_string_fun);
INSTALL_NATIVE(JSFunction, "$toDetailString", to_detail_string_fun);
INSTALL_NATIVE(JSFunction, "ToObject", to_object_fun);
INSTALL_NATIVE(JSFunction, "ToInteger", to_integer_fun);
INSTALL_NATIVE(JSFunction, "ToUint32", to_uint32_fun);
INSTALL_NATIVE(JSFunction, "ToInt32", to_int32_fun);
INSTALL_NATIVE(JSFunction, "ToLength", to_length_fun);
INSTALL_NATIVE(JSFunction, "$toObject", to_object_fun);
INSTALL_NATIVE(JSFunction, "$toInteger", to_integer_fun);
INSTALL_NATIVE(JSFunction, "$toUint32", to_uint32_fun);
INSTALL_NATIVE(JSFunction, "$toInt32", to_int32_fun);
INSTALL_NATIVE(JSFunction, "$toLength", to_length_fun);
INSTALL_NATIVE(JSFunction, "$globalEval", global_eval_fun);
INSTALL_NATIVE(JSFunction, "$getStackTraceLine", get_stack_trace_line_fun);
......
......@@ -222,7 +222,7 @@ function SetForEach(f, receiver) {
while (%SetIteratorNext(iterator, value_array)) {
if (stepping) %DebugPrepareStepInIfStepping(f);
key = value_array[0];
var new_receiver = needs_wrapper ? ToObject(receiver) : receiver;
var new_receiver = needs_wrapper ? $toObject(receiver) : receiver;
%_CallFunction(new_receiver, key, key, this, f);
}
}
......@@ -410,7 +410,7 @@ function MapForEach(f, receiver) {
var value_array = [UNDEFINED, UNDEFINED];
while (%MapIteratorNext(iterator, value_array)) {
if (stepping) %DebugPrepareStepInIfStepping(f);
var new_receiver = needs_wrapper ? ToObject(receiver) : receiver;
var new_receiver = needs_wrapper ? $toObject(receiver) : receiver;
%_CallFunction(new_receiver, value_array[1], value_array[0], this, f);
}
}
......
This diff is collapsed.
......@@ -202,7 +202,8 @@ BreakPoint.prototype.isTriggered = function(exec_state) {
try {
var mirror = exec_state.frame(0).evaluate(this.condition());
// If no sensible mirror or non true value break point not triggered.
if (!(mirror instanceof ValueMirror) || !%ToBoolean(mirror.value_)) {
if (!(mirror instanceof ValueMirror) ||
!builtins.$toBoolean(mirror.value_)) {
return false;
}
} catch (e) {
......@@ -924,8 +925,8 @@ function ExecutionState(break_id) {
ExecutionState.prototype.prepareStep = function(opt_action, opt_count,
opt_callframe) {
var action = Debug.StepAction.StepIn;
if (!IS_UNDEFINED(opt_action)) action = %ToNumber(opt_action);
var count = opt_count ? %ToNumber(opt_count) : 1;
if (!IS_UNDEFINED(opt_action)) action = builtins.$toNumber(opt_action);
var count = opt_count ? builtins.$toNumber(opt_count) : 1;
var callFrameId = 0;
if (!IS_UNDEFINED(opt_callframe)) {
callFrameId = opt_callframe.details_.frameId();
......@@ -959,7 +960,7 @@ ExecutionState.prototype.frame = function(opt_index) {
};
ExecutionState.prototype.setSelectedFrame = function(index) {
var i = %ToNumber(index);
var i = builtins.$toNumber(index);
if (i < 0 || i >= this.frameCount()) throw new Error('Illegal frame index.');
this.selected_frame = i;
};
......@@ -1402,7 +1403,7 @@ DebugCommandProcessor.prototype.processDebugJSONRequest = function(
response = this.createResponse();
}
response.success = false;
response.message = %ToString(e);
response.message = builtins.$toString(e);
}
// Return the response as a JSON encoded string.
......@@ -1419,7 +1420,7 @@ DebugCommandProcessor.prototype.processDebugJSONRequest = function(
'"request_seq":' + request.seq + ',' +
'"type":"response",' +
'"success":false,' +
'"message":"Internal error: ' + %ToString(e) + '"}';
'"message":"Internal error: ' + builtins.$toString(e) + '"}';
}
} catch (e) {
// Failed in one of the catch blocks above - most generic error.
......@@ -1440,7 +1441,7 @@ DebugCommandProcessor.prototype.continueRequest_ = function(request, response) {
// Get the stepcount argument if any.
if (stepcount) {
count = %ToNumber(stepcount);
count = builtins.$toNumber(stepcount);
if (count < 0) {
throw new Error('Invalid stepcount argument "' + stepcount + '".');
}
......@@ -1513,7 +1514,7 @@ DebugCommandProcessor.prototype.setBreakPointRequest_ =
// Find the function through a global evaluate.
f = this.exec_state_.evaluateGlobal(target).value();
} catch (e) {
response.failed('Error: "' + %ToString(e) +
response.failed('Error: "' + builtins.$toString(e) +
'" evaluating "' + target + '"');
return;
}
......@@ -1602,7 +1603,7 @@ DebugCommandProcessor.prototype.changeBreakPointRequest_ = function(
}
// Pull out arguments.
var break_point = %ToNumber(request.arguments.breakpoint);
var break_point = builtins.$toNumber(request.arguments.breakpoint);
var enabled = request.arguments.enabled;
var condition = request.arguments.condition;
var ignoreCount = request.arguments.ignoreCount;
......@@ -1678,7 +1679,7 @@ DebugCommandProcessor.prototype.clearBreakPointRequest_ = function(
}
// Pull out arguments.
var break_point = %ToNumber(request.arguments.breakpoint);
var break_point = builtins.$toNumber(request.arguments.breakpoint);
// Check for legal arguments.
if (!break_point) {
......@@ -1935,7 +1936,7 @@ DebugCommandProcessor.prototype.scopeRequest_ = function(request, response) {
// With no scope argument just return top scope.
var scope_index = 0;
if (request.arguments && !IS_UNDEFINED(request.arguments.number)) {
scope_index = %ToNumber(request.arguments.number);
scope_index = builtins.$toNumber(request.arguments.number);
if (scope_index < 0 || scope_holder.scopeCount() <= scope_index) {
return response.failed('Invalid scope number');
}
......@@ -1999,7 +2000,7 @@ DebugCommandProcessor.prototype.setVariableValueRequest_ =
if (IS_UNDEFINED(scope_description.number)) {
response.failed('Missing scope number');
}
var scope_index = %ToNumber(scope_description.number);
var scope_index = builtins.$toNumber(scope_description.number);
var scope = scope_holder.scope(scope_index);
......@@ -2077,7 +2078,7 @@ DebugCommandProcessor.prototype.evaluateRequest_ = function(request, response) {
// Check whether a frame was specified.
if (!IS_UNDEFINED(frame)) {
var frame_number = %ToNumber(frame);
var frame_number = builtins.$toNumber(frame);
if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) {
return response.failed('Invalid frame "' + frame + '"');
}
......@@ -2109,7 +2110,7 @@ DebugCommandProcessor.prototype.lookupRequest_ = function(request, response) {
// Set 'includeSource' option for script lookup.
if (!IS_UNDEFINED(request.arguments.includeSource)) {
var includeSource = %ToBoolean(request.arguments.includeSource);
var includeSource = builtins.$toBoolean(request.arguments.includeSource);
response.setOption('includeSource', includeSource);
}
......@@ -2177,7 +2178,7 @@ DebugCommandProcessor.prototype.sourceRequest_ = function(request, response) {
to_line = request.arguments.toLine;
if (!IS_UNDEFINED(request.arguments.frame)) {
var frame_number = %ToNumber(request.arguments.frame);
var frame_number = builtins.$toNumber(request.arguments.frame);
if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) {
return response.failed('Invalid frame "' + frame + '"');
}
......@@ -2213,7 +2214,7 @@ DebugCommandProcessor.prototype.scriptsRequest_ = function(request, response) {
if (request.arguments) {
// Pull out arguments.
if (!IS_UNDEFINED(request.arguments.types)) {
types = %ToNumber(request.arguments.types);
types = builtins.$toNumber(request.arguments.types);
if (isNaN(types) || types < 0) {
return response.failed('Invalid types "' +
request.arguments.types + '"');
......@@ -2221,7 +2222,7 @@ DebugCommandProcessor.prototype.scriptsRequest_ = function(request, response) {
}
if (!IS_UNDEFINED(request.arguments.includeSource)) {
includeSource = %ToBoolean(request.arguments.includeSource);
includeSource = builtins.$toBoolean(request.arguments.includeSource);
response.setOption('includeSource', includeSource);
}
......@@ -2236,7 +2237,7 @@ DebugCommandProcessor.prototype.scriptsRequest_ = function(request, response) {
var filterStr = null;
var filterNum = null;
if (!IS_UNDEFINED(request.arguments.filter)) {
var num = %ToNumber(request.arguments.filter);
var num = builtins.$toNumber(request.arguments.filter);
if (!isNaN(num)) {
filterNum = num;
}
......@@ -2372,7 +2373,7 @@ DebugCommandProcessor.prototype.restartFrameRequest_ = function(
var frame_mirror;
// Check whether a frame was specified.
if (!IS_UNDEFINED(frame)) {
var frame_number = %ToNumber(frame);
var frame_number = builtins.$toNumber(frame);
if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) {
return response.failed('Invalid frame "' + frame + '"');
}
......
......@@ -16,14 +16,14 @@ var GlobalArray = global.Array;
// https://github.com/tc39/Array.prototype.includes
// 6e3b78c927aeda20b9d40e81303f9d44596cd904
function ArrayIncludes(searchElement, fromIndex) {
var array = ToObject(this);
var len = ToLength(array.length);
var array = $toObject(this);
var len = $toLength(array.length);
if (len === 0) {
return false;
}
var n = ToInteger(fromIndex);
var n = $toInteger(fromIndex);
var k;
if (n >= 0) {
......@@ -37,7 +37,7 @@ function ArrayIncludes(searchElement, fromIndex) {
while (k < len) {
var elementK = array[k];
if (SameValueZero(searchElement, elementK)) {
if ($sameValueZero(searchElement, elementK)) {
return true;
}
......
......@@ -18,7 +18,7 @@ function ArrayCopyWithin(target, start, end) {
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.copyWithin");
var array = TO_OBJECT_INLINE(this);
var length = ToLength(array.length);
var length = $toLength(array.length);
target = TO_INTEGER(target);
var to;
......@@ -70,8 +70,8 @@ function ArrayCopyWithin(target, start, end) {
function ArrayFind(predicate /* thisArg */) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.find");
var array = ToObject(this);
var length = ToInteger(array.length);
var array = $toObject(this);
var length = $toInteger(array.length);
if (!IS_SPEC_FUNCTION(predicate)) {
throw MakeTypeError(kCalledNonCallable, predicate);
......@@ -92,7 +92,7 @@ function ArrayFind(predicate /* thisArg */) { // length == 1
for (var i = 0; i < length; i++) {
if (i in array) {
var element = array[i];
var newThisArg = needs_wrapper ? ToObject(thisArg) : thisArg;
var newThisArg = needs_wrapper ? $toObject(thisArg) : thisArg;
if (%_CallFunction(newThisArg, element, i, array, predicate)) {
return element;
}
......@@ -107,8 +107,8 @@ function ArrayFind(predicate /* thisArg */) { // length == 1
function ArrayFindIndex(predicate /* thisArg */) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.findIndex");
var array = ToObject(this);
var length = ToInteger(array.length);
var array = $toObject(this);
var length = $toInteger(array.length);
if (!IS_SPEC_FUNCTION(predicate)) {
throw MakeTypeError(kCalledNonCallable, predicate);
......@@ -129,7 +129,7 @@ function ArrayFindIndex(predicate /* thisArg */) { // length == 1
for (var i = 0; i < length; i++) {
if (i in array) {
var element = array[i];
var newThisArg = needs_wrapper ? ToObject(thisArg) : thisArg;
var newThisArg = needs_wrapper ? $toObject(thisArg) : thisArg;
if (%_CallFunction(newThisArg, element, i, array, predicate)) {
return i;
}
......@@ -144,7 +144,7 @@ function ArrayFindIndex(predicate /* thisArg */) { // length == 1
function ArrayFill(value /* [, start [, end ] ] */) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.fill");
var array = ToObject(this);
var array = $toObject(this);
var length = TO_UINT32(array.length);
var i = 0;
......@@ -184,7 +184,7 @@ function ArrayFill(value /* [, start [, end ] ] */) { // length == 1
// ES6, draft 10-14-14, section 22.1.2.1
function ArrayFrom(arrayLike, mapfn, receiver) {
var items = ToObject(arrayLike);
var items = $toObject(arrayLike);
var mapping = !IS_UNDEFINED(mapfn);
if (mapping) {
......@@ -232,8 +232,8 @@ function ArrayFrom(arrayLike, mapfn, receiver) {
%AddElement(result, k++, mappedValue, NONE);
}
} else {
var len = ToLength(items.length);
result = %IsConstructor(this) ? new this(len) : new $Array(len);
var len = $toLength(items.length);
result = %IsConstructor(this) ? new this(len) : new GlobalArray(len);
for (k = 0; k < len; ++k) {
nextValue = items[k];
......
......@@ -16,7 +16,7 @@ var GlobalRegExp = global.RegExp;
// + https://bugs.ecmascript.org/show_bug.cgi?id=3423
function RegExpGetFlags() {
if (!IS_SPEC_OBJECT(this)) {
throw MakeTypeError(kFlagsGetterNonObject, %ToString(this));
throw MakeTypeError(kFlagsGetterNonObject, $toString(this));
}
var result = '';
if (this.global) result += 'g';
......
......@@ -55,7 +55,7 @@ function NAMEForEach(f /* thisArg */) { // length == 1
var element = this[i];
// Prepare break slots for debugger step in.
if (stepping) %DebugPrepareStepInIfStepping(f);
var new_receiver = needs_wrapper ? ToObject(receiver) : receiver;
var new_receiver = needs_wrapper ? $toObject(receiver) : receiver;
%_CallFunction(new_receiver, TO_OBJECT_INLINE(element), i, this, f);
}
}
......
......@@ -287,7 +287,7 @@ function supportedLocalesOf(service, locales, options) {
if (options === undefined) {
options = {};
} else {
options = ToObject(options);
options = $toObject(options);
}
var matcher = options.localeMatcher;
......@@ -743,7 +743,7 @@ function initializeLocaleList(locales) {
return freezeArray(seen);
}
var o = ToObject(locales);
var o = $toObject(locales);
// Converts it to UInt32 (>>> is shr on 32bit integers).
var len = o.length >>> 0;
......@@ -955,7 +955,7 @@ function initializeCollator(collator, locales, options) {
return new Intl.Collator(locales, options);
}
return initializeCollator(ToObject(this), locales, options);
return initializeCollator($toObject(this), locales, options);
},
DONT_ENUM
);
......@@ -1181,7 +1181,7 @@ function initializeNumberFormat(numberFormat, locales, options) {
return new Intl.NumberFormat(locales, options);
}
return initializeNumberFormat(ToObject(this), locales, options);
return initializeNumberFormat($toObject(this), locales, options);
},
DONT_ENUM
);
......@@ -1266,7 +1266,7 @@ $setFunctionName(Intl.NumberFormat.supportedLocalesOf, 'supportedLocalesOf');
*/
function formatNumber(formatter, value) {
// Spec treats -0 and +0 as 0.
var number = GlobalNumber(value) + 0;
var number = $toNumber(value) + 0;
return %InternalNumberFormat(%GetImplFromInitializedIntlObject(formatter),
number);
......@@ -1573,7 +1573,7 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
return new Intl.DateTimeFormat(locales, options);
}
return initializeDateTimeFormat(ToObject(this), locales, options);
return initializeDateTimeFormat($toObject(this), locales, options);
},
DONT_ENUM
);
......@@ -1661,7 +1661,7 @@ function formatDate(formatter, dateValue) {
if (dateValue === undefined) {
dateMs = GlobalDate.now();
} else {
dateMs = GlobalNumber(dateValue);
dateMs = $toNumber(dateValue);
}
if (!$isFinite(dateMs)) throw MakeRangeError(kDateRange);
......@@ -1774,7 +1774,7 @@ function initializeBreakIterator(iterator, locales, options) {
return new Intl.v8BreakIterator(locales, options);
}
return initializeBreakIterator(ToObject(this), locales, options);
return initializeBreakIterator($toObject(this), locales, options);
},
DONT_ENUM
);
......
......@@ -154,10 +154,10 @@ function JSONSerialize(key, holder, replacer, stack, indent, gap) {
if (IS_ARRAY(value)) {
return SerializeArray(value, replacer, stack, indent, gap);
} else if (IS_NUMBER_WRAPPER(value)) {
value = ToNumber(value);
value = $toNumber(value);
return JSON_NUMBER_TO_STRING(value);
} else if (IS_STRING_WRAPPER(value)) {
return %QuoteJSONString(ToString(value));
return %QuoteJSONString($toString(value));
} else if (IS_BOOLEAN_WRAPPER(value)) {
return %_ValueOf(value) ? "true" : "false";
} else {
......@@ -176,14 +176,14 @@ function JSONStringify(value, replacer, space) {
if (IS_OBJECT(space)) {
// Unwrap 'space' if it is wrapped
if (IS_NUMBER_WRAPPER(space)) {
space = ToNumber(space);
space = $toNumber(space);
} else if (IS_STRING_WRAPPER(space)) {
space = ToString(space);
space = $toString(space);
}
}
var gap;
if (IS_NUMBER(space)) {
space = $max(0, $min(ToInteger(space), 10));
space = $max(0, $min($toInteger(space), 10));
gap = %_SubString(" ", 0, space);
} else if (IS_STRING(space)) {
if (space.length > 10) {
......@@ -203,9 +203,9 @@ function JSONStringify(value, replacer, space) {
for (var i = 0; i < length; i++) {
var item = replacer[i];
if (IS_STRING_WRAPPER(item)) {
item = ToString(item);
item = $toString(item);
} else {
if (IS_NUMBER_WRAPPER(item)) item = ToNumber(item);
if (IS_NUMBER_WRAPPER(item)) item = $toNumber(item);
if (IS_NUMBER(item)) item = %_NumberToString(item);
}
if (IS_STRING(item) && seen_properties[item] != seen_sentinel) {
......
......@@ -143,14 +143,14 @@ define kBoundArgumentsStartIndex = 2;
# Inline macros. Use %IS_VAR to make sure arg is evaluated only once.
macro NUMBER_IS_NAN(arg) = (!%_IsSmi(%IS_VAR(arg)) && !(arg == arg));
macro NUMBER_IS_FINITE(arg) = (%_IsSmi(%IS_VAR(arg)) || ((arg == arg) && (arg != 1/0) && (arg != -1/0)));
macro TO_INTEGER(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : %NumberToInteger(ToNumber(arg)));
macro TO_INTEGER_FOR_SIDE_EFFECT(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : ToNumber(arg));
macro TO_INTEGER_MAP_MINUS_ZERO(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : %NumberToIntegerMapMinusZero(ToNumber(arg)));
macro TO_INTEGER(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : %NumberToInteger($toNumber(arg)));
macro TO_INTEGER_FOR_SIDE_EFFECT(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : $toNumber(arg));
macro TO_INTEGER_MAP_MINUS_ZERO(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : %NumberToIntegerMapMinusZero($toNumber(arg)));
macro TO_INT32(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : (arg >> 0));
macro TO_UINT32(arg) = (arg >>> 0);
macro TO_STRING_INLINE(arg) = (IS_STRING(%IS_VAR(arg)) ? arg : NonStringToString(arg));
macro TO_NUMBER_INLINE(arg) = (IS_NUMBER(%IS_VAR(arg)) ? arg : NonNumberToNumber(arg));
macro TO_OBJECT_INLINE(arg) = (IS_SPEC_OBJECT(%IS_VAR(arg)) ? arg : ToObject(arg));
macro TO_STRING_INLINE(arg) = (IS_STRING(%IS_VAR(arg)) ? arg : $nonStringToString(arg));
macro TO_NUMBER_INLINE(arg) = (IS_NUMBER(%IS_VAR(arg)) ? arg : $nonNumberToNumber(arg));
macro TO_OBJECT_INLINE(arg) = (IS_SPEC_OBJECT(%IS_VAR(arg)) ? arg : $toObject(arg));
macro JSON_NUMBER_TO_STRING(arg) = ((%_IsSmi(%IS_VAR(arg)) || arg - arg == 0) ? %_NumberToString(arg) : "null");
macro HAS_OWN_PROPERTY(arg, index) = (%_CallFunction(arg, index, $objectHasOwnProperty));
macro SHOULD_CREATE_WRAPPER(functionName, receiver) = (!IS_SPEC_OBJECT(receiver) && %IsSloppyModeFunction(functionName));
......
......@@ -88,7 +88,7 @@ function MathMax(arg1, arg2) { // length == 2
var r = -INFINITY;
for (var i = 0; i < length; i++) {
var n = %_Arguments(i);
if (!IS_NUMBER(n)) n = NonNumberToNumber(n);
n = TO_NUMBER_INLINE(n);
// Make sure +0 is considered greater than -0.
if (NUMBER_IS_NAN(n) || n > r || (r === 0 && n === 0 && %_IsMinusZero(r))) {
r = n;
......@@ -115,7 +115,7 @@ function MathMin(arg1, arg2) { // length == 2
var r = INFINITY;
for (var i = 0; i < length; i++) {
var n = %_Arguments(i);
if (!IS_NUMBER(n)) n = NonNumberToNumber(n);
n = TO_NUMBER_INLINE(n);
// Make sure -0 is considered less than +0.
if (NUMBER_IS_NAN(n) || n < r || (r === 0 && n === 0 && %_IsMinusZero(n))) {
r = n;
......@@ -175,7 +175,7 @@ function MathTrunc(x) {
// ES6 draft 09-27-13, section 20.2.2.33.
function MathTanh(x) {
if (!IS_NUMBER(x)) x = NonNumberToNumber(x);
x = TO_NUMBER_INLINE(x);
// Idempotent for +/-0.
if (x === 0) return x;
// Returns +/-1 for +/-Infinity.
......@@ -187,7 +187,7 @@ function MathTanh(x) {
// ES6 draft 09-27-13, section 20.2.2.5.
function MathAsinh(x) {
if (!IS_NUMBER(x)) x = NonNumberToNumber(x);
x = TO_NUMBER_INLINE(x);
// Idempotent for NaN, +/-0 and +/-Infinity.
if (x === 0 || !NUMBER_IS_FINITE(x)) return x;
if (x > 0) return MathLog(x + %_MathSqrt(x * x + 1));
......@@ -197,7 +197,7 @@ function MathAsinh(x) {
// ES6 draft 09-27-13, section 20.2.2.3.
function MathAcosh(x) {
if (!IS_NUMBER(x)) x = NonNumberToNumber(x);
x = TO_NUMBER_INLINE(x);
if (x < 1) return NAN;
// Idempotent for NaN and +Infinity.
if (!NUMBER_IS_FINITE(x)) return x;
......@@ -206,7 +206,7 @@ function MathAcosh(x) {
// ES6 draft 09-27-13, section 20.2.2.7.
function MathAtanh(x) {
if (!IS_NUMBER(x)) x = NonNumberToNumber(x);
x = TO_NUMBER_INLINE(x);
// Idempotent for +/-0.
if (x === 0) return x;
// Returns NaN for NaN and +/- Infinity.
......@@ -224,7 +224,7 @@ function MathHypot(x, y) { // Function length is 2.
var max = 0;
for (var i = 0; i < length; i++) {
var n = %_Arguments(i);
if (!IS_NUMBER(n)) n = NonNumberToNumber(n);
n = TO_NUMBER_INLINE(n);
if (n === INFINITY || n === -INFINITY) return INFINITY;
n = MathAbs(n);
if (n > max) max = n;
......@@ -261,7 +261,7 @@ function MathClz32JS(x) {
// Using initial approximation adapted from Kahan's cbrt and 4 iterations
// of Newton's method.
function MathCbrt(x) {
if (!IS_NUMBER(x)) x = NonNumberToNumber(x);
x = TO_NUMBER_INLINE(x);
if (x == 0 || !NUMBER_IS_FINITE(x)) return x;
return x >= 0 ? CubeRoot(x) : -CubeRoot(-x);
}
......
......@@ -269,7 +269,7 @@ function ToStringCheckErrorObject(obj) {
if (CanBeSafelyTreatedAsAnErrorObject(obj)) {
return %_CallFunction(obj, ErrorToString);
} else {
return ToString(obj);
return $toString(obj);
}
}
......@@ -1089,7 +1089,7 @@ function DefineError(f) {
// object. This avoids going through getters and setters defined
// on prototype objects.
if (!IS_UNDEFINED(m)) {
%AddNamedProperty(this, 'message', ToString(m), DONT_ENUM);
%AddNamedProperty(this, 'message', $toString(m), DONT_ENUM);
}
} else {
return new f(m);
......
......@@ -823,7 +823,7 @@ ObjectMirror.prototype.internalProperties = function() {
ObjectMirror.prototype.property = function(name) {
var details = %DebugGetPropertyDetails(this.value_, %ToName(name));
var details = %DebugGetPropertyDetails(this.value_, builtins.$toName(name));
if (details) {
return new PropertyMirror(this, name, details);
}
......@@ -1186,7 +1186,7 @@ ArrayMirror.prototype.indexedPropertiesFromRange = function(opt_from_index,
if (from_index > to_index) return new Array();
var values = new Array(to_index - from_index + 1);
for (var i = from_index; i <= to_index; i++) {
var details = %DebugGetPropertyDetails(this.value_, %ToString(i));
var details = %DebugGetPropertyDetails(this.value_, builtins.$toString(i));
var value;
if (details) {
value = new PropertyMirror(this, i, details);
......
......@@ -317,7 +317,7 @@ function ConvertAcceptListToTypeMap(arg) {
if (!IS_SPEC_OBJECT(arg)) throw MakeTypeError(kObserveInvalidAccept);
var len = ToInteger(arg.length);
var len = $toInteger(arg.length);
if (len < 0) len = 0;
return TypeMapCreateFromList(arg, len);
......
......@@ -2245,8 +2245,8 @@ class JSObject: public JSReceiver {
// permissible values (see the DCHECK in heap.cc).
static const int kInitialMaxFastElementArray = 100000;
// This constant applies only to the initial map of "$Object" aka
// "global.Object" and not to arbitrary other JSObject maps.
// This constant applies only to the initial map of "global.Object" and
// not to arbitrary other JSObject maps.
static const int kInitialGlobalObjectUnusedPropertiesCount = 4;
static const int kMaxInstanceSize = 255 * kPointerSize;
......
......@@ -55,8 +55,8 @@ function DoConstructRegExp(object, pattern, flags) {
pattern = pattern.source;
}
pattern = IS_UNDEFINED(pattern) ? '' : ToString(pattern);
flags = IS_UNDEFINED(flags) ? '' : ToString(flags);
pattern = IS_UNDEFINED(pattern) ? '' : $toString(pattern);
flags = IS_UNDEFINED(flags) ? '' : $toString(flags);
%RegExpInitializeAndCompile(object, pattern, flags);
}
......@@ -381,7 +381,7 @@ var RegExpGetInput = function() {
return IS_UNDEFINED(regExpInput) ? "" : regExpInput;
};
var RegExpSetInput = function(string) {
LAST_INPUT($regexpLastMatchInfo) = ToString(string);
LAST_INPUT($regexpLastMatchInfo) = $toString(string);
};
%OptimizeObjectForAddingMultipleProperties(GlobalRegExp, 22);
......
This diff is collapsed.
......@@ -39,7 +39,7 @@ function StringIteratorIterator() {
// 21.1.5.2.1 %StringIteratorPrototype%.next( )
function StringIteratorNext() {
var iterator = ToObject(this);
var iterator = $toObject(this);
if (!HAS_DEFINED_PRIVATE(iterator, stringIteratorNextIndexSymbol)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
......
......@@ -113,7 +113,7 @@ function StringLastIndexOfJS(pat /* position */) { // length == 1
var patLength = pat.length;
var index = subLength - patLength;
if (%_ArgumentsLength() > 1) {
var position = ToNumber(%_Arguments(1));
var position = $toNumber(%_Arguments(1));
if (!NUMBER_IS_NAN(position)) {
position = TO_INTEGER(position);
if (position < 0) {
......@@ -803,7 +803,7 @@ function StringTrimRight() {
function StringFromCharCode(code) {
var n = %_ArgumentsLength();
if (n == 1) {
if (!%_IsSmi(code)) code = ToNumber(code);
if (!%_IsSmi(code)) code = $toNumber(code);
return %_StringCharFromCode(code & 0xffff);
}
......@@ -811,7 +811,7 @@ function StringFromCharCode(code) {
var i;
for (i = 0; i < n; i++) {
var code = %_Arguments(i);
if (!%_IsSmi(code)) code = ToNumber(code) & 0xffff;
if (!%_IsSmi(code)) code = $toNumber(code) & 0xffff;
if (code < 0) code = code & 0xffff;
if (code > 0xff) break;
%_OneByteSeqStringSetChar(i, code, one_byte);
......@@ -822,7 +822,7 @@ function StringFromCharCode(code) {
var two_byte = %NewString(n - i, NEW_TWO_BYTE_STRING);
for (var j = 0; i < n; i++, j++) {
var code = %_Arguments(i);
if (!%_IsSmi(code)) code = ToNumber(code) & 0xffff;
if (!%_IsSmi(code)) code = $toNumber(code) & 0xffff;
%_TwoByteSeqStringSetChar(j, code, two_byte);
}
return one_byte + two_byte;
......@@ -930,7 +930,7 @@ function StringRepeat(count) {
CHECK_OBJECT_COERCIBLE(this, "String.prototype.repeat");
var s = TO_STRING_INLINE(this);
var n = ToInteger(count);
var n = $toInteger(count);
// The maximum string length is stored in a smi, so a longer repeat
// must result in a range error.
if (n < 0 || n > %_MaxSmi()) throw MakeRangeError(kInvalidCountValue);
......@@ -959,7 +959,7 @@ function StringStartsWith(searchString /* position */) { // length == 1
var pos = 0;
if (%_ArgumentsLength() > 1) {
pos = %_Arguments(1); // position
pos = ToInteger(pos);
pos = $toInteger(pos);
}
var s_len = s.length;
......@@ -989,7 +989,7 @@ function StringEndsWith(searchString /* position */) { // length == 1
if (%_ArgumentsLength() > 1) {
var arg = %_Arguments(1); // position
if (!IS_UNDEFINED(arg)) {
pos = ToInteger(arg);
pos = $toInteger(arg);
}
}
......@@ -1018,7 +1018,7 @@ function StringIncludes(searchString /* position */) { // length == 1
var pos = 0;
if (%_ArgumentsLength() > 1) {
pos = %_Arguments(1); // position
pos = ToInteger(pos);
pos = $toInteger(pos);
}
var s_len = s.length;
......@@ -1063,7 +1063,7 @@ function StringFromCodePoint(_) { // length = 1
for (index = 0; index < length; index++) {
code = %_Arguments(index);
if (!%_IsSmi(code)) {
code = ToNumber(code);
code = $toNumber(code);
}
if (code < 0 || code > 0x10FFFF || code !== TO_INTEGER(code)) {
throw MakeRangeError(kInvalidCodePoint, code);
......@@ -1087,18 +1087,18 @@ function StringFromCodePoint(_) { // length = 1
function StringRaw(callSite) {
// TODO(caitp): Use rest parameters when implemented
var numberOfSubstitutions = %_ArgumentsLength();
var cooked = ToObject(callSite);
var raw = ToObject(cooked.raw);
var literalSegments = ToLength(raw.length);
var cooked = $toObject(callSite);
var raw = $toObject(cooked.raw);
var literalSegments = $toLength(raw.length);
if (literalSegments <= 0) return "";
var result = ToString(raw[0]);
var result = $toString(raw[0]);
for (var i = 1; i < literalSegments; ++i) {
if (i < numberOfSubstitutions) {
result += ToString(%_Arguments(i));
result += $toString(%_Arguments(i));
}
result += ToString(raw[i]);
result += $toString(raw[i]);
}
return result;
......
......@@ -26,7 +26,7 @@ var GlobalSymbol = global.Symbol;
function SymbolConstructor(x) {
if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Symbol");
// NOTE: Passing in a Symbol value will throw on ToString().
return %CreateSymbol(IS_UNDEFINED(x) ? x : ToString(x));
return %CreateSymbol(IS_UNDEFINED(x) ? x : $toString(x));
}
......@@ -69,7 +69,7 @@ function SymbolKeyFor(symbol) {
// ES6 19.1.2.8
function ObjectGetOwnPropertySymbols(obj) {
obj = ToObject(obj);
obj = $toObject(obj);
// TODO(arv): Proxies use a shared trap for String and Symbol keys.
......
......@@ -38,10 +38,10 @@ macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE)
function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) {
if (!IS_UNDEFINED(byteOffset)) {
byteOffset =
ToPositiveInteger(byteOffset, kInvalidTypedArrayLength);
$toPositiveInteger(byteOffset, kInvalidTypedArrayLength);
}
if (!IS_UNDEFINED(length)) {
length = ToPositiveInteger(length, kInvalidTypedArrayLength);
length = $toPositiveInteger(length, kInvalidTypedArrayLength);
}
var bufferByteLength = %_ArrayBufferGetByteLength(buffer);
......@@ -82,7 +82,7 @@ function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) {
function NAMEConstructByLength(obj, length) {
var l = IS_UNDEFINED(length) ?
0 : ToPositiveInteger(length, kInvalidTypedArrayLength);
0 : $toPositiveInteger(length, kInvalidTypedArrayLength);
if (l > %_MaxSmi()) {
throw MakeRangeError(kInvalidTypedArrayLength);
}
......@@ -97,7 +97,7 @@ function NAMEConstructByLength(obj, length) {
function NAMEConstructByArrayLike(obj, arrayLike) {
var length = arrayLike.length;
var l = ToPositiveInteger(length, kInvalidTypedArrayLength);
var l = $toPositiveInteger(length, kInvalidTypedArrayLength);
if (l > %_MaxSmi()) {
throw MakeRangeError(kInvalidTypedArrayLength);
......@@ -335,7 +335,7 @@ function DataViewConstructor(buffer, byteOffset, byteLength) { // length = 3
if (%_IsConstructCall()) {
if (!IS_ARRAYBUFFER(buffer)) throw MakeTypeError(kDataViewNotArrayBuffer);
if (!IS_UNDEFINED(byteOffset)) {
byteOffset = ToPositiveInteger(byteOffset, kInvalidDataViewOffset);
byteOffset = $toPositiveInteger(byteOffset, kInvalidDataViewOffset);
}
if (!IS_UNDEFINED(byteLength)) {
byteLength = TO_INTEGER(byteLength);
......@@ -392,10 +392,6 @@ macro DATA_VIEW_TYPES(FUNCTION)
FUNCTION(Float64)
endmacro
function ToPositiveDataViewOffset(offset) {
return ToPositiveInteger(offset, kInvalidDataViewAccessorOffset);
}
macro DATA_VIEW_GETTER_SETTER(TYPENAME)
function DataViewGetTYPENAMEJS(offset, little_endian) {
......@@ -404,9 +400,8 @@ function DataViewGetTYPENAMEJS(offset, little_endian) {
'DataView.getTYPENAME', this);
}
if (%_ArgumentsLength() < 1) throw MakeTypeError(kInvalidArgument);
return %DataViewGetTYPENAME(this,
ToPositiveDataViewOffset(offset),
!!little_endian);
offset = $toPositiveInteger(offset, kInvalidDataViewAccessorOffset);
return %DataViewGetTYPENAME(this, offset, !!little_endian);
}
function DataViewSetTYPENAMEJS(offset, value, little_endian) {
......@@ -415,10 +410,8 @@ function DataViewSetTYPENAMEJS(offset, value, little_endian) {
'DataView.setTYPENAME', this);
}
if (%_ArgumentsLength() < 2) throw MakeTypeError(kInvalidArgument);
%DataViewSetTYPENAME(this,
ToPositiveDataViewOffset(offset),
TO_NUMBER_INLINE(value),
!!little_endian);
offset = $toPositiveInteger(offset, kInvalidDataViewAccessorOffset);
%DataViewSetTYPENAME(this, offset, TO_NUMBER_INLINE(value), !!little_endian);
}
endmacro
......
......@@ -262,13 +262,13 @@ function Decode(uri, reserved) {
// ECMA-262 - B.2.1.
function URIEscapeJS(str) {
var s = ToString(str);
var s = $toString(str);
return %URIEscape(s);
}
// ECMA-262 - B.2.2.
function URIUnescapeJS(str) {
var s = ToString(str);
var s = $toString(str);
return %URIUnescape(s);
}
......@@ -292,14 +292,14 @@ function URIDecode(uri) {
return false;
};
var string = ToString(uri);
var string = $toString(uri);
return Decode(string, reservedPredicate);
}
// ECMA-262 - 15.1.3.2.
function URIDecodeComponent(component) {
var reservedPredicate = function(cc) { return false; };
var string = ToString(component);
var string = $toString(component);
return Decode(string, reservedPredicate);
}
......@@ -326,7 +326,7 @@ function URIEncode(uri) {
return false;
};
var string = ToString(uri);
var string = $toString(uri);
return Encode(string, unescapePredicate);
}
......@@ -347,7 +347,7 @@ function URIEncodeComponent(component) {
return false;
};
var string = ToString(component);
var string = $toString(component);
return Encode(string, unescapePredicate);
}
......
This diff is collapsed.
......@@ -158,7 +158,7 @@ TEST(RuntimeCallCPP2) {
TEST(RuntimeCallJS) {
FLAG_allow_natives_syntax = true;
FunctionTester T("(function(a) { return %ToString(a); })");
FunctionTester T("(function(a) { return %$toString(a); })");
T.CheckCall(T.Val("23"), T.Val(23), T.undefined());
T.CheckCall(T.Val("4.2"), T.Val(4.2), T.undefined());
......
......@@ -32,71 +32,73 @@
var obj1 = {x: 10, y: 11, z: "test"};
var obj2 = {x: 10, y: 11, z: "test"};
assertTrue(natives.SameValue(0, 0));
assertTrue(natives.SameValue(+0, +0));
assertTrue(natives.SameValue(-0, -0));
assertTrue(natives.SameValue(1, 1));
assertTrue(natives.SameValue(2, 2));
assertTrue(natives.SameValue(-1, -1));
assertTrue(natives.SameValue(0.5, 0.5));
assertTrue(natives.SameValue(true, true));
assertTrue(natives.SameValue(false, false));
assertTrue(natives.SameValue(NaN, NaN));
assertTrue(natives.SameValue(null, null));
assertTrue(natives.SameValue("foo", "foo"));
assertTrue(natives.SameValue(obj1, obj1));
var sameValue = natives.$sameValue;
assertTrue(sameValue(0, 0));
assertTrue(sameValue(+0, +0));
assertTrue(sameValue(-0, -0));
assertTrue(sameValue(1, 1));
assertTrue(sameValue(2, 2));
assertTrue(sameValue(-1, -1));
assertTrue(sameValue(0.5, 0.5));
assertTrue(sameValue(true, true));
assertTrue(sameValue(false, false));
assertTrue(sameValue(NaN, NaN));
assertTrue(sameValue(null, null));
assertTrue(sameValue("foo", "foo"));
assertTrue(sameValue(obj1, obj1));
// Undefined values.
assertTrue(natives.SameValue());
assertTrue(natives.SameValue(undefined, undefined));
assertTrue(sameValue());
assertTrue(sameValue(undefined, undefined));
assertFalse(natives.SameValue(0,1));
assertFalse(natives.SameValue("foo", "bar"));
assertFalse(natives.SameValue(obj1, obj2));
assertFalse(natives.SameValue(true, false));
assertFalse(sameValue(0,1));
assertFalse(sameValue("foo", "bar"));
assertFalse(sameValue(obj1, obj2));
assertFalse(sameValue(true, false));
assertFalse(natives.SameValue(obj1, true));
assertFalse(natives.SameValue(obj1, "foo"));
assertFalse(natives.SameValue(obj1, 1));
assertFalse(natives.SameValue(obj1, undefined));
assertFalse(natives.SameValue(obj1, NaN));
assertFalse(sameValue(obj1, true));
assertFalse(sameValue(obj1, "foo"));
assertFalse(sameValue(obj1, 1));
assertFalse(sameValue(obj1, undefined));
assertFalse(sameValue(obj1, NaN));
assertFalse(natives.SameValue(undefined, true));
assertFalse(natives.SameValue(undefined, "foo"));
assertFalse(natives.SameValue(undefined, 1));
assertFalse(natives.SameValue(undefined, obj1));
assertFalse(natives.SameValue(undefined, NaN));
assertFalse(sameValue(undefined, true));
assertFalse(sameValue(undefined, "foo"));
assertFalse(sameValue(undefined, 1));
assertFalse(sameValue(undefined, obj1));
assertFalse(sameValue(undefined, NaN));
assertFalse(natives.SameValue(NaN, true));
assertFalse(natives.SameValue(NaN, "foo"));
assertFalse(natives.SameValue(NaN, 1));
assertFalse(natives.SameValue(NaN, obj1));
assertFalse(natives.SameValue(NaN, undefined));
assertFalse(sameValue(NaN, true));
assertFalse(sameValue(NaN, "foo"));
assertFalse(sameValue(NaN, 1));
assertFalse(sameValue(NaN, obj1));
assertFalse(sameValue(NaN, undefined));
assertFalse(natives.SameValue("foo", true));
assertFalse(natives.SameValue("foo", 1));
assertFalse(natives.SameValue("foo", obj1));
assertFalse(natives.SameValue("foo", undefined));
assertFalse(natives.SameValue("foo", NaN));
assertFalse(sameValue("foo", true));
assertFalse(sameValue("foo", 1));
assertFalse(sameValue("foo", obj1));
assertFalse(sameValue("foo", undefined));
assertFalse(sameValue("foo", NaN));
assertFalse(natives.SameValue(true, 1));
assertFalse(natives.SameValue(true, obj1));
assertFalse(natives.SameValue(true, undefined));
assertFalse(natives.SameValue(true, NaN));
assertFalse(natives.SameValue(true, "foo"));
assertFalse(sameValue(true, 1));
assertFalse(sameValue(true, obj1));
assertFalse(sameValue(true, undefined));
assertFalse(sameValue(true, NaN));
assertFalse(sameValue(true, "foo"));
assertFalse(natives.SameValue(1, true));
assertFalse(natives.SameValue(1, obj1));
assertFalse(natives.SameValue(1, undefined));
assertFalse(natives.SameValue(1, NaN));
assertFalse(natives.SameValue(1, "foo"));
assertFalse(sameValue(1, true));
assertFalse(sameValue(1, obj1));
assertFalse(sameValue(1, undefined));
assertFalse(sameValue(1, NaN));
assertFalse(sameValue(1, "foo"));
// Special string cases.
assertFalse(natives.SameValue("1", 1));
assertFalse(natives.SameValue("true", true));
assertFalse(natives.SameValue("false", false));
assertFalse(natives.SameValue("undefined", undefined));
assertFalse(natives.SameValue("NaN", NaN));
assertFalse(sameValue("1", 1));
assertFalse(sameValue("true", true));
assertFalse(sameValue("false", false));
assertFalse(sameValue("undefined", undefined));
assertFalse(sameValue("NaN", NaN));
// -0 and +0 are should be different
assertFalse(natives.SameValue(+0, -0));
assertFalse(natives.SameValue(-0, +0));
assertFalse(sameValue(+0, -0));
assertFalse(sameValue(-0, +0));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment