| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 147 |
| 148 function SetupGlobal() { | 148 function SetupGlobal() { |
| 149 // ECMA 262 - 15.1.1.1. | 149 // ECMA 262 - 15.1.1.1. |
| 150 %SetProperty(global, "NaN", $NaN, DONT_ENUM | DONT_DELETE); | 150 %SetProperty(global, "NaN", $NaN, DONT_ENUM | DONT_DELETE); |
| 151 | 151 |
| 152 // ECMA-262 - 15.1.1.2. | 152 // ECMA-262 - 15.1.1.2. |
| 153 %SetProperty(global, "Infinity", 1/0, DONT_ENUM | DONT_DELETE); | 153 %SetProperty(global, "Infinity", 1/0, DONT_ENUM | DONT_DELETE); |
| 154 | 154 |
| 155 // ECMA-262 - 15.1.1.3. | 155 // ECMA-262 - 15.1.1.3. |
| 156 %SetProperty(global, "undefined", void 0, DONT_ENUM | DONT_DELETE); | 156 %SetProperty(global, "undefined", void 0, DONT_ENUM | DONT_DELETE); |
| 157 | 157 |
| 158 // Setup non-enumerable function on the global object. | 158 // Setup non-enumerable function on the global object. |
| 159 InstallFunctions(global, DONT_ENUM, $Array( | 159 InstallFunctions(global, DONT_ENUM, $Array( |
| 160 "isNaN", GlobalIsNaN, | 160 "isNaN", GlobalIsNaN, |
| 161 "isFinite", GlobalIsFinite, | 161 "isFinite", GlobalIsFinite, |
| 162 "parseInt", GlobalParseInt, | 162 "parseInt", GlobalParseInt, |
| 163 "parseFloat", GlobalParseFloat, | 163 "parseFloat", GlobalParseFloat, |
| 164 "eval", GlobalEval, | 164 "eval", GlobalEval, |
| 165 "execScript", GlobalExecScript | 165 "execScript", GlobalExecScript |
| 166 )); | 166 )); |
| 167 } | 167 } |
| 168 | 168 |
| 169 SetupGlobal(); | 169 SetupGlobal(); |
| 170 | 170 |
| 171 | 171 |
| 172 // ---------------------------------------------------------------------------- | 172 // ---------------------------------------------------------------------------- |
| 173 // Boolean (first part of definition) | 173 // Boolean (first part of definition) |
| 174 | 174 |
| 175 | 175 |
| 176 %SetCode($Boolean, function(x) { | 176 %SetCode($Boolean, function(x) { |
| 177 if (%IsConstructCall()) { | 177 if (%_IsConstructCall()) { |
| 178 %_SetValueOf(this, ToBoolean(x)); | 178 %_SetValueOf(this, ToBoolean(x)); |
| 179 } else { | 179 } else { |
| 180 return ToBoolean(x); | 180 return ToBoolean(x); |
| 181 } | 181 } |
| 182 }); | 182 }); |
| 183 | 183 |
| 184 %FunctionSetPrototype($Boolean, new $Boolean(false)); | 184 %FunctionSetPrototype($Boolean, new $Boolean(false)); |
| 185 | 185 |
| 186 %SetProperty($Boolean.prototype, "constructor", $Boolean, DONT_ENUM); | 186 %SetProperty($Boolean.prototype, "constructor", $Boolean, DONT_ENUM); |
| 187 | 187 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 | 266 |
| 267 function ObjectLookupSetter(name) { | 267 function ObjectLookupSetter(name) { |
| 268 if (this == null) { | 268 if (this == null) { |
| 269 throw new $TypeError('Object.prototype.__lookupSetter__: this is Null'); | 269 throw new $TypeError('Object.prototype.__lookupSetter__: this is Null'); |
| 270 } | 270 } |
| 271 return %LookupAccessor(ToObject(this), ToString(name), SETTER); | 271 return %LookupAccessor(ToObject(this), ToString(name), SETTER); |
| 272 } | 272 } |
| 273 | 273 |
| 274 | 274 |
| 275 %SetCode($Object, function(x) { | 275 %SetCode($Object, function(x) { |
| 276 if (%IsConstructCall()) { | 276 if (%_IsConstructCall()) { |
| 277 if (x == null) return this; | 277 if (x == null) return this; |
| 278 return ToObject(x); | 278 return ToObject(x); |
| 279 } else { | 279 } else { |
| 280 if (x == null) return { }; | 280 if (x == null) return { }; |
| 281 return ToObject(x); | 281 return ToObject(x); |
| 282 } | 282 } |
| 283 }); | 283 }); |
| 284 | 284 |
| 285 | 285 |
| 286 // ---------------------------------------------------------------------------- | 286 // ---------------------------------------------------------------------------- |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 } | 343 } |
| 344 | 344 |
| 345 SetupBoolean(); | 345 SetupBoolean(); |
| 346 | 346 |
| 347 // ---------------------------------------------------------------------------- | 347 // ---------------------------------------------------------------------------- |
| 348 // Number | 348 // Number |
| 349 | 349 |
| 350 // Set the Number function and constructor. | 350 // Set the Number function and constructor. |
| 351 %SetCode($Number, function(x) { | 351 %SetCode($Number, function(x) { |
| 352 var value = %_ArgumentsLength() == 0 ? 0 : ToNumber(x); | 352 var value = %_ArgumentsLength() == 0 ? 0 : ToNumber(x); |
| 353 if (%IsConstructCall()) { | 353 if (%_IsConstructCall()) { |
| 354 %_SetValueOf(this, value); | 354 %_SetValueOf(this, value); |
| 355 } else { | 355 } else { |
| 356 return value; | 356 return value; |
| 357 } | 357 } |
| 358 }); | 358 }); |
| 359 | 359 |
| 360 %FunctionSetPrototype($Number, new $Number(0)); | 360 %FunctionSetPrototype($Number, new $Number(0)); |
| 361 | 361 |
| 362 // ECMA-262 section 15.7.4.2. | 362 // ECMA-262 section 15.7.4.2. |
| 363 function NumberToString(radix) { | 363 function NumberToString(radix) { |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 | 563 |
| 564 // ---------------------------------------------------------------------------- | 564 // ---------------------------------------------------------------------------- |
| 565 | 565 |
| 566 function SetupFunction() { | 566 function SetupFunction() { |
| 567 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 567 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
| 568 "toString", FunctionToString | 568 "toString", FunctionToString |
| 569 )); | 569 )); |
| 570 } | 570 } |
| 571 | 571 |
| 572 SetupFunction(); | 572 SetupFunction(); |
| 573 | |
| OLD | NEW |