mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 880041 (part 12) - Use JSObject::{is,as} for BlockObject. r=evilpies.
--HG-- extra : rebase_source : c41de9544c966c8859a429a8a0c63875c7d00b71
This commit is contained in:
parent
fe57abd6a0
commit
80f8b2c55e
@ -4311,7 +4311,7 @@ baseops::SetPropertyHelper(JSContext *cx, HandleObject obj, HandleObject receive
|
||||
}
|
||||
} else {
|
||||
/* We should never add properties to lexical blocks. */
|
||||
JS_ASSERT(!obj->isBlock());
|
||||
JS_ASSERT(!obj->is<BlockObject>());
|
||||
|
||||
if (obj->isGlobal() &&
|
||||
(defineHow & DNP_UNQUALIFIED) &&
|
||||
|
@ -204,7 +204,6 @@ DeleteGeneric(JSContext *cx, HandleObject obj, HandleId id, JSBool *succeeded);
|
||||
} /* namespace js::baseops */
|
||||
|
||||
extern Class ArrayClass;
|
||||
extern Class BlockClass;
|
||||
extern Class BooleanClass;
|
||||
extern Class CallableObjectClass;
|
||||
extern Class DateClass;
|
||||
@ -223,7 +222,6 @@ extern Class WeakMapClass;
|
||||
extern Class WithClass;
|
||||
|
||||
class ArrayBufferObject;
|
||||
class BlockObject;
|
||||
class BooleanObject;
|
||||
class ClonedBlockObject;
|
||||
class DebugScopeObject;
|
||||
@ -932,7 +930,7 @@ class JSObject : public js::ObjectImpl
|
||||
* }
|
||||
*
|
||||
* These XObject classes form a hierarchy. For example, for a cloned block
|
||||
* object, the following predicates are true: isClonedBlock, isBlock,
|
||||
* object, the following predicates are true: isClonedBlock, is<BlockObject>,
|
||||
* isNestedScope and isScope. Each of these has a respective class that
|
||||
* derives and adds operations.
|
||||
*
|
||||
@ -974,16 +972,15 @@ class JSObject : public js::ObjectImpl
|
||||
inline bool isObject() const { return hasClass(&js::ObjectClass); }
|
||||
using js::ObjectImpl::isProxy;
|
||||
inline bool isRegExpStatics() const { return hasClass(&js::RegExpStaticsClass); }
|
||||
inline bool isScope() const { return isCall() || isDeclEnv() || isNestedScope(); }
|
||||
inline bool isScope() const;
|
||||
inline bool isStopIteration() const { return hasClass(&js::StopIterationClass); }
|
||||
inline bool isTypedArray() const;
|
||||
inline bool isWeakMap() const { return hasClass(&js::WeakMapClass); }
|
||||
|
||||
/* Subtypes of ScopeObject. */
|
||||
inline bool isBlock() const { return hasClass(&js::BlockClass); }
|
||||
inline bool isCall() const { return hasClass(&js::CallClass); }
|
||||
inline bool isDeclEnv() const { return hasClass(&js::DeclEnvClass); }
|
||||
inline bool isNestedScope() const { return isBlock() || isWith(); }
|
||||
inline bool isNestedScope() const;
|
||||
inline bool isWith() const { return hasClass(&js::WithClass); }
|
||||
inline bool isClonedBlock() const;
|
||||
inline bool isStaticBlock() const;
|
||||
@ -999,7 +996,6 @@ class JSObject : public js::ObjectImpl
|
||||
inline bool isFunctionProxy() const { return hasClass(&js::FunctionProxyClass); }
|
||||
inline bool isCrossCompartmentWrapper() const;
|
||||
|
||||
inline js::BlockObject &asBlock();
|
||||
inline js::BooleanObject &asBoolean();
|
||||
inline js::CallObject &asCall();
|
||||
inline js::ClonedBlockObject &asClonedBlock();
|
||||
|
@ -845,8 +845,8 @@ inline bool JSObject::watched() const
|
||||
return lastProperty()->hasObjectFlag(js::BaseShape::WATCHED);
|
||||
}
|
||||
|
||||
inline bool JSObject::isClonedBlock() const { return isBlock() && !!getProto(); }
|
||||
inline bool JSObject::isStaticBlock() const { return isBlock() && !getProto(); }
|
||||
inline bool JSObject::isClonedBlock() const { return is<js::BlockObject>() && !!getProto(); }
|
||||
inline bool JSObject::isStaticBlock() const { return is<js::BlockObject>() && !getProto(); }
|
||||
inline bool JSObject::isTypedArray() const { return IsTypedArrayClass(getClass()); }
|
||||
|
||||
inline js::NumberObject &
|
||||
|
@ -476,8 +476,9 @@ ToDisassemblySource(JSContext *cx, jsval v, JSAutoByteString *bytes)
|
||||
|
||||
if (!JSVAL_IS_PRIMITIVE(v)) {
|
||||
JSObject *obj = JSVAL_TO_OBJECT(v);
|
||||
if (obj->isBlock()) {
|
||||
char *source = JS_sprintf_append(NULL, "depth %d {", obj->asBlock().stackDepth());
|
||||
if (obj->is<BlockObject>()) {
|
||||
char *source = JS_sprintf_append(NULL, "depth %d {",
|
||||
obj->as<BlockObject>().stackDepth());
|
||||
if (!source)
|
||||
return false;
|
||||
|
||||
@ -1089,7 +1090,8 @@ GetBlockChainAtPC(JSContext *cx, JSScript *script, jsbytecode *pc)
|
||||
case JSOP_ENTERLET0:
|
||||
case JSOP_ENTERLET1: {
|
||||
JSObject *child = script->getObject(p);
|
||||
JS_ASSERT_IF(blockChain, child->asBlock().stackDepth() >= blockChain->asBlock().stackDepth());
|
||||
JS_ASSERT_IF(blockChain, child->as<BlockObject>().stackDepth() >=
|
||||
blockChain->as<BlockObject>().stackDepth());
|
||||
blockChain = child;
|
||||
break;
|
||||
}
|
||||
@ -1104,7 +1106,7 @@ GetBlockChainAtPC(JSContext *cx, JSScript *script, jsbytecode *pc)
|
||||
if (!(sn && SN_TYPE(sn) == SRC_HIDDEN)) {
|
||||
JS_ASSERT(blockChain);
|
||||
blockChain = blockChain->asStaticBlock().enclosingBlock();
|
||||
JS_ASSERT_IF(blockChain, blockChain->isBlock());
|
||||
JS_ASSERT_IF(blockChain, blockChain->is<BlockObject>());
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1404,9 +1406,9 @@ ExpressionDecompiler::findLetVar(jsbytecode *pc, unsigned depth)
|
||||
JSObject *chain = GetBlockChainAtPC(cx, script, pc);
|
||||
if (!chain)
|
||||
return NULL;
|
||||
JS_ASSERT(chain->isBlock());
|
||||
JS_ASSERT(chain->is<BlockObject>());
|
||||
do {
|
||||
BlockObject &block = chain->asBlock();
|
||||
BlockObject &block = chain->as<BlockObject>();
|
||||
uint32_t blockDepth = block.stackDepth();
|
||||
uint32_t blockCount = block.slotCount();
|
||||
if (uint32_t(depth - blockDepth) < uint32_t(blockCount)) {
|
||||
@ -1417,7 +1419,7 @@ ExpressionDecompiler::findLetVar(jsbytecode *pc, unsigned depth)
|
||||
}
|
||||
}
|
||||
chain = chain->getParent();
|
||||
} while (chain && chain->isBlock());
|
||||
} while (chain && chain->is<BlockObject>());
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -657,7 +657,7 @@ js::XDRScript(XDRState<mode> *xdr, HandleObject enclosingScope, HandleScript enc
|
||||
if (mode == XDR_ENCODE) {
|
||||
JSObject *obj = *objp;
|
||||
JS_ASSERT(obj->isFunction() || obj->isStaticBlock());
|
||||
isBlock = obj->isBlock() ? 1 : 0;
|
||||
isBlock = obj->is<BlockObject>() ? 1 : 0;
|
||||
}
|
||||
if (!xdr->codeUint32(&isBlock))
|
||||
return false;
|
||||
|
@ -383,7 +383,7 @@ class ReferenceFinder {
|
||||
JSObject *object = static_cast<JSObject *>(cell);
|
||||
|
||||
/* Certain classes of object are for internal use only. */
|
||||
if (object->isBlock() ||
|
||||
if (object->is<BlockObject>() ||
|
||||
object->isCall() ||
|
||||
object->isWith() ||
|
||||
object->isDeclEnv()) {
|
||||
|
@ -31,7 +31,7 @@ ScopeObject::enclosingScope() const
|
||||
inline void
|
||||
ScopeObject::setEnclosingScope(HandleObject obj)
|
||||
{
|
||||
JS_ASSERT_IF(obj->isCall() || obj->isDeclEnv() || obj->isBlock(),
|
||||
JS_ASSERT_IF(obj->isCall() || obj->isDeclEnv() || obj->is<BlockObject>(),
|
||||
obj->isDelegate());
|
||||
setFixedSlot(SCOPE_CHAIN_SLOT, ObjectValue(*obj));
|
||||
}
|
||||
@ -276,7 +276,7 @@ JSObject::asDeclEnv()
|
||||
inline js::NestedScopeObject &
|
||||
JSObject::asNestedScope()
|
||||
{
|
||||
JS_ASSERT(isWith() || isBlock());
|
||||
JS_ASSERT(isWith() || is<js::BlockObject>());
|
||||
return *static_cast<js::NestedScopeObject *>(this);
|
||||
}
|
||||
|
||||
@ -287,13 +287,6 @@ JSObject::asWith()
|
||||
return *static_cast<js::WithObject *>(this);
|
||||
}
|
||||
|
||||
inline js::BlockObject &
|
||||
JSObject::asBlock()
|
||||
{
|
||||
JS_ASSERT(isBlock());
|
||||
return *static_cast<js::BlockObject *>(this);
|
||||
}
|
||||
|
||||
inline js::StaticBlockObject &
|
||||
JSObject::asStaticBlock()
|
||||
{
|
||||
|
@ -650,9 +650,9 @@ ClonedBlockObject *
|
||||
ClonedBlockObject::create(JSContext *cx, Handle<StaticBlockObject *> block, AbstractFramePtr frame)
|
||||
{
|
||||
assertSameCompartment(cx, frame);
|
||||
JS_ASSERT(block->getClass() == &BlockClass);
|
||||
JS_ASSERT(block->getClass() == &BlockObject::class_);
|
||||
|
||||
RootedTypeObject type(cx, block->getNewType(cx, &BlockClass));
|
||||
RootedTypeObject type(cx, block->getNewType(cx, &BlockObject::class_));
|
||||
if (!type)
|
||||
return NULL;
|
||||
|
||||
@ -706,13 +706,13 @@ ClonedBlockObject::copyUnaliasedValues(AbstractFramePtr frame)
|
||||
StaticBlockObject *
|
||||
StaticBlockObject::create(JSContext *cx)
|
||||
{
|
||||
RootedTypeObject type(cx, cx->compartment()->getNewType(cx, &BlockClass, NULL));
|
||||
RootedTypeObject type(cx, cx->compartment()->getNewType(cx, &BlockObject::class_, NULL));
|
||||
if (!type)
|
||||
return NULL;
|
||||
|
||||
RootedShape emptyBlockShape(cx);
|
||||
emptyBlockShape = EmptyShape::getInitialShape(cx, &BlockClass, NULL, NULL, NULL, FINALIZE_KIND,
|
||||
BaseShape::DELEGATE);
|
||||
emptyBlockShape = EmptyShape::getInitialShape(cx, &BlockObject::class_, NULL, NULL, NULL,
|
||||
FINALIZE_KIND, BaseShape::DELEGATE);
|
||||
if (!emptyBlockShape)
|
||||
return NULL;
|
||||
|
||||
@ -742,14 +742,14 @@ StaticBlockObject::addVar(JSContext *cx, Handle<StaticBlockObject*> block, Handl
|
||||
* Don't convert this object to dictionary mode so that we can clone the
|
||||
* block's shape later.
|
||||
*/
|
||||
uint32_t slot = JSSLOT_FREE(&BlockClass) + index;
|
||||
uint32_t slot = JSSLOT_FREE(&BlockObject::class_) + index;
|
||||
return JSObject::addPropertyInternal(cx, block, id, /* getter = */ NULL, /* setter = */ NULL,
|
||||
slot, JSPROP_ENUMERATE | JSPROP_PERMANENT,
|
||||
Shape::HAS_SHORTID, index, spp,
|
||||
/* allowDictionary = */ false);
|
||||
}
|
||||
|
||||
Class js::BlockClass = {
|
||||
Class BlockObject::class_ = {
|
||||
"Block",
|
||||
JSCLASS_IMPLEMENTS_BARRIERS |
|
||||
JSCLASS_HAS_RESERVED_SLOTS(BlockObject::RESERVED_SLOTS) |
|
||||
@ -1572,7 +1572,7 @@ bool
|
||||
DebugScopeObject::isForDeclarative() const
|
||||
{
|
||||
ScopeObject &s = scope();
|
||||
return s.isCall() || s.isBlock() || s.isDeclEnv();
|
||||
return s.isCall() || s.is<BlockObject>() || s.isDeclEnv();
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -279,6 +279,8 @@ class BlockObject : public NestedScopeObject
|
||||
static const unsigned RESERVED_SLOTS = 2;
|
||||
static const gc::AllocKind FINALIZE_KIND = gc::FINALIZE_OBJECT4_BACKGROUND;
|
||||
|
||||
static Class class_;
|
||||
|
||||
/* Return the number of variables associated with this block. */
|
||||
inline uint32_t slotCount() const;
|
||||
|
||||
@ -617,4 +619,17 @@ class DebugScopes
|
||||
};
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
inline bool
|
||||
JSObject::isNestedScope() const
|
||||
{
|
||||
return is<js::BlockObject>() || isWith();
|
||||
}
|
||||
|
||||
inline bool
|
||||
JSObject::isScope() const
|
||||
{
|
||||
return isCall() || isDeclEnv() || isNestedScope();
|
||||
}
|
||||
|
||||
#endif /* ScopeObject_h___ */
|
||||
|
@ -31,7 +31,7 @@ namespace js {
|
||||
static inline bool
|
||||
IsCacheableNonGlobalScope(JSObject *obj)
|
||||
{
|
||||
bool cacheable = (obj->isCall() || obj->isBlock() || obj->isDeclEnv());
|
||||
bool cacheable = (obj->isCall() || obj->is<BlockObject>() || obj->isDeclEnv());
|
||||
|
||||
JS_ASSERT_IF(cacheable, !obj->getOps()->lookupProperty);
|
||||
return cacheable;
|
||||
|
Loading…
Reference in New Issue
Block a user