ruffle/core/src/avm2
David Wendt 915b2da42b Allow binding a reciever to a function, and make all method traits bind themselves to the object they were constructed on.
Our already odd `super` handling throws up another subtlety regarding bound recievers. Since we have to construct an instance of a parent class in order to get traits on it, we also have to make sure that we initialize traits with the correct reciever. I'll demonstrate here:

```let mut base = base_proto.construct(avm, context, &[])?;
let name = base.resolve_multiname(&multiname).unwrap();
let value = base.get_property(object, &name, avm, context)?.resolve(avm, context)?```

In this case, if `name` is the name of a method, getter, or setter trait, then `get_property` will instantiate that trait on `base` but bound to `reciever`. This is correct behavior for this case, but more generally, trait instantiation is permenant and therefore there's potential for confusing shenanigans if you `get_property` with the wrong reciever.

To be very clear, `reciever` should *always* be the same object that is getting `get_property` et. all called on it. In the event that you need to instantiate traits with a different `reciever`, you should construct a one-off object and retrieve prototypes from that.
2020-07-13 17:44:28 -04:00
..
globals Allow binding a reciever to a function, and make all method traits bind themselves to the object they were constructed on. 2020-07-13 17:44:28 -04:00
activation.rs Impl `callsuper`, `callsupervoid`, and `constructsuper`. 2020-07-13 17:44:15 -04:00
function.rs Allow binding a reciever to a function, and make all method traits bind themselves to the object they were constructed on. 2020-07-13 17:44:28 -04:00
globals.rs Impl `callmethod`, `callproperty`, `callproplex`, `callpropvoid`, and `callstatic`. 2020-07-13 17:43:49 -04:00
names.rs Implement `Object.prototype.hasOwnProperty` and resolution of `Namespace::Any`. 2020-07-13 17:44:26 -04:00
object.rs Allow binding a reciever to a function, and make all method traits bind themselves to the object they were constructed on. 2020-07-13 17:44:28 -04:00
property.rs Completely overhaul the way traits are defined on objects. 2020-07-13 17:44:27 -04:00
return_value.rs Implement namespaces as a value type 2020-07-13 17:42:49 -04:00
scope.rs Completely overhaul the way traits are defined on objects. 2020-07-13 17:44:27 -04:00
script_object.rs Completely overhaul the way traits are defined on objects. 2020-07-13 17:44:27 -04:00
slot.rs Impl `initproperty` 2020-07-13 17:43:45 -04:00
value.rs Implement slot traits. 2020-07-13 17:43:28 -04:00