2009-06-10 18:29:44 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4; -*-
|
2009-09-30 15:28:00 -07:00
|
|
|
* vim: set ts=4 sw=4 et tw=99:
|
2008-07-05 17:29:55 -07:00
|
|
|
*
|
|
|
|
* ***** 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 Mozilla SpiderMonkey JavaScript 1.9 code, released
|
|
|
|
* May 28, 2008.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Andreas Gal <gal@mozilla.com>
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Brendan Eich <brendan@mozilla.org>
|
2008-07-15 15:05:16 -07:00
|
|
|
* Mike Shaver <shaver@mozilla.org>
|
|
|
|
* David Anderson <danderson@mozilla.com>
|
2008-07-05 17:29:55 -07:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either of 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 ***** */
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#include "jsapi.h"
|
2009-03-18 11:38:16 -07:00
|
|
|
#include "jsstdint.h"
|
2008-07-27 15:34:23 -07:00
|
|
|
#include "jsarray.h"
|
|
|
|
#include "jsbool.h"
|
2008-07-05 17:29:55 -07:00
|
|
|
#include "jscntxt.h"
|
2008-08-06 13:36:29 -07:00
|
|
|
#include "jsgc.h"
|
|
|
|
#include "jsiter.h"
|
2009-07-11 12:40:37 -07:00
|
|
|
#include "jsnum.h"
|
2008-09-08 20:06:58 -07:00
|
|
|
#include "jslibmath.h"
|
2008-07-30 15:51:44 -07:00
|
|
|
#include "jsmath.h"
|
2008-08-06 13:36:29 -07:00
|
|
|
#include "jsnum.h"
|
2008-09-26 11:37:50 -07:00
|
|
|
#include "prmjtime.h"
|
2008-10-06 17:28:22 -07:00
|
|
|
#include "jsdate.h"
|
2008-08-08 14:38:44 -07:00
|
|
|
#include "jsscope.h"
|
2008-07-29 07:32:18 -07:00
|
|
|
#include "jsstr.h"
|
2008-10-08 15:08:33 -07:00
|
|
|
#include "jsbuiltins.h"
|
2008-10-12 15:39:32 -07:00
|
|
|
#include "jstracer.h"
|
2009-08-18 15:43:17 -07:00
|
|
|
#include "jsvector.h"
|
2008-08-06 13:36:29 -07:00
|
|
|
|
2009-07-13 14:55:04 -07:00
|
|
|
#include "jsatominlines.h"
|
2011-06-10 11:44:16 -07:00
|
|
|
#include "jscntxtinlines.h"
|
|
|
|
#include "jsnuminlines.h"
|
2009-11-18 12:29:58 -08:00
|
|
|
#include "jsobjinlines.h"
|
2009-10-26 13:39:39 -07:00
|
|
|
#include "jsscopeinlines.h"
|
2009-07-13 14:55:04 -07:00
|
|
|
|
2008-08-06 15:56:31 -07:00
|
|
|
using namespace avmplus;
|
2008-07-08 23:48:06 -07:00
|
|
|
using namespace nanojit;
|
2010-01-22 14:49:18 -08:00
|
|
|
using namespace js;
|
2008-07-08 23:48:06 -07:00
|
|
|
|
2009-04-09 16:07:00 -07:00
|
|
|
JS_FRIEND_API(void)
|
|
|
|
js_SetTraceableNativeFailed(JSContext *cx)
|
|
|
|
{
|
2011-02-01 10:16:44 -08:00
|
|
|
/*
|
|
|
|
* We might not be on trace (we might have deep bailed) so we hope
|
|
|
|
* cx->compartment is correct.
|
|
|
|
*/
|
2011-02-01 10:18:06 -08:00
|
|
|
SetBuiltinError(JS_TRACE_MONITOR_FROM_CONTEXT(cx));
|
2009-04-09 16:07:00 -07:00
|
|
|
}
|
|
|
|
|
2008-09-02 15:37:22 -07:00
|
|
|
/*
|
|
|
|
* NB: bool FASTCALL is not compatible with Nanojit's calling convention usage.
|
|
|
|
* Do not use bool FASTCALL, use JSBool only!
|
|
|
|
*/
|
|
|
|
|
2008-08-10 00:39:18 -07:00
|
|
|
jsdouble FASTCALL
|
|
|
|
js_dmod(jsdouble a, jsdouble b)
|
2008-07-05 17:29:55 -07:00
|
|
|
{
|
|
|
|
if (b == 0.0) {
|
|
|
|
jsdpun u;
|
2010-07-19 11:28:13 -07:00
|
|
|
u.s.hi = JSDOUBLE_HI32_NAN;
|
|
|
|
u.s.lo = JSDOUBLE_LO32_NAN;
|
2008-07-05 17:29:55 -07:00
|
|
|
return u.d;
|
|
|
|
}
|
2009-07-11 12:40:37 -07:00
|
|
|
return js_fmod(a, b);
|
2008-07-05 17:29:55 -07:00
|
|
|
}
|
2010-07-27 22:33:42 -07:00
|
|
|
JS_DEFINE_CALLINFO_2(extern, DOUBLE, js_dmod, DOUBLE, DOUBLE, 1, ACCSET_NONE)
|
2008-07-05 17:29:55 -07:00
|
|
|
|
2008-10-08 15:08:33 -07:00
|
|
|
int32 FASTCALL
|
|
|
|
js_imod(int32 a, int32 b)
|
2008-09-15 19:59:06 -07:00
|
|
|
{
|
2008-09-24 23:28:56 -07:00
|
|
|
if (a < 0 || b <= 0)
|
|
|
|
return -1;
|
|
|
|
int r = a % b;
|
|
|
|
return r;
|
2008-09-15 19:59:06 -07:00
|
|
|
}
|
2010-07-27 22:33:42 -07:00
|
|
|
JS_DEFINE_CALLINFO_2(extern, INT32, js_imod, INT32, INT32, 1, ACCSET_NONE)
|
2008-09-15 19:59:06 -07:00
|
|
|
|
2010-07-14 23:19:36 -07:00
|
|
|
#if JS_BITS_PER_WORD == 32
|
|
|
|
|
|
|
|
jsdouble FASTCALL
|
2011-05-19 17:02:46 -07:00
|
|
|
js_UnboxNumberAsDouble(uint32 tag, uint32 payload)
|
2008-07-05 17:29:55 -07:00
|
|
|
{
|
2010-07-14 23:19:36 -07:00
|
|
|
if (tag == JSVAL_TAG_INT32)
|
|
|
|
return (double)(int32)payload;
|
|
|
|
|
2011-05-19 17:02:46 -07:00
|
|
|
JS_ASSERT(tag <= JSVAL_TAG_CLEAR);
|
2010-07-14 23:19:36 -07:00
|
|
|
jsval_layout l;
|
|
|
|
l.s.tag = (JSValueTag)tag;
|
|
|
|
l.s.payload.u32 = payload;
|
|
|
|
return l.asDouble;
|
2008-07-05 17:29:55 -07:00
|
|
|
}
|
2011-05-19 17:02:46 -07:00
|
|
|
JS_DEFINE_CALLINFO_2(extern, DOUBLE, js_UnboxNumberAsDouble, UINT32, UINT32, 1, ACCSET_NONE)
|
2008-07-05 17:29:55 -07:00
|
|
|
|
2010-07-14 23:19:36 -07:00
|
|
|
int32 FASTCALL
|
2011-05-19 17:02:46 -07:00
|
|
|
js_UnboxNumberAsInt32(uint32 tag, uint32 payload)
|
2008-07-05 17:29:55 -07:00
|
|
|
{
|
2010-07-14 23:19:36 -07:00
|
|
|
if (tag == JSVAL_TAG_INT32)
|
|
|
|
return (int32)payload;
|
|
|
|
|
2011-05-19 17:02:46 -07:00
|
|
|
JS_ASSERT(tag <= JSVAL_TAG_CLEAR);
|
2010-07-14 23:19:36 -07:00
|
|
|
jsval_layout l;
|
|
|
|
l.s.tag = (JSValueTag)tag;
|
|
|
|
l.s.payload.u32 = payload;
|
|
|
|
return js_DoubleToECMAInt32(l.asDouble);
|
2009-07-27 18:40:12 -07:00
|
|
|
}
|
2011-05-19 17:02:46 -07:00
|
|
|
JS_DEFINE_CALLINFO_2(extern, INT32, js_UnboxNumberAsInt32, UINT32, UINT32, 1, ACCSET_NONE)
|
2010-07-14 23:19:36 -07:00
|
|
|
|
|
|
|
#elif JS_BITS_PER_WORD == 64
|
2008-07-05 17:29:55 -07:00
|
|
|
|
2008-08-10 00:39:18 -07:00
|
|
|
jsdouble FASTCALL
|
2011-05-19 17:02:46 -07:00
|
|
|
js_UnboxNumberAsDouble(Value v)
|
2008-07-06 15:55:04 -07:00
|
|
|
{
|
2010-07-14 23:19:36 -07:00
|
|
|
if (v.isInt32())
|
|
|
|
return (jsdouble)v.toInt32();
|
2011-05-19 17:02:46 -07:00
|
|
|
JS_ASSERT(v.isDouble());
|
2010-07-14 23:19:36 -07:00
|
|
|
return v.toDouble();
|
2008-07-06 15:55:04 -07:00
|
|
|
}
|
2011-05-19 17:02:46 -07:00
|
|
|
JS_DEFINE_CALLINFO_1(extern, DOUBLE, js_UnboxNumberAsDouble, JSVAL, 1, ACCSET_NONE)
|
2008-07-06 15:55:04 -07:00
|
|
|
|
2008-10-08 15:08:33 -07:00
|
|
|
int32 FASTCALL
|
2011-05-19 17:02:46 -07:00
|
|
|
js_UnboxNumberAsInt32(Value v)
|
2008-07-05 17:29:55 -07:00
|
|
|
{
|
2010-07-14 23:19:36 -07:00
|
|
|
if (v.isInt32())
|
|
|
|
return v.toInt32();
|
2011-05-19 17:02:46 -07:00
|
|
|
JS_ASSERT(v.isDouble());
|
2010-07-14 23:19:36 -07:00
|
|
|
return js_DoubleToECMAInt32(v.toDouble());
|
2008-07-05 17:29:55 -07:00
|
|
|
}
|
2011-05-19 17:02:46 -07:00
|
|
|
JS_DEFINE_CALLINFO_1(extern, INT32, js_UnboxNumberAsInt32, VALUE, 1, ACCSET_NONE)
|
2008-07-05 22:04:58 -07:00
|
|
|
|
2010-07-14 23:19:36 -07:00
|
|
|
#endif
|
2009-09-30 15:28:00 -07:00
|
|
|
|
2008-08-10 00:39:18 -07:00
|
|
|
int32 FASTCALL
|
|
|
|
js_DoubleToInt32(jsdouble d)
|
2008-07-05 22:04:58 -07:00
|
|
|
{
|
|
|
|
return js_DoubleToECMAInt32(d);
|
|
|
|
}
|
2010-07-27 22:33:42 -07:00
|
|
|
JS_DEFINE_CALLINFO_1(extern, INT32, js_DoubleToInt32, DOUBLE, 1, ACCSET_NONE)
|
2008-07-06 10:59:55 -07:00
|
|
|
|
2008-10-08 15:08:33 -07:00
|
|
|
uint32 FASTCALL
|
2008-08-10 00:39:18 -07:00
|
|
|
js_DoubleToUint32(jsdouble d)
|
2008-07-06 10:59:55 -07:00
|
|
|
{
|
|
|
|
return js_DoubleToECMAUint32(d);
|
|
|
|
}
|
2010-07-27 22:33:42 -07:00
|
|
|
JS_DEFINE_CALLINFO_1(extern, UINT32, js_DoubleToUint32, DOUBLE, 1, ACCSET_NONE)
|
2008-07-08 23:48:06 -07:00
|
|
|
|
2011-01-13 19:14:46 -08:00
|
|
|
/*
|
|
|
|
* js_StringToNumber and js_StringToInt32 store into their second argument, so
|
|
|
|
* they need to be annotated accordingly. To be future-proof, we use
|
|
|
|
* ACCSET_STORE_ANY so that new callers don't have to remember to update the
|
|
|
|
* annotation.
|
|
|
|
*/
|
2008-07-31 07:41:58 -07:00
|
|
|
jsdouble FASTCALL
|
2010-12-06 10:26:58 -08:00
|
|
|
js_StringToNumber(JSContext* cx, JSString* str, JSBool *ok)
|
2008-07-31 07:41:58 -07:00
|
|
|
{
|
2010-12-06 10:26:58 -08:00
|
|
|
double out = 0; /* silence warnings. */
|
|
|
|
*ok = StringToNumberType<jsdouble>(cx, str, &out);
|
|
|
|
return out;
|
2008-07-31 07:41:58 -07:00
|
|
|
}
|
2011-01-13 19:14:46 -08:00
|
|
|
JS_DEFINE_CALLINFO_3(extern, DOUBLE, js_StringToNumber, CONTEXT, STRING, BOOLPTR,
|
|
|
|
0, ACCSET_STORE_ANY)
|
2008-07-31 07:41:58 -07:00
|
|
|
|
2008-10-08 15:08:33 -07:00
|
|
|
int32 FASTCALL
|
2010-12-06 10:26:58 -08:00
|
|
|
js_StringToInt32(JSContext* cx, JSString* str, JSBool *ok)
|
2008-07-31 11:35:08 -07:00
|
|
|
{
|
2010-12-06 10:26:58 -08:00
|
|
|
int32 out = 0; /* silence warnings. */
|
|
|
|
*ok = StringToNumberType<int32>(cx, str, &out);
|
|
|
|
return out;
|
2008-09-07 00:41:10 -07:00
|
|
|
}
|
2011-01-13 19:14:46 -08:00
|
|
|
JS_DEFINE_CALLINFO_3(extern, INT32, js_StringToInt32, CONTEXT, STRING, BOOLPTR,
|
|
|
|
0, ACCSET_STORE_ANY)
|
2008-09-07 00:41:10 -07:00
|
|
|
|
2010-05-12 19:34:01 -07:00
|
|
|
/* Nb: it's always safe to set isDefinitelyAtom to false if you're unsure or don't know. */
|
|
|
|
static inline JSBool
|
2010-08-29 11:57:08 -07:00
|
|
|
AddPropertyHelper(JSContext* cx, JSObject* obj, Shape* shape, bool isDefinitelyAtom)
|
2008-08-08 14:38:44 -07:00
|
|
|
{
|
2010-08-29 11:57:08 -07:00
|
|
|
JS_ASSERT(shape->previous() == obj->lastProperty());
|
2009-04-20 03:10:29 -07:00
|
|
|
|
2010-08-29 11:57:08 -07:00
|
|
|
if (obj->nativeEmpty()) {
|
|
|
|
if (!obj->ensureClassReservedSlotsForEmptyObject(cx))
|
2010-10-22 17:04:22 -07:00
|
|
|
return false;
|
2008-08-08 14:38:44 -07:00
|
|
|
}
|
|
|
|
|
2010-08-29 11:57:08 -07:00
|
|
|
uint32 slot;
|
|
|
|
slot = shape->slot;
|
2010-09-03 11:05:43 -07:00
|
|
|
JS_ASSERT(slot == obj->slotSpan());
|
2010-08-29 11:57:08 -07:00
|
|
|
|
|
|
|
if (slot < obj->numSlots()) {
|
|
|
|
JS_ASSERT(obj->getSlot(slot).isUndefined());
|
2009-04-20 03:10:29 -07:00
|
|
|
} else {
|
2010-08-29 11:57:08 -07:00
|
|
|
if (!obj->allocSlot(cx, &slot))
|
2010-10-22 17:04:22 -07:00
|
|
|
return false;
|
2010-08-29 11:57:08 -07:00
|
|
|
JS_ASSERT(slot == shape->slot);
|
2008-08-08 14:38:44 -07:00
|
|
|
}
|
|
|
|
|
2010-08-29 11:57:08 -07:00
|
|
|
obj->extend(cx, shape, isDefinitelyAtom);
|
2010-10-22 17:04:22 -07:00
|
|
|
return !js_IsPropertyCacheDisabled(cx);
|
2008-08-08 14:38:44 -07:00
|
|
|
}
|
2010-05-12 19:34:01 -07:00
|
|
|
|
|
|
|
JSBool FASTCALL
|
2010-08-29 11:57:08 -07:00
|
|
|
js_AddProperty(JSContext* cx, JSObject* obj, Shape* shape)
|
2010-05-12 19:34:01 -07:00
|
|
|
{
|
2010-08-29 11:57:08 -07:00
|
|
|
return AddPropertyHelper(cx, obj, shape, /* isDefinitelyAtom = */false);
|
2010-05-12 19:34:01 -07:00
|
|
|
}
|
2010-08-29 11:57:08 -07:00
|
|
|
JS_DEFINE_CALLINFO_3(extern, BOOL, js_AddProperty, CONTEXT, OBJECT, SHAPE, 0, ACCSET_STORE_ANY)
|
2008-08-08 14:38:44 -07:00
|
|
|
|
2010-05-12 19:34:01 -07:00
|
|
|
JSBool FASTCALL
|
2010-08-29 11:57:08 -07:00
|
|
|
js_AddAtomProperty(JSContext* cx, JSObject* obj, Shape* shape)
|
2010-05-12 19:34:01 -07:00
|
|
|
{
|
2010-08-29 11:57:08 -07:00
|
|
|
return AddPropertyHelper(cx, obj, shape, /* isDefinitelyAtom = */true);
|
2010-05-12 19:34:01 -07:00
|
|
|
}
|
2010-08-29 11:57:08 -07:00
|
|
|
JS_DEFINE_CALLINFO_3(extern, BOOL, js_AddAtomProperty, CONTEXT, OBJECT, SHAPE, 0, ACCSET_STORE_ANY)
|
2010-05-12 19:34:01 -07:00
|
|
|
|
2009-01-08 21:59:24 -08:00
|
|
|
static JSBool
|
|
|
|
HasProperty(JSContext* cx, JSObject* obj, jsid id)
|
2008-08-27 23:00:43 -07:00
|
|
|
{
|
2009-02-05 17:49:54 -08:00
|
|
|
// Check that we know how the lookup op will behave.
|
2010-03-04 20:44:09 -08:00
|
|
|
for (JSObject* pobj = obj; pobj; pobj = pobj->getProto()) {
|
2010-06-12 09:29:04 -07:00
|
|
|
if (pobj->getOps()->lookupProperty)
|
2010-07-14 23:19:36 -07:00
|
|
|
return JS_NEITHER;
|
|
|
|
Class* clasp = pobj->getClass();
|
2009-04-14 14:59:55 -07:00
|
|
|
if (clasp->resolve != JS_ResolveStub && clasp != &js_StringClass)
|
2010-07-14 23:19:36 -07:00
|
|
|
return JS_NEITHER;
|
2009-04-14 14:59:55 -07:00
|
|
|
}
|
2008-08-27 23:00:43 -07:00
|
|
|
|
|
|
|
JSObject* obj2;
|
|
|
|
JSProperty* prop;
|
2011-01-21 05:10:16 -08:00
|
|
|
if (!LookupPropertyWithFlags(cx, obj, id, JSRESOLVE_QUALIFIED, &obj2, &prop))
|
2010-07-14 23:19:36 -07:00
|
|
|
return JS_NEITHER;
|
2008-08-27 23:00:43 -07:00
|
|
|
return prop != NULL;
|
|
|
|
}
|
|
|
|
|
2009-01-08 21:59:24 -08:00
|
|
|
JSBool FASTCALL
|
|
|
|
js_HasNamedProperty(JSContext* cx, JSObject* obj, JSString* idstr)
|
|
|
|
{
|
2011-05-17 12:15:12 -07:00
|
|
|
JSAtom *atom = js_AtomizeString(cx, idstr);
|
2010-07-14 23:19:36 -07:00
|
|
|
if (!atom)
|
|
|
|
return JS_NEITHER;
|
2009-01-08 21:59:24 -08:00
|
|
|
|
2010-07-14 23:19:36 -07:00
|
|
|
return HasProperty(cx, obj, ATOM_TO_JSID(atom));
|
2009-01-08 21:59:24 -08:00
|
|
|
}
|
2010-07-27 22:33:42 -07:00
|
|
|
JS_DEFINE_CALLINFO_3(extern, BOOL, js_HasNamedProperty, CONTEXT, OBJECT, STRING,
|
|
|
|
0, ACCSET_STORE_ANY)
|
2009-01-08 21:59:24 -08:00
|
|
|
|
2008-11-16 22:13:13 -08:00
|
|
|
JSBool FASTCALL
|
|
|
|
js_HasNamedPropertyInt32(JSContext* cx, JSObject* obj, int32 index)
|
|
|
|
{
|
|
|
|
jsid id;
|
2008-12-16 19:03:42 -08:00
|
|
|
if (!js_Int32ToId(cx, index, &id))
|
2010-07-14 23:19:36 -07:00
|
|
|
return JS_NEITHER;
|
2008-11-17 16:29:40 -08:00
|
|
|
|
2009-01-08 21:59:24 -08:00
|
|
|
return HasProperty(cx, obj, id);
|
2008-11-16 22:13:13 -08:00
|
|
|
}
|
2010-07-27 22:33:42 -07:00
|
|
|
JS_DEFINE_CALLINFO_3(extern, BOOL, js_HasNamedPropertyInt32, CONTEXT, OBJECT, INT32,
|
|
|
|
0, ACCSET_STORE_ANY)
|
2008-11-16 22:13:13 -08:00
|
|
|
|
2008-08-09 19:54:01 -07:00
|
|
|
JSString* FASTCALL
|
2008-08-10 00:39:18 -07:00
|
|
|
js_TypeOfObject(JSContext* cx, JSObject* obj)
|
2008-08-09 19:54:01 -07:00
|
|
|
{
|
2010-07-14 23:19:36 -07:00
|
|
|
JS_ASSERT(obj);
|
2011-03-14 13:59:53 -07:00
|
|
|
return cx->runtime->atomState.typeAtoms[obj->typeOf(cx)];
|
2008-08-09 19:54:01 -07:00
|
|
|
}
|
2010-07-27 22:33:42 -07:00
|
|
|
JS_DEFINE_CALLINFO_2(extern, STRING, js_TypeOfObject, CONTEXT, OBJECT, 1, ACCSET_NONE)
|
2008-08-09 19:54:01 -07:00
|
|
|
|
2008-10-29 00:14:30 -07:00
|
|
|
JSString* FASTCALL
|
2010-03-18 12:12:06 -07:00
|
|
|
js_BooleanIntToString(JSContext *cx, int32 unboxed)
|
2008-10-29 00:14:30 -07:00
|
|
|
{
|
2010-03-18 12:12:06 -07:00
|
|
|
JS_ASSERT(uint32(unboxed) <= 1);
|
2011-03-14 13:59:53 -07:00
|
|
|
return cx->runtime->atomState.booleanAtoms[unboxed];
|
2008-10-29 00:14:30 -07:00
|
|
|
}
|
2010-07-27 22:33:42 -07:00
|
|
|
JS_DEFINE_CALLINFO_2(extern, STRING, js_BooleanIntToString, CONTEXT, INT32, 1, ACCSET_NONE)
|
2008-10-29 00:14:30 -07:00
|
|
|
|
2009-04-05 21:17:22 -07:00
|
|
|
JSObject* FASTCALL
|
2009-05-14 03:35:23 -07:00
|
|
|
js_NewNullClosure(JSContext* cx, JSObject* funobj, JSObject* proto, JSObject* parent)
|
2009-04-05 21:17:22 -07:00
|
|
|
{
|
2010-03-31 22:13:51 -07:00
|
|
|
JS_ASSERT(funobj->isFunction());
|
|
|
|
JS_ASSERT(proto->isFunction());
|
2009-05-14 03:35:23 -07:00
|
|
|
JS_ASSERT(JS_ON_TRACE(cx));
|
2009-04-05 21:17:22 -07:00
|
|
|
|
|
|
|
JSFunction *fun = (JSFunction*) funobj;
|
|
|
|
JS_ASSERT(GET_FUNCTION_PRIVATE(cx, funobj) == fun);
|
|
|
|
|
2010-12-18 20:44:51 -08:00
|
|
|
types::TypeObject *type = proto->getNewType(cx);
|
|
|
|
if (!type)
|
|
|
|
return NULL;
|
|
|
|
|
2010-10-13 11:49:22 -07:00
|
|
|
JSObject* closure = js_NewGCObject(cx, gc::FINALIZE_OBJECT2);
|
2009-04-05 21:17:22 -07:00
|
|
|
if (!closure)
|
|
|
|
return NULL;
|
|
|
|
|
2010-12-18 20:44:51 -08:00
|
|
|
if (!closure->initSharingEmptyShape(cx, &js_FunctionClass, type, parent,
|
2010-10-13 11:49:22 -07:00
|
|
|
fun, gc::FINALIZE_OBJECT2)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2009-04-05 21:17:22 -07:00
|
|
|
return closure;
|
|
|
|
}
|
2010-07-27 22:33:42 -07:00
|
|
|
JS_DEFINE_CALLINFO_4(extern, OBJECT, js_NewNullClosure, CONTEXT, OBJECT, OBJECT, OBJECT,
|
|
|
|
0, ACCSET_STORE_ANY)
|
2009-04-05 21:17:22 -07:00
|
|
|
|