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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 'be the global object from which eval originated'); | 141 'be the global object from which eval originated'); |
142 } | 142 } |
143 | 143 |
144 var f = %CompileString(x); | 144 var f = %CompileString(x); |
145 if (!IS_FUNCTION(f)) return f; | 145 if (!IS_FUNCTION(f)) return f; |
146 | 146 |
147 return %_CallFunction(this, f); | 147 return %_CallFunction(this, f); |
148 } | 148 } |
149 | 149 |
150 | 150 |
151 // execScript for IE compatibility. | |
152 function GlobalExecScript(expr, lang) { | |
153 // NOTE: We don't care about the character casing. | |
154 if (!lang || /javascript/i.test(lang)) { | |
155 var f = %CompileString(ToString(expr)); | |
156 %_CallFunction(%GlobalReceiver(global), f); | |
157 } | |
158 return null; | |
159 } | |
160 | |
161 | |
162 // ---------------------------------------------------------------------------- | 151 // ---------------------------------------------------------------------------- |
163 | 152 |
164 | 153 |
165 function SetupGlobal() { | 154 function SetupGlobal() { |
166 // ECMA 262 - 15.1.1.1. | 155 // ECMA 262 - 15.1.1.1. |
167 %SetProperty(global, "NaN", $NaN, DONT_ENUM | DONT_DELETE); | 156 %SetProperty(global, "NaN", $NaN, DONT_ENUM | DONT_DELETE); |
168 | 157 |
169 // ECMA-262 - 15.1.1.2. | 158 // ECMA-262 - 15.1.1.2. |
170 %SetProperty(global, "Infinity", 1/0, DONT_ENUM | DONT_DELETE); | 159 %SetProperty(global, "Infinity", 1/0, DONT_ENUM | DONT_DELETE); |
171 | 160 |
172 // ECMA-262 - 15.1.1.3. | 161 // ECMA-262 - 15.1.1.3. |
173 %SetProperty(global, "undefined", void 0, DONT_ENUM | DONT_DELETE); | 162 %SetProperty(global, "undefined", void 0, DONT_ENUM | DONT_DELETE); |
174 | 163 |
175 // Setup non-enumerable function on the global object. | 164 // Setup non-enumerable function on the global object. |
176 InstallFunctions(global, DONT_ENUM, $Array( | 165 InstallFunctions(global, DONT_ENUM, $Array( |
177 "isNaN", GlobalIsNaN, | 166 "isNaN", GlobalIsNaN, |
178 "isFinite", GlobalIsFinite, | 167 "isFinite", GlobalIsFinite, |
179 "parseInt", GlobalParseInt, | 168 "parseInt", GlobalParseInt, |
180 "parseFloat", GlobalParseFloat, | 169 "parseFloat", GlobalParseFloat, |
181 "eval", GlobalEval, | 170 "eval", GlobalEval |
182 "execScript", GlobalExecScript | |
183 )); | 171 )); |
184 } | 172 } |
185 | 173 |
186 SetupGlobal(); | 174 SetupGlobal(); |
187 | 175 |
188 | 176 |
189 // ---------------------------------------------------------------------------- | 177 // ---------------------------------------------------------------------------- |
190 // Boolean (first part of definition) | 178 // Boolean (first part of definition) |
191 | 179 |
192 | 180 |
(...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1313 // ---------------------------------------------------------------------------- | 1301 // ---------------------------------------------------------------------------- |
1314 | 1302 |
1315 function SetupFunction() { | 1303 function SetupFunction() { |
1316 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1304 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
1317 "bind", FunctionBind, | 1305 "bind", FunctionBind, |
1318 "toString", FunctionToString | 1306 "toString", FunctionToString |
1319 )); | 1307 )); |
1320 } | 1308 } |
1321 | 1309 |
1322 SetupFunction(); | 1310 SetupFunction(); |
OLD | NEW |