ruffle/core
Aaron Hill b56eace008
avm2: Implement property type coercions
Properties can be declared with a type
(e.g. `var foo:MyClass = new MyClass();`). When
`set_property`/`init_property` is invoked for that property,
the VM will attempt to coerce the value to the provided type,
throwing an error if this fails. This can have observable behavior
consequences - if a property has type `integer`, for example, then
storing a floating point `Number` to that property will cause the
value to be coerced to an integer. Some SWFs (e.g. 'Solarmax') rely
on this behavior in order to implicitly coerce a floating point value
that's later used for array indexing.

This PR implements property type coercions in Ruffle. There are several
important considerations:

* The class lookup for property types needs to be done lazily, since
we can have a cycle between two classes (e.g. `var prop1:Class2;`
and `var prop2:Class1` in two different classes).
* The class lookup uses special rules (different from
  `resolve_definition`), and does *not* use `ScopeStack/`ScopeTree`
This means that a private class can specified as a property name -
the lookup will succeed without using a scope, even though
`flash.utils.getDefinitionByName` would fail with the same name
* The specialized 'Vector' classes (e.g "Vector$int") can be used
as property types, even though they cannot be lookup up normally.

Some Ruffle class definitions were previously using nonexistent
classes as property types (e.g. "BareObject") - these are fixed
in this PR.
2022-06-30 21:34:26 -07:00
..
assets core: Extend the embedded fake device font with more characters 2022-02-09 20:09:52 +01:00
build_playerglobal avm2: Introduce ActionScript entry-points 2022-06-18 18:26:57 +03:00
macros build(deps): bump quote from 1.0.19 to 1.0.20 2022-06-28 00:09:48 +03:00
src avm2: Implement property type coercions 2022-06-30 21:34:26 -07:00
Cargo.toml build(deps): bump gif from 0.11.3 to 0.11.4 2022-06-28 00:51:23 +03:00
build.rs avm2: Allow implementing classes in ActionScript in custom `playerglobal` 2022-06-15 22:00:17 +03:00