Index: src/v8natives.js |
=================================================================== |
--- src/v8natives.js (revision 2947) |
+++ src/v8natives.js (working copy) |
@@ -276,6 +276,13 @@ |
} |
+function ObjectKeys(obj) { |
+ if ((!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj)) && !IS_FUNCTION(obj)) |
+ throw MakeTypeError('object_keys_non_object', [obj]); |
+ return %LocalKeys(obj); |
+} |
+ |
+ |
%SetCode($Object, function(x) { |
if (%_IsConstructCall()) { |
if (x == null) return this; |
@@ -304,6 +311,9 @@ |
"__defineSetter__", ObjectDefineSetter, |
"__lookupSetter__", ObjectLookupSetter |
)); |
+ InstallFunctions($Object, DONT_ENUM, $Array( |
+ "keys", ObjectKeys |
+ )); |
} |
SetupObject(); |
@@ -514,7 +524,7 @@ |
} |
var source = %FunctionGetSourceCode(func); |
- if (!IS_STRING(source)) { |
+ if (!IS_STRING(source) || %FunctionIsBuiltin(func)) { |
var name = %FunctionGetName(func); |
if (name) { |
// Mimic what KJS does. |
@@ -524,12 +534,6 @@ |
} |
} |
- // Censor occurrences of internal calls. We do that for all |
- // functions and don't cache under the assumption that people rarly |
- // convert functions to strings. Note that we (apparently) can't |
- // use regular expression literals in natives files. |
- var regexp = ORIGINAL_REGEXP("%(\\w+\\()", "gm"); |
- if (source.match(regexp)) source = source.replace(regexp, "$1"); |
var name = %FunctionGetName(func); |
return 'function ' + name + source; |
} |