Commit Graph

792 Commits

Author SHA1 Message Date
Nathan Adams 2650433271 Fixed get_keys with prototypes 2019-11-27 22:30:31 +01:00
Nathan Adams 585c520b87 Added prototype_enumerate test, `for (key in obj)` 2019-11-27 21:46:21 +01:00
Nathan Adams fdbd16a5d9 Ignore extends_chain, that's NYI 2019-11-27 21:11:03 +01:00
Nathan Adams 57d8469e3b Added a test for isPrototypeOf 2019-11-27 21:09:14 +01:00
David Wendt 1eb4dfa696 Merge remote-tracking branch 'dinnerbone/feature/extends_test' into feature/prototyping 2019-11-27 14:58:47 -05:00
David Wendt 5999aded7a Merge remote-tracking branch 'dinnerbone/feature/prototype_tests' into feature/prototyping 2019-11-27 14:56:39 -05:00
David Wendt 46e58c3ecd Remove `ReturnValue.ignore` entirely, since you really *do* need to resolve `ReturnValue`s, even if you don't want the result. 2019-11-27 14:52:07 -05:00
Nathan Adams b0f0008596 Added test for hasOwnProperty 2019-11-27 20:51:40 +01:00
Nathan Adams 03713f32e9 Correct fla for object_prototypes 2019-11-27 20:46:09 +01:00
Nathan Adams b43436bdd2 Enable recursive_prototypes test as it now passes 2019-11-27 20:31:33 +01:00
David Wendt 2c87888e28 Implement prototype chain recursion limit of 255 prototypes.
In Flash, this also at least claims to halt ActionScript execution on the movie. No such implementation of AVM poisoning currently exists in Ruffle, primarily because it's unclear what gets poisoned and implementing some of these options isn't yet possible:

1. AVM (e.g. all movies) - we would need to make the AVM fail silently in this case. This is the most straightforward way to poison the movie, but I'm not sure if this is how Flash actually does it, or if it poisons...
2. Movie - the current structure of movies is incompatible with adding arbitrary data to them. We need to merge `moviefetch` in before we can attach data to loaded movies.
3. MovieClip - this would also be implementable but has problems. How do child MovieClips know that their parent has been poisoned, or vice versa? What if a movie clip is loaded from one movie and moved into another?

As a result, I have decided to hold off on implementing recursion poisoning until I know where it's supposed to go and how to implement that.
2019-11-27 08:59:16 -05:00
Nathan Adams e9ad733e68 Add a test to see if the avm crashes with recursive prototypes.
Spoilers: it does.
2019-11-26 23:38:34 +01:00
Nathan Adams de1f5417ec Added test for extending MovieClip prototype 2019-11-26 23:22:07 +01:00
Nathan Adams ffaf10b604 Add test for prototyping 2019-11-26 23:22:07 +01:00
Nathan Adams 3bcd9ed71b Added test for class & interface hierarchy 2019-11-26 22:42:11 +01:00
David Wendt 4655ebe73f Always push the constructed object on the stack. 2019-11-26 15:07:59 -05:00
David Wendt b9f02c290c Functions should be traceable. 2019-11-26 15:07:03 -05:00
David Wendt 0b1afcf8be Implement `ActionInstanceOf` (for non-interface types) 2019-11-26 14:51:06 -05:00
David Wendt 3c8d9b9c1c `new` should be called on the prototype - not the constructor function. This will allow different host object impls to subclass correctly. 2019-11-26 14:51:06 -05:00
David Wendt e8632bbcaa Implement `valueOf` for `Object` and fix the `toString` impl. 2019-11-26 14:51:06 -05:00
David Wendt 73c3b42cd4 Move `force_set` and `force_set_virtual` into the `Object` trait. They are now called `define_value` and `add_property`, respectively.
While I don't expect every host object to implement it correctly, this also gets rid of a lot of unnecessary `unwrap` calls that would allow a poorly-written Flash file to kill the interpreter.
2019-11-26 14:51:06 -05:00
David Wendt 983c0fb200 Add proto chain inspection to the object interface. 2019-11-26 14:51:06 -05:00
David Wendt 0e59e1c961 Allow host-provided constructors to override `new` and provide host objects to the AVM when a particular constructor is called. 2019-11-26 14:51:06 -05:00
David Wendt d25bdbacf8 Separate `Object` into an interface trait and a standard implementation. Host object implementations may bypass `ScriptObject` and directly interface with the AVM using this trait.
Note that host objects that do so will *not* have access to their standard representation from within member functions - you will need to extend the interface to accomodate for them. This is due to long-standing limitations with type IDs and downcasting with types that bear lifetimes - it's entirely an unsafe operation and exposing such a facility to safe Rust is unsound. However, this will at least let us separate out several things from ScriptObject that don't need to be there for the time being.
2019-11-26 14:51:05 -05:00
David Wendt 6dd40f8354 Split properties into a separate module. 2019-11-26 14:51:05 -05:00
David Wendt 813783881b Implement explicit prototypes on user-generated functions.
`Object::function` now returns a pre-allocated function object. You may supply it an explicit prototype to have it linked into the function object (which is why we have to return a cell).
2019-11-26 14:51:05 -05:00
David Wendt f347992eeb Add `as_usize` method to `Value` 2019-11-26 14:51:05 -05:00
David Wendt 207a157f20 Add missing usize conversion 2019-11-26 14:51:05 -05:00
kmeisthax fb34f73159 Manually constructing `Value` should no longer be necessary
Co-Authored-By: Nathan Adams <dinnerbone@dinnerbone.com>
2019-11-26 14:51:05 -05:00
David Wendt 1cb374da8a `ActionSetMember` accepts non-String names as parameters. 2019-11-26 14:51:04 -05:00
David Wendt fafad818d4 Implement `ActionInitObject` 2019-11-26 14:51:04 -05:00
David Wendt da315c7311 Fix docstrings on these modules 2019-11-26 14:51:04 -05:00
David Wendt b4e9b8442e Implement `isPropertyEnumerable` and `isPrototypeOf`. 2019-11-26 14:51:04 -05:00
David Wendt aa7997b658 Expose user-defined virtual properties to AVM code 2019-11-26 14:51:04 -05:00
David Wendt a8e1654c9e Implement `ActionNewMethod` and `ActionNewObject` 2019-11-26 14:51:04 -05:00
David Wendt 2f965d1c64 First stab at moving system builtins to explicit prototypes 2019-11-26 14:51:03 -05:00
Nathan Adams 882373d969 Object prototyping 2019-11-26 14:51:03 -05:00
Mike Welsh 9a258e9b51 web: Default demo build to production mode 2019-11-25 17:00:29 -08:00
Mike Welsh 2fa2addca2 ci: Tweak extension build script 2019-11-25 17:00:29 -08:00
Mike Welsh ea5ea354fa ci: Bump cache version 2019-11-25 17:00:29 -08:00
Mike Welsh 42d724292f extension: Add missing obfuscated_event_prefix 2019-11-25 17:00:29 -08:00
Mike Welsh 24bf3a49bb extension: Fix webpack config to build even if web demo hasn't been built. Fix #122 2019-11-25 17:00:29 -08:00
Mike Welsh 6eaab8efdf
core: Merge #113, interworking of Rust + ActionScript
Internal support for interworking Rust and ActionScript code
2019-11-25 04:27:05 -08:00
dependabot-preview[bot] 60c7887b88 build(deps): bump num-traits from 0.2.9 to 0.2.10
Bumps [num-traits](https://github.com/rust-num/num-traits) from 0.2.9 to 0.2.10.
- [Release notes](https://github.com/rust-num/num-traits/releases)
- [Changelog](https://github.com/rust-num/num-traits/blob/master/RELEASES.md)
- [Commits](https://github.com/rust-num/num-traits/compare/num-traits-0.2.9...num-traits-0.2.10)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-25 11:13:02 +00:00
dependabot-preview[bot] 112411aa7a build(deps): bump structopt from 0.3.4 to 0.3.5
Bumps [structopt](https://github.com/TeXitoi/structopt) from 0.3.4 to 0.3.5.
- [Release notes](https://github.com/TeXitoi/structopt/releases)
- [Changelog](https://github.com/TeXitoi/structopt/blob/master/CHANGELOG.md)
- [Commits](https://github.com/TeXitoi/structopt/compare/v0.3.4...v0.3.5)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-25 10:53:04 +00:00
dependabot-preview[bot] 62171e31f6 build(deps): bump serde from 1.0.102 to 1.0.103
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.102 to 1.0.103.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.102...v1.0.103)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-25 10:39:40 +00:00
Nathan Adams 35d80a254b chore: Use new method of setting png color & depth 2019-11-25 10:39:01 +00:00
dependabot-preview[bot] aa61516c1d build(deps): bump png from 0.14.1 to 0.15.1
Bumps [png](https://github.com/image-rs/image-png) from 0.14.1 to 0.15.1.
- [Release notes](https://github.com/image-rs/image-png/releases)
- [Changelog](https://github.com/image-rs/image-png/blob/master/CHANGES.md)
- [Commits](https://github.com/image-rs/image-png/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-25 10:39:01 +00:00
David Wendt b8c24890fc Allow overwriting read-only virtual properties in scope chains.
The previous behavior had an oversight: if you tried to set a variable with the same name as an in-scope property, it would always try to overwrite that property. This can fail silently and doesn't match with Flash Player behavior. Now, an attempt to overwrite a read-only property is instead correctly rejected so that it can be defined in local scope.
2019-11-23 22:00:37 -05:00
dependabot-preview[bot] 2e75f06ee5 build(deps): bump gc-arena-derive from 0.1.1 to 0.2.0
Bumps [gc-arena-derive](https://github.com/kyren/gc-arena) from 0.1.1 to 0.2.0.
- [Release notes](https://github.com/kyren/gc-arena/releases)
- [Changelog](https://github.com/kyren/gc-arena/blob/master/CHANGELOG.md)
- [Commits](https://github.com/kyren/gc-arena/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-22 18:07:50 +00:00