Пример #1
0
    // Execute the ToString algorithm as described in ECMA-262 Section 9.8.
    // This is ToString(ToPrimitive(input argument, hint String))
    // ToPrimitive(input argument, hint String) calls [[DefaultValue]]
    // described in ECMA-262 8.6.2.6.  The [[DefaultValue]] algorithm
    // with hint String is inlined here.
    Stringp ScriptObject::toString()
    {
        AvmCore *core = this->core();
        Toplevel* toplevel = this->toplevel();

        Atom atomv_out[1];

        // call this.toString()
        // NOTE use callers versioned public to get correct toString
        Multiname tempname(core->findPublicNamespace(), core->ktoString);
        atomv_out[0] = atom();
        Atom result = toplevel->callproperty(atom(), &tempname, 0, atomv_out, vtable);

        // if result is primitive, return its ToString
        if (atomKind(result) != kObjectType)
            return core->string(result);

        // otherwise call this.valueOf()
        tempname.setName(core->kvalueOf);
        atomv_out[0] = atom();
        result = toplevel->callproperty(atom(), &tempname, 0, atomv_out, vtable);

        // if result is primitive, return it
        if (atomKind(result) != kObjectType)
            return core->string(result);

        // could not convert to primitive.
        toplevel->throwTypeError(kConvertToPrimitiveError, core->toErrorString(traits()));
        return NULL; // unreachable
    }
Пример #2
0
Atom Stubs::do_abc_callpropx(MethodFrame* f, const Multiname* name, Atom index,
                             int argc, Atom* args) {
  Multiname tempname;
  initnamex(core(f), name, index, &tempname);
  Toplevel* t = toplevel(f);
  return t->callproperty(args[0], &tempname, argc - 1, args,
                         toVTable(t, args[0]));
}
Пример #3
0
Atom Stubs::do_abc_callprop(MethodFrame* f, const Multiname* name, int argc,
                            Atom* args) {
  Toplevel* t = toplevel(f);
  return t->callproperty(args[0], name, argc - 1, args, toVTable(t, args[0]));
}
Пример #4
0
Atom Stubs::do_abc_callproplex(MethodFrame* f, const Multiname* name, int argc,
                               Atom* args) {
  Atom base = getBase(args);
  Toplevel* t = toplevel(f);
  return t->callproperty(base, name, argc - 1, args, toVTable(t, base));
}