| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 133 |
| 134 var global_receiver = %GlobalReceiver(global); | 134 var global_receiver = %GlobalReceiver(global); |
| 135 var this_is_global_receiver = (this === global_receiver); | 135 var this_is_global_receiver = (this === global_receiver); |
| 136 var global_is_detached = (global === global_receiver); | 136 var global_is_detached = (global === global_receiver); |
| 137 | 137 |
| 138 if (!this_is_global_receiver || global_is_detached) { | 138 if (!this_is_global_receiver || global_is_detached) { |
| 139 throw new $EvalError('The "this" object passed to eval must ' + | 139 throw new $EvalError('The "this" object passed to eval must ' + |
| 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, false); | 143 var f = %CompileString(x); |
| 144 if (!IS_FUNCTION(f)) return f; | 144 if (!IS_FUNCTION(f)) return f; |
| 145 | 145 |
| 146 return f.call(this); | 146 return f.call(this); |
| 147 } | 147 } |
| 148 | 148 |
| 149 | 149 |
| 150 // execScript for IE compatibility. | 150 // execScript for IE compatibility. |
| 151 function GlobalExecScript(expr, lang) { | 151 function GlobalExecScript(expr, lang) { |
| 152 // NOTE: We don't care about the character casing. | 152 // NOTE: We don't care about the character casing. |
| 153 if (!lang || /javascript/i.test(lang)) { | 153 if (!lang || /javascript/i.test(lang)) { |
| 154 var f = %CompileString(ToString(expr), false); | 154 var f = %CompileString(ToString(expr)); |
| 155 f.call(%GlobalReceiver(global)); | 155 f.call(%GlobalReceiver(global)); |
| 156 } | 156 } |
| 157 return null; | 157 return null; |
| 158 } | 158 } |
| 159 | 159 |
| 160 | 160 |
| 161 // ---------------------------------------------------------------------------- | 161 // ---------------------------------------------------------------------------- |
| 162 | 162 |
| 163 | 163 |
| 164 function SetupGlobal() { | 164 function SetupGlobal() { |
| (...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1170 // If the formal parameters string include ) - an illegal | 1170 // If the formal parameters string include ) - an illegal |
| 1171 // character - it may make the combined function expression | 1171 // character - it may make the combined function expression |
| 1172 // compile. We avoid this problem by checking for this early on. | 1172 // compile. We avoid this problem by checking for this early on. |
| 1173 if (p.indexOf(')') != -1) throw MakeSyntaxError('unable_to_parse',[]); | 1173 if (p.indexOf(')') != -1) throw MakeSyntaxError('unable_to_parse',[]); |
| 1174 } | 1174 } |
| 1175 var body = (n > 0) ? ToString(%_Arguments(n - 1)) : ''; | 1175 var body = (n > 0) ? ToString(%_Arguments(n - 1)) : ''; |
| 1176 var source = '(function(' + p + ') {\n' + body + '\n})'; | 1176 var source = '(function(' + p + ') {\n' + body + '\n})'; |
| 1177 | 1177 |
| 1178 // The call to SetNewFunctionAttributes will ensure the prototype | 1178 // The call to SetNewFunctionAttributes will ensure the prototype |
| 1179 // property of the resulting function is enumerable (ECMA262, 15.3.5.2). | 1179 // property of the resulting function is enumerable (ECMA262, 15.3.5.2). |
| 1180 var f = %CompileString(source, false)(); | 1180 var f = %CompileString(source)(); |
| 1181 %FunctionSetName(f, "anonymous"); | 1181 %FunctionSetName(f, "anonymous"); |
| 1182 return %SetNewFunctionAttributes(f); | 1182 return %SetNewFunctionAttributes(f); |
| 1183 } | 1183 } |
| 1184 | 1184 |
| 1185 %SetCode($Function, NewFunction); | 1185 %SetCode($Function, NewFunction); |
| 1186 | 1186 |
| 1187 // ---------------------------------------------------------------------------- | 1187 // ---------------------------------------------------------------------------- |
| 1188 | 1188 |
| 1189 function SetupFunction() { | 1189 function SetupFunction() { |
| 1190 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1190 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
| 1191 "bind", FunctionBind, | 1191 "bind", FunctionBind, |
| 1192 "toString", FunctionToString | 1192 "toString", FunctionToString |
| 1193 )); | 1193 )); |
| 1194 } | 1194 } |
| 1195 | 1195 |
| 1196 SetupFunction(); | 1196 SetupFunction(); |
| OLD | NEW |