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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 108 |
109 // ECMA-262 - 15.1.2.3 | 109 // ECMA-262 - 15.1.2.3 |
110 function GlobalParseFloat(string) { | 110 function GlobalParseFloat(string) { |
111 return %StringParseFloat(ToString(string)); | 111 return %StringParseFloat(ToString(string)); |
112 } | 112 } |
113 | 113 |
114 | 114 |
115 function GlobalEval(x) { | 115 function GlobalEval(x) { |
116 if (!IS_STRING(x)) return x; | 116 if (!IS_STRING(x)) return x; |
117 | 117 |
118 if (this !== global && this !== %GlobalReceiver(global)) { | 118 var global_receiver = %GlobalReceiver(global); |
119 throw new $EvalError('The "this" object passed to eval must ' + | 119 var this_is_global_receiver = (this === global_receiver); |
| 120 var global_is_detached = (global === global_receiver); |
| 121 |
| 122 if (!this_is_global_receiver || global_is_detached) { |
| 123 throw new $EvalError('The "this" object passed to eval must ' + |
120 'be the global object from which eval originated'); | 124 'be the global object from which eval originated'); |
121 } | 125 } |
122 | 126 |
123 var f = %CompileString(x, false); | 127 var f = %CompileString(x, false); |
124 if (!IS_FUNCTION(f)) return f; | 128 if (!IS_FUNCTION(f)) return f; |
125 | 129 |
126 return f.call(this); | 130 return f.call(this); |
127 } | 131 } |
128 | 132 |
129 | 133 |
130 // execScript for IE compatibility. | 134 // execScript for IE compatibility. |
131 function GlobalExecScript(expr, lang) { | 135 function GlobalExecScript(expr, lang) { |
132 // NOTE: We don't care about the character casing. | 136 // NOTE: We don't care about the character casing. |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 // ---------------------------------------------------------------------------- | 564 // ---------------------------------------------------------------------------- |
561 | 565 |
562 function SetupFunction() { | 566 function SetupFunction() { |
563 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 567 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
564 "toString", FunctionToString | 568 "toString", FunctionToString |
565 )); | 569 )); |
566 } | 570 } |
567 | 571 |
568 SetupFunction(); | 572 SetupFunction(); |
569 | 573 |
OLD | NEW |