Commit Graph

1674 Commits

Author SHA1 Message Date
David Wendt 60f9613365 Implement and test for `convert_b`. 2020-08-10 16:38:04 -07:00
David Wendt 6cf48eb543 Implement and test `not`. 2020-08-10 16:38:04 -07:00
David Wendt b972c24f7e Oh look, I figured out how to emit `istrue`, so that's tested, too. 2020-08-10 16:38:04 -07:00
David Wendt 850ebc88a2 Add test for truthiness.
As compiled by Adobe Animate CC 2020, this test appears to only use `iffalse`. However, both `op_is_false` and `op_is_true` coerce in the same manner, so I'm not entirely sure this is a problem for now.
2020-08-10 16:38:04 -07:00
David Wendt e5c8c5b340 Expose `Infinity` to AS3. 2020-08-10 16:38:04 -07:00
David Wendt 5bb8c1836f Replace `as_bool` with `coerce_to_bool`.
Functions that need to assert Boolness without coercion should either:

1. Ensure their function declaration requires a Boolean. (We don't enforce type errors on ES4 typehints yet, but we should.)
2. Check the value type themselves and raise their own errors if necessary.

As it stands the only users of `as_bool` either needed to check the type themselves or use `coerce_to_bool`. Notably, `setPropertyIsEnumerable` doesn't appear to coerce *or* throw an error: it instead fails silently if you hand it a non-`Boolean` value.
2020-08-10 16:38:04 -07:00
dependabot-preview[bot] 04b146ffc4 build(deps): bump enumset from 1.0.0 to 1.0.1
Bumps [enumset](https://github.com/Lymia/enumset) from 1.0.0 to 1.0.1.
- [Release notes](https://github.com/Lymia/enumset/releases)
- [Changelog](https://github.com/Lymia/enumset/blob/master/RELEASES.md)
- [Commits](https://github.com/Lymia/enumset/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-09 13:15:38 -07:00
dependabot-preview[bot] 178178d9dd build(deps): bump indexmap from 1.5.0 to 1.5.1
Bumps [indexmap](https://github.com/bluss/indexmap) from 1.5.0 to 1.5.1.
- [Release notes](https://github.com/bluss/indexmap/releases)
- [Commits](https://github.com/bluss/indexmap/compare/1.5.0...1.5.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-08 13:37:32 -07:00
dependabot-preview[bot] 53d32d4dac build(deps): bump num_enum from 0.5.0 to 0.5.1
Bumps [num_enum](https://github.com/illicitonion/num_enum) from 0.5.0 to 0.5.1.
- [Release notes](https://github.com/illicitonion/num_enum/releases)
- [Commits](https://github.com/illicitonion/num_enum/compare/0.5.0...0.5.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-05 16:00:27 -07:00
dependabot-preview[bot] 0c7edda6c2 build(deps): bump syn from 1.0.37 to 1.0.38
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.37 to 1.0.38.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.37...1.0.38)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-05 15:59:02 -07:00
unknown 47a8eb6f3e avm1: Copy broadcast functions for MovieClipLoader 2020-08-04 07:02:14 -07:00
dependabot-preview[bot] f8aa185c3e build(deps): bump syn from 1.0.36 to 1.0.37
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.36 to 1.0.37.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.36...1.0.37)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-03 16:57:45 -07:00
David Wendt 8cb6e4af39 Further adjustments that fell through before. 2020-08-01 16:11:11 -04:00
David Wendt 4dbd26807e Remove useless lifetime in `notify_system_listeners` 2020-08-01 15:49:29 -04:00
David Wendt 8ebf5405e2 Move AVM2 into the UpdateContext. 2020-08-01 15:49:29 -04:00
David Wendt bfa5f8ae35 Further compilation fixes necessary to get the refactor to compile again.
Notably, all of the `Avm1` "run stack frame" functions can no longer take a self parameter as the update context they will be getting also has that same parameter. Ergo, they're associated functions that get the moral equivalent of self from the update context.

This also introduces a new `Activation::from_stub` which creates a stub frame that runs everything on the main movie in layer 0. This significantly reduces boilerplate code elsewhere in the project.
2020-08-01 15:49:28 -04:00
David Wendt 9b089ae1d7 Convert `array.rs` to the new activation-only format.
This also removes the function parameter on `sort_compare_numeric`. As it was only being used for string comparisons, and it was causing unfixable lifetime issues, I have instead had it take the case-sensitivity flag and call the two functions it would have been passed anyway. This fixes the lifetime issue.
2020-08-01 15:49:26 -04:00
David Wendt a19595c8b4 Embed `UpdateContext` in `Activation` directly.
The process of constructing an `Activation` now involves calling `UpdateContext.reborrow`, which "sheds" a lifetime by copying all of the borrows into a new "owned" context with that lifetime.

Likewise, to call out to functions that don't need an `Activation`, just borrow the context out of the current activation. You can also construct child-frame activations by reborrowing the parent activation's context.
2020-08-01 15:49:19 -04:00
David Wendt 7c7b019087 Move AVM1 inside UpdateContext. 2020-08-01 13:44:04 -04:00
David Wendt 14bfbc358f wip: Move UpdateContext into Activation 2020-08-01 13:33:04 -04:00
David Wendt 9f76a7b964 Ensure that `Player` always has a movie in level zero, even if no movie has been queued up yet.
There is a race condition inadvertently caused by allowing movies to be fetched in slot 0: it is possible for the player to be caught mid-load without a root movie. A lot of code assumes level 0 always exists (e.g. `levels.get(0).unwrap()`), while our initialization methods assumed no Player methods would be called until the root movie is installed. This is an unreasonable assumption, as among other things users can trigger the race condition by just playing the movie too quickly.
2020-08-01 02:35:00 -07:00
Nathan Adams 26b14bd904 avm1: Undone some __constructor__ setting on objects that don't actually construct 2020-08-01 02:33:14 -07:00
Nathan Adams db4f5007f3 avm1: TObject::create_bare_object doesn't use or need args 2020-08-01 02:33:14 -07:00
Nathan Adams 79af3ffe44 avm1: Rename TObject::new to TObject::create_bare_object 2020-08-01 02:33:14 -07:00
Nathan Adams 2131f7860b avm1: Change Object::construct to create and return a new object, instead of requiring the caller to do that first 2020-08-01 02:33:14 -07:00
Nathan Adams e74d4f0abb avm1: Make FunctionObject::allocate_function require prototype, it's not optional 2020-08-01 02:33:14 -07:00
Nathan Adams fb7fb6f99a avm1: Make FunctionObject::functional require prototype, it's not optional 2020-08-01 02:33:14 -07:00
Nathan Adams 9123d92513 avm1: Make FunctionObject::constructor require prototype, it's not optional 2020-08-01 02:33:14 -07:00
Nathan Adams 691e3b6804 avm1: Make FunctionObject::function_and_constructor require prototype, it's not optional 2020-08-01 02:33:14 -07:00
Nathan Adams 88a31cc5a9 avm1: Ensure we call movie constructors through Function::construct, not manually, to set __constructor__ 2020-08-01 02:33:14 -07:00
Nathan Adams 69a4d10338 avm1: Replace manual constructor calling with Function::construct, to ensure we set __constructor__ 2020-08-01 02:33:14 -07:00
Nathan Adams 2faf35d43e avm1: Set __constructor__ in Function::construct 2020-08-01 02:33:14 -07:00
unknown d6eeb723dc avm1: Fix panic in broadcastMessage 2020-07-29 15:24:23 -07:00
unknown 1d17910b6d chore: Remove an unnecessary file 2020-07-29 15:24:23 -07:00
unknown ef4240e95d chore: Satisfy rustfmt and clippy 2020-07-29 15:24:23 -07:00
unknown a14f19e9e5 avm1: Call the respective listeners 2020-07-29 15:24:23 -07:00
unknown 795cd72dce avm1: Broadcasting functions are now copied from AsBroadcaster 2020-07-29 15:24:23 -07:00
unknown b72dbcae96 chore: Assert his inside of listeners 2020-07-29 15:24:23 -07:00
unknown df50cbb27f avm1: Fix the behavior of addListener and removeListener 2020-07-29 15:24:23 -07:00
unknown 20989ef03d avm1: Initialize now copies the functions from AsBroadcaster 2020-07-29 15:24:23 -07:00
unknown 3a0af11e34 chore: Run rustfmt 2020-07-29 15:24:23 -07:00
unknown 890dc0ea13 avm1: Implement AsBroadcaster 2020-07-29 15:24:23 -07:00
Nathan Adams 32be19da6d avm1: Allow gotoAndStop/gotoAndPlay with frame numbers in paths - #915 2020-07-29 13:53:57 -07:00
Mike Welsh 5d08956152 tests: Add typeof and labels for Object() test 2020-07-29 13:52:51 -07:00
CUB3D 0fe3a23fd6 core: Correct handling of Object function without args 2020-07-29 13:52:51 -07:00
CUB3D 49bee3fe5c core: Implement Object() function 2020-07-29 13:52:51 -07:00
CUB3D fa8b2bca8b chore: Fix formatting 2020-07-27 12:50:31 -07:00
CUB3D c1771d7d4e core: Split function and constructor, tests, fix bug with constructor 2020-07-27 12:50:31 -07:00
CUB3D 4217138d1a chore: Update comment 2020-07-27 12:50:31 -07:00
CUB3D 7792487181 chore: Fix clippy lints 2020-07-27 12:50:31 -07:00
CUB3D afb1d6b42f core: Add global Array() function 2020-07-27 12:50:31 -07:00
CUB3D 22db5ab76a core: Populate function when creating a constructor 2020-07-27 10:38:50 -07:00
CUB3D 01b7e73459 core: Fix build 2020-07-27 10:38:50 -07:00
CUB3D adb9af5a62 core: Update arguments 2020-07-27 10:38:50 -07:00
CUB3D 7b66968ebb core: Cleanup 2020-07-27 10:38:50 -07:00
CUB3D 5f87b1361b core: Update NewMethod action and update globals to use constructor 2020-07-27 10:38:50 -07:00
CUB3D e83dbf7327 core: Split construct and call for function objects 2020-07-27 10:38:50 -07:00
Nathan Adams 337e3292dd avm1: Treat MovieClipLoader _listeners as an array, not an object 2020-07-27 05:36:28 -07:00
dependabot-preview[bot] ed07ea6db2 build(deps): bump syn from 1.0.35 to 1.0.36
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.35 to 1.0.36.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.35...1.0.36)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-27 05:17:11 -07:00
Nathan Adams 17344613e3 core: Lock variable dumping behind avm_debug 2020-07-27 04:13:31 -07:00
Nathan Adams e98b953088 avm1: Use avm_warn and avm_error in all of avm1 2020-07-27 04:13:31 -07:00
Nathan Adams 10a739f714 avm1: Always assign function names (where possible) when running in avm_debug, not just when spamming output 2020-07-27 04:13:31 -07:00
Nathan Adams 810e231b8b avm1: Add macros for more advanced log/error printing when avm_debug is on 2020-07-27 04:13:31 -07:00
Mike Welsh e5480ee9b2 chore: Use matches! to fix clippy lint 2020-07-27 04:13:11 -07:00
Nathan Adams f1f04e0e7a avm1: Fixed a bunch of cases where we're using _level0 instead of current object (fixes #926) 2020-07-27 01:40:28 -07:00
Nathan Adams cf61f8a4d3 avm1: Add failing test for registerClass in a loaded movie 2020-07-27 01:40:28 -07:00
Mike Welsh 8ac2ad9b40
avm1: Store movie URL on load and implement _url (merge #912) 2020-07-27 01:38:28 -07:00
David Wendt acd7ceb706 Fix missing import on web. 2020-07-25 22:20:30 -04:00
David Wendt 153b7b78a5 Add a web version of `url_from_relative_path` that just yields an error.
This allows us to remove the conditionals on implementations of `from_path` that need to call this function, as the function is now always guaranteed to be there, even if it's just a no-op/`Err` generator.
2020-07-25 19:48:32 -04:00
Mike Welsh 07122dc931 avm1: Implement Key listeners 2020-07-24 14:32:41 -07:00
Mike Welsh 85d9caef56 avm1: All properties of _global are DontEnum 2020-07-23 22:58:58 -07:00
Mike Welsh 794dc69809 avm1: Implement isFinite 2020-07-23 22:58:58 -07:00
David Wendt aed47d458d Level loads in GetURL2 should also propagate origin information. 2020-07-23 23:09:08 -04:00
David Wendt a34e81a704 `_url` on desktop should always return a file URL for file-loaded movies. 2020-07-23 23:02:56 -04:00
David Wendt f0e2c77c1f URLs from paths is a desktop-only feature. 2020-07-23 23:02:55 -04:00
David Wendt 9b9d4076fe Expose movie URL to ActionScript. 2020-07-23 23:02:55 -04:00
David Wendt a8877ab63c Yield the correct error when the root movie load fails. 2020-07-23 23:02:55 -04:00
David Wendt d172441663 Also make absolute URLs for all movie loads passed through the load manager. 2020-07-23 23:02:54 -04:00
David Wendt 5d15f5bfe3 When loading a movie from the filesystem outside of the core, ensure that the URL is properly made absolute. 2020-07-23 23:02:54 -04:00
David Wendt c926da8888 Refactor URL relativization into two utility methods that backends can provide base URLs and paths to. 2020-07-23 23:02:54 -04:00
David Wendt 7433bfe28f Add a `NavigatorBackend` method to resolve relative URLs. 2020-07-23 23:02:53 -04:00
David Wendt 4813942fe7 The player should always change the audio backend's framerate itself. 2020-07-23 23:02:52 -04:00
David Wendt f56d16a68d Separate player creation from root movie setup, and allow users of Ruffle to load in movies synchronously or asynchronously.
During the small period of time when a player is created but has no root movie, a temporary empty movie is installed with an assumed stage size and framerate of 550x400@12fps. This is Flash default for new projects, so it seemed appropriate. User ActionScript cannot see these values, and I'm not even sure JavaScript can, either.
2020-07-23 23:02:51 -04:00
David Wendt 6998dafdb9 Store an origin URL on every movie that is loaded. 2020-07-23 23:02:50 -04:00
Nathan Adams 7f7281493f core: Allow toggling avm_debug output on and off with ctrl+alt+d, defaults to off 2020-07-23 19:14:32 -07:00
Mike Welsh efa059ff8d tests: Add test for LoadVars 2020-07-23 03:00:19 -07:00
Mike Welsh 1709e76409 avm1: Implement LoadVars 2020-07-23 03:00:19 -07:00
Mike Welsh 74cb8609c1 avm1: Support loading into _level in GetURL2
Calling loadMovieNum with a variable parameter compiles into a
GetURL2 call with a `_level` window target parameter. Previously
this triggered Ruffle to try to navigate to the SWF. Now it
properly loads the SWF inside the current movie.
2020-07-23 02:08:48 -07:00
Nathan Adams f0980301da avm1: Implement arguments.callee 2020-07-22 15:57:45 -07:00
Nathan Adams 4a56cb1062 avm1: Make virtual properties store Object instead of Executable, so we can refer to the callee 2020-07-22 15:57:45 -07:00
Nathan Adams f4ab57d6e0 avm1: Make property watchers take Object, not Executable, so we can track the callee 2020-07-22 15:57:45 -07:00
Nathan Adams 9ae10b6387 avm1: Made AvmString debug actually show contents of the string 2020-07-22 13:23:57 -07:00
Nathan Adams 3b2b7c226c avm1: Fix gc unsoundness with missing collects in SystemPrototypes 2020-07-21 09:43:07 -07:00
Nathan Adams 0e0be34e17 avm1: Fix compile error when using avm_debug flag 2020-07-21 09:42:41 -07:00
Nathan Adams d5deeee1b7 avm1: Properly implement the arguments object, it's an array 2020-07-21 07:49:00 -07:00
dependabot-preview[bot] aa966fbfb6 build(deps): bump syn from 1.0.34 to 1.0.35
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.34 to 1.0.35.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.34...1.0.35)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-20 14:24:56 -07:00
Mike Welsh 1a5d7fe452
avm2: Initial AVM2 interpreter (merge #404)
Initial work on the AVM2 interpreter.
2020-07-19 19:59:05 -07:00
David Wendt 7adabc8166 Use `unwrap_or_default` 2020-07-18 17:28:07 -04:00
David Wendt 44b924d7b4 `Script` should not hold write locks when probing it's internal caches. 2020-07-18 17:26:11 -04:00
Mike Welsh 034c125b80 core: Support radial gradients in morph shapes
Radial gradients were not accounted for in morph shapes.
Clean up the interpolation code and add support for radials.
Fixes #591.
2020-07-18 14:12:04 -07:00
David Wendt 575a9b091a Use FnvHashMap for the translation unit pools. 2020-07-18 17:02:52 -04:00
David Wendt 262bb148f1 Rename `a2me` to `entry` (or `method` in one case where it lets me simplify a struct declaration) 2020-07-18 17:02:32 -04:00
David Wendt c415190376 Zero-index multinames should generate a validation error in `QName::from_abc_multiname`. 2020-07-18 16:48:10 -04:00
David Wendt dc962f2abd Add AVM2 equivalent of `PropertyMap` for further expansion. 2020-07-18 16:41:35 -04:00
David Wendt 37b6b89d26 Add a stub AVM2 string representation to allow for both VMs' strings to diverge. 2020-07-18 16:20:58 -04:00
David Wendt ccacc540bf Remove dead code on all now-in-use structs and methods. 2020-07-18 16:12:24 -04:00
dependabot-preview[bot] 0bd7f07649 build(deps): bump png from 0.16.6 to 0.16.7
Bumps [png](https://github.com/image-rs/image-png) from 0.16.6 to 0.16.7.
- [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/compare/v0.16.6...v0.16.7)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-18 12:36:46 -07:00
Mike Welsh ae7db80ea3 avm1: Move getURL to MovieClip.prototype (fix #804)
For example, _root.getURL should work.
2020-07-18 01:03:47 -07:00
dependabot-preview[bot] ee2222a425 build(deps): bump indexmap from 1.4.0 to 1.5.0
Bumps [indexmap](https://github.com/bluss/indexmap) from 1.4.0 to 1.5.0.
- [Release notes](https://github.com/bluss/indexmap/releases)
- [Commits](https://github.com/bluss/indexmap/compare/1.4.0...1.5.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-17 20:51:05 -07:00
Mike Welsh 8ecae5a87f avm1: duplicateMovieClip copies clip events
Clip events should be copied from the source clip to the newly
created clip. Fixes objects remaining onscreen in #815.
2020-07-17 20:49:05 -07:00
Mike Welsh 8c1ec01d75 tests: Test clip events copying in duplicateMovieClip
duplicateMovieClip should also copy any clip events on the source
clip to the newly created movie clip.
2020-07-17 20:49:05 -07:00
Mike Welsh 7c52a1bcc4 avm1: Accept path strings in ActionCall (fix #832) 2020-07-14 23:34:21 -07:00
Mike Welsh b43fdca4ad avm1: resolve_text_field_variable -> resolve_variable_path 2020-07-14 23:34:21 -07:00
Mike Welsh f9b1c586d1 tests: Add test for paths in ActionCall 2020-07-14 23:34:21 -07:00
David Wendt e354c53075 Remove any remaining uses of `abc_ref`.
Holding a `Ref` on a garbage-collected object inherently extends any borrow locks on that object. Since ABC files are references already, taking a `Ref` to them only helps to skip the refcount update. This is less useful than expected: in most situations, using `abc_ref` causes double-borrow panics. The few methods that can use it are going to be fragile in the face of future refactors, so I'm nipping the problem in the bud now.
2020-07-14 20:14:23 -04:00
David Wendt f4c5075086 Run all string constant retrieval through the `TranslationUnit`, preventing us from making multiple copies of the same string.
For good measure, most of the other methods in `value` for retrieving pool primitives now also use `TranslationUnit` instead of `AbcFile`. This is the result of a handful of cascading changes throughout the project, and itself caused a few more.
2020-07-14 20:05:25 -04:00
David Wendt 70e9e7e9e9 Add support for cached/interned pool strings in the `TranslationUnit`. 2020-07-13 23:42:07 -04:00
David Wendt e1b9b823fc Remove `abc_string` and replace it with `abc_string_copy`. All code that pulls strings from the ABC file now uses `AvmString`s. 2020-07-13 23:41:46 -04:00
David Wendt 61a3ff8ae6 Replace `String` or `&str` references with `AvmString` everywhere in the AVM2 runtime. 2020-07-13 22:21:18 -04:00
David Wendt 2021cec9d3 Impl `Copy`, `Eq`, `PartialOrd`, `Ord`, and `Hash` for `AvmString`. 2020-07-13 22:09:34 -04:00
David Wendt 508fcd6e9e `pool_string` should return a `Ref<str>` just like `value::abc_string`. 2020-07-13 17:45:12 -04:00
David Wendt a406bdada2 Don't attempt to log debugging information if we're not in a debug build. 2020-07-13 17:45:12 -04:00
David Wendt ae26615bb4 `coerce_string` may return a static string, which we shouldn't clone. 2020-07-13 17:45:12 -04:00
David Wendt f0c633fe81 Allow borrowing string values from an ABC file instead of cloning everything. 2020-07-13 17:45:11 -04:00
David Wendt 64e5b46259 Add tests for `instanceof` and `is` operators. 2020-07-13 17:45:10 -04:00
David Wendt 39a4566f20 Instances should be listed as their prototypes (empty as they are) 2020-07-13 17:45:10 -04:00
David Wendt c917b3d411 Implement `istype`, `istypelate`, and `instanceof`. 2020-07-13 17:45:10 -04:00
David Wendt a0cb052795 Add `is_instance_of` trait method to `TObject` 2020-07-13 17:45:09 -04:00
David Wendt 3fae8b3832 Read the interface list when instantiating classes, resolve them, and stick them in the prototype for later use. 2020-07-13 17:45:09 -04:00
David Wendt cce68dbc21 Add trait methods for getting and setting the interfaces list. 2020-07-13 17:45:08 -04:00
David Wendt 563a515189 Add a test for loading interfaces into the AVM2.
This test will fail if the AVM2 implementation does not support bodyless methods or bare classes properly.
2020-07-13 17:45:07 -04:00
David Wendt 8f2d3315f3 Allow the construction of classes with no base class.
This is primarily used for interfaces, in case you can't guess by the previous commit.
2020-07-13 17:45:07 -04:00
David Wendt 5d89d4ed85 Allow methods to not hold a body.
Interface methods are specifically not allowed to be called: as a result, they don't get a method body. Existing code assumed a 1:1 relationship between methods and bodies, which causes spurious errors.
2020-07-13 17:45:07 -04:00
David Wendt 090fe56bd3 Wrap `BytecodeMethod` (and the bytecode half of `Executable`) in a `Gc`.
This is inspired by Dinnerbone's similar PR on the AVM1 side, where the Action half of that VM's `Executable` was reduced from 128 bytes to 16 by shoving it in a `Gc`. This won't be as dramatic but should still save some memory.

In fact, it should save a *lot* of memory in bytecode execution, where thanks to the previous commit's rebase, we now need to clone the current method once *for each instruction executed*. That is terrible, but should stop now.
2020-07-13 17:45:06 -04:00
David Wendt 97e005622b Invert the role of `Avm2` and it's `Activation`, similar to what was done with `Avm1` and it's `Activation`.
This also results in a far reduced role for `ReturnValue`, since I also took the liberty of removing most of it's use. Furthermore, I also made it apply equally to native and AVM2 code, which ensures all native implementations of methods don't double-borrow.

In AVM1, `ReturnValue` was actually removed entirely, because it's not needed. I attempted to do the same, but the fact that we're currently embedding `ScriptObjectData` in native objects means that we need it for virtual properties. Otherwise, virtual property implementations will see locked objects, which is bad.
2020-07-13 17:45:06 -04:00
David Wendt 5b5bf0719e Remove `Avm2Function` as it is no longer used. 2020-07-13 17:45:05 -04:00
David Wendt 098b034de0 Refactor method-related structs into a separate method module.
This also renames `NativeFunction` and `Avm2MethodEntry` to `NativeMethod` and `BytecodeMethod`, respectively.
2020-07-13 17:45:05 -04:00
David Wendt b6e05519cd Remove `Avm2ClassEntry`. It is no longer used. 2020-07-13 17:45:05 -04:00
David Wendt 12fc13da7f Clippy compliance for the last batch of commits. 2020-07-13 17:45:05 -04:00
David Wendt 041cb0b5c3 Resolve multiname constant zero as an error rather than a panic.
While some code that references pool multinames has zero as a valid index, we cannot validate exactly what the zero index is for a given index. Hence, callers instantiating multinames must check for zero and substitute the correct zero-value interpretation for their given type. If zero is an invalid value, it should ideally throw a different error than what's provided here.
2020-07-13 17:45:04 -04:00
David Wendt 0d2235d2e0 Resolve all remaining compilation issues with this refactor. 2020-07-13 17:45:04 -04:00
David Wendt 7684736bf7 `table_class` should resolve `Class`es straight from the current translation unit. 2020-07-13 17:45:04 -04:00
David Wendt 232c29dc5e Fix remaining problems with method loading using `callstatic` 2020-07-13 17:45:03 -04:00
David Wendt eaebd3c63c Make `Avm2MethodEntry` hold it's `TranslationUnit` rather than an `AbcFile`. 2020-07-13 17:45:03 -04:00
David Wendt 4467bc3193 Make `TranslationUnit` a GC-mandatory type (only referred to by `GcCell`). 2020-07-13 17:45:03 -04:00
David Wendt 60f3ae3ba7 Remove `Avm2ScriptEntry`. It is now obsolete and unused. 2020-07-13 17:45:02 -04:00
David Wendt f549d0146e Fix compilation bugs involved with automatic script initializer execution. 2020-07-13 17:45:02 -04:00
David Wendt b4f944b37b Wrap ABC loading inside of a `TranslationUnit`. 2020-07-13 17:45:01 -04:00
David Wendt 70e9030072 Decouple the entire trait machinery from ABC-provided traits.
This commit breaks the build: we still need to tell `Avm2` how to turn ABC traits into our own internal `Trait<'gc>`, `Class<'gc>`, and `Method<'gc>` types. We also need something to track which traits have already been instantiated, because `callstatic` would otherwise reinstantiate the trait in a different scope. (In fact, I think it *does* do exactly that right now...)
2020-07-13 17:45:01 -04:00
David Wendt 15a62d31cb Add an internal representation of `Trait`, separate from `swf::avm2::types::Trait`, which is specific to the ABC file format.
The intention is to completely replace all usage of `Avm2XYZEntry` with `Class`, `Trait`, and `Method`. This will allow runtime-provided global class traits to coexist with those provided by user code.
2020-07-13 17:45:01 -04:00