uint32_t SlotOffsetsAndAsserts::getSlotOffset(Traits* t, int nameId) { Multiname name; t->pool->parseMultiname(name, nameId); if (name.isNsset()) name.setNamespace(name.getNsset()->nsAt(0)); AvmAssert(!name.isNsset()); const TraitsBindings* tb = t->getTraitsBindings(); Binding b = tb->findBinding(name.getName(), name.getNamespace()); AvmAssert(AvmCore::isSlotBinding(b)); int slotId = AvmCore::bindingToSlotId(b); return tb->getSlotOffset(slotId); }
// This is always safe. We must /not/ use WBRC_NULL here, only the full WBRC functions that // take the gc and container explicitly will be safe. See bugzilla 525875. void HeapMultiname::setMultiname(MMgc::GC* gc, const void* container, const Multiname& that) { WBRC(gc, container, &name.name, that.name); bool const this_nsset = name.isNsset() != 0; bool const that_nsset = that.isNsset() != 0; if (this_nsset != that_nsset) { // gc->rc or vice versa... we have to explicitly null out // any existing value (before setting a new one) because WB/WBRC // assume any existing value is a GCObject/RCObject respectively. if (this_nsset) WB_NULL(&name.ns); // WB_NULL is safe else WBRC(gc, container, &name.ns, NULL); // DO NOT USE WBRC_NULL } if (that_nsset) { WB(gc, container, &name.nsset, that.nsset); } else { WBRC(gc, container, &name.ns, that.ns); } name.flags = that.flags; name.next_index = that.next_index; }