2010-08-11 23:26:59 -07:00
|
|
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
* vim: set ts=8 sw=4 et tw=99:
|
|
|
|
*
|
|
|
|
* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is SpiderMonkey.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* the Mozilla Foundation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2010
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#ifndef jsfuninlines_h___
|
|
|
|
#define jsfuninlines_h___
|
|
|
|
|
|
|
|
#include "jsfun.h"
|
|
|
|
#include "jsscript.h"
|
|
|
|
|
2011-05-09 13:06:53 -07:00
|
|
|
#include "vm/GlobalObject.h"
|
|
|
|
|
2012-01-02 15:02:05 -08:00
|
|
|
#include "vm/ScopeObject-inl.h"
|
|
|
|
|
2010-08-11 23:26:59 -07:00
|
|
|
inline bool
|
|
|
|
JSFunction::inStrictMode() const
|
|
|
|
{
|
2010-12-22 18:06:08 -08:00
|
|
|
return script()->strictModeCode;
|
2010-08-11 23:26:59 -07:00
|
|
|
}
|
|
|
|
|
2011-10-12 22:29:43 -07:00
|
|
|
inline JSObject *
|
2011-11-08 13:42:27 -08:00
|
|
|
JSFunction::environment() const
|
2011-10-12 22:29:43 -07:00
|
|
|
{
|
|
|
|
JS_ASSERT(isInterpreted());
|
2011-12-15 09:41:04 -08:00
|
|
|
return u.i.env_;
|
2011-10-13 12:10:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
2011-11-08 13:42:27 -08:00
|
|
|
JSFunction::setEnvironment(JSObject *obj)
|
2011-10-13 12:10:52 -07:00
|
|
|
{
|
|
|
|
JS_ASSERT(isInterpreted());
|
2011-12-15 09:41:04 -08:00
|
|
|
*(js::HeapPtrObject *)&u.i.env_ = obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
|
|
|
JSFunction::initEnvironment(JSObject *obj)
|
|
|
|
{
|
|
|
|
JS_ASSERT(isInterpreted());
|
|
|
|
((js::HeapPtrObject *)&u.i.env_)->init(obj);
|
2011-10-12 22:29:43 -07:00
|
|
|
}
|
|
|
|
|
2011-11-14 13:03:50 -08:00
|
|
|
inline void
|
|
|
|
JSFunction::initializeExtended()
|
|
|
|
{
|
|
|
|
JS_ASSERT(isExtended());
|
|
|
|
|
2011-11-18 15:20:21 -08:00
|
|
|
JS_ASSERT(js::ArrayLength(toExtended()->extendedSlots) == 2);
|
2011-11-14 13:03:50 -08:00
|
|
|
toExtended()->extendedSlots[0].init(js::UndefinedValue());
|
|
|
|
toExtended()->extendedSlots[1].init(js::UndefinedValue());
|
|
|
|
}
|
|
|
|
|
2011-07-13 15:43:33 -07:00
|
|
|
inline void
|
|
|
|
JSFunction::setJoinable()
|
|
|
|
{
|
2011-08-18 10:39:44 -07:00
|
|
|
JS_ASSERT(isInterpreted());
|
2011-07-13 15:43:33 -07:00
|
|
|
flags |= JSFUN_JOINABLE;
|
|
|
|
}
|
|
|
|
|
2011-10-11 15:28:54 -07:00
|
|
|
inline bool
|
|
|
|
JSFunction::isClonedMethod() const
|
|
|
|
{
|
2011-11-14 09:13:33 -08:00
|
|
|
return joinable() && isExtended() && getExtendedSlot(METHOD_OBJECT_SLOT).isObject();
|
2011-10-26 13:02:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
inline JSAtom *
|
|
|
|
JSFunction::methodAtom() const
|
|
|
|
{
|
2011-11-15 08:58:06 -08:00
|
|
|
return (joinable() && isExtended() && getExtendedSlot(METHOD_PROPERTY_SLOT).isString())
|
2011-11-14 09:13:33 -08:00
|
|
|
? (JSAtom *) getExtendedSlot(METHOD_PROPERTY_SLOT).toString()
|
|
|
|
: NULL;
|
2011-10-11 15:28:54 -07:00
|
|
|
}
|
|
|
|
|
2011-07-13 15:43:33 -07:00
|
|
|
inline void
|
|
|
|
JSFunction::setMethodAtom(JSAtom *atom)
|
|
|
|
{
|
|
|
|
JS_ASSERT(joinable());
|
2011-11-14 09:13:33 -08:00
|
|
|
setExtendedSlot(METHOD_PROPERTY_SLOT, js::StringValue(atom));
|
2011-07-13 15:43:33 -07:00
|
|
|
}
|
|
|
|
|
2011-10-26 13:02:57 -07:00
|
|
|
inline JSObject *
|
|
|
|
JSFunction::methodObj() const
|
2011-10-04 18:46:03 -07:00
|
|
|
{
|
2011-10-26 13:02:57 -07:00
|
|
|
JS_ASSERT(joinable());
|
2011-11-14 09:13:33 -08:00
|
|
|
return isClonedMethod() ? &getExtendedSlot(METHOD_OBJECT_SLOT).toObject() : NULL;
|
2011-10-04 18:46:03 -07:00
|
|
|
}
|
|
|
|
|
2011-10-11 15:28:54 -07:00
|
|
|
inline void
|
|
|
|
JSFunction::setMethodObj(JSObject& obj)
|
2011-10-04 18:46:03 -07:00
|
|
|
{
|
2011-10-26 13:02:57 -07:00
|
|
|
JS_ASSERT(joinable());
|
2011-11-14 09:13:33 -08:00
|
|
|
setExtendedSlot(METHOD_OBJECT_SLOT, js::ObjectValue(obj));
|
2011-10-26 13:02:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
2011-11-14 09:13:33 -08:00
|
|
|
JSFunction::setExtendedSlot(size_t which, const js::Value &val)
|
2011-10-26 13:02:57 -07:00
|
|
|
{
|
2011-11-18 15:20:21 -08:00
|
|
|
JS_ASSERT(which < js::ArrayLength(toExtended()->extendedSlots));
|
2011-11-14 09:13:33 -08:00
|
|
|
toExtended()->extendedSlots[which] = val;
|
2011-10-26 13:02:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
inline const js::Value &
|
2011-11-14 09:13:33 -08:00
|
|
|
JSFunction::getExtendedSlot(size_t which) const
|
2011-10-26 13:02:57 -07:00
|
|
|
{
|
2011-11-18 15:20:21 -08:00
|
|
|
JS_ASSERT(which < js::ArrayLength(toExtended()->extendedSlots));
|
2011-11-14 09:13:33 -08:00
|
|
|
return toExtended()->extendedSlots[which];
|
2011-10-26 13:02:57 -07:00
|
|
|
}
|
|
|
|
|
2011-11-14 09:13:33 -08:00
|
|
|
inline bool
|
|
|
|
JSFunction::hasFlatClosureUpvars() const
|
2011-10-26 13:02:57 -07:00
|
|
|
{
|
|
|
|
JS_ASSERT(isFlatClosure());
|
2011-11-14 09:13:33 -08:00
|
|
|
return isExtended() && !getExtendedSlot(FLAT_CLOSURE_UPVARS_SLOT).isUndefined();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline js::HeapValue *
|
|
|
|
JSFunction::getFlatClosureUpvars() const
|
|
|
|
{
|
|
|
|
JS_ASSERT(hasFlatClosureUpvars());
|
|
|
|
return (js::HeapValue *) getExtendedSlot(FLAT_CLOSURE_UPVARS_SLOT).toPrivate();
|
2011-10-26 13:02:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
|
|
|
JSFunction::finalizeUpvars()
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Cloned function objects may be flat closures with upvars to free.
|
|
|
|
*
|
|
|
|
* We must not access JSScript here that is stored in JSFunction. The
|
|
|
|
* script can be finalized before the function or closure instances. So we
|
|
|
|
* just check if JSSLOT_FLAT_CLOSURE_UPVARS holds a private value encoded
|
|
|
|
* as a double. We must also ignore newborn closures that do not have the
|
|
|
|
* private pointer set.
|
|
|
|
*
|
|
|
|
* FIXME bug 648320 - allocate upvars on the GC heap to avoid doing it
|
|
|
|
* here explicitly.
|
|
|
|
*/
|
2011-11-14 09:13:33 -08:00
|
|
|
if (hasFlatClosureUpvars()) {
|
|
|
|
js::HeapValue *upvars = getFlatClosureUpvars();
|
|
|
|
js::Foreground::free_(upvars);
|
|
|
|
}
|
2011-10-26 13:02:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
inline js::Value
|
Bug 708735 - Use <stdint.h> types in JSAPI and throughout SpiderMonkey. Continue to provide the {u,}int{8,16,32,64} and JS{Uint,Int}{8,16,32,64} integer types through a single header, however, for a simpler backout strategy -- and also to ease the transition for embedders. r=timeless on switching the jsd API to use the <stdint.h> types, r=luke, r=dmandelin
2011-12-08 19:54:10 -08:00
|
|
|
JSFunction::getFlatClosureUpvar(uint32_t i) const
|
2011-10-26 13:02:57 -07:00
|
|
|
{
|
2011-11-14 09:13:33 -08:00
|
|
|
JS_ASSERT(hasFlatClosureUpvars());
|
|
|
|
JS_ASSERT(script()->bindings.countUpvars() == script()->upvars()->length);
|
2011-10-26 13:02:57 -07:00
|
|
|
JS_ASSERT(i < script()->bindings.countUpvars());
|
|
|
|
return getFlatClosureUpvars()[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
Bug 708735 - Use <stdint.h> types in JSAPI and throughout SpiderMonkey. Continue to provide the {u,}int{8,16,32,64} and JS{Uint,Int}{8,16,32,64} integer types through a single header, however, for a simpler backout strategy -- and also to ease the transition for embedders. r=timeless on switching the jsd API to use the <stdint.h> types, r=luke, r=dmandelin
2011-12-08 19:54:10 -08:00
|
|
|
JSFunction::setFlatClosureUpvar(uint32_t i, const js::Value &v)
|
2011-10-26 13:02:57 -07:00
|
|
|
{
|
2011-11-14 09:13:33 -08:00
|
|
|
JS_ASSERT(isFlatClosure());
|
|
|
|
JS_ASSERT(script()->bindings.countUpvars() == script()->upvars()->length);
|
2011-10-26 13:02:57 -07:00
|
|
|
JS_ASSERT(i < script()->bindings.countUpvars());
|
|
|
|
getFlatClosureUpvars()[i] = v;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
Bug 708735 - Use <stdint.h> types in JSAPI and throughout SpiderMonkey. Continue to provide the {u,}int{8,16,32,64} and JS{Uint,Int}{8,16,32,64} integer types through a single header, however, for a simpler backout strategy -- and also to ease the transition for embedders. r=timeless on switching the jsd API to use the <stdint.h> types, r=luke, r=dmandelin
2011-12-08 19:54:10 -08:00
|
|
|
JSFunction::initFlatClosureUpvar(uint32_t i, const js::Value &v)
|
2011-10-26 13:02:57 -07:00
|
|
|
{
|
|
|
|
JS_ASSERT(isFlatClosure());
|
2011-11-14 09:13:33 -08:00
|
|
|
JS_ASSERT(script()->bindings.countUpvars() == script()->upvars()->length);
|
|
|
|
JS_ASSERT(i < script()->bindings.countUpvars());
|
|
|
|
getFlatClosureUpvars()[i].init(v);
|
2011-10-26 13:02:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ inline size_t
|
|
|
|
JSFunction::getFlatClosureUpvarsOffset()
|
|
|
|
{
|
2011-11-14 09:13:33 -08:00
|
|
|
return offsetof(js::FunctionExtended, extendedSlots[FLAT_CLOSURE_UPVARS_SLOT]);
|
2011-10-04 18:46:03 -07:00
|
|
|
}
|
|
|
|
|
2011-10-11 15:28:54 -07:00
|
|
|
namespace js {
|
|
|
|
|
2011-10-04 18:46:03 -07:00
|
|
|
static JS_ALWAYS_INLINE bool
|
2011-10-11 15:28:54 -07:00
|
|
|
IsFunctionObject(const js::Value &v)
|
2011-10-04 18:46:03 -07:00
|
|
|
{
|
2011-10-11 15:28:54 -07:00
|
|
|
return v.isObject() && v.toObject().isFunction();
|
2011-10-04 18:46:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static JS_ALWAYS_INLINE bool
|
|
|
|
IsFunctionObject(const js::Value &v, JSFunction **fun)
|
|
|
|
{
|
2011-10-11 15:28:54 -07:00
|
|
|
if (v.isObject() && v.toObject().isFunction()) {
|
|
|
|
*fun = v.toObject().toFunction();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2011-10-04 18:46:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static JS_ALWAYS_INLINE bool
|
|
|
|
IsNativeFunction(const js::Value &v)
|
|
|
|
{
|
|
|
|
JSFunction *fun;
|
|
|
|
return IsFunctionObject(v, &fun) && fun->isNative();
|
|
|
|
}
|
|
|
|
|
|
|
|
static JS_ALWAYS_INLINE bool
|
|
|
|
IsNativeFunction(const js::Value &v, JSFunction **fun)
|
|
|
|
{
|
|
|
|
return IsFunctionObject(v, fun) && (*fun)->isNative();
|
|
|
|
}
|
|
|
|
|
|
|
|
static JS_ALWAYS_INLINE bool
|
|
|
|
IsNativeFunction(const js::Value &v, JSNative native)
|
|
|
|
{
|
|
|
|
JSFunction *fun;
|
|
|
|
return IsFunctionObject(v, &fun) && fun->maybeNative() == native;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* When we have an object of a builtin class, we don't quite know what its
|
|
|
|
* valueOf/toString methods are, since these methods may have been overwritten
|
|
|
|
* or shadowed. However, we can still do better than the general case by
|
|
|
|
* hard-coding the necessary properties for us to find the native we expect.
|
|
|
|
*
|
|
|
|
* TODO: a per-thread shape-based cache would be faster and simpler.
|
|
|
|
*/
|
|
|
|
static JS_ALWAYS_INLINE bool
|
|
|
|
ClassMethodIsNative(JSContext *cx, JSObject *obj, Class *clasp, jsid methodid, JSNative native)
|
|
|
|
{
|
|
|
|
JS_ASSERT(obj->getClass() == clasp);
|
|
|
|
|
|
|
|
Value v;
|
|
|
|
if (!HasDataProperty(cx, obj, methodid, &v)) {
|
|
|
|
JSObject *proto = obj->getProto();
|
|
|
|
if (!proto || proto->getClass() != clasp || !HasDataProperty(cx, proto, methodid, &v))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return js::IsNativeFunction(v, native);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern JS_ALWAYS_INLINE bool
|
|
|
|
SameTraceType(const Value &lhs, const Value &rhs)
|
|
|
|
{
|
|
|
|
return SameType(lhs, rhs) &&
|
|
|
|
(lhs.isPrimitive() ||
|
|
|
|
lhs.toObject().isFunction() == rhs.toObject().isFunction());
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Valueified JS_IsConstructing. */
|
|
|
|
static JS_ALWAYS_INLINE bool
|
|
|
|
IsConstructing(const Value *vp)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
JSObject *callee = &JS_CALLEE(cx, vp).toObject();
|
|
|
|
if (callee->isFunction()) {
|
2011-10-11 15:28:54 -07:00
|
|
|
JSFunction *fun = callee->toFunction();
|
2011-10-04 18:46:03 -07:00
|
|
|
JS_ASSERT((fun->flags & JSFUN_CONSTRUCTOR) != 0);
|
|
|
|
} else {
|
|
|
|
JS_ASSERT(callee->getClass()->construct != NULL);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return vp[1].isMagic();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool
|
|
|
|
IsConstructing(CallReceiver call)
|
|
|
|
{
|
|
|
|
return IsConstructing(call.base());
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const char *
|
|
|
|
GetFunctionNameBytes(JSContext *cx, JSFunction *fun, JSAutoByteString *bytes)
|
|
|
|
{
|
|
|
|
if (fun->atom)
|
|
|
|
return bytes->encode(cx, fun->atom);
|
|
|
|
return js_anonymous_str;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern JSFunctionSpec function_methods[];
|
|
|
|
|
|
|
|
extern JSBool
|
2012-02-28 15:11:11 -08:00
|
|
|
Function(JSContext *cx, unsigned argc, Value *vp);
|
2011-10-04 18:46:03 -07:00
|
|
|
|
|
|
|
extern bool
|
|
|
|
IsBuiltinFunctionConstructor(JSFunction *fun);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Preconditions: funobj->isInterpreted() && !funobj->isFunctionPrototype() &&
|
|
|
|
* !funobj->isBoundFunction(). This is sufficient to establish that funobj has
|
|
|
|
* a non-configurable non-method .prototype data property, thought it might not
|
|
|
|
* have been resolved yet, and its value could be anything.
|
|
|
|
*
|
|
|
|
* Return the shape of the .prototype property of funobj, resolving it if
|
|
|
|
* needed. On error, return NULL.
|
|
|
|
*
|
|
|
|
* This is not safe to call on trace because it defines properties, which can
|
|
|
|
* trigger lookups that could reenter.
|
|
|
|
*/
|
|
|
|
const Shape *
|
|
|
|
LookupInterpretedFunctionPrototype(JSContext *cx, JSObject *funobj);
|
|
|
|
|
2011-10-19 08:12:44 -07:00
|
|
|
static inline JSObject *
|
|
|
|
SkipScopeParent(JSObject *parent)
|
|
|
|
{
|
|
|
|
if (!parent)
|
|
|
|
return NULL;
|
2012-01-02 15:02:05 -08:00
|
|
|
while (parent->isScope())
|
|
|
|
parent = &parent->asScope().enclosingScope();
|
2011-10-19 08:12:44 -07:00
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
2011-10-12 22:29:43 -07:00
|
|
|
inline JSFunction *
|
|
|
|
CloneFunctionObject(JSContext *cx, JSFunction *fun, JSObject *parent,
|
2011-10-26 13:02:57 -07:00
|
|
|
gc::AllocKind kind = JSFunction::FinalizeKind)
|
2011-10-12 22:29:43 -07:00
|
|
|
{
|
|
|
|
JS_ASSERT(parent);
|
2012-01-02 15:02:05 -08:00
|
|
|
JSObject *proto = parent->global().getOrCreateFunctionPrototype(cx);
|
2011-05-09 13:06:53 -07:00
|
|
|
if (!proto)
|
2011-10-12 22:29:43 -07:00
|
|
|
return NULL;
|
|
|
|
|
2011-10-26 13:02:57 -07:00
|
|
|
return js_CloneFunctionObject(cx, fun, parent, proto, kind);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline JSFunction *
|
|
|
|
CloneFunctionObjectIfNotSingleton(JSContext *cx, JSFunction *fun, JSObject *parent)
|
|
|
|
{
|
2011-10-12 22:29:43 -07:00
|
|
|
/*
|
|
|
|
* For attempts to clone functions at a function definition opcode or from
|
|
|
|
* a method barrier, don't perform the clone if the function has singleton
|
2011-10-26 13:02:57 -07:00
|
|
|
* type. This was called pessimistically, and we need to preserve the
|
|
|
|
* type's property that if it is singleton there is only a single object
|
|
|
|
* with its type in existence.
|
2011-10-12 22:29:43 -07:00
|
|
|
*/
|
2011-10-26 13:02:57 -07:00
|
|
|
if (fun->hasSingletonType()) {
|
2011-10-19 08:12:44 -07:00
|
|
|
if (!fun->setParent(cx, SkipScopeParent(parent)))
|
|
|
|
return NULL;
|
2011-11-08 13:42:27 -08:00
|
|
|
fun->setEnvironment(parent);
|
2011-10-12 22:29:43 -07:00
|
|
|
return fun;
|
|
|
|
}
|
|
|
|
|
2011-10-26 13:02:57 -07:00
|
|
|
return CloneFunctionObject(cx, fun, parent);
|
2011-10-12 22:29:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
inline JSFunction *
|
|
|
|
CloneFunctionObject(JSContext *cx, JSFunction *fun)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Variant which makes an exact clone of fun, preserving parent and proto.
|
|
|
|
* Calling the above version CloneFunctionObject(cx, fun, fun->getParent())
|
|
|
|
* is not equivalent: API clients, including XPConnect, can reparent
|
2012-01-02 15:02:05 -08:00
|
|
|
* objects so that fun->global() != fun->getProto()->global().
|
2011-10-12 22:29:43 -07:00
|
|
|
* See ReparentWrapperIfFound.
|
|
|
|
*/
|
|
|
|
JS_ASSERT(fun->getParent() && fun->getProto());
|
|
|
|
|
|
|
|
if (fun->hasSingletonType())
|
|
|
|
return fun;
|
|
|
|
|
2011-11-08 13:42:27 -08:00
|
|
|
return js_CloneFunctionObject(cx, fun, fun->environment(), fun->getProto(),
|
2011-10-26 13:02:57 -07:00
|
|
|
JSFunction::ExtendedFinalizeKind);
|
2011-10-12 22:29:43 -07:00
|
|
|
}
|
|
|
|
|
2011-10-04 18:46:03 -07:00
|
|
|
} /* namespace js */
|
|
|
|
|
2011-10-25 16:07:42 -07:00
|
|
|
inline void
|
|
|
|
JSFunction::setScript(JSScript *script_)
|
|
|
|
{
|
|
|
|
JS_ASSERT(isInterpreted());
|
|
|
|
script() = script_;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
|
|
|
JSFunction::initScript(JSScript *script_)
|
|
|
|
{
|
|
|
|
JS_ASSERT(isInterpreted());
|
|
|
|
script().init(script_);
|
|
|
|
}
|
|
|
|
|
2010-08-11 23:26:59 -07:00
|
|
|
#endif /* jsfuninlines_h___ */
|