OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 function GlobalParseFloat(string) { | 155 function GlobalParseFloat(string) { |
156 string = TO_STRING_INLINE(string); | 156 string = TO_STRING_INLINE(string); |
157 if (%_HasCachedArrayIndex(string)) return %_GetCachedArrayIndex(string); | 157 if (%_HasCachedArrayIndex(string)) return %_GetCachedArrayIndex(string); |
158 return %StringParseFloat(string); | 158 return %StringParseFloat(string); |
159 } | 159 } |
160 | 160 |
161 | 161 |
162 function GlobalEval(x) { | 162 function GlobalEval(x) { |
163 if (!IS_STRING(x)) return x; | 163 if (!IS_STRING(x)) return x; |
164 | 164 |
165 var receiver = this; | |
166 var global_receiver = %GlobalReceiver(global); | 165 var global_receiver = %GlobalReceiver(global); |
167 | |
168 if (receiver == null && !IS_UNDETECTABLE(receiver)) { | |
169 receiver = global_receiver; | |
170 } | |
171 | |
172 var this_is_global_receiver = (receiver === global_receiver); | |
173 var global_is_detached = (global === global_receiver); | 166 var global_is_detached = (global === global_receiver); |
174 | 167 |
175 // For consistency with JSC we require the global object passed to | 168 // For consistency with JSC we require the global object passed to |
176 // eval to be the global object from which 'eval' originated. This | 169 // eval to be the global object from which 'eval' originated. This |
177 // is not mandated by the spec. | 170 // is not mandated by the spec. |
178 if (!this_is_global_receiver || global_is_detached) { | 171 // We only throw if the global has been detached, since we need the |
179 throw new $EvalError('The "this" object passed to eval must ' + | 172 // receiver as this-value for the call. |
| 173 if (global_is_detached) { |
| 174 throw new $EvalError('The "this" value passed to eval must ' + |
180 'be the global object from which eval originated'); | 175 'be the global object from which eval originated'); |
181 } | 176 } |
182 | 177 |
183 var f = %CompileString(x); | 178 var f = %CompileString(x); |
184 if (!IS_FUNCTION(f)) return f; | 179 if (!IS_FUNCTION(f)) return f; |
185 | 180 |
186 return %_CallFunction(receiver, f); | 181 return %_CallFunction(global_receiver, f); |
187 } | 182 } |
188 | 183 |
189 | 184 |
190 // ---------------------------------------------------------------------------- | 185 // ---------------------------------------------------------------------------- |
191 | 186 |
192 // Set up global object. | 187 // Set up global object. |
193 function SetUpGlobal() { | 188 function SetUpGlobal() { |
194 %CheckIsBootstrapping(); | 189 %CheckIsBootstrapping(); |
195 // ECMA 262 - 15.1.1.1. | 190 // ECMA 262 - 15.1.1.1. |
196 %SetProperty(global, "NaN", $NaN, DONT_ENUM | DONT_DELETE | READ_ONLY); | 191 %SetProperty(global, "NaN", $NaN, DONT_ENUM | DONT_DELETE | READ_ONLY); |
(...skipping 1410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1607 | 1602 |
1608 function SetUpFunction() { | 1603 function SetUpFunction() { |
1609 %CheckIsBootstrapping(); | 1604 %CheckIsBootstrapping(); |
1610 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1605 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
1611 "bind", FunctionBind, | 1606 "bind", FunctionBind, |
1612 "toString", FunctionToString | 1607 "toString", FunctionToString |
1613 )); | 1608 )); |
1614 } | 1609 } |
1615 | 1610 |
1616 SetUpFunction(); | 1611 SetUpFunction(); |
OLD | NEW |