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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 'be the global object from which eval originated'); | 140 'be the global object from which eval originated'); |
141 } | 141 } |
142 | 142 |
143 var f = %CompileString(x); | 143 var f = %CompileString(x); |
144 if (!IS_FUNCTION(f)) return f; | 144 if (!IS_FUNCTION(f)) return f; |
145 | 145 |
146 return %_CallFunction(this, f); | 146 return %_CallFunction(this, f); |
147 } | 147 } |
148 | 148 |
149 | 149 |
150 // execScript for IE compatibility. | |
151 function GlobalExecScript(expr, lang) { | |
152 // NOTE: We don't care about the character casing. | |
153 if (!lang || /javascript/i.test(lang)) { | |
154 var f = %CompileString(ToString(expr)); | |
155 %_CallFunction(%GlobalReceiver(global), f); | |
156 } | |
157 return null; | |
158 } | |
159 | |
160 | |
161 // ---------------------------------------------------------------------------- | 150 // ---------------------------------------------------------------------------- |
162 | 151 |
163 | 152 |
164 function SetupGlobal() { | 153 function SetupGlobal() { |
165 // ECMA 262 - 15.1.1.1. | 154 // ECMA 262 - 15.1.1.1. |
166 %SetProperty(global, "NaN", $NaN, DONT_ENUM | DONT_DELETE); | 155 %SetProperty(global, "NaN", $NaN, DONT_ENUM | DONT_DELETE); |
167 | 156 |
168 // ECMA-262 - 15.1.1.2. | 157 // ECMA-262 - 15.1.1.2. |
169 %SetProperty(global, "Infinity", 1/0, DONT_ENUM | DONT_DELETE); | 158 %SetProperty(global, "Infinity", 1/0, DONT_ENUM | DONT_DELETE); |
170 | 159 |
171 // ECMA-262 - 15.1.1.3. | 160 // ECMA-262 - 15.1.1.3. |
172 %SetProperty(global, "undefined", void 0, DONT_ENUM | DONT_DELETE); | 161 %SetProperty(global, "undefined", void 0, DONT_ENUM | DONT_DELETE); |
173 | 162 |
174 // Setup non-enumerable function on the global object. | 163 // Setup non-enumerable function on the global object. |
175 InstallFunctions(global, DONT_ENUM, $Array( | 164 InstallFunctions(global, DONT_ENUM, $Array( |
176 "isNaN", GlobalIsNaN, | 165 "isNaN", GlobalIsNaN, |
177 "isFinite", GlobalIsFinite, | 166 "isFinite", GlobalIsFinite, |
178 "parseInt", GlobalParseInt, | 167 "parseInt", GlobalParseInt, |
179 "parseFloat", GlobalParseFloat, | 168 "parseFloat", GlobalParseFloat, |
180 "eval", GlobalEval, | 169 "eval", GlobalEval |
181 "execScript", GlobalExecScript | |
182 )); | 170 )); |
183 } | 171 } |
184 | 172 |
185 SetupGlobal(); | 173 SetupGlobal(); |
186 | 174 |
187 | 175 |
188 // ---------------------------------------------------------------------------- | 176 // ---------------------------------------------------------------------------- |
189 // Boolean (first part of definition) | 177 // Boolean (first part of definition) |
190 | 178 |
191 | 179 |
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1284 // ---------------------------------------------------------------------------- | 1272 // ---------------------------------------------------------------------------- |
1285 | 1273 |
1286 function SetupFunction() { | 1274 function SetupFunction() { |
1287 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1275 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
1288 "bind", FunctionBind, | 1276 "bind", FunctionBind, |
1289 "toString", FunctionToString | 1277 "toString", FunctionToString |
1290 )); | 1278 )); |
1291 } | 1279 } |
1292 | 1280 |
1293 SetupFunction(); | 1281 SetupFunction(); |
OLD | NEW |