-
-
Save egdelwonk/a9a1672f5707c2cb2124 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -r bb4dd9872236 js/src/builtin/Array.js | |
--- a/js/src/builtin/Array.js Thu Mar 27 14:14:32 2014 +0100 | |
+++ b/js/src/builtin/Array.js Wed Apr 09 18:24:53 2014 -0500 | |
@@ -558,16 +558,79 @@ | |
function ArrayEntries() { | |
return CreateArrayIterator(this, ITEM_KIND_KEY_AND_VALUE); | |
} | |
function ArrayKeys() { | |
return CreateArrayIterator(this, ITEM_KIND_KEY); | |
} | |
+function StrictSetLength(a, len) { | |
+ "use strict"; a.length = len; | |
+} | |
+ | |
+/* ES6 22.1.2.1 */ | |
+function ArrayFrom (arrayLike, mapfn, thisArg) { | |
+ | |
+ /* Step 1 */ | |
+ var C = this; | |
+ | |
+ | |
+ /* Step 2 */ | |
+ var items = ToObject(arrayLike); | |
+ | |
+ var mapping = false; | |
+ | |
+ /*Steps 4 - 5 */ | |
+ if (mapfn !== undefined) { | |
+ if (!IsCallable(mapfn)) { | |
+ ThrowError(JSMSG_NOT_FUNCTION, DecompileArg(1, mapfn)); | |
+ } | |
+ if (thisArg !== undefined) { | |
+ var T = thisArg; | |
+ } | |
+ mapping = true; | |
+ } | |
+ var A = (IsConstructor(C)) ? new C() : new Array(); | |
+ var k = 0; | |
+ | |
+ /* Step 8 */ | |
+ if ("@@iterator" in items) { | |
+ for (var nextValue of items) { | |
+ var mappedValue; | |
+ | |
+ if (mapping) { | |
+ mappedValue = callFunction(mapfn, T, nextValue); | |
+ } else { | |
+ mappedValue = nextValue; | |
+ } | |
+ | |
+ A[k] = mappedValue; | |
+ k++; | |
+ } | |
+ } else { | |
+ while(k < Object.keys(items).length){ | |
+ var kValue = items[nextValue]; | |
+ | |
+ if (mapping) { | |
+ mappedValue = callFunction(mapfn, T, kValue, k, items); | |
+ mapfn.call(T, [kValue, k, items]); | |
+ } else { | |
+ mappedValue = kValue; | |
+ } | |
+ | |
+ A[k] = mappedValue; | |
+ k++; | |
+ } | |
+ } | |
+ | |
+ StrictSetLength(A, k); | |
+ return A; | |
+} | |
+ | |
#ifdef ENABLE_PARALLEL_JS | |
/* | |
* Strawman spec: | |
* http://wiki.ecmascript.org/doku.php?id=strawman:data_parallelism | |
*/ | |
/** | |
diff -r bb4dd9872236 js/src/builtin/Object.cpp | |
--- a/js/src/builtin/Object.cpp Thu Mar 27 14:14:32 2014 +0100 | |
+++ b/js/src/builtin/Object.cpp Wed Apr 09 18:24:53 2014 -0500 | |
@@ -366,17 +366,17 @@ | |
template<DefineType Type> | |
static bool | |
DefineAccessor(JSContext *cx, unsigned argc, Value *vp) | |
{ | |
CallArgs args = CallArgsFromVp(argc, vp); | |
if (!BoxNonStrictThis(cx, args)) | |
return false; | |
- if (args.length() < 2 || !js_IsCallable(args[1])) { | |
+ if (args.length() < 2 || !IsCallable(args[1])) { | |
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, | |
JSMSG_BAD_GETTER_OR_SETTER, | |
Type == GetterAccessor ? js_getter_str : js_setter_str); | |
return false; | |
} | |
RootedId id(cx); | |
if (!ValueToId<CanGC>(cx, args[0], &id)) | |
diff -r bb4dd9872236 js/src/jsarray.cpp | |
--- a/js/src/jsarray.cpp Thu Mar 27 14:14:32 2014 +0100 | |
+++ b/js/src/jsarray.cpp Wed Apr 09 18:24:53 2014 -0500 | |
@@ -1151,17 +1151,17 @@ | |
RootedObject obj(cx, ToObject(cx, args.thisv())); | |
if (!obj) | |
return false; | |
RootedValue join(cx, args.calleev()); | |
if (!JSObject::getProperty(cx, obj, obj, cx->names().join, &join)) | |
return false; | |
- if (!js_IsCallable(join)) { | |
+ if (!IsCallable(join)) { | |
JSString *str = JS_BasicObjectToString(cx, obj); | |
if (!str) | |
return false; | |
args.rval().setString(str); | |
return true; | |
} | |
InvokeArgs args2(cx); | |
@@ -2994,16 +2994,17 @@ | |
JS_SELF_HOSTED_FN("lastIndexOf", "ArrayStaticLastIndexOf", 2,0), | |
JS_SELF_HOSTED_FN("indexOf", "ArrayStaticIndexOf", 2,0), | |
JS_SELF_HOSTED_FN("forEach", "ArrayStaticForEach", 2,0), | |
JS_SELF_HOSTED_FN("map", "ArrayStaticMap", 2,0), | |
JS_SELF_HOSTED_FN("every", "ArrayStaticEvery", 2,0), | |
JS_SELF_HOSTED_FN("some", "ArrayStaticSome", 2,0), | |
JS_SELF_HOSTED_FN("reduce", "ArrayStaticReduce", 2,0), | |
JS_SELF_HOSTED_FN("reduceRight", "ArrayStaticReduceRight", 2,0), | |
+ JS_SELF_HOSTED_FN("from", "ArrayFrom", 3,0), | |
JS_FN("of", array_of, 0,0), | |
#ifdef ENABLE_PARALLEL_JS | |
JS_SELF_HOSTED_FN("build", "ArrayStaticBuild", 2,0), | |
/* Parallelizable and pure static methods. */ | |
JS_SELF_HOSTED_FN("buildPar", "ArrayStaticBuildPar", 3,0), | |
#endif | |
diff -r bb4dd9872236 js/src/jsdate.cpp | |
--- a/js/src/jsdate.cpp Thu Mar 27 14:14:32 2014 +0100 | |
+++ b/js/src/jsdate.cpp Wed Apr 09 18:24:53 2014 -0500 | |
@@ -2474,17 +2474,17 @@ | |
} | |
/* Step 4. */ | |
RootedValue toISO(cx); | |
if (!JSObject::getProperty(cx, obj, obj, cx->names().toISOString, &toISO)) | |
return false; | |
/* Step 5. */ | |
- if (!js_IsCallable(toISO)) { | |
+ if (!IsCallable(toISO)) { | |
JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, js_GetErrorMessage, nullptr, | |
JSMSG_BAD_TOISOSTRING_PROP); | |
return false; | |
} | |
/* Step 6. */ | |
InvokeArgs args2(cx); | |
if (!args2.init(0)) | |
diff -r bb4dd9872236 js/src/jsfun.cpp | |
--- a/js/src/jsfun.cpp Thu Mar 27 14:14:32 2014 +0100 | |
+++ b/js/src/jsfun.cpp Wed Apr 09 18:24:53 2014 -0500 | |
@@ -916,17 +916,17 @@ | |
#endif | |
bool | |
js_fun_call(JSContext *cx, unsigned argc, Value *vp) | |
{ | |
CallArgs args = CallArgsFromVp(argc, vp); | |
HandleValue fval = args.thisv(); | |
- if (!js_IsCallable(fval)) { | |
+ if (!IsCallable(fval)) { | |
ReportIncompatibleMethod(cx, args, &JSFunction::class_); | |
return false; | |
} | |
args.setCallee(fval); | |
args.setThis(args.get(0)); | |
if (args.length() > 0) { | |
@@ -941,17 +941,17 @@ | |
// ES5 15.3.4.3 | |
bool | |
js_fun_apply(JSContext *cx, unsigned argc, Value *vp) | |
{ | |
CallArgs args = CallArgsFromVp(argc, vp); | |
// Step 1. | |
HandleValue fval = args.thisv(); | |
- if (!js_IsCallable(fval)) { | |
+ if (!IsCallable(fval)) { | |
ReportIncompatibleMethod(cx, args, &JSFunction::class_); | |
return false; | |
} | |
// Step 2. | |
if (args.length() < 2 || args[1].isNullOrUndefined()) | |
return js_fun_call(cx, (args.length() > 0) ? 1 : 0, vp); | |
@@ -1305,17 +1305,17 @@ | |
fun_bind(JSContext *cx, unsigned argc, Value *vp) | |
{ | |
CallArgs args = CallArgsFromVp(argc, vp); | |
/* Step 1. */ | |
Value thisv = args.thisv(); | |
/* Step 2. */ | |
- if (!js_IsCallable(thisv)) { | |
+ if (!IsCallable(thisv)) { | |
ReportIncompatibleMethod(cx, args, &JSFunction::class_); | |
return false; | |
} | |
/* Step 3. */ | |
Value *boundArgs = nullptr; | |
unsigned argslen = 0; | |
if (args.length() > 1) { | |
@@ -1821,33 +1821,16 @@ | |
RootedValue funVal(cx, ObjectValue(*fun)); | |
if (!JSObject::defineGeneric(cx, obj, id, funVal, gop, sop, flags & ~JSFUN_FLAGS_MASK)) | |
return nullptr; | |
return fun; | |
} | |
-bool | |
-js::IsConstructor(const Value &v) | |
-{ | |
- // Step 2. | |
- if (!v.isObject()) | |
- return false; | |
- | |
- // Step 3-4, a bit complex for us, since we have several flavors of | |
- // [[Construct]] internal method. | |
- JSObject &obj = v.toObject(); | |
- if (obj.is<JSFunction>()) { | |
- JSFunction &fun = obj.as<JSFunction>(); | |
- return fun.isNativeConstructor() || fun.isInterpretedConstructor(); | |
- } | |
- return obj.getClass()->construct != nullptr; | |
-} | |
- | |
void | |
js::ReportIncompatibleMethod(JSContext *cx, CallReceiver call, const Class *clasp) | |
{ | |
RootedValue thisv(cx, call.thisv()); | |
#ifdef DEBUG | |
if (thisv.isObject()) { | |
JS_ASSERT(thisv.toObject().getClass() != clasp || | |
diff -r bb4dd9872236 js/src/jsfun.h | |
--- a/js/src/jsfun.h Thu Mar 27 14:14:32 2014 +0100 | |
+++ b/js/src/jsfun.h Wed Apr 09 18:24:53 2014 -0500 | |
@@ -529,19 +529,16 @@ | |
bool | |
FunctionHasResolveHook(const JSAtomState &atomState, PropertyName *name); | |
extern bool | |
fun_resolve(JSContext *cx, HandleObject obj, HandleId id, | |
unsigned flags, MutableHandleObject objp); | |
-// ES6 9.2.5 IsConstructor | |
-bool IsConstructor(const Value &v); | |
- | |
/* | |
* Function extended with reserved slots for use by various kinds of functions. | |
* Most functions do not have these extensions, but enough do that efficient | |
* storage is required (no malloc'ed reserved slots). | |
*/ | |
class FunctionExtended : public JSFunction | |
{ | |
public: | |
diff -r bb4dd9872236 js/src/jsobj.cpp | |
--- a/js/src/jsobj.cpp Thu Mar 27 14:14:32 2014 +0100 | |
+++ b/js/src/jsobj.cpp Wed Apr 09 18:24:53 2014 -0500 | |
@@ -3330,16 +3330,26 @@ | |
if (shape->hasSlot()) | |
v = pobj->nativeGetSlot(shape->slot()); | |
} | |
if (v.isObject()) | |
protop.set(&v.toObject()); | |
return true; | |
} | |
+bool | |
+JSObject::isConstructor() const | |
+{ | |
+ if (is<JSFunction>()) { | |
+ const JSFunction &fun = as<JSFunction>(); | |
+ return fun.isNativeConstructor() || fun.isInterpretedConstructor(); | |
+ } | |
+ return getClass()->construct != nullptr; | |
+} | |
+ | |
/* static */ bool | |
JSObject::allocSlot(ThreadSafeContext *cx, HandleObject obj, uint32_t *slotp) | |
{ | |
JS_ASSERT(cx->isThreadLocal(obj)); | |
uint32_t slot = obj->slotSpan(); | |
JS_ASSERT(slot >= JSSLOT_FREE(obj->getClass())); | |
@@ -5299,17 +5309,17 @@ | |
* This is a mini-abstraction for ES5 8.12.8 [[DefaultValue]], either steps 1-2 | |
* or steps 3-4. | |
*/ | |
static bool | |
MaybeCallMethod(JSContext *cx, HandleObject obj, HandleId id, MutableHandleValue vp) | |
{ | |
if (!JSObject::getGeneric(cx, obj, obj, id, vp)) | |
return false; | |
- if (!js_IsCallable(vp)) { | |
+ if (!IsCallable(vp)) { | |
vp.setObject(*obj); | |
return true; | |
} | |
return Invoke(cx, ObjectValue(*obj), vp, 0, nullptr, vp); | |
} | |
JS_FRIEND_API(bool) | |
js::DefaultValue(JSContext *cx, HandleObject obj, JSType hint, MutableHandleValue vp) | |
diff -r bb4dd9872236 js/src/jsobj.h | |
--- a/js/src/jsobj.h Thu Mar 27 14:14:32 2014 +0100 | |
+++ b/js/src/jsobj.h Wed Apr 09 18:24:53 2014 -0500 | |
@@ -825,16 +825,17 @@ | |
static const uint32_t ITER_CLASS_NFIXED_SLOTS = 1; | |
/* | |
* Back to generic stuff. | |
*/ | |
bool isCallable() { | |
return getClass()->isCallable(); | |
} | |
+ bool isConstructor() const; | |
inline void finish(js::FreeOp *fop); | |
MOZ_ALWAYS_INLINE void finalize(js::FreeOp *fop); | |
static inline bool hasProperty(JSContext *cx, js::HandleObject obj, | |
js::HandleId id, bool *foundp, unsigned flags = 0); | |
/* | |
@@ -1204,38 +1205,49 @@ | |
} | |
struct JSObject_Slots2 : JSObject { js::Value fslots[2]; }; | |
struct JSObject_Slots4 : JSObject { js::Value fslots[4]; }; | |
struct JSObject_Slots8 : JSObject { js::Value fslots[8]; }; | |
struct JSObject_Slots12 : JSObject { js::Value fslots[12]; }; | |
struct JSObject_Slots16 : JSObject { js::Value fslots[16]; }; | |
-static inline bool | |
-js_IsCallable(const js::Value &v) | |
+namespace js { | |
+ | |
+inline bool | |
+IsCallable(const Value &v) | |
{ | |
return v.isObject() && v.toObject().isCallable(); | |
} | |
+// ES6 7.2.5 IsConstructor | |
+inline bool | |
+IsConstructor(const Value &v) | |
+{ | |
+ return v.isObject() && v.toObject().isConstructor(); | |
+} | |
+ | |
inline JSObject * | |
GetInnerObject(JSContext *cx, js::HandleObject obj) | |
{ | |
if (JSObjectOp op = obj->getClass()->ext.innerObject) | |
return op(cx, obj); | |
return obj; | |
} | |
inline JSObject * | |
GetOuterObject(JSContext *cx, js::HandleObject obj) | |
{ | |
if (JSObjectOp op = obj->getClass()->ext.outerObject) | |
return op(cx, obj); | |
return obj; | |
} | |
+} // namespace js | |
+ | |
class JSValueArray { | |
public: | |
const jsval *array; | |
size_t length; | |
JSValueArray(const jsval *v, size_t c) : array(v), length(c) {} | |
}; | |
diff -r bb4dd9872236 js/src/jsobjinlines.h | |
--- a/js/src/jsobjinlines.h Thu Mar 27 14:14:32 2014 +0100 | |
+++ b/js/src/jsobjinlines.h Wed Apr 09 18:24:53 2014 -0500 | |
@@ -668,18 +668,18 @@ | |
get_(getter), set_(setter), | |
attrs(JSPROP_GETTER | JSPROP_SETTER | JSPROP_SHARED | | |
(enumerable ? JSPROP_ENUMERATE : 0) | | |
(configurable ? 0 : JSPROP_PERMANENT)), | |
hasGet_(true), hasSet_(true), | |
hasValue_(false), hasWritable_(false), hasEnumerable_(true), hasConfigurable_(true), | |
isUndefined_(false) | |
{ | |
- MOZ_ASSERT(getter.isUndefined() || js_IsCallable(getter)); | |
- MOZ_ASSERT(setter.isUndefined() || js_IsCallable(setter)); | |
+ MOZ_ASSERT(getter.isUndefined() || IsCallable(getter)); | |
+ MOZ_ASSERT(setter.isUndefined() || IsCallable(setter)); | |
} | |
static MOZ_ALWAYS_INLINE bool | |
IsFunctionObject(const js::Value &v) | |
{ | |
return v.isObject() && v.toObject().is<JSFunction>(); | |
} | |
diff -r bb4dd9872236 js/src/json.cpp | |
--- a/js/src/json.cpp Thu Mar 27 14:14:32 2014 +0100 | |
+++ b/js/src/json.cpp Wed Apr 09 18:24:53 2014 -0500 | |
@@ -190,17 +190,17 @@ | |
/* Step 2. */ | |
if (vp.isObject()) { | |
RootedValue toJSON(cx); | |
RootedObject obj(cx, &vp.toObject()); | |
if (!JSObject::getProperty(cx, obj, obj, cx->names().toJSON, &toJSON)) | |
return false; | |
- if (js_IsCallable(toJSON)) { | |
+ if (IsCallable(toJSON)) { | |
keyStr = KeyStringifier<KeyType>::toString(cx, key); | |
if (!keyStr) | |
return false; | |
InvokeArgs args(cx); | |
if (!args.init(1)) | |
return false; | |
@@ -262,17 +262,17 @@ | |
* gauntlet will result in Str returning |undefined|. This function is used to | |
* properly omit properties resulting in such values when stringifying objects, | |
* while properly stringifying such properties as null when they're encountered | |
* in arrays. | |
*/ | |
static inline bool | |
IsFilteredValue(const Value &v) | |
{ | |
- return v.isUndefined() || js_IsCallable(v); | |
+ return v.isUndefined() || IsCallable(v); | |
} | |
/* ES5 15.12.3 JO. */ | |
static bool | |
JO(JSContext *cx, HandleObject obj, StringifyContext *scx) | |
{ | |
/* | |
* This method implements the JO algorithm in ES5 15.12.3, but: | |
@@ -778,17 +778,17 @@ | |
HandleValue reviver, MutableHandleValue vp) | |
{ | |
/* 15.12.2 steps 2-3. */ | |
JSONParser parser(cx, chars, length); | |
if (!parser.parse(vp)) | |
return false; | |
/* 15.12.2 steps 4-5. */ | |
- if (js_IsCallable(reviver)) | |
+ if (IsCallable(reviver)) | |
return Revive(cx, reviver, vp); | |
return true; | |
} | |
#if JS_HAS_TOSOURCE | |
static bool | |
json_toSource(JSContext *cx, unsigned argc, Value *vp) | |
{ | |
diff -r bb4dd9872236 js/src/jsproxy.cpp | |
--- a/js/src/jsproxy.cpp Thu Mar 27 14:14:32 2014 +0100 | |
+++ b/js/src/jsproxy.cpp Wed Apr 09 18:24:53 2014 -0500 | |
@@ -936,30 +936,30 @@ | |
bool | |
ScriptedIndirectProxyHandler::has(JSContext *cx, HandleObject proxy, HandleId id, bool *bp) | |
{ | |
RootedObject handler(cx, GetIndirectProxyHandlerObject(proxy)); | |
RootedValue fval(cx), value(cx); | |
if (!GetDerivedTrap(cx, handler, cx->names().has, &fval)) | |
return false; | |
- if (!js_IsCallable(fval)) | |
+ if (!IsCallable(fval)) | |
return BaseProxyHandler::has(cx, proxy, id, bp); | |
return Trap1(cx, handler, fval, id, &value) && | |
ValueToBool(value, bp); | |
} | |
bool | |
ScriptedIndirectProxyHandler::hasOwn(JSContext *cx, HandleObject proxy, HandleId id, bool *bp) | |
{ | |
RootedObject handler(cx, GetIndirectProxyHandlerObject(proxy)); | |
RootedValue fval(cx), value(cx); | |
if (!GetDerivedTrap(cx, handler, cx->names().hasOwn, &fval)) | |
return false; | |
- if (!js_IsCallable(fval)) | |
+ if (!IsCallable(fval)) | |
return BaseProxyHandler::hasOwn(cx, proxy, id, bp); | |
return Trap1(cx, handler, fval, id, &value) && | |
ValueToBool(value, bp); | |
} | |
bool | |
ScriptedIndirectProxyHandler::get(JSContext *cx, HandleObject proxy, HandleObject receiver, | |
HandleId id, MutableHandleValue vp) | |
@@ -971,17 +971,17 @@ | |
return false; | |
RootedValue value(cx, StringValue(str)); | |
JS::AutoValueArray<2> argv(cx); | |
argv[0].setObjectOrNull(receiver); | |
argv[1].set(value); | |
RootedValue fval(cx); | |
if (!GetDerivedTrap(cx, handler, cx->names().get, &fval)) | |
return false; | |
- if (!js_IsCallable(fval)) | |
+ if (!IsCallable(fval)) | |
return BaseProxyHandler::get(cx, proxy, receiver, id, vp); | |
return Trap(cx, handler, fval, 2, argv.begin(), vp); | |
} | |
bool | |
ScriptedIndirectProxyHandler::set(JSContext *cx, HandleObject proxy, HandleObject receiver, | |
HandleId id, bool strict, MutableHandleValue vp) | |
{ | |
@@ -993,43 +993,43 @@ | |
RootedValue value(cx, StringValue(str)); | |
JS::AutoValueArray<3> argv(cx); | |
argv[0].setObjectOrNull(receiver); | |
argv[1].set(value); | |
argv[2].set(vp); | |
RootedValue fval(cx); | |
if (!GetDerivedTrap(cx, handler, cx->names().set, &fval)) | |
return false; | |
- if (!js_IsCallable(fval)) | |
+ if (!IsCallable(fval)) | |
return BaseProxyHandler::set(cx, proxy, receiver, id, strict, vp); | |
return Trap(cx, handler, fval, 3, argv.begin(), &value); | |
} | |
bool | |
ScriptedIndirectProxyHandler::keys(JSContext *cx, HandleObject proxy, AutoIdVector &props) | |
{ | |
RootedObject handler(cx, GetIndirectProxyHandlerObject(proxy)); | |
RootedValue value(cx); | |
if (!GetDerivedTrap(cx, handler, cx->names().keys, &value)) | |
return false; | |
- if (!js_IsCallable(value)) | |
+ if (!IsCallable(value)) | |
return BaseProxyHandler::keys(cx, proxy, props); | |
return Trap(cx, handler, value, 0, nullptr, &value) && | |
ArrayToIdVector(cx, value, props); | |
} | |
bool | |
ScriptedIndirectProxyHandler::iterate(JSContext *cx, HandleObject proxy, unsigned flags, | |
MutableHandleValue vp) | |
{ | |
RootedObject handler(cx, GetIndirectProxyHandlerObject(proxy)); | |
RootedValue value(cx); | |
if (!GetDerivedTrap(cx, handler, cx->names().iterate, &value)) | |
return false; | |
- if (!js_IsCallable(value)) | |
+ if (!IsCallable(value)) | |
return BaseProxyHandler::iterate(cx, proxy, flags, vp); | |
return Trap(cx, handler, value, 0, nullptr, vp) && | |
ReturnedValueMustNotBePrimitive(cx, proxy, cx->names().iterate, vp); | |
} | |
bool | |
ScriptedIndirectProxyHandler::call(JSContext *cx, HandleObject proxy, const CallArgs &args) | |
{ | |
diff -r bb4dd9872236 js/src/jsstr.cpp | |
--- a/js/src/jsstr.cpp Thu Mar 27 14:14:32 2014 +0100 | |
+++ b/js/src/jsstr.cpp Wed Apr 09 18:24:53 2014 -0500 | |
@@ -3027,17 +3027,17 @@ | |
rdata.str = ThisToStringForStringProto(cx, args); | |
if (!rdata.str) | |
return false; | |
if (!rdata.g.init(cx, args)) | |
return false; | |
/* Extract replacement string/function. */ | |
- if (args.length() >= ReplaceOptArg && js_IsCallable(args[1])) { | |
+ if (args.length() >= ReplaceOptArg && IsCallable(args[1])) { | |
rdata.setReplacementFunction(&args[1].toObject()); | |
if (!LambdaIsGetElem(cx, *rdata.lambda, &rdata.elembase)) | |
return false; | |
} else { | |
JSLinearString *string = ArgToRootedString(cx, args, 1); | |
if (!string) | |
return false; | |
@@ -4163,17 +4163,17 @@ | |
} | |
return ToString<CanGC>(cx, v); | |
} | |
RootedValue fval(cx); | |
RootedObject obj(cx, &v.toObject()); | |
if (!JSObject::getProperty(cx, obj, obj, cx->names().toSource, &fval)) | |
return nullptr; | |
- if (js_IsCallable(fval)) { | |
+ if (IsCallable(fval)) { | |
RootedValue rval(cx); | |
if (!Invoke(cx, ObjectValue(*obj), fval, 0, nullptr, &rval)) | |
return nullptr; | |
return ToString<CanGC>(cx, rval); | |
} | |
return ObjectToSource(cx, obj); | |
} | |
diff -r bb4dd9872236 js/src/vm/Debugger.cpp | |
--- a/js/src/vm/Debugger.cpp Thu Mar 27 14:14:32 2014 +0100 | |
+++ b/js/src/vm/Debugger.cpp Wed Apr 09 18:24:53 2014 -0500 | |
@@ -968,17 +968,17 @@ | |
rval.setUndefined(); | |
JSAtom *atom = Atomize(cx, name, strlen(name)); | |
if (!atom) | |
return false; | |
RootedId id(cx, AtomToId(atom)); | |
RootedValue fval(cx); | |
return JSObject::getGeneric(cx, obj, obj, id, &fval) && | |
- (!js_IsCallable(fval) || Invoke(cx, ObjectValue(*obj), fval, argc, argv, rval)); | |
+ (!IsCallable(fval) || Invoke(cx, ObjectValue(*obj), fval, argc, argv, rval)); | |
} | |
JSTrapStatus | |
Debugger::fireDebuggerStatement(JSContext *cx, MutableHandleValue vp) | |
{ | |
RootedObject hook(cx, getHook(OnDebuggerStatement)); | |
JS_ASSERT(hook); | |
JS_ASSERT(hook->isCallable()); | |
diff -r bb4dd9872236 js/src/vm/ObjectImpl.cpp | |
--- a/js/src/vm/ObjectImpl.cpp Thu Mar 27 14:14:32 2014 +0100 | |
+++ b/js/src/vm/ObjectImpl.cpp Wed Apr 09 18:24:53 2014 -0500 | |
@@ -32,30 +32,30 @@ | |
isUndefined_(true) | |
{ | |
} | |
bool | |
PropDesc::checkGetter(JSContext *cx) | |
{ | |
if (hasGet_) { | |
- if (!js_IsCallable(get_) && !get_.isUndefined()) { | |
+ if (!IsCallable(get_) && !get_.isUndefined()) { | |
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_GET_SET_FIELD, | |
js_getter_str); | |
return false; | |
} | |
} | |
return true; | |
} | |
bool | |
PropDesc::checkSetter(JSContext *cx) | |
{ | |
if (hasSet_) { | |
- if (!js_IsCallable(set_) && !set_.isUndefined()) { | |
+ if (!IsCallable(set_) && !set_.isUndefined()) { | |
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_GET_SET_FIELD, | |
js_setter_str); | |
return false; | |
} | |
} | |
return true; | |
} | |
diff -r bb4dd9872236 js/src/vm/SelfHosting.cpp | |
--- a/js/src/vm/SelfHosting.cpp Thu Mar 27 14:14:32 2014 +0100 | |
+++ b/js/src/vm/SelfHosting.cpp Wed Apr 09 18:24:53 2014 -0500 | |
@@ -68,19 +68,25 @@ | |
args.rval().setDouble(result); | |
return true; | |
} | |
bool | |
js::intrinsic_IsCallable(JSContext *cx, unsigned argc, Value *vp) | |
{ | |
CallArgs args = CallArgsFromVp(argc, vp); | |
- Value val = args[0]; | |
- bool isCallable = val.isObject() && val.toObject().isCallable(); | |
- args.rval().setBoolean(isCallable); | |
+ args.rval().setBoolean(IsCallable(args[0])); | |
+ return true; | |
+} | |
+ | |
+static bool | |
+intrinsic_IsConstructor(JSContext *cx, unsigned argc, Value *vp) | |
+{ | |
+ CallArgs args = CallArgsFromVp(argc, vp); | |
+ args.rval().setBoolean(IsConstructor(args[0])); | |
return true; | |
} | |
bool | |
js::intrinsic_ThrowError(JSContext *cx, unsigned argc, Value *vp) | |
{ | |
CallArgs args = CallArgsFromVp(argc, vp); | |
JS_ASSERT(args.length() >= 1); | |
@@ -693,16 +699,17 @@ | |
args.rval().setString(jslocale); | |
return true; | |
} | |
static const JSFunctionSpec intrinsic_functions[] = { | |
JS_FN("ToObject", intrinsic_ToObject, 1,0), | |
JS_FN("ToInteger", intrinsic_ToInteger, 1,0), | |
JS_FN("IsCallable", intrinsic_IsCallable, 1,0), | |
+ JS_FN("IsConstructor", intrinsic_IsConstructor, 1,0), | |
JS_FN("ThrowError", intrinsic_ThrowError, 4,0), | |
JS_FN("AssertionFailed", intrinsic_AssertionFailed, 1,0), | |
JS_FN("SetScriptHints", intrinsic_SetScriptHints, 2,0), | |
JS_FN("MakeConstructible", intrinsic_MakeConstructible, 1,0), | |
JS_FN("DecompileArg", intrinsic_DecompileArg, 2,0), | |
JS_FN("RuntimeDefaultLocale", intrinsic_RuntimeDefaultLocale, 0,0), | |
JS_FN("UnsafePutElements", intrinsic_UnsafePutElements, 3,0), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment