Exemple #1
0
        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);
        }
Exemple #2
0
    double SamplerScript::_getInvocationCount(ScriptObject* self, Atom a, QNameObject* qname, uint32_t type)
    {
#ifdef DEBUGGER
        AvmCore* core = self->core();
        Sampler* s = core->get_sampler();
        if (!s || !trusted(self))
            return -1;

        Multiname multiname;
        if(qname)
            qname->getMultiname(multiname);

        ScriptObject* object = self->toplevel()->global();
        if(!AvmCore::isObject(a))
        {
            // not sure if this will be true for standalone avmplus
            AvmAssert(core->codeContext() != NULL);
            DomainEnv *domainEnv = core->codeContext()->domainEnv();
            ScriptEnv* script = (ScriptEnv*) core->domainMgr()->findScriptEnvInDomainEnvByMultiname(domainEnv, multiname);
            if (script != (ScriptEnv*)BIND_NONE)
            {
                if (script == (ScriptEnv*)BIND_AMBIGUOUS)
                    self->toplevel()->throwReferenceError(kAmbiguousBindingError, &multiname);

                object = script->global;
                if (object == NULL)
                {
                    object = script->initGlobal();
                    script->coerceEnter(script->global->atom());
                }
            }
        }
        else
        {
            object = AvmCore::atomToScriptObject(a);

            if(AvmCore::istype(a, CLASS_TYPE) && !qname) {
                // return constructor count
                ClassClosure *cc = (ClassClosure*)object;
                if (cc->vtable->init) // Vector related crash here, Tommy says: I didn't think a type could ever not have a constructor but I guess there's no reason it has to.
                    return (double)cc->vtable->init->invocationCount();
            }
        }

        if(!object || !qname)
            return -1;

        VTable *v = object->vtable;

    again:

        MethodEnv *env = NULL;
        Binding b = self->toplevel()->getBinding(v->traits, &multiname);
        switch (AvmCore::bindingKind(b))
        {
        case BKIND_VAR:
        case BKIND_CONST:
        {
            // only look at slots for first pass, otherwise we're applying instance traits to the Class
            if(v == object->vtable) {
                Atom method = object->getSlotAtom(AvmCore::bindingToSlotId(b));
                if(AvmCore::isObject(method))
                {
                    env = AvmCore::atomToScriptObject(method)->getCallMethodEnv();
                }
            }
            break;
        }
        case BKIND_METHOD:
        {
            int m = AvmCore::bindingToMethodId(b);
            env = v->methods[m];
            break;
        }
        case BKIND_GET:
        case BKIND_GETSET:
        case BKIND_SET:
        {
            if(type == GET && AvmCore::hasGetterBinding(b))
                env = v->methods[AvmCore::bindingToGetterId(b)];
            else if(type == SET && AvmCore::hasSetterBinding(b))
                env = v->methods[AvmCore::bindingToSetterId(b)];
            break;
        }
        case BKIND_NONE:
        {
            Atom method = object->getStringProperty(multiname.getName());
            if(AvmCore::isObject(method))
            {
                env = AvmCore::atomToScriptObject(method)->getCallMethodEnv();
            }
            else if(v->ivtable)
            {
                v = v->ivtable;
                goto again;
            }
        }
        default:
            break;
        }

        if(env)
            return (double)env->invocationCount();
#else
        (void)self;
        (void)type;
        (void)qname;
        (void)a;
#endif

        return -1;
    }