Native context: debug.js does not load from js builtins object anymore.
This mainly changes how we share ToBoolean, ToNumber and ToString between native scripts. Instead of putting them on the js builtins object, we now explicitly export and import those functions. I also had to change the import/export mechanism slightly. Previously, exports and imports are hooked up after all native scripts have been executed. This means that imported functions cannot be called at the time the native script is executed. However, since ToBoolean (and also e.g. ObjectDefineProperties) is called in v8natives.js, I changed the mechanism so that exports from previous native scripts (runtime.js for ToBoolean) is imported immediately and can be called. R=cbruni@chromium.org Review URL: https://codereview.chromium.org/1302533002 Cr-Commit-Position: refs/heads/master@{#30244}
This commit is contained in:
parent
7fc7957be5
commit
eb8c092822
15
src/array.js
15
src/array.js
@ -19,16 +19,17 @@ var $arrayUnshift;
|
||||
// -------------------------------------------------------------------
|
||||
// Imports
|
||||
|
||||
var Delete;
|
||||
var GlobalArray = global.Array;
|
||||
var InternalArray = utils.InternalArray;
|
||||
var InternalPackedArray = utils.InternalPackedArray;
|
||||
|
||||
var Delete;
|
||||
var MathMin;
|
||||
var ObjectHasOwnProperty;
|
||||
var ObjectIsFrozen;
|
||||
var ObjectIsSealed;
|
||||
var ObjectToString;
|
||||
var ToNumber;
|
||||
var ToString;
|
||||
|
||||
utils.Import(function(from) {
|
||||
Delete = from.Delete;
|
||||
@ -37,6 +38,8 @@ utils.Import(function(from) {
|
||||
ObjectIsFrozen = from.ObjectIsFrozen;
|
||||
ObjectIsSealed = from.ObjectIsSealed;
|
||||
ObjectToString = from.ObjectToString;
|
||||
ToNumber = from.ToNumber;
|
||||
ToString = from.ToString;
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
@ -216,7 +219,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));
|
||||
}
|
||||
|
||||
|
||||
@ -228,7 +231,7 @@ function ConvertToLocaleString(e) {
|
||||
// must throw a TypeError if ToObject(e).toLocaleString isn't
|
||||
// callable.
|
||||
var e_obj = TO_OBJECT(e);
|
||||
return $toString(e_obj.toLocaleString());
|
||||
return ToString(e_obj.toLocaleString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -914,8 +917,8 @@ function InnerArraySort(length, 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;
|
||||
};
|
||||
|
@ -13,13 +13,14 @@
|
||||
|
||||
var GlobalArrayBuffer = global.ArrayBuffer;
|
||||
var GlobalObject = global.Object;
|
||||
|
||||
var MathMax;
|
||||
var MathMin;
|
||||
var ToNumber;
|
||||
|
||||
utils.Import(function(from) {
|
||||
MathMax = from.MathMax;
|
||||
MathMin = from.MathMin;
|
||||
ToNumber = from.ToNumber;
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
113
src/date.js
113
src/date.js
@ -17,15 +17,18 @@ var $createDate;
|
||||
|
||||
var GlobalDate = global.Date;
|
||||
var InternalArray = utils.InternalArray;
|
||||
|
||||
var IsFinite;
|
||||
var MathAbs;
|
||||
var MathFloor;
|
||||
var ToNumber;
|
||||
var ToString;
|
||||
|
||||
utils.Import(function(from) {
|
||||
IsFinite = from.IsFinite;
|
||||
MathAbs = from.MathAbs;
|
||||
MathFloor = from.MathFloor;
|
||||
ToNumber = from.ToNumber;
|
||||
ToString = from.ToString;
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
@ -169,17 +172,17 @@ function DateConstructor(year, month, date, hours, minutes, seconds, ms) {
|
||||
// which is the default for everything else than Date objects.
|
||||
// This makes us behave like KJS and SpiderMonkey.
|
||||
var time = $toPrimitive(year, NUMBER_HINT);
|
||||
value = IS_STRING(time) ? DateParse(time) : $toNumber(time);
|
||||
value = IS_STRING(time) ? DateParse(time) : ToNumber(time);
|
||||
}
|
||||
SET_UTC_DATE_VALUE(this, value);
|
||||
} else {
|
||||
year = $toNumber(year);
|
||||
month = $toNumber(month);
|
||||
date = argc > 2 ? $toNumber(date) : 1;
|
||||
hours = argc > 3 ? $toNumber(hours) : 0;
|
||||
minutes = argc > 4 ? $toNumber(minutes) : 0;
|
||||
seconds = argc > 5 ? $toNumber(seconds) : 0;
|
||||
ms = argc > 6 ? $toNumber(ms) : 0;
|
||||
year = ToNumber(year);
|
||||
month = ToNumber(month);
|
||||
date = argc > 2 ? ToNumber(date) : 1;
|
||||
hours = argc > 3 ? ToNumber(hours) : 0;
|
||||
minutes = argc > 4 ? ToNumber(minutes) : 0;
|
||||
seconds = argc > 5 ? ToNumber(seconds) : 0;
|
||||
ms = argc > 6 ? ToNumber(ms) : 0;
|
||||
year = (!NUMBER_IS_NAN(year) &&
|
||||
0 <= TO_INTEGER(year) &&
|
||||
TO_INTEGER(year) <= 99) ? 1900 + TO_INTEGER(year) : year;
|
||||
@ -267,7 +270,7 @@ var parse_buffer = new InternalArray(8);
|
||||
|
||||
// ECMA 262 - 15.9.4.2
|
||||
function DateParse(string) {
|
||||
var arr = %DateParseString($toString(string), parse_buffer);
|
||||
var arr = %DateParseString(ToString(string), parse_buffer);
|
||||
if (IS_NULL(arr)) return NAN;
|
||||
|
||||
var day = MakeDay(arr[0], arr[1], arr[2]);
|
||||
@ -284,14 +287,14 @@ function DateParse(string) {
|
||||
|
||||
// ECMA 262 - 15.9.4.3
|
||||
function DateUTC(year, month, date, hours, minutes, seconds, ms) {
|
||||
year = $toNumber(year);
|
||||
month = $toNumber(month);
|
||||
year = ToNumber(year);
|
||||
month = ToNumber(month);
|
||||
var argc = %_ArgumentsLength();
|
||||
date = argc > 2 ? $toNumber(date) : 1;
|
||||
hours = argc > 3 ? $toNumber(hours) : 0;
|
||||
minutes = argc > 4 ? $toNumber(minutes) : 0;
|
||||
seconds = argc > 5 ? $toNumber(seconds) : 0;
|
||||
ms = argc > 6 ? $toNumber(ms) : 0;
|
||||
date = argc > 2 ? ToNumber(date) : 1;
|
||||
hours = argc > 3 ? ToNumber(hours) : 0;
|
||||
minutes = argc > 4 ? ToNumber(minutes) : 0;
|
||||
seconds = argc > 5 ? ToNumber(seconds) : 0;
|
||||
ms = argc > 6 ? ToNumber(ms) : 0;
|
||||
year = (!NUMBER_IS_NAN(year) &&
|
||||
0 <= TO_INTEGER(year) &&
|
||||
TO_INTEGER(year) <= 99) ? 1900 + TO_INTEGER(year) : year;
|
||||
@ -497,7 +500,7 @@ function DateGetTimezoneOffset() {
|
||||
// ECMA 262 - 15.9.5.27
|
||||
function DateSetTime(ms) {
|
||||
CHECK_DATE(this);
|
||||
SET_UTC_DATE_VALUE(this, $toNumber(ms));
|
||||
SET_UTC_DATE_VALUE(this, ToNumber(ms));
|
||||
return UTC_DATE_VALUE(this);
|
||||
}
|
||||
|
||||
@ -506,7 +509,7 @@ function DateSetTime(ms) {
|
||||
function DateSetMilliseconds(ms) {
|
||||
CHECK_DATE(this);
|
||||
var t = LOCAL_DATE_VALUE(this);
|
||||
ms = $toNumber(ms);
|
||||
ms = ToNumber(ms);
|
||||
var time = MakeTime(LOCAL_HOUR(this), LOCAL_MIN(this), LOCAL_SEC(this), ms);
|
||||
return SET_LOCAL_DATE_VALUE(this, MakeDate(LOCAL_DAYS(this), time));
|
||||
}
|
||||
@ -516,7 +519,7 @@ function DateSetMilliseconds(ms) {
|
||||
function DateSetUTCMilliseconds(ms) {
|
||||
CHECK_DATE(this);
|
||||
var t = UTC_DATE_VALUE(this);
|
||||
ms = $toNumber(ms);
|
||||
ms = ToNumber(ms);
|
||||
var time = MakeTime(UTC_HOUR(this),
|
||||
UTC_MIN(this),
|
||||
UTC_SEC(this),
|
||||
@ -529,8 +532,8 @@ function DateSetUTCMilliseconds(ms) {
|
||||
function DateSetSeconds(sec, ms) {
|
||||
CHECK_DATE(this);
|
||||
var t = LOCAL_DATE_VALUE(this);
|
||||
sec = $toNumber(sec);
|
||||
ms = %_ArgumentsLength() < 2 ? LOCAL_MS(this) : $toNumber(ms);
|
||||
sec = ToNumber(sec);
|
||||
ms = %_ArgumentsLength() < 2 ? LOCAL_MS(this) : ToNumber(ms);
|
||||
var time = MakeTime(LOCAL_HOUR(this), LOCAL_MIN(this), sec, ms);
|
||||
return SET_LOCAL_DATE_VALUE(this, MakeDate(LOCAL_DAYS(this), time));
|
||||
}
|
||||
@ -540,8 +543,8 @@ function DateSetSeconds(sec, ms) {
|
||||
function DateSetUTCSeconds(sec, ms) {
|
||||
CHECK_DATE(this);
|
||||
var t = UTC_DATE_VALUE(this);
|
||||
sec = $toNumber(sec);
|
||||
ms = %_ArgumentsLength() < 2 ? UTC_MS(this) : $toNumber(ms);
|
||||
sec = ToNumber(sec);
|
||||
ms = %_ArgumentsLength() < 2 ? UTC_MS(this) : ToNumber(ms);
|
||||
var time = MakeTime(UTC_HOUR(this), UTC_MIN(this), sec, ms);
|
||||
return SET_UTC_DATE_VALUE(this, MakeDate(UTC_DAYS(this), time));
|
||||
}
|
||||
@ -551,10 +554,10 @@ function DateSetUTCSeconds(sec, ms) {
|
||||
function DateSetMinutes(min, sec, ms) {
|
||||
CHECK_DATE(this);
|
||||
var t = LOCAL_DATE_VALUE(this);
|
||||
min = $toNumber(min);
|
||||
min = ToNumber(min);
|
||||
var argc = %_ArgumentsLength();
|
||||
sec = argc < 2 ? LOCAL_SEC(this) : $toNumber(sec);
|
||||
ms = argc < 3 ? LOCAL_MS(this) : $toNumber(ms);
|
||||
sec = argc < 2 ? LOCAL_SEC(this) : ToNumber(sec);
|
||||
ms = argc < 3 ? LOCAL_MS(this) : ToNumber(ms);
|
||||
var time = MakeTime(LOCAL_HOUR(this), min, sec, ms);
|
||||
return SET_LOCAL_DATE_VALUE(this, MakeDate(LOCAL_DAYS(this), time));
|
||||
}
|
||||
@ -564,10 +567,10 @@ function DateSetMinutes(min, sec, ms) {
|
||||
function DateSetUTCMinutes(min, sec, ms) {
|
||||
CHECK_DATE(this);
|
||||
var t = UTC_DATE_VALUE(this);
|
||||
min = $toNumber(min);
|
||||
min = ToNumber(min);
|
||||
var argc = %_ArgumentsLength();
|
||||
sec = argc < 2 ? UTC_SEC(this) : $toNumber(sec);
|
||||
ms = argc < 3 ? UTC_MS(this) : $toNumber(ms);
|
||||
sec = argc < 2 ? UTC_SEC(this) : ToNumber(sec);
|
||||
ms = argc < 3 ? UTC_MS(this) : ToNumber(ms);
|
||||
var time = MakeTime(UTC_HOUR(this), min, sec, ms);
|
||||
return SET_UTC_DATE_VALUE(this, MakeDate(UTC_DAYS(this), time));
|
||||
}
|
||||
@ -577,11 +580,11 @@ function DateSetUTCMinutes(min, sec, ms) {
|
||||
function DateSetHours(hour, min, sec, ms) {
|
||||
CHECK_DATE(this);
|
||||
var t = LOCAL_DATE_VALUE(this);
|
||||
hour = $toNumber(hour);
|
||||
hour = ToNumber(hour);
|
||||
var argc = %_ArgumentsLength();
|
||||
min = argc < 2 ? LOCAL_MIN(this) : $toNumber(min);
|
||||
sec = argc < 3 ? LOCAL_SEC(this) : $toNumber(sec);
|
||||
ms = argc < 4 ? LOCAL_MS(this) : $toNumber(ms);
|
||||
min = argc < 2 ? LOCAL_MIN(this) : ToNumber(min);
|
||||
sec = argc < 3 ? LOCAL_SEC(this) : ToNumber(sec);
|
||||
ms = argc < 4 ? LOCAL_MS(this) : ToNumber(ms);
|
||||
var time = MakeTime(hour, min, sec, ms);
|
||||
return SET_LOCAL_DATE_VALUE(this, MakeDate(LOCAL_DAYS(this), time));
|
||||
}
|
||||
@ -591,11 +594,11 @@ function DateSetHours(hour, min, sec, ms) {
|
||||
function DateSetUTCHours(hour, min, sec, ms) {
|
||||
CHECK_DATE(this);
|
||||
var t = UTC_DATE_VALUE(this);
|
||||
hour = $toNumber(hour);
|
||||
hour = ToNumber(hour);
|
||||
var argc = %_ArgumentsLength();
|
||||
min = argc < 2 ? UTC_MIN(this) : $toNumber(min);
|
||||
sec = argc < 3 ? UTC_SEC(this) : $toNumber(sec);
|
||||
ms = argc < 4 ? UTC_MS(this) : $toNumber(ms);
|
||||
min = argc < 2 ? UTC_MIN(this) : ToNumber(min);
|
||||
sec = argc < 3 ? UTC_SEC(this) : ToNumber(sec);
|
||||
ms = argc < 4 ? UTC_MS(this) : ToNumber(ms);
|
||||
var time = MakeTime(hour, min, sec, ms);
|
||||
return SET_UTC_DATE_VALUE(this, MakeDate(UTC_DAYS(this), time));
|
||||
}
|
||||
@ -605,7 +608,7 @@ function DateSetUTCHours(hour, min, sec, ms) {
|
||||
function DateSetDate(date) {
|
||||
CHECK_DATE(this);
|
||||
var t = LOCAL_DATE_VALUE(this);
|
||||
date = $toNumber(date);
|
||||
date = ToNumber(date);
|
||||
var day = MakeDay(LOCAL_YEAR(this), LOCAL_MONTH(this), date);
|
||||
return SET_LOCAL_DATE_VALUE(this, MakeDate(day, LOCAL_TIME_IN_DAY(this)));
|
||||
}
|
||||
@ -615,7 +618,7 @@ function DateSetDate(date) {
|
||||
function DateSetUTCDate(date) {
|
||||
CHECK_DATE(this);
|
||||
var t = UTC_DATE_VALUE(this);
|
||||
date = $toNumber(date);
|
||||
date = ToNumber(date);
|
||||
var day = MakeDay(UTC_YEAR(this), UTC_MONTH(this), date);
|
||||
return SET_UTC_DATE_VALUE(this, MakeDate(day, UTC_TIME_IN_DAY(this)));
|
||||
}
|
||||
@ -625,8 +628,8 @@ function DateSetUTCDate(date) {
|
||||
function DateSetMonth(month, date) {
|
||||
CHECK_DATE(this);
|
||||
var t = LOCAL_DATE_VALUE(this);
|
||||
month = $toNumber(month);
|
||||
date = %_ArgumentsLength() < 2 ? LOCAL_DAY(this) : $toNumber(date);
|
||||
month = ToNumber(month);
|
||||
date = %_ArgumentsLength() < 2 ? LOCAL_DAY(this) : ToNumber(date);
|
||||
var day = MakeDay(LOCAL_YEAR(this), month, date);
|
||||
return SET_LOCAL_DATE_VALUE(this, MakeDate(day, LOCAL_TIME_IN_DAY(this)));
|
||||
}
|
||||
@ -636,8 +639,8 @@ function DateSetMonth(month, date) {
|
||||
function DateSetUTCMonth(month, date) {
|
||||
CHECK_DATE(this);
|
||||
var t = UTC_DATE_VALUE(this);
|
||||
month = $toNumber(month);
|
||||
date = %_ArgumentsLength() < 2 ? UTC_DAY(this) : $toNumber(date);
|
||||
month = ToNumber(month);
|
||||
date = %_ArgumentsLength() < 2 ? UTC_DAY(this) : ToNumber(date);
|
||||
var day = MakeDay(UTC_YEAR(this), month, date);
|
||||
return SET_UTC_DATE_VALUE(this, MakeDate(day, UTC_TIME_IN_DAY(this)));
|
||||
}
|
||||
@ -647,16 +650,16 @@ function DateSetUTCMonth(month, date) {
|
||||
function DateSetFullYear(year, month, date) {
|
||||
CHECK_DATE(this);
|
||||
var t = LOCAL_DATE_VALUE(this);
|
||||
year = $toNumber(year);
|
||||
year = ToNumber(year);
|
||||
var argc = %_ArgumentsLength();
|
||||
var time ;
|
||||
if (NUMBER_IS_NAN(t)) {
|
||||
month = argc < 2 ? 0 : $toNumber(month);
|
||||
date = argc < 3 ? 1 : $toNumber(date);
|
||||
month = argc < 2 ? 0 : ToNumber(month);
|
||||
date = argc < 3 ? 1 : ToNumber(date);
|
||||
time = 0;
|
||||
} else {
|
||||
month = argc < 2 ? LOCAL_MONTH(this) : $toNumber(month);
|
||||
date = argc < 3 ? LOCAL_DAY(this) : $toNumber(date);
|
||||
month = argc < 2 ? LOCAL_MONTH(this) : ToNumber(month);
|
||||
date = argc < 3 ? LOCAL_DAY(this) : ToNumber(date);
|
||||
time = LOCAL_TIME_IN_DAY(this);
|
||||
}
|
||||
var day = MakeDay(year, month, date);
|
||||
@ -668,16 +671,16 @@ function DateSetFullYear(year, month, date) {
|
||||
function DateSetUTCFullYear(year, month, date) {
|
||||
CHECK_DATE(this);
|
||||
var t = UTC_DATE_VALUE(this);
|
||||
year = $toNumber(year);
|
||||
year = ToNumber(year);
|
||||
var argc = %_ArgumentsLength();
|
||||
var time ;
|
||||
if (NUMBER_IS_NAN(t)) {
|
||||
month = argc < 2 ? 0 : $toNumber(month);
|
||||
date = argc < 3 ? 1 : $toNumber(date);
|
||||
month = argc < 2 ? 0 : ToNumber(month);
|
||||
date = argc < 3 ? 1 : ToNumber(date);
|
||||
time = 0;
|
||||
} else {
|
||||
month = argc < 2 ? UTC_MONTH(this) : $toNumber(month);
|
||||
date = argc < 3 ? UTC_DAY(this) : $toNumber(date);
|
||||
month = argc < 2 ? UTC_MONTH(this) : ToNumber(month);
|
||||
date = argc < 3 ? UTC_DAY(this) : ToNumber(date);
|
||||
time = UTC_TIME_IN_DAY(this);
|
||||
}
|
||||
var day = MakeDay(year, month, date);
|
||||
@ -709,7 +712,7 @@ function DateGetYear() {
|
||||
// ECMA 262 - B.2.5
|
||||
function DateSetYear(year) {
|
||||
CHECK_DATE(this);
|
||||
year = $toNumber(year);
|
||||
year = ToNumber(year);
|
||||
if (NUMBER_IS_NAN(year)) return SET_UTC_DATE_VALUE(this, NAN);
|
||||
year = (0 <= TO_INTEGER(year) && TO_INTEGER(year) <= 99)
|
||||
? 1900 + TO_INTEGER(year) : year;
|
||||
|
@ -21,10 +21,16 @@ var MathMin = global.Math.min;
|
||||
var Mirror = global.Mirror;
|
||||
var MirrorType;
|
||||
var ParseInt = global.parseInt;
|
||||
var ToBoolean;
|
||||
var ToNumber;
|
||||
var ToString;
|
||||
var ValueMirror = global.ValueMirror;
|
||||
|
||||
utils.Import(function(from) {
|
||||
MirrorType = from.MirrorType;
|
||||
ToBoolean = from.ToBoolean;
|
||||
ToNumber = from.ToNumber;
|
||||
ToString = from.ToString;
|
||||
});
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@ -228,7 +234,7 @@ 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) || !ToBoolean(mirror.value_)) {
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
@ -944,8 +950,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 = ToNumber(opt_action);
|
||||
var count = opt_count ? ToNumber(opt_count) : 1;
|
||||
var callFrameId = 0;
|
||||
if (!IS_UNDEFINED(opt_callframe)) {
|
||||
callFrameId = opt_callframe.details_.frameId();
|
||||
@ -957,7 +963,7 @@ ExecutionState.prototype.prepareStep = function(opt_action, opt_count,
|
||||
ExecutionState.prototype.evaluateGlobal = function(source, disable_break,
|
||||
opt_additional_context) {
|
||||
return MakeMirror(%DebugEvaluateGlobal(this.break_id, source,
|
||||
$toBoolean(disable_break),
|
||||
ToBoolean(disable_break),
|
||||
opt_additional_context));
|
||||
};
|
||||
|
||||
@ -979,7 +985,7 @@ ExecutionState.prototype.frame = function(opt_index) {
|
||||
};
|
||||
|
||||
ExecutionState.prototype.setSelectedFrame = function(index) {
|
||||
var i = $toNumber(index);
|
||||
var i = ToNumber(index);
|
||||
if (i < 0 || i >= this.frameCount()) {
|
||||
throw MakeTypeError(kDebuggerFrame);
|
||||
}
|
||||
@ -1426,7 +1432,7 @@ DebugCommandProcessor.prototype.processDebugJSONRequest = function(
|
||||
response = this.createResponse();
|
||||
}
|
||||
response.success = false;
|
||||
response.message = $toString(e);
|
||||
response.message = ToString(e);
|
||||
}
|
||||
|
||||
// Return the response as a JSON encoded string.
|
||||
@ -1443,7 +1449,7 @@ DebugCommandProcessor.prototype.processDebugJSONRequest = function(
|
||||
'"request_seq":' + request.seq + ',' +
|
||||
'"type":"response",' +
|
||||
'"success":false,' +
|
||||
'"message":"Internal error: ' + $toString(e) + '"}';
|
||||
'"message":"Internal error: ' + ToString(e) + '"}';
|
||||
}
|
||||
} catch (e) {
|
||||
// Failed in one of the catch blocks above - most generic error.
|
||||
@ -1464,7 +1470,7 @@ DebugCommandProcessor.prototype.continueRequest_ = function(request, response) {
|
||||
|
||||
// Get the stepcount argument if any.
|
||||
if (stepcount) {
|
||||
count = $toNumber(stepcount);
|
||||
count = ToNumber(stepcount);
|
||||
if (count < 0) {
|
||||
throw MakeError(kDebugger,
|
||||
'Invalid stepcount argument "' + stepcount + '".');
|
||||
@ -1539,7 +1545,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: "' + ToString(e) +
|
||||
'" evaluating "' + target + '"');
|
||||
return;
|
||||
}
|
||||
@ -1628,7 +1634,7 @@ DebugCommandProcessor.prototype.changeBreakPointRequest_ = function(
|
||||
}
|
||||
|
||||
// Pull out arguments.
|
||||
var break_point = $toNumber(request.arguments.breakpoint);
|
||||
var break_point = ToNumber(request.arguments.breakpoint);
|
||||
var enabled = request.arguments.enabled;
|
||||
var condition = request.arguments.condition;
|
||||
var ignoreCount = request.arguments.ignoreCount;
|
||||
@ -1704,7 +1710,7 @@ DebugCommandProcessor.prototype.clearBreakPointRequest_ = function(
|
||||
}
|
||||
|
||||
// Pull out arguments.
|
||||
var break_point = $toNumber(request.arguments.breakpoint);
|
||||
var break_point = ToNumber(request.arguments.breakpoint);
|
||||
|
||||
// Check for legal arguments.
|
||||
if (!break_point) {
|
||||
@ -1962,7 +1968,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 = ToNumber(request.arguments.number);
|
||||
if (scope_index < 0 || scope_holder.scopeCount() <= scope_index) {
|
||||
return response.failed('Invalid scope number');
|
||||
}
|
||||
@ -1986,11 +1992,11 @@ DebugCommandProcessor.resolveValue_ = function(value_description) {
|
||||
return value_mirror.value();
|
||||
} else if ("stringDescription" in value_description) {
|
||||
if (value_description.type == MirrorType.BOOLEAN_TYPE) {
|
||||
return $toBoolean(value_description.stringDescription);
|
||||
return ToBoolean(value_description.stringDescription);
|
||||
} else if (value_description.type == MirrorType.NUMBER_TYPE) {
|
||||
return $toNumber(value_description.stringDescription);
|
||||
return ToNumber(value_description.stringDescription);
|
||||
} if (value_description.type == MirrorType.STRING_TYPE) {
|
||||
return $toString(value_description.stringDescription);
|
||||
return ToString(value_description.stringDescription);
|
||||
} else {
|
||||
throw MakeError(kDebugger, "Unknown type");
|
||||
}
|
||||
@ -2026,7 +2032,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 = ToNumber(scope_description.number);
|
||||
|
||||
var scope = scope_holder.scope(scope_index);
|
||||
|
||||
@ -2058,7 +2064,7 @@ DebugCommandProcessor.prototype.evaluateRequest_ = function(request, response) {
|
||||
// The expression argument could be an integer so we convert it to a
|
||||
// string.
|
||||
try {
|
||||
expression = $toString(expression);
|
||||
expression = ToString(expression);
|
||||
} catch(e) {
|
||||
return response.failed('Failed to convert expression argument to string');
|
||||
}
|
||||
@ -2088,7 +2094,7 @@ DebugCommandProcessor.prototype.evaluateRequest_ = function(request, response) {
|
||||
if (global) {
|
||||
// Evaluate in the native context.
|
||||
response.body = this.exec_state_.evaluateGlobal(
|
||||
expression, $toBoolean(disable_break), additional_context_object);
|
||||
expression, ToBoolean(disable_break), additional_context_object);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2104,18 +2110,18 @@ DebugCommandProcessor.prototype.evaluateRequest_ = function(request, response) {
|
||||
|
||||
// Check whether a frame was specified.
|
||||
if (!IS_UNDEFINED(frame)) {
|
||||
var frame_number = $toNumber(frame);
|
||||
var frame_number = ToNumber(frame);
|
||||
if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) {
|
||||
return response.failed('Invalid frame "' + frame + '"');
|
||||
}
|
||||
// Evaluate in the specified frame.
|
||||
response.body = this.exec_state_.frame(frame_number).evaluate(
|
||||
expression, $toBoolean(disable_break), additional_context_object);
|
||||
expression, ToBoolean(disable_break), additional_context_object);
|
||||
return;
|
||||
} else {
|
||||
// Evaluate in the selected frame.
|
||||
response.body = this.exec_state_.frame().evaluate(
|
||||
expression, $toBoolean(disable_break), additional_context_object);
|
||||
expression, ToBoolean(disable_break), additional_context_object);
|
||||
return;
|
||||
}
|
||||
};
|
||||
@ -2136,7 +2142,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 = ToBoolean(request.arguments.includeSource);
|
||||
response.setOption('includeSource', includeSource);
|
||||
}
|
||||
|
||||
@ -2204,7 +2210,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 = ToNumber(request.arguments.frame);
|
||||
if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) {
|
||||
return response.failed('Invalid frame "' + frame + '"');
|
||||
}
|
||||
@ -2240,7 +2246,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 = ToNumber(request.arguments.types);
|
||||
if (IsNaN(types) || types < 0) {
|
||||
return response.failed('Invalid types "' +
|
||||
request.arguments.types + '"');
|
||||
@ -2248,7 +2254,7 @@ DebugCommandProcessor.prototype.scriptsRequest_ = function(request, response) {
|
||||
}
|
||||
|
||||
if (!IS_UNDEFINED(request.arguments.includeSource)) {
|
||||
includeSource = $toBoolean(request.arguments.includeSource);
|
||||
includeSource = ToBoolean(request.arguments.includeSource);
|
||||
response.setOption('includeSource', includeSource);
|
||||
}
|
||||
|
||||
@ -2263,7 +2269,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 = ToNumber(request.arguments.filter);
|
||||
if (!IsNaN(num)) {
|
||||
filterNum = num;
|
||||
}
|
||||
@ -2399,7 +2405,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 = ToNumber(frame);
|
||||
if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) {
|
||||
return response.failed('Invalid frame "' + frame + '"');
|
||||
}
|
||||
|
@ -8,10 +8,19 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Imports
|
||||
|
||||
var FunctionSourceString;
|
||||
var GlobalArray = global.Array;
|
||||
var IsNaN = global.isNaN;
|
||||
var JSONStringify = global.JSON.stringify;
|
||||
var MathMin = global.Math.min;
|
||||
var ToBoolean;
|
||||
var ToString;
|
||||
|
||||
utils.Import(function(from) {
|
||||
FunctionSourceString = from.FunctionSourceString;
|
||||
ToBoolean = from.ToBoolean;
|
||||
ToString = from.ToString;
|
||||
});
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@ -990,7 +999,7 @@ FunctionMirror.prototype.source = function() {
|
||||
// Return source if function is resolved. Otherwise just fall through to
|
||||
// return undefined.
|
||||
if (this.resolved()) {
|
||||
return builtins.$functionSourceString(this.value_);
|
||||
return FunctionSourceString(this.value_);
|
||||
}
|
||||
};
|
||||
|
||||
@ -1168,7 +1177,7 @@ ArrayMirror.prototype.indexedPropertiesFromRange = function(opt_from_index,
|
||||
if (from_index > to_index) return new GlobalArray();
|
||||
var values = new GlobalArray(to_index - from_index + 1);
|
||||
for (var i = from_index; i <= to_index; i++) {
|
||||
var details = %DebugGetPropertyDetails(this.value_, builtins.$toString(i));
|
||||
var details = %DebugGetPropertyDetails(this.value_, ToString(i));
|
||||
var value;
|
||||
if (details) {
|
||||
value = new PropertyMirror(this, i, details);
|
||||
@ -2068,7 +2077,7 @@ FrameMirror.prototype.evaluate = function(source, disable_break,
|
||||
this.details_.frameId(),
|
||||
this.details_.inlinedFrameIndex(),
|
||||
source,
|
||||
$toBoolean(disable_break),
|
||||
ToBoolean(disable_break),
|
||||
opt_context_object));
|
||||
};
|
||||
|
||||
|
@ -11,15 +11,15 @@
|
||||
// -------------------------------------------------------------------
|
||||
// Imports
|
||||
|
||||
var GlobalArray = global.Array;
|
||||
var GlobalSymbol = global.Symbol;
|
||||
|
||||
var GetIterator;
|
||||
var GetMethod;
|
||||
var GlobalArray = global.Array;
|
||||
var GlobalSymbol = global.Symbol;
|
||||
var MathMax;
|
||||
var MathMin;
|
||||
var ObjectIsFrozen;
|
||||
var ObjectDefineProperty;
|
||||
var ToNumber;
|
||||
|
||||
utils.Import(function(from) {
|
||||
GetIterator = from.GetIterator;
|
||||
@ -28,6 +28,7 @@ utils.Import(function(from) {
|
||||
MathMin = from.MathMin;
|
||||
ObjectIsFrozen = from.ObjectIsFrozen;
|
||||
ObjectDefineProperty = from.ObjectDefineProperty;
|
||||
ToNumber = from.ToNumber;
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
@ -12,11 +12,12 @@
|
||||
// Imports
|
||||
|
||||
var GlobalObject = global.Object;
|
||||
|
||||
var MathMax;
|
||||
var ToNumber;
|
||||
|
||||
utils.Import(function(from) {
|
||||
MathMax = from.MathMax;
|
||||
ToNumber = from.ToNumber;
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
@ -49,8 +50,8 @@ function AtomicsCompareExchangeJS(sta, index, oldValue, newValue) {
|
||||
if (index < 0 || index >= %_TypedArrayGetLength(sta)) {
|
||||
return UNDEFINED;
|
||||
}
|
||||
oldValue = $toNumber(oldValue);
|
||||
newValue = $toNumber(newValue);
|
||||
oldValue = ToNumber(oldValue);
|
||||
newValue = ToNumber(newValue);
|
||||
return %_AtomicsCompareExchange(sta, index, oldValue, newValue);
|
||||
}
|
||||
|
||||
@ -69,7 +70,7 @@ function AtomicsStoreJS(sta, index, value) {
|
||||
if (index < 0 || index >= %_TypedArrayGetLength(sta)) {
|
||||
return UNDEFINED;
|
||||
}
|
||||
value = $toNumber(value);
|
||||
value = ToNumber(value);
|
||||
return %_AtomicsStore(sta, index, value);
|
||||
}
|
||||
|
||||
@ -79,7 +80,7 @@ function AtomicsAddJS(ia, index, value) {
|
||||
if (index < 0 || index >= %_TypedArrayGetLength(ia)) {
|
||||
return UNDEFINED;
|
||||
}
|
||||
value = $toNumber(value);
|
||||
value = ToNumber(value);
|
||||
return %_AtomicsAdd(ia, index, value);
|
||||
}
|
||||
|
||||
@ -89,7 +90,7 @@ function AtomicsSubJS(ia, index, value) {
|
||||
if (index < 0 || index >= %_TypedArrayGetLength(ia)) {
|
||||
return UNDEFINED;
|
||||
}
|
||||
value = $toNumber(value);
|
||||
value = ToNumber(value);
|
||||
return %_AtomicsSub(ia, index, value);
|
||||
}
|
||||
|
||||
@ -99,7 +100,7 @@ function AtomicsAndJS(ia, index, value) {
|
||||
if (index < 0 || index >= %_TypedArrayGetLength(ia)) {
|
||||
return UNDEFINED;
|
||||
}
|
||||
value = $toNumber(value);
|
||||
value = ToNumber(value);
|
||||
return %_AtomicsAnd(ia, index, value);
|
||||
}
|
||||
|
||||
@ -109,7 +110,7 @@ function AtomicsOrJS(ia, index, value) {
|
||||
if (index < 0 || index >= %_TypedArrayGetLength(ia)) {
|
||||
return UNDEFINED;
|
||||
}
|
||||
value = $toNumber(value);
|
||||
value = ToNumber(value);
|
||||
return %_AtomicsOr(ia, index, value);
|
||||
}
|
||||
|
||||
@ -119,7 +120,7 @@ function AtomicsXorJS(ia, index, value) {
|
||||
if (index < 0 || index >= %_TypedArrayGetLength(ia)) {
|
||||
return UNDEFINED;
|
||||
}
|
||||
value = $toNumber(value);
|
||||
value = ToNumber(value);
|
||||
return %_AtomicsXor(ia, index, value);
|
||||
}
|
||||
|
||||
@ -129,7 +130,7 @@ function AtomicsExchangeJS(ia, index, value) {
|
||||
if (index < 0 || index >= %_TypedArrayGetLength(ia)) {
|
||||
return UNDEFINED;
|
||||
}
|
||||
value = $toNumber(value);
|
||||
value = ToNumber(value);
|
||||
return %_AtomicsExchange(ia, index, value);
|
||||
}
|
||||
|
||||
@ -148,7 +149,7 @@ function AtomicsFutexWaitJS(ia, index, value, timeout) {
|
||||
if (IS_UNDEFINED(timeout)) {
|
||||
timeout = INFINITY;
|
||||
} else {
|
||||
timeout = $toNumber(timeout);
|
||||
timeout = ToNumber(timeout);
|
||||
if (NUMBER_IS_NAN(timeout)) {
|
||||
timeout = INFINITY;
|
||||
} else {
|
||||
|
@ -13,7 +13,6 @@
|
||||
// Imports
|
||||
|
||||
var GlobalObject = global.Object;
|
||||
|
||||
var OwnPropertyKeys;
|
||||
|
||||
utils.Import(function(from) {
|
||||
|
@ -8,7 +8,15 @@
|
||||
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Imports
|
||||
|
||||
var GlobalRegExp = global.RegExp;
|
||||
var ToString;
|
||||
|
||||
utils.Import(function(from) {
|
||||
ToString = from.ToString;
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
@ -16,7 +24,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';
|
||||
|
@ -51,6 +51,7 @@ var IsNaN;
|
||||
var MathMax;
|
||||
var MathMin;
|
||||
var PackedArrayReverse;
|
||||
var ToNumber;
|
||||
|
||||
utils.Import(function(from) {
|
||||
ArrayFrom = from.ArrayFrom;
|
||||
@ -75,6 +76,7 @@ utils.Import(function(from) {
|
||||
MathMax = from.MathMax;
|
||||
MathMin = from.MathMin;
|
||||
PackedArrayReverse = from.PackedArrayReverse;
|
||||
ToNumber = from.ToNumber;
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
23
src/i18n.js
23
src/i18n.js
@ -17,21 +17,18 @@
|
||||
// -------------------------------------------------------------------
|
||||
// Imports
|
||||
|
||||
var ArrayIndexOf;
|
||||
var ArrayJoin;
|
||||
var IsFinite;
|
||||
var IsNaN;
|
||||
var GlobalBoolean = global.Boolean;
|
||||
var GlobalDate = global.Date;
|
||||
var GlobalNumber = global.Number;
|
||||
var GlobalRegExp = global.RegExp;
|
||||
var GlobalString = global.String;
|
||||
var ObjectDefineProperties = utils.ObjectDefineProperties;
|
||||
var ObjectDefineProperty = utils.ObjectDefineProperty;
|
||||
var SetFunctionName = utils.SetFunctionName;
|
||||
|
||||
var ArrayIndexOf;
|
||||
var ArrayJoin;
|
||||
var IsFinite;
|
||||
var IsNaN;
|
||||
var MathFloor;
|
||||
var RegExpTest;
|
||||
var SetFunctionName = utils.SetFunctionName;
|
||||
var StringIndexOf;
|
||||
var StringLastIndexOf;
|
||||
var StringMatch;
|
||||
@ -54,6 +51,12 @@ utils.Import(function(from) {
|
||||
StringSplit = from.StringSplit;
|
||||
StringSubstr = from.StringSubstr;
|
||||
StringSubstring = from.StringSubstring;
|
||||
ToNumber = from.ToNumber;
|
||||
});
|
||||
|
||||
utils.ImportNow(function(from) {
|
||||
ObjectDefineProperties = from.ObjectDefineProperties;
|
||||
ObjectDefineProperty = from.ObjectDefineProperty;
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
@ -1276,7 +1279,7 @@ SetFunctionName(Intl.NumberFormat.supportedLocalesOf, 'supportedLocalesOf');
|
||||
*/
|
||||
function formatNumber(formatter, value) {
|
||||
// Spec treats -0 and +0 as 0.
|
||||
var number = $toNumber(value) + 0;
|
||||
var number = ToNumber(value) + 0;
|
||||
|
||||
return %InternalNumberFormat(%GetImplFromInitializedIntlObject(formatter),
|
||||
number);
|
||||
@ -1701,7 +1704,7 @@ function formatDate(formatter, dateValue) {
|
||||
if (IS_UNDEFINED(dateValue)) {
|
||||
dateMs = %DateCurrentTime();
|
||||
} else {
|
||||
dateMs = $toNumber(dateValue);
|
||||
dateMs = ToNumber(dateValue);
|
||||
}
|
||||
|
||||
if (!IsFinite(dateMs)) throw MakeRangeError(kDateRange);
|
||||
|
15
src/json.js
15
src/json.js
@ -13,15 +13,18 @@
|
||||
|
||||
var GlobalJSON = global.JSON;
|
||||
var InternalArray = utils.InternalArray;
|
||||
|
||||
var MathMax;
|
||||
var MathMin;
|
||||
var ObjectHasOwnProperty;
|
||||
var ToNumber;
|
||||
var ToString;
|
||||
|
||||
utils.Import(function(from) {
|
||||
MathMax = from.MathMax;
|
||||
MathMin = from.MathMin;
|
||||
ObjectHasOwnProperty = from.ObjectHasOwnProperty;
|
||||
ToNumber = from.ToNumber;
|
||||
ToString = from.ToString;
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
@ -162,10 +165,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 {
|
||||
@ -194,7 +197,7 @@ function JSONStringify(value, replacer, space) {
|
||||
} else if (IS_NUMBER(v)) {
|
||||
item = %_NumberToString(v);
|
||||
} else if (IS_STRING_WRAPPER(v) || IS_NUMBER_WRAPPER(v)) {
|
||||
item = $toString(v);
|
||||
item = ToString(v);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
@ -208,9 +211,9 @@ 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;
|
||||
|
@ -145,9 +145,9 @@ 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) = (arg | 0);
|
||||
macro TO_UINT32(arg) = (arg >>> 0);
|
||||
macro TO_STRING_INLINE(arg) = (IS_STRING(%IS_VAR(arg)) ? arg : $nonStringToString(arg));
|
||||
|
@ -22,38 +22,43 @@ var MakeURIError;
|
||||
// -------------------------------------------------------------------
|
||||
// Imports
|
||||
|
||||
var GlobalObject = global.Object;
|
||||
var InternalArray = utils.InternalArray;
|
||||
var ObjectDefineProperty = utils.ObjectDefineProperty;
|
||||
|
||||
var ArrayJoin;
|
||||
var Bool16x8ToString;
|
||||
var Bool32x4ToString;
|
||||
var Bool8x16ToString;
|
||||
var Float32x4ToString;
|
||||
var FunctionSourceString
|
||||
var GlobalObject = global.Object;
|
||||
var Int16x8ToString;
|
||||
var Int32x4ToString;
|
||||
var Int8x16ToString;
|
||||
var InternalArray = utils.InternalArray;
|
||||
var ObjectDefineProperty;
|
||||
var ObjectToString;
|
||||
var StringCharAt;
|
||||
var StringIndexOf;
|
||||
var StringSubstring;
|
||||
|
||||
var Float32x4ToString;
|
||||
var Int32x4ToString;
|
||||
var Bool32x4ToString;
|
||||
var Int16x8ToString;
|
||||
var Bool16x8ToString;
|
||||
var Int8x16ToString;
|
||||
var Bool8x16ToString;
|
||||
|
||||
var ToString;
|
||||
|
||||
utils.Import(function(from) {
|
||||
ArrayJoin = from.ArrayJoin;
|
||||
Bool16x8ToString = from.Bool16x8ToString;
|
||||
Bool32x4ToString = from.Bool32x4ToString;
|
||||
Bool8x16ToString = from.Bool8x16ToString;
|
||||
Float32x4ToString = from.Float32x4ToString;
|
||||
FunctionSourceString = from.FunctionSourceString;
|
||||
Int16x8ToString = from.Int16x8ToString;
|
||||
Int32x4ToString = from.Int32x4ToString;
|
||||
Int8x16ToString = from.Int8x16ToString;
|
||||
ObjectDefineProperty = from.ObjectDefineProperty;
|
||||
ObjectToString = from.ObjectToString;
|
||||
StringCharAt = from.StringCharAt;
|
||||
StringIndexOf = from.StringIndexOf;
|
||||
StringSubstring = from.StringSubstring;
|
||||
Float32x4ToString = from.Float32x4ToString;
|
||||
Int32x4ToString = from.Int32x4ToString;
|
||||
Bool32x4ToString = from.Bool32x4ToString;
|
||||
Int16x8ToString = from.Int16x8ToString;
|
||||
Bool16x8ToString = from.Bool16x8ToString;
|
||||
Int8x16ToString = from.Int8x16ToString;
|
||||
Bool8x16ToString = from.Bool8x16ToString;
|
||||
});
|
||||
|
||||
utils.ImportNow(function(from) {
|
||||
ToString = from.ToString;
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
@ -81,7 +86,7 @@ function NoSideEffectToString(obj) {
|
||||
if (IS_UNDEFINED(obj)) return 'undefined';
|
||||
if (IS_NULL(obj)) return 'null';
|
||||
if (IS_FUNCTION(obj)) {
|
||||
var str = %_CallFunction(obj, obj, $functionSourceString);
|
||||
var str = %_CallFunction(obj, obj, FunctionSourceString);
|
||||
if (str.length > 128) {
|
||||
str = %_SubString(str, 0, 111) + "...<omitted>..." +
|
||||
%_SubString(str, str.length - 2, str.length);
|
||||
@ -147,7 +152,7 @@ function ToStringCheckErrorObject(obj) {
|
||||
if (CanBeSafelyTreatedAsAnErrorObject(obj)) {
|
||||
return %_CallFunction(obj, ErrorToString);
|
||||
} else {
|
||||
return $toString(obj);
|
||||
return ToString(obj);
|
||||
}
|
||||
}
|
||||
|
||||
@ -968,7 +973,7 @@ function DefineError(global, 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);
|
||||
|
@ -12,17 +12,16 @@
|
||||
// Utils
|
||||
|
||||
var imports = UNDEFINED;
|
||||
var exports = UNDEFINED;
|
||||
var imports_from_experimental = UNDEFINED;
|
||||
var exports_to_runtime = UNDEFINED;
|
||||
var exports_container = {};
|
||||
|
||||
// Export to other scripts.
|
||||
// In normal natives, this exports functions to other normal natives.
|
||||
// In experimental natives, this exports to other experimental natives and
|
||||
// to normal natives that import using utils.ImportFromExperimental.
|
||||
function Export(f) {
|
||||
f.next = exports;
|
||||
exports = f;
|
||||
f(exports_container);
|
||||
}
|
||||
|
||||
|
||||
@ -32,7 +31,11 @@ function ExportToRuntime(f) {
|
||||
exports_to_runtime = f;
|
||||
}
|
||||
|
||||
// Import from other scripts.
|
||||
|
||||
// Import from other scripts. The actual importing happens in PostNatives and
|
||||
// PostExperimental so that we can import from scripts executed later. However,
|
||||
// that means that the import is not available until the very end. If the
|
||||
// import needs to be available immediate, use ImportNow.
|
||||
// In normal natives, this imports from other normal natives.
|
||||
// In experimental natives, this imports from other experimental natives and
|
||||
// whitelisted exports from normal natives.
|
||||
@ -41,6 +44,13 @@ function Import(f) {
|
||||
imports = f;
|
||||
}
|
||||
|
||||
// Import immediately from exports of previous scripts. We need this for
|
||||
// functions called during bootstrapping. Hooking up imports in PostNatives
|
||||
// would be too late.
|
||||
function ImportNow(f) {
|
||||
f(exports_container);
|
||||
}
|
||||
|
||||
|
||||
// In normal natives, import from experimental natives.
|
||||
// Not callable from experimental natives.
|
||||
@ -149,14 +159,12 @@ function SetUpLockedPrototype(
|
||||
// -----------------------------------------------------------------------
|
||||
// To be called by bootstrapper
|
||||
|
||||
var experimental_exports = UNDEFINED;
|
||||
|
||||
function PostNatives(utils) {
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
var container = {};
|
||||
for ( ; !IS_UNDEFINED(exports); exports = exports.next) exports(container);
|
||||
for ( ; !IS_UNDEFINED(imports); imports = imports.next) imports(container);
|
||||
for ( ; !IS_UNDEFINED(imports); imports = imports.next) {
|
||||
imports(exports_container);
|
||||
}
|
||||
|
||||
var runtime_container = {};
|
||||
for ( ; !IS_UNDEFINED(exports_to_runtime);
|
||||
@ -165,9 +173,10 @@ function PostNatives(utils) {
|
||||
}
|
||||
%ImportToRuntime(runtime_container);
|
||||
|
||||
// Whitelist of exports from normal natives to experimental natives.
|
||||
var expose_to_experimental = [
|
||||
// Whitelist of exports from normal natives to experimental natives and debug.
|
||||
var expose_list = [
|
||||
"ArrayToString",
|
||||
"FunctionSourceString",
|
||||
"GetIterator",
|
||||
"GetMethod",
|
||||
"InnerArrayEvery",
|
||||
@ -190,15 +199,19 @@ function PostNatives(utils) {
|
||||
"ObjectDefineProperty",
|
||||
"OwnPropertyKeys",
|
||||
"ToNameArray",
|
||||
"ToBoolean",
|
||||
"ToNumber",
|
||||
"ToString",
|
||||
];
|
||||
experimental_exports = {};
|
||||
|
||||
var filtered_exports = {};
|
||||
%OptimizeObjectForAddingMultipleProperties(
|
||||
experimental_exports, expose_to_experimental.length);
|
||||
for (var key of expose_to_experimental) {
|
||||
experimental_exports[key] = container[key];
|
||||
filtered_exports, expose_list.length);
|
||||
for (var key of expose_list) {
|
||||
filtered_exports[key] = exports_container[key];
|
||||
}
|
||||
%ToFastProperties(experimental_exports);
|
||||
container = UNDEFINED;
|
||||
%ToFastProperties(filtered_exports);
|
||||
exports_container = filtered_exports;
|
||||
|
||||
utils.PostNatives = UNDEFINED;
|
||||
utils.ImportFromExperimental = UNDEFINED;
|
||||
@ -208,15 +221,12 @@ function PostNatives(utils) {
|
||||
function PostExperimentals(utils) {
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
for ( ; !IS_UNDEFINED(exports); exports = exports.next) {
|
||||
exports(experimental_exports);
|
||||
}
|
||||
for ( ; !IS_UNDEFINED(imports); imports = imports.next) {
|
||||
imports(experimental_exports);
|
||||
imports(exports_container);
|
||||
}
|
||||
for ( ; !IS_UNDEFINED(imports_from_experimental);
|
||||
imports_from_experimental = imports_from_experimental.next) {
|
||||
imports_from_experimental(experimental_exports);
|
||||
imports_from_experimental(exports_container);
|
||||
}
|
||||
var runtime_container = {};
|
||||
for ( ; !IS_UNDEFINED(exports_to_runtime);
|
||||
@ -225,7 +235,7 @@ function PostExperimentals(utils) {
|
||||
}
|
||||
%ImportExperimentalToRuntime(runtime_container);
|
||||
|
||||
experimental_exports = UNDEFINED;
|
||||
exports_container = UNDEFINED;
|
||||
|
||||
utils.PostExperimentals = UNDEFINED;
|
||||
utils.PostDebug = UNDEFINED;
|
||||
@ -235,13 +245,12 @@ function PostExperimentals(utils) {
|
||||
|
||||
|
||||
function PostDebug(utils) {
|
||||
for ( ; !IS_UNDEFINED(exports); exports = exports.next) {
|
||||
exports(experimental_exports);
|
||||
}
|
||||
for ( ; !IS_UNDEFINED(imports); imports = imports.next) {
|
||||
imports(experimental_exports);
|
||||
imports(exports_container);
|
||||
}
|
||||
|
||||
exports_container = UNDEFINED;
|
||||
|
||||
utils.PostDebug = UNDEFINED;
|
||||
utils.PostExperimentals = UNDEFINED;
|
||||
utils.Import = UNDEFINED;
|
||||
@ -250,9 +259,10 @@ function PostDebug(utils) {
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
%OptimizeObjectForAddingMultipleProperties(utils, 13);
|
||||
%OptimizeObjectForAddingMultipleProperties(utils, 14);
|
||||
|
||||
utils.Import = Import;
|
||||
utils.ImportNow = ImportNow;
|
||||
utils.Export = Export;
|
||||
utils.ExportToRuntime = ExportToRuntime;
|
||||
utils.ImportFromExperimental = ImportFromExperimental;
|
||||
|
@ -16,6 +16,10 @@ var harmony_unicode_regexps = false;
|
||||
var GlobalRegExp = global.RegExp;
|
||||
var InternalPackedArray = utils.InternalPackedArray;
|
||||
|
||||
utils.Import(function(from) {
|
||||
ToNumber = from.ToNumber;
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
// Property of the builtins object for recording the result of the last
|
||||
|
@ -66,7 +66,6 @@ var $nonNumberToNumber;
|
||||
var $nonStringToString;
|
||||
var $sameValue;
|
||||
var $sameValueZero;
|
||||
var $toBoolean;
|
||||
var $toInteger;
|
||||
var $toLength;
|
||||
var $toName;
|
||||
@ -907,7 +906,6 @@ $nonNumberToNumber = NonNumberToNumber;
|
||||
$nonStringToString = NonStringToString;
|
||||
$sameValue = SameValue;
|
||||
$sameValueZero = SameValueZero;
|
||||
$toBoolean = ToBoolean;
|
||||
$toInteger = ToInteger;
|
||||
$toLength = ToLength;
|
||||
$toName = ToName;
|
||||
@ -917,10 +915,16 @@ $toPrimitive = ToPrimitive;
|
||||
$toString = ToString;
|
||||
|
||||
utils.ExportToRuntime(function(to) {
|
||||
to.ToNumber = $toNumber;
|
||||
to.ToString = $toString;
|
||||
to.ToInteger = $toInteger;
|
||||
to.ToLength = $toLength;
|
||||
to.ToNumber = ToNumber;
|
||||
to.ToString = ToString;
|
||||
to.ToInteger = ToInteger;
|
||||
to.ToLength = ToLength;
|
||||
});
|
||||
|
||||
utils.Export(function(to) {
|
||||
to.ToBoolean = ToBoolean;
|
||||
to.ToNumber = ToNumber;
|
||||
to.ToString = ToString;
|
||||
})
|
||||
|
||||
})
|
||||
|
@ -9,18 +9,19 @@
|
||||
// -------------------------------------------------------------------
|
||||
// Imports
|
||||
|
||||
var ArrayIndexOf;
|
||||
var ArrayJoin;
|
||||
var GlobalRegExp = global.RegExp;
|
||||
var GlobalString = global.String;
|
||||
var InternalArray = utils.InternalArray;
|
||||
var InternalPackedArray = utils.InternalPackedArray;
|
||||
|
||||
var ArrayIndexOf;
|
||||
var ArrayJoin;
|
||||
var MathMax;
|
||||
var MathMin;
|
||||
var RegExpExec;
|
||||
var RegExpExecNoTests;
|
||||
var RegExpLastMatchInfo;
|
||||
var ToNumber;
|
||||
var ToString;
|
||||
|
||||
utils.Import(function(from) {
|
||||
ArrayIndexOf = from.ArrayIndexOf;
|
||||
@ -30,6 +31,8 @@ utils.Import(function(from) {
|
||||
RegExpExec = from.RegExpExec;
|
||||
RegExpExecNoTests = from.RegExpExecNoTests;
|
||||
RegExpLastMatchInfo = from.RegExpLastMatchInfo;
|
||||
ToNumber = from.ToNumber;
|
||||
ToString = from.ToString;
|
||||
});
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@ -132,7 +135,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) {
|
||||
@ -823,7 +826,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);
|
||||
}
|
||||
|
||||
@ -831,7 +834,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);
|
||||
@ -842,7 +845,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;
|
||||
@ -1088,7 +1091,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);
|
||||
@ -1117,13 +1120,13 @@ function StringRaw(callSite) {
|
||||
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;
|
||||
|
@ -23,11 +23,12 @@ var $symbolToString;
|
||||
|
||||
var GlobalObject = global.Object;
|
||||
var GlobalSymbol = global.Symbol;
|
||||
|
||||
var ObjectGetOwnPropertyKeys;
|
||||
var ToString;
|
||||
|
||||
utils.Import(function(from) {
|
||||
ObjectGetOwnPropertyKeys = from.ObjectGetOwnPropertyKeys;
|
||||
ToString = from.ToString;
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
@ -35,7 +36,7 @@ utils.Import(function(from) {
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
|
@ -37,10 +37,12 @@ TYPED_ARRAYS(DECLARE_GLOBALS)
|
||||
|
||||
var MathMax;
|
||||
var MathMin;
|
||||
var ToNumber;
|
||||
|
||||
utils.Import(function(from) {
|
||||
MathMax = from.MathMax;
|
||||
MathMin = from.MathMin;
|
||||
ToNumber = from.ToNumber;
|
||||
});
|
||||
|
||||
var InternalArray = utils.InternalArray;
|
||||
|
17
src/uri.js
17
src/uri.js
@ -17,6 +17,11 @@
|
||||
var GlobalObject = global.Object;
|
||||
var GlobalArray = global.Array;
|
||||
var InternalArray = utils.InternalArray;
|
||||
var ToString;
|
||||
|
||||
utils.Import(function(from) {
|
||||
ToString = from.ToString;
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Define internal helper functions.
|
||||
@ -274,13 +279,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);
|
||||
}
|
||||
|
||||
@ -304,14 +309,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);
|
||||
}
|
||||
|
||||
@ -338,7 +343,7 @@ function URIEncode(uri) {
|
||||
|
||||
return false;
|
||||
};
|
||||
var string = $toString(uri);
|
||||
var string = ToString(uri);
|
||||
return Encode(string, unescapePredicate);
|
||||
}
|
||||
|
||||
@ -359,7 +364,7 @@ function URIEncodeComponent(component) {
|
||||
|
||||
return false;
|
||||
};
|
||||
var string = $toString(component);
|
||||
var string = ToString(component);
|
||||
return Encode(string, unescapePredicate);
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
var $functionSourceString;
|
||||
|
||||
(function(global, utils) {
|
||||
|
||||
%CheckIsBootstrapping();
|
||||
@ -17,16 +15,24 @@ var GlobalFunction = global.Function;
|
||||
var GlobalNumber = global.Number;
|
||||
var GlobalObject = global.Object;
|
||||
var InternalArray = utils.InternalArray;
|
||||
|
||||
var MathAbs;
|
||||
var ProxyDelegateCallAndConstruct;
|
||||
var ProxyDerivedHasOwnTrap;
|
||||
var ProxyDerivedKeysTrap;
|
||||
var StringIndexOf;
|
||||
var ToBoolean;
|
||||
var ToNumber;
|
||||
var ToString;
|
||||
|
||||
utils.Import(function(from) {
|
||||
MathAbs = from.MathAbs;
|
||||
StringIndexOf = from.StringIndexOf;
|
||||
ToString = from.ToString;
|
||||
});
|
||||
|
||||
utils.ImportNow(function(from) {
|
||||
ToBoolean = from.ToBoolean;
|
||||
ToNumber = from.ToNumber;
|
||||
});
|
||||
|
||||
utils.ImportFromExperimental(function(from) {
|
||||
@ -346,11 +352,11 @@ function ToPropertyDescriptor(obj) {
|
||||
var desc = new PropertyDescriptor();
|
||||
|
||||
if ("enumerable" in obj) {
|
||||
desc.setEnumerable($toBoolean(obj.enumerable));
|
||||
desc.setEnumerable(ToBoolean(obj.enumerable));
|
||||
}
|
||||
|
||||
if ("configurable" in obj) {
|
||||
desc.setConfigurable($toBoolean(obj.configurable));
|
||||
desc.setConfigurable(ToBoolean(obj.configurable));
|
||||
}
|
||||
|
||||
if ("value" in obj) {
|
||||
@ -358,7 +364,7 @@ function ToPropertyDescriptor(obj) {
|
||||
}
|
||||
|
||||
if ("writable" in obj) {
|
||||
desc.setWritable($toBoolean(obj.writable));
|
||||
desc.setWritable(ToBoolean(obj.writable));
|
||||
}
|
||||
|
||||
if ("get" in obj) {
|
||||
@ -612,7 +618,7 @@ function DefineProxyProperty(obj, p, attributes, should_throw) {
|
||||
|
||||
var handler = %GetHandler(obj);
|
||||
var result = CallTrap2(handler, "defineProperty", UNDEFINED, p, attributes);
|
||||
if (!$toBoolean(result)) {
|
||||
if (!ToBoolean(result)) {
|
||||
if (should_throw) {
|
||||
throw MakeTypeError(kProxyHandlerReturned,
|
||||
handler, "false", "defineProperty");
|
||||
@ -801,7 +807,7 @@ function DefineArrayProperty(obj, p, desc, should_throw) {
|
||||
if (!IS_SYMBOL(p)) {
|
||||
var index = TO_UINT32(p);
|
||||
var emit_splice = false;
|
||||
if ($toString(index) == p && index != 4294967295) {
|
||||
if (ToString(index) == p && index != 4294967295) {
|
||||
var length = obj.length;
|
||||
if (index >= length && %IsObserved(obj)) {
|
||||
emit_splice = true;
|
||||
@ -969,7 +975,7 @@ function ObjectGetOwnPropertyKeys(obj, filter) {
|
||||
}
|
||||
} else {
|
||||
if (filter & PROPERTY_ATTRIBUTES_STRING) continue;
|
||||
name = $toString(name);
|
||||
name = ToString(name);
|
||||
}
|
||||
if (seenKeys[name]) continue;
|
||||
seenKeys[name] = true;
|
||||
@ -1337,9 +1343,9 @@ utils.InstallFunctions(GlobalObject, DONT_ENUM, [
|
||||
|
||||
function BooleanConstructor(x) {
|
||||
if (%_IsConstructCall()) {
|
||||
%_SetValueOf(this, $toBoolean(x));
|
||||
%_SetValueOf(this, ToBoolean(x));
|
||||
} else {
|
||||
return $toBoolean(x);
|
||||
return ToBoolean(x);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1385,7 +1391,7 @@ utils.InstallFunctions(GlobalBoolean.prototype, DONT_ENUM, [
|
||||
// Number
|
||||
|
||||
function NumberConstructor(x) {
|
||||
var value = %_ArgumentsLength() == 0 ? 0 : $toNumber(x);
|
||||
var value = %_ArgumentsLength() == 0 ? 0 : ToNumber(x);
|
||||
if (%_IsConstructCall()) {
|
||||
%_SetValueOf(this, value);
|
||||
} else {
|
||||
@ -1498,7 +1504,7 @@ function NumberToPrecisionJS(precision) {
|
||||
// Get the value of this number in case it's an object.
|
||||
x = %_ValueOf(this);
|
||||
}
|
||||
if (IS_UNDEFINED(precision)) return $toString(%_ValueOf(this));
|
||||
if (IS_UNDEFINED(precision)) return ToString(%_ValueOf(this));
|
||||
var p = TO_INTEGER(precision);
|
||||
|
||||
if (NUMBER_IS_NAN(x)) return "NaN";
|
||||
@ -1718,9 +1724,9 @@ function NewFunctionString(args, function_token) {
|
||||
var n = args.length;
|
||||
var p = '';
|
||||
if (n > 1) {
|
||||
p = $toString(args[0]);
|
||||
p = ToString(args[0]);
|
||||
for (var i = 1; i < n - 1; i++) {
|
||||
p += ',' + $toString(args[i]);
|
||||
p += ',' + ToString(args[i]);
|
||||
}
|
||||
// If the formal parameters string include ) - an illegal
|
||||
// character - it may make the combined function expression
|
||||
@ -1733,7 +1739,7 @@ function NewFunctionString(args, function_token) {
|
||||
// comments we can include a trailing block comment to catch this.
|
||||
p += '\n/' + '**/';
|
||||
}
|
||||
var body = (n > 0) ? $toString(args[n - 1]) : '';
|
||||
var body = (n > 0) ? ToString(args[n - 1]) : '';
|
||||
return '(' + function_token + '(' + p + ') {\n' + body + '\n})';
|
||||
}
|
||||
|
||||
@ -1782,19 +1788,16 @@ function GetIterator(obj, method) {
|
||||
// ----------------------------------------------------------------------------
|
||||
// Exports
|
||||
|
||||
$functionSourceString = FunctionSourceString;
|
||||
|
||||
utils.ObjectDefineProperties = ObjectDefineProperties;
|
||||
utils.ObjectDefineProperty = ObjectDefineProperty;
|
||||
|
||||
utils.Export(function(to) {
|
||||
to.Delete = Delete;
|
||||
to.FunctionSourceString = FunctionSourceString;
|
||||
to.GetIterator = GetIterator;
|
||||
to.GetMethod = GetMethod;
|
||||
to.IsFinite = GlobalIsFinite;
|
||||
to.IsNaN = GlobalIsNaN;
|
||||
to.NewFunctionString = NewFunctionString;
|
||||
to.NumberIsNaN = NumberIsNaN;
|
||||
to.ObjectDefineProperties = ObjectDefineProperties;
|
||||
to.ObjectDefineProperty = ObjectDefineProperty;
|
||||
to.ObjectFreeze = ObjectFreezeJS;
|
||||
to.ObjectGetOwnPropertyKeys = ObjectGetOwnPropertyKeys;
|
||||
|
Loading…
Reference in New Issue
Block a user