Commit 8ef4b0ca authored by yangguo@chromium.org's avatar yangguo@chromium.org

Cosmetic: Add macros for NaN, undefined and Infinity to native js code.

Nobody should need to use $NaN, 0/0, 1/0 and void 0.

R=mvstanton@chromium.org
BUG=

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17252 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent f8cc87a0
...@@ -36,9 +36,9 @@ var ARRAY_ITERATOR_KIND_VALUES = 2; ...@@ -36,9 +36,9 @@ var ARRAY_ITERATOR_KIND_VALUES = 2;
var ARRAY_ITERATOR_KIND_ENTRIES = 3; var ARRAY_ITERATOR_KIND_ENTRIES = 3;
// The spec draft also has "sparse" but it is never used. // The spec draft also has "sparse" but it is never used.
var iteratorObjectSymbol = %CreateSymbol(void 0); var iteratorObjectSymbol = %CreateSymbol(UNDEFINED);
var arrayIteratorNextIndexSymbol = %CreateSymbol(void 0); var arrayIteratorNextIndexSymbol = %CreateSymbol(UNDEFINED);
var arrayIterationKindSymbol = %CreateSymbol(void 0); var arrayIterationKindSymbol = %CreateSymbol(UNDEFINED);
function ArrayIterator() {} function ArrayIterator() {}
...@@ -74,7 +74,7 @@ function ArrayIteratorNext() { ...@@ -74,7 +74,7 @@ function ArrayIteratorNext() {
if (index >= length) { if (index >= length) {
iterator[arrayIteratorNextIndexSymbol] = 1 / 0; // Infinity iterator[arrayIteratorNextIndexSymbol] = 1 / 0; // Infinity
return CreateIteratorResultObject(void 0, true); return CreateIteratorResultObject(UNDEFINED, true);
} }
iterator[arrayIteratorNextIndexSymbol] = index + 1; iterator[arrayIteratorNextIndexSymbol] = index + 1;
......
...@@ -677,7 +677,7 @@ function ArraySlice(start, end) { ...@@ -677,7 +677,7 @@ function ArraySlice(start, end) {
var start_i = TO_INTEGER(start); var start_i = TO_INTEGER(start);
var end_i = len; var end_i = len;
if (end !== void 0) end_i = TO_INTEGER(end); if (!IS_UNDEFINED(end)) end_i = TO_INTEGER(end);
if (start_i < 0) { if (start_i < 0) {
start_i += len; start_i += len;
...@@ -1016,7 +1016,7 @@ function ArraySort(comparefn) { ...@@ -1016,7 +1016,7 @@ function ArraySort(comparefn) {
var proto_length = indices; var proto_length = indices;
for (var i = from; i < proto_length; i++) { for (var i = from; i < proto_length; i++) {
if (proto.hasOwnProperty(i)) { if (proto.hasOwnProperty(i)) {
obj[i] = void 0; obj[i] = UNDEFINED;
} }
} }
} else { } else {
...@@ -1024,7 +1024,7 @@ function ArraySort(comparefn) { ...@@ -1024,7 +1024,7 @@ function ArraySort(comparefn) {
var index = indices[i]; var index = indices[i];
if (!IS_UNDEFINED(index) && from <= index && if (!IS_UNDEFINED(index) && from <= index &&
proto.hasOwnProperty(index)) { proto.hasOwnProperty(index)) {
obj[index] = void 0; obj[index] = UNDEFINED;
} }
} }
} }
...@@ -1061,7 +1061,7 @@ function ArraySort(comparefn) { ...@@ -1061,7 +1061,7 @@ function ArraySort(comparefn) {
if (first_undefined < last_defined) { if (first_undefined < last_defined) {
// Fill in hole or undefined. // Fill in hole or undefined.
obj[first_undefined] = obj[last_defined]; obj[first_undefined] = obj[last_defined];
obj[last_defined] = void 0; obj[last_defined] = UNDEFINED;
} }
} }
// If there were any undefineds in the entire array, first_undefined // If there were any undefineds in the entire array, first_undefined
...@@ -1073,12 +1073,12 @@ function ArraySort(comparefn) { ...@@ -1073,12 +1073,12 @@ function ArraySort(comparefn) {
// an undefined should be and vice versa. // an undefined should be and vice versa.
var i; var i;
for (i = first_undefined; i < length - num_holes; i++) { for (i = first_undefined; i < length - num_holes; i++) {
obj[i] = void 0; obj[i] = UNDEFINED;
} }
for (i = length - num_holes; i < length; i++) { for (i = length - num_holes; i < length; i++) {
// For compatability with Webkit, do not expose elements in the prototype. // For compatability with Webkit, do not expose elements in the prototype.
if (i in %GetPrototype(obj)) { if (i in %GetPrototype(obj)) {
obj[i] = void 0; obj[i] = UNDEFINED;
} else { } else {
delete obj[i]; delete obj[i];
} }
......
...@@ -40,7 +40,7 @@ function log10(num) { ...@@ -40,7 +40,7 @@ function log10(num) {
function ToInspectableObject(obj) { function ToInspectableObject(obj) {
if (!obj && typeof obj === 'object') { if (!obj && typeof obj === 'object') {
return void 0; return UNDEFINED;
} else { } else {
return Object(obj); return Object(obj);
} }
...@@ -333,7 +333,7 @@ function DebugRequest(cmd_line) { ...@@ -333,7 +333,7 @@ function DebugRequest(cmd_line) {
} }
if ((cmd === undefined) || !cmd) { if ((cmd === undefined) || !cmd) {
this.request_ = void 0; this.request_ = UNDEFINED;
return; return;
} }
...@@ -492,7 +492,7 @@ function DebugRequest(cmd_line) { ...@@ -492,7 +492,7 @@ function DebugRequest(cmd_line) {
case 'trace': case 'trace':
case 'tr': case 'tr':
// Return undefined to indicate command handled internally (no JSON). // Return undefined to indicate command handled internally (no JSON).
this.request_ = void 0; this.request_ = UNDEFINED;
this.traceCommand_(args); this.traceCommand_(args);
break; break;
...@@ -500,7 +500,7 @@ function DebugRequest(cmd_line) { ...@@ -500,7 +500,7 @@ function DebugRequest(cmd_line) {
case '?': case '?':
this.helpCommand_(args); this.helpCommand_(args);
// Return undefined to indicate command handled internally (no JSON). // Return undefined to indicate command handled internally (no JSON).
this.request_ = void 0; this.request_ = UNDEFINED;
break; break;
default: default:
...@@ -2124,7 +2124,7 @@ function SimpleObjectToJSON_(object) { ...@@ -2124,7 +2124,7 @@ function SimpleObjectToJSON_(object) {
var property_value_json; var property_value_json;
switch (typeof property_value) { switch (typeof property_value) {
case 'object': case 'object':
if (property_value === null) { if (IS_NULL(property_value)) {
property_value_json = 'null'; property_value_json = 'null';
} else if (typeof property_value.toJSONProtocol == 'function') { } else if (typeof property_value.toJSONProtocol == 'function') {
property_value_json = property_value.toJSONProtocol(true); property_value_json = property_value.toJSONProtocol(true);
...@@ -2217,7 +2217,7 @@ function Stringify(x, depth) { ...@@ -2217,7 +2217,7 @@ function Stringify(x, depth) {
case "symbol": case "symbol":
return "Symbol(" + (x.name ? Stringify(x.name, depth) : "") + ")" return "Symbol(" + (x.name ? Stringify(x.name, depth) : "") + ")"
case "object": case "object":
if (x === null) return "null"; if (IS_NULL(x)) return "null";
if (x.constructor && x.constructor.name === "Array") { if (x.constructor && x.constructor.name === "Array") {
var elems = []; var elems = [];
for (var i = 0; i < x.length; ++i) { for (var i = 0; i < x.length; ++i) {
...@@ -2233,7 +2233,7 @@ function Stringify(x, depth) { ...@@ -2233,7 +2233,7 @@ function Stringify(x, depth) {
var props = []; var props = [];
for (var name in x) { for (var name in x) {
var desc = Object.getOwnPropertyDescriptor(x, name); var desc = Object.getOwnPropertyDescriptor(x, name);
if (desc === void 0) continue; if (IS_UNDEFINED(desc)) continue;
if ("value" in desc) { if ("value" in desc) {
props.push(name + ": " + Stringify(desc.value, depth - 1)); props.push(name + ": " + Stringify(desc.value, depth - 1));
} }
......
...@@ -41,7 +41,7 @@ function ThrowDateTypeError() { ...@@ -41,7 +41,7 @@ function ThrowDateTypeError() {
} }
var timezone_cache_time = $NaN; var timezone_cache_time = NAN;
var timezone_cache_timezone; var timezone_cache_timezone;
function LocalTimezone(t) { function LocalTimezone(t) {
...@@ -66,10 +66,10 @@ function UTC(time) { ...@@ -66,10 +66,10 @@ function UTC(time) {
// ECMA 262 - 15.9.1.11 // ECMA 262 - 15.9.1.11
function MakeTime(hour, min, sec, ms) { function MakeTime(hour, min, sec, ms) {
if (!$isFinite(hour)) return $NaN; if (!$isFinite(hour)) return NAN;
if (!$isFinite(min)) return $NaN; if (!$isFinite(min)) return NAN;
if (!$isFinite(sec)) return $NaN; if (!$isFinite(sec)) return NAN;
if (!$isFinite(ms)) return $NaN; if (!$isFinite(ms)) return NAN;
return TO_INTEGER(hour) * msPerHour return TO_INTEGER(hour) * msPerHour
+ TO_INTEGER(min) * msPerMinute + TO_INTEGER(min) * msPerMinute
+ TO_INTEGER(sec) * msPerSecond + TO_INTEGER(sec) * msPerSecond
...@@ -90,7 +90,7 @@ function TimeInYear(year) { ...@@ -90,7 +90,7 @@ function TimeInYear(year) {
// MakeDay(2007, -33, 1) --> MakeDay(2004, 3, 1) // MakeDay(2007, -33, 1) --> MakeDay(2004, 3, 1)
// MakeDay(2007, 14, -50) --> MakeDay(2007, 8, 11) // MakeDay(2007, 14, -50) --> MakeDay(2007, 8, 11)
function MakeDay(year, month, date) { function MakeDay(year, month, date) {
if (!$isFinite(year) || !$isFinite(month) || !$isFinite(date)) return $NaN; if (!$isFinite(year) || !$isFinite(month) || !$isFinite(date)) return NAN;
// Convert to integer and map -0 to 0. // Convert to integer and map -0 to 0.
year = TO_INTEGER_MAP_MINUS_ZERO(year); year = TO_INTEGER_MAP_MINUS_ZERO(year);
...@@ -99,7 +99,7 @@ function MakeDay(year, month, date) { ...@@ -99,7 +99,7 @@ function MakeDay(year, month, date) {
if (year < kMinYear || year > kMaxYear || if (year < kMinYear || year > kMaxYear ||
month < kMinMonth || month > kMaxMonth) { month < kMinMonth || month > kMaxMonth) {
return $NaN; return NAN;
} }
// Now we rely on year and month being SMIs. // Now we rely on year and month being SMIs.
...@@ -115,15 +115,15 @@ function MakeDate(day, time) { ...@@ -115,15 +115,15 @@ function MakeDate(day, time) {
// is no way that the time can be within range even after UTC // is no way that the time can be within range even after UTC
// conversion we return NaN immediately instead of relying on // conversion we return NaN immediately instead of relying on
// TimeClip to do it. // TimeClip to do it.
if ($abs(time) > MAX_TIME_BEFORE_UTC) return $NaN; if ($abs(time) > MAX_TIME_BEFORE_UTC) return NAN;
return time; return time;
} }
// ECMA 262 - 15.9.1.14 // ECMA 262 - 15.9.1.14
function TimeClip(time) { function TimeClip(time) {
if (!$isFinite(time)) return $NaN; if (!$isFinite(time)) return NAN;
if ($abs(time) > MAX_TIME_MS) return $NaN; if ($abs(time) > MAX_TIME_MS) return NAN;
return TO_INTEGER(time); return TO_INTEGER(time);
} }
...@@ -132,7 +132,7 @@ function TimeClip(time) { ...@@ -132,7 +132,7 @@ function TimeClip(time) {
// strings over and over again. // strings over and over again.
var Date_cache = { var Date_cache = {
// Cached time value. // Cached time value.
time: $NaN, time: NAN,
// String input for which the cached time is valid. // String input for which the cached time is valid.
string: null string: null
}; };
...@@ -269,7 +269,7 @@ var parse_buffer = $Array(8); ...@@ -269,7 +269,7 @@ var parse_buffer = $Array(8);
// ECMA 262 - 15.9.4.2 // ECMA 262 - 15.9.4.2
function DateParse(string) { function DateParse(string) {
var arr = %DateParseString(ToString(string), parse_buffer); var arr = %DateParseString(ToString(string), parse_buffer);
if (IS_NULL(arr)) return $NaN; if (IS_NULL(arr)) return NAN;
var day = MakeDay(arr[0], arr[1], arr[2]); var day = MakeDay(arr[0], arr[1], arr[2]);
var time = MakeTime(arr[3], arr[4], arr[5], arr[6]); var time = MakeTime(arr[3], arr[4], arr[5], arr[6]);
...@@ -671,7 +671,7 @@ function DateGetYear() { ...@@ -671,7 +671,7 @@ function DateGetYear() {
function DateSetYear(year) { function DateSetYear(year) {
CHECK_DATE(this); CHECK_DATE(this);
year = ToNumber(year); year = ToNumber(year);
if (NUMBER_IS_NAN(year)) return SET_UTC_DATE_VALUE(this, $NaN); if (NUMBER_IS_NAN(year)) return SET_UTC_DATE_VALUE(this, NAN);
year = (0 <= TO_INTEGER(year) && TO_INTEGER(year) <= 99) year = (0 <= TO_INTEGER(year) && TO_INTEGER(year) <= 99)
? 1900 + TO_INTEGER(year) : year; ? 1900 + TO_INTEGER(year) : year;
var t = LOCAL_DATE_VALUE(this); var t = LOCAL_DATE_VALUE(this);
...@@ -746,12 +746,12 @@ function DateToJSON(key) { ...@@ -746,12 +746,12 @@ function DateToJSON(key) {
function ResetDateCache() { function ResetDateCache() {
// Reset the timezone cache: // Reset the timezone cache:
timezone_cache_time = $NaN; timezone_cache_time = NAN;
timezone_cache_timezone = undefined; timezone_cache_timezone = undefined;
// Reset the date cache: // Reset the date cache:
cache = Date_cache; cache = Date_cache;
cache.time = $NaN; cache.time = NAN;
cache.string = null; cache.string = null;
} }
...@@ -762,7 +762,7 @@ function SetUpDate() { ...@@ -762,7 +762,7 @@ function SetUpDate() {
%CheckIsBootstrapping(); %CheckIsBootstrapping();
%SetCode($Date, DateConstructor); %SetCode($Date, DateConstructor);
%FunctionSetPrototype($Date, new $Date($NaN)); %FunctionSetPrototype($Date, new $Date(NAN));
// Set up non-enumerable properties of the Date object itself. // Set up non-enumerable properties of the Date object itself.
InstallFunctions($Date, DONT_ENUM, $Array( InstallFunctions($Date, DONT_ENUM, $Array(
......
...@@ -448,7 +448,7 @@ ScriptBreakPoint.prototype.set = function (script) { ...@@ -448,7 +448,7 @@ ScriptBreakPoint.prototype.set = function (script) {
// If the position is not found in the script (the script might be shorter // If the position is not found in the script (the script might be shorter
// than it used to be) just ignore it. // than it used to be) just ignore it.
if (position === null) return; if (IS_NULL(position)) return;
// Create a break point object and set the break point. // Create a break point object and set the break point.
break_point = MakeBreakPoint(position, this); break_point = MakeBreakPoint(position, this);
...@@ -2064,7 +2064,7 @@ DebugCommandProcessor.resolveValue_ = function(value_description) { ...@@ -2064,7 +2064,7 @@ DebugCommandProcessor.resolveValue_ = function(value_description) {
} else if ("value" in value_description) { } else if ("value" in value_description) {
return value_description.value; return value_description.value;
} else if (value_description.type == UNDEFINED_TYPE) { } else if (value_description.type == UNDEFINED_TYPE) {
return void 0; return UNDEFINED;
} else if (value_description.type == NULL_TYPE) { } else if (value_description.type == NULL_TYPE) {
return null; return null;
} else { } else {
......
...@@ -290,7 +290,7 @@ function addBoundMethod(obj, methodName, implementation, length) { ...@@ -290,7 +290,7 @@ function addBoundMethod(obj, methodName, implementation, length) {
* Parameter locales is treated as a priority list. * Parameter locales is treated as a priority list.
*/ */
function supportedLocalesOf(service, locales, options) { function supportedLocalesOf(service, locales, options) {
if (service.match(GetServiceRE()) === null) { if (IS_NULL(service.match(GetServiceRE()))) {
throw new $Error('Internal error, wrong service type: ' + service); throw new $Error('Internal error, wrong service type: ' + service);
} }
...@@ -447,7 +447,7 @@ function resolveLocale(service, requestedLocales, options) { ...@@ -447,7 +447,7 @@ function resolveLocale(service, requestedLocales, options) {
* lookup algorithm. * lookup algorithm.
*/ */
function lookupMatcher(service, requestedLocales) { function lookupMatcher(service, requestedLocales) {
if (service.match(GetServiceRE()) === null) { if (IS_NULL(service.match(GetServiceRE()))) {
throw new $Error('Internal error, wrong service type: ' + service); throw new $Error('Internal error, wrong service type: ' + service);
} }
...@@ -463,7 +463,7 @@ function lookupMatcher(service, requestedLocales) { ...@@ -463,7 +463,7 @@ function lookupMatcher(service, requestedLocales) {
if (AVAILABLE_LOCALES[service][locale] !== undefined) { if (AVAILABLE_LOCALES[service][locale] !== undefined) {
// Return the resolved locale and extension. // Return the resolved locale and extension.
var extensionMatch = requestedLocales[i].match(GetUnicodeExtensionRE()); var extensionMatch = requestedLocales[i].match(GetUnicodeExtensionRE());
var extension = (extensionMatch === null) ? '' : extensionMatch[0]; var extension = IS_NULL(extensionMatch) ? '' : extensionMatch[0];
return {'locale': locale, 'extension': extension, 'position': i}; return {'locale': locale, 'extension': extension, 'position': i};
} }
// Truncate locale if possible. // Truncate locale if possible.
...@@ -535,7 +535,7 @@ function parseExtension(extension) { ...@@ -535,7 +535,7 @@ function parseExtension(extension) {
* Converts parameter to an Object if possible. * Converts parameter to an Object if possible.
*/ */
function toObject(value) { function toObject(value) {
if (value === undefined || value === null) { if (IS_NULL_OR_UNDEFINED(value)) {
throw new $TypeError('Value cannot be converted to an Object.'); throw new $TypeError('Value cannot be converted to an Object.');
} }
...@@ -733,7 +733,7 @@ function toTitleCaseWord(word) { ...@@ -733,7 +733,7 @@ function toTitleCaseWord(word) {
function canonicalizeLanguageTag(localeID) { function canonicalizeLanguageTag(localeID) {
// null is typeof 'object' so we have to do extra check. // null is typeof 'object' so we have to do extra check.
if (typeof localeID !== 'string' && typeof localeID !== 'object' || if (typeof localeID !== 'string' && typeof localeID !== 'object' ||
localeID === null) { IS_NULL(localeID)) {
throw new $TypeError('Language ID should be string or object.'); throw new $TypeError('Language ID should be string or object.');
} }
...@@ -1449,7 +1449,7 @@ function fromLDMLString(ldmlString) { ...@@ -1449,7 +1449,7 @@ function fromLDMLString(ldmlString) {
function appendToDateTimeObject(options, option, match, pairs) { function appendToDateTimeObject(options, option, match, pairs) {
if (match === null) { if (IS_NULL(match)) {
if (!options.hasOwnProperty(option)) { if (!options.hasOwnProperty(option)) {
defineWEProperty(options, option, undefined); defineWEProperty(options, option, undefined);
} }
...@@ -1751,7 +1751,7 @@ function canonicalizeTimeZoneID(tzID) { ...@@ -1751,7 +1751,7 @@ function canonicalizeTimeZoneID(tzID) {
// We expect only _ and / beside ASCII letters. // We expect only _ and / beside ASCII letters.
// All inputs should conform to Area/Location from now on. // All inputs should conform to Area/Location from now on.
var match = GetTimezoneNameCheckRE().exec(tzID); var match = GetTimezoneNameCheckRE().exec(tzID);
if (match === null) { if (IS_NULL(match)) {
throw new $RangeError('Expected Area/Location for time zone, got ' + tzID); throw new $RangeError('Expected Area/Location for time zone, got ' + tzID);
} }
...@@ -1971,7 +1971,7 @@ $Object.defineProperty($String.prototype, 'localeCompare', { ...@@ -1971,7 +1971,7 @@ $Object.defineProperty($String.prototype, 'localeCompare', {
throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR); throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
} }
if (this === undefined || this === null) { if (IS_NULL_OR_UNDEFINED(this)) {
throw new $TypeError('Method invoked on undefined or null value.'); throw new $TypeError('Method invoked on undefined or null value.');
} }
......
...@@ -181,7 +181,7 @@ function JSONSerialize(key, holder, replacer, stack, indent, gap) { ...@@ -181,7 +181,7 @@ function JSONSerialize(key, holder, replacer, stack, indent, gap) {
} }
} }
// Undefined or a callable object. // Undefined or a callable object.
return void 0; return UNDEFINED;
} }
...@@ -236,5 +236,5 @@ function JSONSerializeAdapter(key, object) { ...@@ -236,5 +236,5 @@ function JSONSerializeAdapter(key, object) {
var holder = {}; var holder = {};
holder[key] = object; holder[key] = object;
// No need to pass the actual holder since there is no replacer function. // No need to pass the actual holder since there is no replacer function.
return JSONSerialize(key, holder, void 0, new InternalArray(), "", ""); return JSONSerialize(key, holder, UNDEFINED, new InternalArray(), "", "");
} }
...@@ -186,7 +186,7 @@ Debug.LiveEdit = new function() { ...@@ -186,7 +186,7 @@ Debug.LiveEdit = new function() {
// to old version. // to old version.
if (link_to_old_script_list.length == 0) { if (link_to_old_script_list.length == 0) {
%LiveEditReplaceScript(script, new_source, null); %LiveEditReplaceScript(script, new_source, null);
old_script = void 0; old_script = UNDEFINED;
} else { } else {
var old_script_name = CreateNameForOldScript(script); var old_script_name = CreateNameForOldScript(script);
...@@ -266,7 +266,7 @@ Debug.LiveEdit = new function() { ...@@ -266,7 +266,7 @@ Debug.LiveEdit = new function() {
// LiveEdit itself believe that any function in heap that points to a // LiveEdit itself believe that any function in heap that points to a
// particular script is a regular function. // particular script is a regular function.
// For some functions we will restore this link later. // For some functions we will restore this link later.
%LiveEditFunctionSetScript(info.shared_function_info, void 0); %LiveEditFunctionSetScript(info.shared_function_info, UNDEFINED);
compile_info.push(info); compile_info.push(info);
old_index_map.push(i); old_index_map.push(i);
} }
...@@ -542,16 +542,16 @@ Debug.LiveEdit = new function() { ...@@ -542,16 +542,16 @@ Debug.LiveEdit = new function() {
this.children = children; this.children = children;
// an index in array of compile_info // an index in array of compile_info
this.array_index = array_index; this.array_index = array_index;
this.parent = void 0; this.parent = UNDEFINED;
this.status = FunctionStatus.UNCHANGED; this.status = FunctionStatus.UNCHANGED;
// Status explanation is used for debugging purposes and will be shown // Status explanation is used for debugging purposes and will be shown
// in user UI if some explanations are needed. // in user UI if some explanations are needed.
this.status_explanation = void 0; this.status_explanation = UNDEFINED;
this.new_start_pos = void 0; this.new_start_pos = UNDEFINED;
this.new_end_pos = void 0; this.new_end_pos = UNDEFINED;
this.corresponding_node = void 0; this.corresponding_node = UNDEFINED;
this.unmatched_new_nodes = void 0; this.unmatched_new_nodes = UNDEFINED;
// 'Textual' correspondence/matching is weaker than 'pure' // 'Textual' correspondence/matching is weaker than 'pure'
// correspondence/matching. We need 'textual' level for visual presentation // correspondence/matching. We need 'textual' level for visual presentation
...@@ -559,10 +559,10 @@ Debug.LiveEdit = new function() { ...@@ -559,10 +559,10 @@ Debug.LiveEdit = new function() {
// Sometimes only function body is changed (functions in old and new script // Sometimes only function body is changed (functions in old and new script
// textually correspond), but we cannot patch the code, so we see them // textually correspond), but we cannot patch the code, so we see them
// as an old function deleted and new function created. // as an old function deleted and new function created.
this.textual_corresponding_node = void 0; this.textual_corresponding_node = UNDEFINED;
this.textually_unmatched_new_nodes = void 0; this.textually_unmatched_new_nodes = UNDEFINED;
this.live_shared_function_infos = void 0; this.live_shared_function_infos = UNDEFINED;
} }
// From array of function infos that is implicitly a tree creates // From array of function infos that is implicitly a tree creates
...@@ -740,7 +740,7 @@ Debug.LiveEdit = new function() { ...@@ -740,7 +740,7 @@ Debug.LiveEdit = new function() {
old_children[old_index].status_explanation = old_children[old_index].status_explanation =
"Enclosing function is now incompatible. " + "Enclosing function is now incompatible. " +
scope_change_description; scope_change_description;
old_children[old_index].corresponding_node = void 0; old_children[old_index].corresponding_node = UNDEFINED;
} else if (old_children[old_index].status != } else if (old_children[old_index].status !=
FunctionStatus.UNCHANGED) { FunctionStatus.UNCHANGED) {
ProcessNode(old_children[old_index], ProcessNode(old_children[old_index],
...@@ -748,7 +748,7 @@ Debug.LiveEdit = new function() { ...@@ -748,7 +748,7 @@ Debug.LiveEdit = new function() {
if (old_children[old_index].status == FunctionStatus.DAMAGED) { if (old_children[old_index].status == FunctionStatus.DAMAGED) {
unmatched_new_nodes_list.push( unmatched_new_nodes_list.push(
old_children[old_index].corresponding_node); old_children[old_index].corresponding_node);
old_children[old_index].corresponding_node = void 0; old_children[old_index].corresponding_node = UNDEFINED;
old_node.status = FunctionStatus.CHANGED; old_node.status = FunctionStatus.CHANGED;
} }
} }
......
...@@ -157,6 +157,11 @@ macro TO_NUMBER_INLINE(arg) = (IS_NUMBER(%IS_VAR(arg)) ? arg : NonNumberToNumber ...@@ -157,6 +157,11 @@ macro TO_NUMBER_INLINE(arg) = (IS_NUMBER(%IS_VAR(arg)) ? arg : NonNumberToNumber
macro TO_OBJECT_INLINE(arg) = (IS_SPEC_OBJECT(%IS_VAR(arg)) ? arg : ToObject(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 JSON_NUMBER_TO_STRING(arg) = ((%_IsSmi(%IS_VAR(arg)) || arg - arg == 0) ? %_NumberToString(arg) : "null");
# Constants. The compiler constant folds them.
const NAN = $NaN;
const INFINITY = (1/0);
const UNDEFINED = (void 0);
# Macros implemented in Python. # Macros implemented in Python.
python macro CHAR_CODE(str) = ord(str[1]); python macro CHAR_CODE(str) = ord(str[1]);
......
...@@ -131,9 +131,9 @@ function MathMax(arg1, arg2) { // length == 2 ...@@ -131,9 +131,9 @@ function MathMax(arg1, arg2) { // length == 2
return (arg1 == 0 && !%_IsSmi(arg1) && 1 / arg1 < 0) ? arg2 : arg1; return (arg1 == 0 && !%_IsSmi(arg1) && 1 / arg1 < 0) ? arg2 : arg1;
} }
// All comparisons failed, one of the arguments must be NaN. // All comparisons failed, one of the arguments must be NaN.
return 0/0; // Compiler constant-folds this to NaN. return NAN;
} }
var r = -1/0; // Compiler constant-folds this to -Infinity. var r = -INFINITY;
for (var i = 0; i < length; i++) { for (var i = 0; i < length; i++) {
var n = %_Arguments(i); var n = %_Arguments(i);
if (!IS_NUMBER(n)) n = NonNumberToNumber(n); if (!IS_NUMBER(n)) n = NonNumberToNumber(n);
...@@ -161,9 +161,9 @@ function MathMin(arg1, arg2) { // length == 2 ...@@ -161,9 +161,9 @@ function MathMin(arg1, arg2) { // length == 2
return (arg1 == 0 && !%_IsSmi(arg1) && 1 / arg1 < 0) ? arg1 : arg2; return (arg1 == 0 && !%_IsSmi(arg1) && 1 / arg1 < 0) ? arg1 : arg2;
} }
// All comparisons failed, one of the arguments must be NaN. // All comparisons failed, one of the arguments must be NaN.
return 0/0; // Compiler constant-folds this to NaN. return NAN;
} }
var r = 1/0; // Compiler constant-folds this to Infinity. var r = INFINITY;
for (var i = 0; i < length; i++) { for (var i = 0; i < length; i++) {
var n = %_Arguments(i); var n = %_Arguments(i);
if (!IS_NUMBER(n)) n = NonNumberToNumber(n); if (!IS_NUMBER(n)) n = NonNumberToNumber(n);
......
...@@ -796,7 +796,7 @@ function CallSite(receiver, fun, pos, strict_mode) { ...@@ -796,7 +796,7 @@ function CallSite(receiver, fun, pos, strict_mode) {
} }
function CallSiteGetThis() { function CallSiteGetThis() {
return this[CallSiteStrictModeKey] ? void 0 : this[CallSiteReceiverKey]; return this[CallSiteStrictModeKey] ? UNDEFINED : this[CallSiteReceiverKey];
} }
function CallSiteGetTypeName() { function CallSiteGetTypeName() {
...@@ -826,7 +826,7 @@ function CallSiteGetScriptNameOrSourceURL() { ...@@ -826,7 +826,7 @@ function CallSiteGetScriptNameOrSourceURL() {
} }
function CallSiteGetFunction() { function CallSiteGetFunction() {
return this[CallSiteStrictModeKey] ? void 0 : this[CallSiteFunctionKey]; return this[CallSiteStrictModeKey] ? UNDEFINED : this[CallSiteFunctionKey];
} }
function CallSiteGetFunctionName() { function CallSiteGetFunctionName() {
...@@ -1092,7 +1092,7 @@ function FormatStackTrace(obj, error_string, frames) { ...@@ -1092,7 +1092,7 @@ function FormatStackTrace(obj, error_string, frames) {
var array = []; var array = [];
%MoveArrayContents(frames, array); %MoveArrayContents(frames, array);
formatting_custom_stack_trace = true; formatting_custom_stack_trace = true;
var stack_trace = void 0; var stack_trace = UNDEFINED;
try { try {
stack_trace = $Error.prepareStackTrace(obj, array); stack_trace = $Error.prepareStackTrace(obj, array);
} catch (e) { } catch (e) {
...@@ -1160,7 +1160,7 @@ function captureStackTrace(obj, cons_opt) { ...@@ -1160,7 +1160,7 @@ function captureStackTrace(obj, cons_opt) {
// Turn this accessor into a data property. // Turn this accessor into a data property.
%DefineOrRedefineDataProperty(obj, 'stack', result, NONE); %DefineOrRedefineDataProperty(obj, 'stack', result, NONE);
// Release context values. // Release context values.
stack = error_string = void 0; stack = error_string = UNDEFINED;
return result; return result;
}; };
...@@ -1171,7 +1171,7 @@ function captureStackTrace(obj, cons_opt) { ...@@ -1171,7 +1171,7 @@ function captureStackTrace(obj, cons_opt) {
%DefineOrRedefineDataProperty(this, 'stack', v, NONE); %DefineOrRedefineDataProperty(this, 'stack', v, NONE);
if (this === obj) { if (this === obj) {
// Release context values if holder is the same as the receiver. // Release context values if holder is the same as the receiver.
stack = error_string = void 0; stack = error_string = UNDEFINED;
} }
}; };
...@@ -1213,7 +1213,7 @@ function SetUpError() { ...@@ -1213,7 +1213,7 @@ function SetUpError() {
// Define all the expected properties directly on the error // Define all the expected properties directly on the error
// object. This avoids going through getters and setters defined // object. This avoids going through getters and setters defined
// on prototype objects. // on prototype objects.
%IgnoreAttributesAndSetProperty(this, 'stack', void 0, DONT_ENUM); %IgnoreAttributesAndSetProperty(this, 'stack', UNDEFINED, DONT_ENUM);
if (!IS_UNDEFINED(m)) { if (!IS_UNDEFINED(m)) {
%IgnoreAttributesAndSetProperty( %IgnoreAttributesAndSetProperty(
this, 'message', ToString(m), DONT_ENUM); this, 'message', ToString(m), DONT_ENUM);
...@@ -1251,7 +1251,7 @@ function GetPropertyWithoutInvokingMonkeyGetters(error, name) { ...@@ -1251,7 +1251,7 @@ function GetPropertyWithoutInvokingMonkeyGetters(error, name) {
while (error && !%HasLocalProperty(error, name)) { while (error && !%HasLocalProperty(error, name)) {
error = %GetPrototype(error); error = %GetPrototype(error);
} }
if (error === null) return void 0; if (IS_NULL(error)) return UNDEFINED;
if (!IS_OBJECT(error)) return error[name]; if (!IS_OBJECT(error)) return error[name];
// If the property is an accessor on one of the predefined errors that can be // If the property is an accessor on one of the predefined errors that can be
// generated statically by the compiler, don't touch it. This is to address // generated statically by the compiler, don't touch it. This is to address
...@@ -1260,11 +1260,11 @@ function GetPropertyWithoutInvokingMonkeyGetters(error, name) { ...@@ -1260,11 +1260,11 @@ function GetPropertyWithoutInvokingMonkeyGetters(error, name) {
if (desc && desc[IS_ACCESSOR_INDEX]) { if (desc && desc[IS_ACCESSOR_INDEX]) {
var isName = name === "name"; var isName = name === "name";
if (error === $ReferenceError.prototype) if (error === $ReferenceError.prototype)
return isName ? "ReferenceError" : void 0; return isName ? "ReferenceError" : UNDEFINED;
if (error === $SyntaxError.prototype) if (error === $SyntaxError.prototype)
return isName ? "SyntaxError" : void 0; return isName ? "SyntaxError" : UNDEFINED;
if (error === $TypeError.prototype) if (error === $TypeError.prototype)
return isName ? "TypeError" : void 0; return isName ? "TypeError" : UNDEFINED;
} }
// Otherwise, read normally. // Otherwise, read normally.
return error[name]; return error[name];
......
...@@ -117,7 +117,7 @@ function LookupMirror(handle) { ...@@ -117,7 +117,7 @@ function LookupMirror(handle) {
* @returns {Mirror} the mirror reflects the undefined value * @returns {Mirror} the mirror reflects the undefined value
*/ */
function GetUndefinedMirror() { function GetUndefinedMirror() {
return MakeMirror(void 0); return MakeMirror(UNDEFINED);
} }
...@@ -482,7 +482,7 @@ ValueMirror.prototype.value = function() { ...@@ -482,7 +482,7 @@ ValueMirror.prototype.value = function() {
* @extends ValueMirror * @extends ValueMirror
*/ */
function UndefinedMirror() { function UndefinedMirror() {
%_CallFunction(this, UNDEFINED_TYPE, void 0, ValueMirror); %_CallFunction(this, UNDEFINED_TYPE, UNDEFINED, ValueMirror);
} }
inherits(UndefinedMirror, ValueMirror); inherits(UndefinedMirror, ValueMirror);
...@@ -957,7 +957,7 @@ FunctionMirror.prototype.scopeCount = function() { ...@@ -957,7 +957,7 @@ FunctionMirror.prototype.scopeCount = function() {
FunctionMirror.prototype.scope = function(index) { FunctionMirror.prototype.scope = function(index) {
if (this.resolved()) { if (this.resolved()) {
return new ScopeMirror(void 0, this, index); return new ScopeMirror(UNDEFINED, this, index);
} }
}; };
...@@ -1670,7 +1670,7 @@ FrameMirror.prototype.scopeCount = function() { ...@@ -1670,7 +1670,7 @@ FrameMirror.prototype.scopeCount = function() {
FrameMirror.prototype.scope = function(index) { FrameMirror.prototype.scope = function(index) {
return new ScopeMirror(this, void 0, index); return new ScopeMirror(this, UNDEFINED, index);
}; };
......
...@@ -72,12 +72,12 @@ function ObservationWeakMap(map) { ...@@ -72,12 +72,12 @@ function ObservationWeakMap(map) {
ObservationWeakMap.prototype = { ObservationWeakMap.prototype = {
get: function(key) { get: function(key) {
key = %UnwrapGlobalProxy(key); key = %UnwrapGlobalProxy(key);
if (!IS_SPEC_OBJECT(key)) return void 0; if (!IS_SPEC_OBJECT(key)) return UNDEFINED;
return %WeakCollectionGet(this.map_, key); return %WeakCollectionGet(this.map_, key);
}, },
set: function(key, value) { set: function(key, value) {
key = %UnwrapGlobalProxy(key); key = %UnwrapGlobalProxy(key);
if (!IS_SPEC_OBJECT(key)) return void 0; if (!IS_SPEC_OBJECT(key)) return UNDEFINED;
%WeakCollectionSet(this.map_, key, value); %WeakCollectionSet(this.map_, key, value);
}, },
has: function(key) { has: function(key) {
...@@ -492,7 +492,7 @@ function ObjectNotifierPerformChange(changeType, changeFn) { ...@@ -492,7 +492,7 @@ function ObjectNotifierPerformChange(changeType, changeFn) {
ObjectInfoAddPerformingType(objectInfo, changeType); ObjectInfoAddPerformingType(objectInfo, changeType);
try { try {
%_CallFunction(void 0, changeFn); %_CallFunction(UNDEFINED, changeFn);
} finally { } finally {
ObjectInfoRemovePerformingType(objectInfo, changeType); ObjectInfoRemovePerformingType(objectInfo, changeType);
} }
...@@ -525,7 +525,7 @@ function CallbackDeliverPending(callback) { ...@@ -525,7 +525,7 @@ function CallbackDeliverPending(callback) {
%MoveArrayContents(callbackInfo, delivered); %MoveArrayContents(callbackInfo, delivered);
try { try {
%_CallFunction(void 0, delivered, callback); %_CallFunction(UNDEFINED, delivered, callback);
} catch (ex) {} } catch (ex) {}
return true; return true;
} }
......
...@@ -40,7 +40,7 @@ function ProxyCreate(handler, proto) { ...@@ -40,7 +40,7 @@ function ProxyCreate(handler, proto) {
throw MakeTypeError("handler_non_object", ["create"]) throw MakeTypeError("handler_non_object", ["create"])
if (IS_UNDEFINED(proto)) if (IS_UNDEFINED(proto))
proto = null proto = null
else if (!(IS_SPEC_OBJECT(proto) || proto === null)) else if (!(IS_SPEC_OBJECT(proto) || IS_NULL(proto)))
throw MakeTypeError("proto_non_object", ["create"]) throw MakeTypeError("proto_non_object", ["create"])
return %CreateJSProxy(handler, proto) return %CreateJSProxy(handler, proto)
} }
...@@ -56,7 +56,7 @@ function ProxyCreateFunction(handler, callTrap, constructTrap) { ...@@ -56,7 +56,7 @@ function ProxyCreateFunction(handler, callTrap, constructTrap) {
// Make sure the trap receives 'undefined' as this. // Make sure the trap receives 'undefined' as this.
var construct = constructTrap var construct = constructTrap
constructTrap = function() { constructTrap = function() {
return %Apply(construct, void 0, arguments, 0, %_ArgumentsLength()); return %Apply(construct, UNDEFINED, arguments, 0, %_ArgumentsLength());
} }
} else { } else {
throw MakeTypeError("trap_function_expected", throw MakeTypeError("trap_function_expected",
......
...@@ -189,7 +189,7 @@ function RegExpExec(string) { ...@@ -189,7 +189,7 @@ function RegExpExec(string) {
// matchIndices is either null or the lastMatchInfo array. // matchIndices is either null or the lastMatchInfo array.
var matchIndices = %_RegExpExec(this, string, i, lastMatchInfo); var matchIndices = %_RegExpExec(this, string, i, lastMatchInfo);
if (matchIndices === null) { if (IS_NULL(matchIndices)) {
this.lastIndex = 0; this.lastIndex = 0;
return null; return null;
} }
...@@ -232,7 +232,7 @@ function RegExpTest(string) { ...@@ -232,7 +232,7 @@ function RegExpTest(string) {
%_Log('regexp', 'regexp-exec,%0r,%1S,%2i', [this, string, lastIndex]); %_Log('regexp', 'regexp-exec,%0r,%1S,%2i', [this, string, lastIndex]);
// matchIndices is either null or the lastMatchInfo array. // matchIndices is either null or the lastMatchInfo array.
var matchIndices = %_RegExpExec(this, string, i, lastMatchInfo); var matchIndices = %_RegExpExec(this, string, i, lastMatchInfo);
if (matchIndices === null) { if (IS_NULL(matchIndices)) {
this.lastIndex = 0; this.lastIndex = 0;
return false; return false;
} }
...@@ -253,7 +253,7 @@ function RegExpTest(string) { ...@@ -253,7 +253,7 @@ function RegExpTest(string) {
%_Log('regexp', 'regexp-exec,%0r,%1S,%2i', [regexp, string, lastIndex]); %_Log('regexp', 'regexp-exec,%0r,%1S,%2i', [regexp, string, lastIndex]);
// matchIndices is either null or the lastMatchInfo array. // matchIndices is either null or the lastMatchInfo array.
var matchIndices = %_RegExpExec(regexp, string, 0, lastMatchInfo); var matchIndices = %_RegExpExec(regexp, string, 0, lastMatchInfo);
if (matchIndices === null) { if (IS_NULL(matchIndices)) {
this.lastIndex = 0; this.lastIndex = 0;
return false; return false;
} }
...@@ -384,7 +384,7 @@ function RegExpMakeCaptureGetter(n) { ...@@ -384,7 +384,7 @@ function RegExpMakeCaptureGetter(n) {
var lastMatchInfo = new InternalPackedArray( var lastMatchInfo = new InternalPackedArray(
2, // REGEXP_NUMBER_OF_CAPTURES 2, // REGEXP_NUMBER_OF_CAPTURES
"", // Last subject. "", // Last subject.
void 0, // Last input - settable with RegExpSetInput. UNDEFINED, // Last input - settable with RegExpSetInput.
0, // REGEXP_FIRST_CAPTURE + 0 0, // REGEXP_FIRST_CAPTURE + 0
0 // REGEXP_FIRST_CAPTURE + 1 0 // REGEXP_FIRST_CAPTURE + 1
); );
......
...@@ -526,8 +526,8 @@ function ToNumber(x) { ...@@ -526,8 +526,8 @@ function ToNumber(x) {
: %StringToNumber(x); : %StringToNumber(x);
} }
if (IS_BOOLEAN(x)) return x ? 1 : 0; if (IS_BOOLEAN(x)) return x ? 1 : 0;
if (IS_UNDEFINED(x)) return $NaN; if (IS_UNDEFINED(x)) return NAN;
if (IS_SYMBOL(x)) return $NaN; if (IS_SYMBOL(x)) return NAN;
return (IS_NULL(x)) ? 0 : ToNumber(%DefaultNumber(x)); return (IS_NULL(x)) ? 0 : ToNumber(%DefaultNumber(x));
} }
...@@ -537,8 +537,8 @@ function NonNumberToNumber(x) { ...@@ -537,8 +537,8 @@ function NonNumberToNumber(x) {
: %StringToNumber(x); : %StringToNumber(x);
} }
if (IS_BOOLEAN(x)) return x ? 1 : 0; if (IS_BOOLEAN(x)) return x ? 1 : 0;
if (IS_UNDEFINED(x)) return $NaN; if (IS_UNDEFINED(x)) return NAN;
if (IS_SYMBOL(x)) return $NaN; if (IS_SYMBOL(x)) return NAN;
return (IS_NULL(x)) ? 0 : ToNumber(%DefaultNumber(x)); return (IS_NULL(x)) ? 0 : ToNumber(%DefaultNumber(x));
} }
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
// This file relies on the fact that the following declaration has been made // This file relies on the fact that the following declaration has been made
// in runtime.js: // in runtime.js:
// var $String = global.String; // var $String = global.String;
// var $NaN = 0/0;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
...@@ -574,7 +573,7 @@ function StringSlice(start, end) { ...@@ -574,7 +573,7 @@ function StringSlice(start, end) {
var s_len = s.length; var s_len = s.length;
var start_i = TO_INTEGER(start); var start_i = TO_INTEGER(start);
var end_i = s_len; var end_i = s_len;
if (end !== void 0) { if (!IS_UNDEFINED(end)) {
end_i = TO_INTEGER(end); end_i = TO_INTEGER(end);
} }
...@@ -699,7 +698,7 @@ function StringSplitOnRegExp(subject, separator, limit, length) { ...@@ -699,7 +698,7 @@ function StringSplitOnRegExp(subject, separator, limit, length) {
%_CallFunction(result, %_SubString(subject, start, end), %_CallFunction(result, %_SubString(subject, start, end),
ArrayPushBuiltin); ArrayPushBuiltin);
} else { } else {
%_CallFunction(result, void 0, ArrayPushBuiltin); %_CallFunction(result, UNDEFINED, ArrayPushBuiltin);
} }
if (result.length === limit) break outer_loop; if (result.length === limit) break outer_loop;
} }
...@@ -756,7 +755,7 @@ function StringSubstr(start, n) { ...@@ -756,7 +755,7 @@ function StringSubstr(start, n) {
// Correct n: If not given, set to string length; if explicitly // Correct n: If not given, set to string length; if explicitly
// set to undefined, zero, or negative, returns empty string. // set to undefined, zero, or negative, returns empty string.
if (n === void 0) { if (IS_UNDEFINED(n)) {
len = s.length; len = s.length;
} else { } else {
len = TO_INTEGER(n); len = TO_INTEGER(n);
...@@ -765,7 +764,7 @@ function StringSubstr(start, n) { ...@@ -765,7 +764,7 @@ function StringSubstr(start, n) {
// Correct start: If not given (or undefined), set to zero; otherwise // Correct start: If not given (or undefined), set to zero; otherwise
// convert to integer and handle negative case. // convert to integer and handle negative case.
if (start === void 0) { if (IS_UNDEFINED(start)) {
start = 0; start = 0;
} else { } else {
start = TO_INTEGER(start); start = TO_INTEGER(start);
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
// var $Number = global.Number; // var $Number = global.Number;
// var $Function = global.Function; // var $Function = global.Function;
// var $Array = global.Array; // var $Array = global.Array;
// var $NaN = 0/0;
// //
// in math.js: // in math.js:
// var $floor = MathFloor // var $floor = MathFloor
...@@ -95,7 +94,7 @@ function SetUpLockedPrototype(constructor, fields, methods) { ...@@ -95,7 +94,7 @@ function SetUpLockedPrototype(constructor, fields, methods) {
} }
if (fields) { if (fields) {
for (var i = 0; i < fields.length; i++) { for (var i = 0; i < fields.length; i++) {
%SetProperty(prototype, fields[i], void 0, DONT_ENUM | DONT_DELETE); %SetProperty(prototype, fields[i], UNDEFINED, DONT_ENUM | DONT_DELETE);
} }
} }
for (var i = 0; i < methods.length; i += 2) { for (var i = 0; i < methods.length; i += 2) {
...@@ -148,7 +147,7 @@ function GlobalParseInt(string, radix) { ...@@ -148,7 +147,7 @@ function GlobalParseInt(string, radix) {
string = TO_STRING_INLINE(string); string = TO_STRING_INLINE(string);
radix = TO_INT32(radix); radix = TO_INT32(radix);
if (!(radix == 0 || (2 <= radix && radix <= 36))) { if (!(radix == 0 || (2 <= radix && radix <= 36))) {
return $NaN; return NAN;
} }
} }
...@@ -197,15 +196,16 @@ function GlobalEval(x) { ...@@ -197,15 +196,16 @@ function GlobalEval(x) {
function SetUpGlobal() { function SetUpGlobal() {
%CheckIsBootstrapping(); %CheckIsBootstrapping();
var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY;
// ECMA 262 - 15.1.1.1. // ECMA 262 - 15.1.1.1.
%SetProperty(global, "NaN", $NaN, DONT_ENUM | DONT_DELETE | READ_ONLY); %SetProperty(global, "NaN", NAN, attributes);
// ECMA-262 - 15.1.1.2. // ECMA-262 - 15.1.1.2.
%SetProperty(global, "Infinity", 1/0, DONT_ENUM | DONT_DELETE | READ_ONLY); %SetProperty(global, "Infinity", INFINITY, attributes);
// ECMA-262 - 15.1.1.3. // ECMA-262 - 15.1.1.3.
%SetProperty(global, "undefined", void 0, %SetProperty(global, "undefined", UNDEFINED, attributes);
DONT_ENUM | DONT_DELETE | READ_ONLY);
// Set up non-enumerable function on the global object. // Set up non-enumerable function on the global object.
InstallFunctions(global, DONT_ENUM, $Array( InstallFunctions(global, DONT_ENUM, $Array(
...@@ -475,12 +475,12 @@ function ToPropertyDescriptor(obj) { ...@@ -475,12 +475,12 @@ function ToPropertyDescriptor(obj) {
function ToCompletePropertyDescriptor(obj) { function ToCompletePropertyDescriptor(obj) {
var desc = ToPropertyDescriptor(obj); var desc = ToPropertyDescriptor(obj);
if (IsGenericDescriptor(desc) || IsDataDescriptor(desc)) { if (IsGenericDescriptor(desc) || IsDataDescriptor(desc)) {
if (!desc.hasValue()) desc.setValue(void 0); if (!desc.hasValue()) desc.setValue(UNDEFINED);
if (!desc.hasWritable()) desc.setWritable(false); if (!desc.hasWritable()) desc.setWritable(false);
} else { } else {
// Is accessor descriptor. // Is accessor descriptor.
if (!desc.hasGetter()) desc.setGet(void 0); if (!desc.hasGetter()) desc.setGet(UNDEFINED);
if (!desc.hasSetter()) desc.setSet(void 0); if (!desc.hasSetter()) desc.setSet(UNDEFINED);
} }
if (!desc.hasEnumerable()) desc.setEnumerable(false); if (!desc.hasEnumerable()) desc.setEnumerable(false);
if (!desc.hasConfigurable()) desc.setConfigurable(false); if (!desc.hasConfigurable()) desc.setConfigurable(false);
...@@ -491,7 +491,7 @@ function ToCompletePropertyDescriptor(obj) { ...@@ -491,7 +491,7 @@ function ToCompletePropertyDescriptor(obj) {
function PropertyDescriptor() { function PropertyDescriptor() {
// Initialize here so they are all in-object and have the same map. // Initialize here so they are all in-object and have the same map.
// Default values from ES5 8.6.1. // Default values from ES5 8.6.1.
this.value_ = void 0; this.value_ = UNDEFINED;
this.hasValue_ = false; this.hasValue_ = false;
this.writable_ = false; this.writable_ = false;
this.hasWritable_ = false; this.hasWritable_ = false;
...@@ -499,9 +499,9 @@ function PropertyDescriptor() { ...@@ -499,9 +499,9 @@ function PropertyDescriptor() {
this.hasEnumerable_ = false; this.hasEnumerable_ = false;
this.configurable_ = false; this.configurable_ = false;
this.hasConfigurable_ = false; this.hasConfigurable_ = false;
this.get_ = void 0; this.get_ = UNDEFINED;
this.hasGetter_ = false; this.hasGetter_ = false;
this.set_ = void 0; this.set_ = UNDEFINED;
this.hasSetter_ = false; this.hasSetter_ = false;
} }
...@@ -593,7 +593,7 @@ function ConvertDescriptorArrayToDescriptor(desc_array) { ...@@ -593,7 +593,7 @@ function ConvertDescriptorArrayToDescriptor(desc_array) {
} }
if (IS_UNDEFINED(desc_array)) { if (IS_UNDEFINED(desc_array)) {
return void 0; return UNDEFINED;
} }
var desc = new PropertyDescriptor(); var desc = new PropertyDescriptor();
...@@ -647,10 +647,11 @@ function GetOwnProperty(obj, v) { ...@@ -647,10 +647,11 @@ function GetOwnProperty(obj, v) {
var p = ToName(v); var p = ToName(v);
if (%IsJSProxy(obj)) { if (%IsJSProxy(obj)) {
// TODO(rossberg): adjust once there is a story for symbols vs proxies. // TODO(rossberg): adjust once there is a story for symbols vs proxies.
if (IS_SYMBOL(v)) return void 0; if (IS_SYMBOL(v)) return UNDEFINED;
var handler = %GetHandler(obj); var handler = %GetHandler(obj);
var descriptor = CallTrap1(handler, "getOwnPropertyDescriptor", void 0, p); var descriptor = CallTrap1(
handler, "getOwnPropertyDescriptor", UNDEFINED, p);
if (IS_UNDEFINED(descriptor)) return descriptor; if (IS_UNDEFINED(descriptor)) return descriptor;
var desc = ToCompletePropertyDescriptor(descriptor); var desc = ToCompletePropertyDescriptor(descriptor);
if (!desc.isConfigurable()) { if (!desc.isConfigurable()) {
...@@ -666,7 +667,7 @@ function GetOwnProperty(obj, v) { ...@@ -666,7 +667,7 @@ function GetOwnProperty(obj, v) {
var props = %GetOwnProperty(ToObject(obj), p); var props = %GetOwnProperty(ToObject(obj), p);
// A false value here means that access checks failed. // A false value here means that access checks failed.
if (props === false) return void 0; if (props === false) return UNDEFINED;
return ConvertDescriptorArrayToDescriptor(props); return ConvertDescriptorArrayToDescriptor(props);
} }
...@@ -693,7 +694,7 @@ function DefineProxyProperty(obj, p, attributes, should_throw) { ...@@ -693,7 +694,7 @@ function DefineProxyProperty(obj, p, attributes, should_throw) {
if (IS_SYMBOL(p)) return false; if (IS_SYMBOL(p)) return false;
var handler = %GetHandler(obj); var handler = %GetHandler(obj);
var result = CallTrap2(handler, "defineProperty", void 0, p, attributes); var result = CallTrap2(handler, "defineProperty", UNDEFINED, p, attributes);
if (!ToBoolean(result)) { if (!ToBoolean(result)) {
if (should_throw) { if (should_throw) {
throw MakeTypeError("handler_returned_false", throw MakeTypeError("handler_returned_false",
...@@ -710,7 +711,7 @@ function DefineProxyProperty(obj, p, attributes, should_throw) { ...@@ -710,7 +711,7 @@ function DefineProxyProperty(obj, p, attributes, should_throw) {
function DefineObjectProperty(obj, p, desc, should_throw) { function DefineObjectProperty(obj, p, desc, should_throw) {
var current_or_access = %GetOwnProperty(ToObject(obj), ToName(p)); var current_or_access = %GetOwnProperty(ToObject(obj), ToName(p));
// A false value here means that access checks failed. // A false value here means that access checks failed.
if (current_or_access === false) return void 0; if (current_or_access === false) return UNDEFINED;
var current = ConvertDescriptorArrayToDescriptor(current_or_access); var current = ConvertDescriptorArrayToDescriptor(current_or_access);
var extensible = %IsExtensible(ToObject(obj)); var extensible = %IsExtensible(ToObject(obj));
...@@ -841,7 +842,7 @@ function DefineObjectProperty(obj, p, desc, should_throw) { ...@@ -841,7 +842,7 @@ function DefineObjectProperty(obj, p, desc, should_throw) {
flag |= READ_ONLY; flag |= READ_ONLY;
} }
var value = void 0; // Default value is undefined. var value = UNDEFINED; // Default value is undefined.
if (desc.hasValue()) { if (desc.hasValue()) {
value = desc.getValue(); value = desc.getValue();
} else if (!IS_UNDEFINED(current) && IsDataDescriptor(current)) { } else if (!IS_UNDEFINED(current) && IsDataDescriptor(current)) {
...@@ -920,7 +921,7 @@ function DefineArrayProperty(obj, p, desc, should_throw) { ...@@ -920,7 +921,7 @@ function DefineArrayProperty(obj, p, desc, should_throw) {
// For the time being, we need a hack to prevent Object.observe from // For the time being, we need a hack to prevent Object.observe from
// generating two change records. // generating two change records.
obj.length = new_length; obj.length = new_length;
desc.value_ = void 0; desc.value_ = UNDEFINED;
desc.hasValue_ = false; desc.hasValue_ = false;
threw = !DefineObjectProperty(obj, "length", desc, should_throw) || threw; threw = !DefineObjectProperty(obj, "length", desc, should_throw) || threw;
if (emit_splice) { if (emit_splice) {
...@@ -1045,7 +1046,7 @@ function ObjectGetOwnPropertyNames(obj) { ...@@ -1045,7 +1046,7 @@ function ObjectGetOwnPropertyNames(obj) {
// Special handling for proxies. // Special handling for proxies.
if (%IsJSProxy(obj)) { if (%IsJSProxy(obj)) {
var handler = %GetHandler(obj); var handler = %GetHandler(obj);
var names = CallTrap0(handler, "getOwnPropertyNames", void 0); var names = CallTrap0(handler, "getOwnPropertyNames", UNDEFINED);
return ToNameArray(names, "getOwnPropertyNames", false); return ToNameArray(names, "getOwnPropertyNames", false);
} }
...@@ -1194,7 +1195,7 @@ function ObjectDefineProperties(obj, properties) { ...@@ -1194,7 +1195,7 @@ function ObjectDefineProperties(obj, properties) {
// Harmony proxies. // Harmony proxies.
function ProxyFix(obj) { function ProxyFix(obj) {
var handler = %GetHandler(obj); var handler = %GetHandler(obj);
var props = CallTrap0(handler, "fix", void 0); var props = CallTrap0(handler, "fix", UNDEFINED);
if (IS_UNDEFINED(props)) { if (IS_UNDEFINED(props)) {
throw MakeTypeError("handler_returned_undefined", [handler, "fix"]); throw MakeTypeError("handler_returned_undefined", [handler, "fix"]);
} }
...@@ -1560,8 +1561,8 @@ function NumberToFixed(fractionDigits) { ...@@ -1560,8 +1561,8 @@ function NumberToFixed(fractionDigits) {
} }
if (NUMBER_IS_NAN(x)) return "NaN"; if (NUMBER_IS_NAN(x)) return "NaN";
if (x == 1/0) return "Infinity"; if (x == INFINITY) return "Infinity";
if (x == -1/0) return "-Infinity"; if (x == -INFINITY) return "-Infinity";
return %NumberToFixed(x, f); return %NumberToFixed(x, f);
} }
...@@ -1578,11 +1579,11 @@ function NumberToExponential(fractionDigits) { ...@@ -1578,11 +1579,11 @@ function NumberToExponential(fractionDigits) {
// Get the value of this number in case it's an object. // Get the value of this number in case it's an object.
x = %_ValueOf(this); x = %_ValueOf(this);
} }
var f = IS_UNDEFINED(fractionDigits) ? void 0 : TO_INTEGER(fractionDigits); var f = IS_UNDEFINED(fractionDigits) ? UNDEFINED : TO_INTEGER(fractionDigits);
if (NUMBER_IS_NAN(x)) return "NaN"; if (NUMBER_IS_NAN(x)) return "NaN";
if (x == 1/0) return "Infinity"; if (x == INFINITY) return "Infinity";
if (x == -1/0) return "-Infinity"; if (x == -INFINITY) return "-Infinity";
if (IS_UNDEFINED(f)) { if (IS_UNDEFINED(f)) {
f = -1; // Signal for runtime function that f is not defined. f = -1; // Signal for runtime function that f is not defined.
...@@ -1608,8 +1609,8 @@ function NumberToPrecision(precision) { ...@@ -1608,8 +1609,8 @@ function NumberToPrecision(precision) {
var p = TO_INTEGER(precision); var p = TO_INTEGER(precision);
if (NUMBER_IS_NAN(x)) return "NaN"; if (NUMBER_IS_NAN(x)) return "NaN";
if (x == 1/0) return "Infinity"; if (x == INFINITY) return "Infinity";
if (x == -1/0) return "-Infinity"; if (x == -INFINITY) return "-Infinity";
if (p < 1 || p > 21) { if (p < 1 || p > 21) {
throw new $RangeError("toPrecision() argument must be between 1 and 21"); throw new $RangeError("toPrecision() argument must be between 1 and 21");
...@@ -1654,18 +1655,18 @@ function SetUpNumber() { ...@@ -1654,18 +1655,18 @@ function SetUpNumber() {
DONT_ENUM | DONT_DELETE | READ_ONLY); DONT_ENUM | DONT_DELETE | READ_ONLY);
// ECMA-262 section 15.7.3.3. // ECMA-262 section 15.7.3.3.
%SetProperty($Number, "NaN", $NaN, DONT_ENUM | DONT_DELETE | READ_ONLY); %SetProperty($Number, "NaN", NAN, DONT_ENUM | DONT_DELETE | READ_ONLY);
// ECMA-262 section 15.7.3.4. // ECMA-262 section 15.7.3.4.
%SetProperty($Number, %SetProperty($Number,
"NEGATIVE_INFINITY", "NEGATIVE_INFINITY",
-1/0, -INFINITY,
DONT_ENUM | DONT_DELETE | READ_ONLY); DONT_ENUM | DONT_DELETE | READ_ONLY);
// ECMA-262 section 15.7.3.5. // ECMA-262 section 15.7.3.5.
%SetProperty($Number, %SetProperty($Number,
"POSITIVE_INFINITY", "POSITIVE_INFINITY",
1/0, INFINITY,
DONT_ENUM | DONT_DELETE | READ_ONLY); DONT_ENUM | DONT_DELETE | READ_ONLY);
%ToFastProperties($Number); %ToFastProperties($Number);
......
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