mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 880041 (part 9) - Use JSObject::{is,as} for RegExpObject. r=sfink.
--HG-- extra : rebase_source : 083c58e8a82bf7edb2a46e24cae47236af51a2ac
This commit is contained in:
parent
ea95c4669f
commit
31bd984125
@ -224,7 +224,7 @@ CompileRegExpObject(JSContext *cx, RegExpObjectBuilder &builder, CallArgs args)
|
||||
/*
|
||||
* Beware, sourceObj may be a (transparent) proxy to a RegExp, so only
|
||||
* use generic (proxyable) operations on sourceObj that do not assume
|
||||
* sourceObj.isRegExp().
|
||||
* sourceObj.is<RegExpObject>().
|
||||
*/
|
||||
RootedObject sourceObj(cx, &sourceValue.toObject());
|
||||
|
||||
@ -306,14 +306,14 @@ CompileRegExpObject(JSContext *cx, RegExpObjectBuilder &builder, CallArgs args)
|
||||
JS_ALWAYS_INLINE bool
|
||||
IsRegExp(const Value &v)
|
||||
{
|
||||
return v.isObject() && v.toObject().hasClass(&RegExpClass);
|
||||
return v.isObject() && v.toObject().is<RegExpObject>();
|
||||
}
|
||||
|
||||
JS_ALWAYS_INLINE bool
|
||||
regexp_compile_impl(JSContext *cx, CallArgs args)
|
||||
{
|
||||
JS_ASSERT(IsRegExp(args.thisv()));
|
||||
RegExpObjectBuilder builder(cx, &args.thisv().toObject().asRegExp());
|
||||
RegExpObjectBuilder builder(cx, &args.thisv().toObject().as<RegExpObject>());
|
||||
return CompileRegExpObject(cx, builder, args);
|
||||
}
|
||||
|
||||
@ -353,7 +353,7 @@ regexp_toString_impl(JSContext *cx, CallArgs args)
|
||||
{
|
||||
JS_ASSERT(IsRegExp(args.thisv()));
|
||||
|
||||
JSString *str = args.thisv().toObject().asRegExp().toString(cx);
|
||||
JSString *str = args.thisv().toObject().as<RegExpObject>().toString(cx);
|
||||
if (!str)
|
||||
return false;
|
||||
|
||||
@ -495,13 +495,13 @@ js_InitRegExpClass(JSContext *cx, HandleObject obj)
|
||||
|
||||
Rooted<GlobalObject*> global(cx, &obj->asGlobal());
|
||||
|
||||
RootedObject proto(cx, global->createBlankPrototype(cx, &RegExpClass));
|
||||
RootedObject proto(cx, global->createBlankPrototype(cx, &RegExpObject::class_));
|
||||
if (!proto)
|
||||
return NULL;
|
||||
proto->setPrivate(NULL);
|
||||
|
||||
HandlePropertyName empty = cx->names().empty;
|
||||
RegExpObjectBuilder builder(cx, &proto->asRegExp());
|
||||
RegExpObjectBuilder builder(cx, &proto->as<RegExpObject>());
|
||||
if (!builder.build(empty, RegExpFlag(0)))
|
||||
return NULL;
|
||||
|
||||
@ -530,7 +530,7 @@ RegExpRunStatus
|
||||
js::ExecuteRegExp(JSContext *cx, HandleObject regexp, HandleString string, MatchConduit &matches)
|
||||
{
|
||||
/* Step 1 (b) was performed by CallNonGenericMethod. */
|
||||
Rooted<RegExpObject*> reobj(cx, ®exp->asRegExp());
|
||||
Rooted<RegExpObject*> reobj(cx, ®exp->as<RegExpObject>());
|
||||
|
||||
RegExpGuard re(cx);
|
||||
if (!reobj->getShared(cx, &re))
|
||||
|
@ -926,7 +926,7 @@ IonBuilder::inlineRegExpTest(CallInfo &callInfo)
|
||||
return InliningStatus_NotInlined;
|
||||
types::StackTypeSet *thisTypes = callInfo.thisArg()->resultTypeSet();
|
||||
Class *clasp = thisTypes ? thisTypes->getKnownClass() : NULL;
|
||||
if (clasp != &RegExpClass)
|
||||
if (clasp != &RegExpObject::class_)
|
||||
return InliningStatus_NotInlined;
|
||||
if (callInfo.getArg(0)->type() != MIRType_String)
|
||||
return InliningStatus_NotInlined;
|
||||
|
@ -1792,10 +1792,12 @@ JS_InitStandardClasses(JSContext *cx, JSObject *objArg)
|
||||
}
|
||||
|
||||
#define CLASP(name) (&name##Class)
|
||||
#define OCLASP(name) (&name##Object::class_)
|
||||
#define TYPED_ARRAY_CLASP(type) (&TypedArray::classes[TypedArray::type])
|
||||
#define EAGER_ATOM(name) NAME_OFFSET(name)
|
||||
#define EAGER_CLASS_ATOM(name) NAME_OFFSET(name)
|
||||
#define EAGER_ATOM_AND_CLASP(name) EAGER_CLASS_ATOM(name), CLASP(name)
|
||||
#define EAGER_ATOM_AND_OCLASP(name) EAGER_CLASS_ATOM(name), OCLASP(name)
|
||||
|
||||
typedef struct JSStdName {
|
||||
JSClassInitializerOp init;
|
||||
@ -1823,17 +1825,17 @@ static JSStdName standard_class_atoms[] = {
|
||||
{js_InitNumberClass, EAGER_ATOM_AND_CLASP(Number)},
|
||||
{js_InitStringClass, EAGER_ATOM_AND_CLASP(String)},
|
||||
{js_InitExceptionClasses, EAGER_ATOM_AND_CLASP(Error)},
|
||||
{js_InitRegExpClass, EAGER_ATOM_AND_CLASP(RegExp)},
|
||||
{js_InitRegExpClass, EAGER_ATOM_AND_OCLASP(RegExp)},
|
||||
#if JS_HAS_GENERATORS
|
||||
{js_InitIteratorClasses, EAGER_ATOM_AND_CLASP(StopIteration)},
|
||||
#endif
|
||||
{js_InitJSONClass, EAGER_ATOM_AND_CLASP(JSON)},
|
||||
{js_InitTypedArrayClasses, EAGER_CLASS_ATOM(ArrayBuffer), &js::ArrayBufferObject::protoClass},
|
||||
{js_InitWeakMapClass, EAGER_ATOM_AND_CLASP(WeakMap)},
|
||||
{js_InitMapClass, EAGER_CLASS_ATOM(Map), &js::MapObject::class_},
|
||||
{js_InitSetClass, EAGER_CLASS_ATOM(Set), &js::SetObject::class_},
|
||||
{js_InitMapClass, EAGER_ATOM_AND_OCLASP(Map)},
|
||||
{js_InitSetClass, EAGER_ATOM_AND_OCLASP(Set)},
|
||||
#ifdef ENABLE_PARALLEL_JS
|
||||
{js_InitParallelArrayClass, EAGER_CLASS_ATOM(ParallelArray), &js::ParallelArrayObject::class_},
|
||||
{js_InitParallelArrayClass, EAGER_ATOM_AND_OCLASP(ParallelArray)},
|
||||
#endif
|
||||
{js_InitProxyClass, EAGER_ATOM_AND_CLASP(Proxy)},
|
||||
#if ENABLE_INTL_API
|
||||
@ -6838,8 +6840,8 @@ JS_ExecuteRegExp(JSContext *cx, JSObject *objArg, JSObject *reobjArg, jschar *ch
|
||||
RegExpStatics *res = obj->asGlobal().getRegExpStatics();
|
||||
|
||||
RootedValue val(cx);
|
||||
if (!ExecuteRegExpLegacy(cx, res, reobj->asRegExp(), NullPtr(), chars, length, indexp, test,
|
||||
&val))
|
||||
if (!ExecuteRegExpLegacy(cx, res, reobj->as<RegExpObject>(), NullPtr(), chars, length, indexp,
|
||||
test, &val))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -6879,8 +6881,8 @@ JS_ExecuteRegExpNoStatics(JSContext *cx, JSObject *objArg, jschar *chars, size_t
|
||||
CHECK_REQUEST(cx);
|
||||
|
||||
RootedValue val(cx);
|
||||
if (!ExecuteRegExpLegacy(cx, NULL, obj->asRegExp(), NullPtr(), chars, length, indexp, test,
|
||||
&val))
|
||||
if (!ExecuteRegExpLegacy(cx, NULL, obj->as<RegExpObject>(), NullPtr(), chars, length, indexp,
|
||||
test, &val))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -6903,7 +6905,7 @@ JS_GetRegExpFlags(JSContext *cx, JSObject *objArg)
|
||||
AssertHeapIsIdle(cx);
|
||||
CHECK_REQUEST(cx);
|
||||
|
||||
return obj->asRegExp().getFlags();
|
||||
return obj->as<RegExpObject>().getFlags();
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSString *)
|
||||
@ -6913,7 +6915,7 @@ JS_GetRegExpSource(JSContext *cx, JSObject *objArg)
|
||||
AssertHeapIsIdle(cx);
|
||||
CHECK_REQUEST(cx);
|
||||
|
||||
return obj->asRegExp().getSource();
|
||||
return obj->as<RegExpObject>().getSource();
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
|
@ -681,8 +681,8 @@ JSStructuredCloneWriter::startWrite(const Value &v)
|
||||
if (backref)
|
||||
return true;
|
||||
|
||||
if (obj->isRegExp()) {
|
||||
RegExpObject &reobj = obj->asRegExp();
|
||||
if (obj->is<RegExpObject>()) {
|
||||
RegExpObject &reobj = obj->as<RegExpObject>();
|
||||
return out.writePair(SCTAG_REGEXP_OBJECT, reobj.getFlags()) &&
|
||||
writeString(SCTAG_STRING, reobj.getSource());
|
||||
} else if (obj->isDate()) {
|
||||
|
@ -6141,7 +6141,7 @@ JSCompartment::getNewType(JSContext *cx, Class *clasp, TaggedProto proto_, JSFun
|
||||
if (fun)
|
||||
CheckNewScriptProperties(cx, type, fun);
|
||||
|
||||
if (obj->isRegExp()) {
|
||||
if (obj->is<RegExpObject>()) {
|
||||
AddTypeProperty(cx, type, "source", types::Type::StringType());
|
||||
AddTypeProperty(cx, type, "global", types::Type::BooleanType());
|
||||
AddTypeProperty(cx, type, "ignoreCase", types::Type::BooleanType());
|
||||
|
@ -471,7 +471,7 @@ GetClassForProtoKey(JSProtoKey key)
|
||||
case JSProto_String:
|
||||
return &StringClass;
|
||||
case JSProto_RegExp:
|
||||
return &RegExpClass;
|
||||
return &RegExpObject::class_;
|
||||
|
||||
case JSProto_Int8Array:
|
||||
case JSProto_Uint8Array:
|
||||
|
@ -1980,7 +1980,7 @@ JSObject::TradeGuts(JSContext *cx, JSObject *a, JSObject *b, TradeGutsReserved &
|
||||
* refcounted JIT code blob for them across compartments instead of just
|
||||
* swapping guts.
|
||||
*/
|
||||
JS_ASSERT(!a->isRegExp() && !b->isRegExp());
|
||||
JS_ASSERT(!a->is<RegExpObject>() && !b->is<RegExpObject>());
|
||||
|
||||
/* Arrays can use their fixed storage for elements. */
|
||||
JS_ASSERT(!a->isArray() && !b->isArray());
|
||||
|
@ -216,7 +216,6 @@ extern Class MathClass;
|
||||
extern Class NumberClass;
|
||||
extern Class ObjectClass;
|
||||
extern Class ProxyClass;
|
||||
extern Class RegExpClass;
|
||||
extern Class RegExpStaticsClass;
|
||||
extern Class SetIteratorClass;
|
||||
extern Class ScriptSourceClass;
|
||||
@ -243,7 +242,6 @@ class SetIteratorObject;
|
||||
class StaticBlockObject;
|
||||
class StrictArgumentsObject;
|
||||
class StringObject;
|
||||
class RegExpObject;
|
||||
class WithObject;
|
||||
|
||||
} /* namespace js */
|
||||
@ -978,7 +976,6 @@ class JSObject : public js::ObjectImpl
|
||||
inline bool isGlobal() const;
|
||||
inline bool isObject() const { return hasClass(&js::ObjectClass); }
|
||||
using js::ObjectImpl::isProxy;
|
||||
inline bool isRegExp() const { return hasClass(&js::RegExpClass); }
|
||||
inline bool isRegExpStatics() const { return hasClass(&js::RegExpStaticsClass); }
|
||||
inline bool isScope() const { return isCall() || isDeclEnv() || isNestedScope(); }
|
||||
inline bool isScriptSource() const { return hasClass(&js::ScriptSourceClass); }
|
||||
@ -1017,7 +1014,6 @@ class JSObject : public js::ObjectImpl
|
||||
inline js::MapObject &asMap();
|
||||
inline js::NestedScopeObject &asNestedScope();
|
||||
inline js::NumberObject &asNumber();
|
||||
inline js::RegExpObject &asRegExp();
|
||||
inline js::ScopeObject &asScope();
|
||||
inline js::SetObject &asSet();
|
||||
inline js::SetIteratorObject &asSetIterator();
|
||||
|
@ -1685,7 +1685,7 @@ ObjectClassIs(HandleObject obj, ESClassValue classValue, JSContext *cx)
|
||||
case ESClass_Number: return obj->isNumber();
|
||||
case ESClass_String: return obj->isString();
|
||||
case ESClass_Boolean: return obj->isBoolean();
|
||||
case ESClass_RegExp: return obj->isRegExp();
|
||||
case ESClass_RegExp: return obj->is<RegExpObject>();
|
||||
case ESClass_ArrayBuffer: return obj->is<ArrayBufferObject>();
|
||||
case ESClass_Date: return obj->isDate();
|
||||
}
|
||||
|
@ -515,8 +515,8 @@ ToDisassemblySource(JSContext *cx, jsval v, JSAutoByteString *bytes)
|
||||
return bytes->encodeLatin1(cx, str);
|
||||
}
|
||||
|
||||
if (obj->isRegExp()) {
|
||||
JSString *source = obj->asRegExp().toString(cx);
|
||||
if (obj->is<RegExpObject>()) {
|
||||
JSString *source = obj->as<RegExpObject>().toString(cx);
|
||||
if (!source)
|
||||
return false;
|
||||
JS::Anchor<JSString *> anchor(source);
|
||||
|
@ -2649,7 +2649,7 @@ ASTSerializer::literal(ParseNode *pn, MutableHandleValue dst)
|
||||
case PNK_REGEXP:
|
||||
{
|
||||
RootedObject re1(cx, pn->pn_objbox ? pn->pn_objbox->object : NULL);
|
||||
LOCAL_ASSERT(re1 && re1->isRegExp());
|
||||
LOCAL_ASSERT(re1 && re1->is<RegExpObject>());
|
||||
|
||||
RootedObject proto(cx);
|
||||
if (!js_GetClassPrototype(cx, JSProto_RegExp, &proto))
|
||||
|
@ -2356,7 +2356,7 @@ js::CloneScript(JSContext *cx, HandleObject enclosingScope, HandleFunction fun,
|
||||
for (unsigned i = 0; i < nregexps; i++) {
|
||||
HeapPtrObject *vector = src->regexps()->vector;
|
||||
for (unsigned i = 0; i < nregexps; i++) {
|
||||
JSObject *clone = CloneScriptRegExpObject(cx, vector[i]->asRegExp());
|
||||
JSObject *clone = CloneScriptRegExpObject(cx, vector[i]->as<RegExpObject>());
|
||||
if (!clone || !regexps.append(clone))
|
||||
return NULL;
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ JSScript::getRegExp(size_t index)
|
||||
js::ObjectArray *arr = regexps();
|
||||
JS_ASSERT(uint32_t(index) < arr->length);
|
||||
JSObject *obj = arr->vector[index];
|
||||
JS_ASSERT(obj->isRegExp());
|
||||
JS_ASSERT(obj->is<js::RegExpObject>());
|
||||
return (js::RegExpObject *) obj;
|
||||
}
|
||||
|
||||
|
@ -15,13 +15,6 @@
|
||||
|
||||
#include "String-inl.h"
|
||||
|
||||
inline js::RegExpObject &
|
||||
JSObject::asRegExp()
|
||||
{
|
||||
JS_ASSERT(isRegExp());
|
||||
return *static_cast<js::RegExpObject *>(this);
|
||||
}
|
||||
|
||||
namespace js {
|
||||
|
||||
inline RegExpShared *
|
||||
@ -114,8 +107,8 @@ RegExpShared::isJITRuntimeEnabled(JSContext *cx)
|
||||
inline bool
|
||||
RegExpToShared(JSContext *cx, HandleObject obj, RegExpGuard *g)
|
||||
{
|
||||
if (obj->isRegExp())
|
||||
return obj->asRegExp().getShared(cx, g);
|
||||
if (obj->is<RegExpObject>())
|
||||
return obj->as<RegExpObject>().getShared(cx, g);
|
||||
return Proxy::regexp_toShared(cx, obj, g);
|
||||
}
|
||||
|
||||
|
@ -37,12 +37,12 @@ RegExpObjectBuilder::getOrCreate()
|
||||
|
||||
// Note: RegExp objects are always allocated in the tenured heap. This is
|
||||
// not strictly required, but simplifies embedding them in jitcode.
|
||||
JSObject *obj = NewBuiltinClassInstance(cx, &RegExpClass, TenuredObject);
|
||||
JSObject *obj = NewBuiltinClassInstance(cx, &RegExpObject::class_, TenuredObject);
|
||||
if (!obj)
|
||||
return false;
|
||||
obj->initPrivate(NULL);
|
||||
|
||||
reobj_ = &obj->asRegExp();
|
||||
reobj_ = &obj->as<RegExpObject>();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -53,13 +53,13 @@ RegExpObjectBuilder::getOrCreateClone(RegExpObject *proto)
|
||||
|
||||
// Note: RegExp objects are always allocated in the tenured heap. This is
|
||||
// not strictly required, but simplifies embedding them in jitcode.
|
||||
JSObject *clone = NewObjectWithGivenProto(cx, &RegExpClass, proto, proto->getParent(),
|
||||
JSObject *clone = NewObjectWithGivenProto(cx, &RegExpObject::class_, proto, proto->getParent(),
|
||||
TenuredObject);
|
||||
if (!clone)
|
||||
return false;
|
||||
clone->initPrivate(NULL);
|
||||
|
||||
reobj_ = &clone->asRegExp();
|
||||
reobj_ = &clone->as<RegExpObject>();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -207,7 +207,7 @@ regexp_trace(JSTracer *trc, JSObject *obj)
|
||||
obj->setPrivate(NULL);
|
||||
}
|
||||
|
||||
Class js::RegExpClass = {
|
||||
Class RegExpObject::class_ = {
|
||||
js_RegExp_str,
|
||||
JSCLASS_HAS_PRIVATE | JSCLASS_IMPLEMENTS_BARRIERS |
|
||||
JSCLASS_HAS_RESERVED_SLOTS(RegExpObject::RESERVED_SLOTS) |
|
||||
@ -273,7 +273,7 @@ RegExpObject::createShared(JSContext *cx, RegExpGuard *g)
|
||||
Shape *
|
||||
RegExpObject::assignInitialShape(JSContext *cx)
|
||||
{
|
||||
JS_ASSERT(isRegExp());
|
||||
JS_ASSERT(is<RegExpObject>());
|
||||
JS_ASSERT(nativeEmpty());
|
||||
|
||||
JS_STATIC_ASSERT(LAST_INDEX_SLOT == 0);
|
||||
@ -736,8 +736,8 @@ JSObject *
|
||||
js::CloneRegExpObject(JSContext *cx, JSObject *obj_, JSObject *proto_)
|
||||
{
|
||||
RegExpObjectBuilder builder(cx);
|
||||
Rooted<RegExpObject*> regex(cx, &obj_->asRegExp());
|
||||
Rooted<RegExpObject*> proto(cx, &proto_->asRegExp());
|
||||
Rooted<RegExpObject*> regex(cx, &obj_->as<RegExpObject>());
|
||||
Rooted<RegExpObject*> proto(cx, &proto_->as<RegExpObject>());
|
||||
return builder.clone(regex, proto);
|
||||
}
|
||||
|
||||
@ -789,7 +789,7 @@ js::XDRScriptRegExpObject(XDRState<mode> *xdr, HeapPtrObject *objp)
|
||||
|
||||
if (mode == XDR_ENCODE) {
|
||||
JS_ASSERT(objp);
|
||||
RegExpObject &reobj = (*objp)->asRegExp();
|
||||
RegExpObject &reobj = (*objp)->as<RegExpObject>();
|
||||
source = reobj.getSource();
|
||||
flagsword = reobj.getFlags();
|
||||
}
|
||||
|
@ -294,6 +294,8 @@ class RegExpObject : public JSObject
|
||||
public:
|
||||
static const unsigned RESERVED_SLOTS = 6;
|
||||
|
||||
static Class class_;
|
||||
|
||||
/*
|
||||
* Note: The regexp statics flags are OR'd into the provided flags,
|
||||
* so this function is really meant for object creation during code
|
||||
|
@ -620,8 +620,8 @@ CloneObject(JSContext *cx, HandleObject srcObj, CloneMemory &clonedObjects)
|
||||
RootedFunction fun(cx, srcObj->toFunction());
|
||||
clone = CloneFunctionObject(cx, fun, cx->global(), fun->getAllocKind(), TenuredObject);
|
||||
}
|
||||
} else if (srcObj->isRegExp()) {
|
||||
RegExpObject &reobj = srcObj->asRegExp();
|
||||
} else if (srcObj->is<RegExpObject>()) {
|
||||
RegExpObject &reobj = srcObj->as<RegExpObject>();
|
||||
RootedAtom source(cx, reobj.getSource());
|
||||
clone = RegExpObject::createNoStatics(cx, source, reobj.getFlags(), NULL);
|
||||
} else if (srcObj->isDate()) {
|
||||
|
Loading…
Reference in New Issue
Block a user