Commit Graph

1965 Commits

Author SHA1 Message Date
David Wendt 685fbc12e0 tests: `Array.reverse`'s test should also include a check for holes. 2020-09-15 02:20:11 -07:00
David Wendt 036f7cbb90 avm2: Implement `Array.shift` and `Array.unshift`.
This also updates `Array.push` to support it's ability to push multiple arguments at once.
2020-09-15 02:20:11 -07:00
David Wendt 879aff3669 avm2: Implement `Array.reverse` 2020-09-15 02:20:11 -07:00
David Wendt 1ce78388a3 avm2: Implement `Array.push` and `Array.pop` 2020-09-15 02:20:11 -07:00
David Wendt 0ece924877 avm2: Implement `indexOf` and `lastIndexOf` 2020-09-15 02:20:11 -07:00
David Wendt 7aa1ab82e4 avm2: Avoid locking the array when running user code.
The array being iterated is explicitly handed to all callbacks, and it is legal for the callback to mutate the array. Hence, we can't actually hold a `Ref` to the array storage when we call user code. Instead, we implement a custom `Iterator` which iterates over the object like user code would.

This actually can't be an `Iterator` impl due to limitations of the underlying trait. Hence, we have to `while let` instead of `for`.
2020-09-15 02:20:11 -07:00
David Wendt 832bbdd711 avm2: Implement `forEach`, `map`, `filter`, `every`, and `some` on `Array`.
This also comes with some refactoring: building the resulting array object and resolving holes is now done in helper methods.
2020-09-15 02:20:11 -07:00
David Wendt 0eeee72be6 avm2: Implement `Array.join`, `Array.toString`, and `Array.valueOf` (w/tests) 2020-09-15 02:20:11 -07:00
David Wendt 79df789028 tests: Add test for `Array.concat`. 2020-09-15 02:20:11 -07:00
David Wendt 75e6018607 tests: Add test for `newarray`. 2020-09-15 02:20:11 -07:00
David Wendt 505018c3b8 avm2: Implement `newarray`. 2020-09-15 02:20:11 -07:00
David Wendt 27793092c2 tests: Add `array_holes` test. 2020-09-15 02:20:11 -07:00
David Wendt 3d37fda1ef tests: Add tests for `deleteproperty` on arrays. 2020-09-15 02:20:11 -07:00
David Wendt 04828663e8 avm2: `deleteproperty` should only ever yield `false` when attempting to delete unknown properties on a sealed class object. 2020-09-15 02:20:11 -07:00
David Wendt 6d9b9c9218 avm2: Attempts to get unknown properties on dynamic objects should yield `undefined`. 2020-09-15 02:20:11 -07:00
David Wendt 966dfc3902 avm2: Add method to get at the `Class` of non-class objects with a prototype.
The only unclassed objects should be bare objects, which are hard to get at.
2020-09-15 02:20:11 -07:00
David Wendt cac1717780 avm2: Add utility method `is_sealed` for `Class`. 2020-09-15 02:20:11 -07:00
David Wendt 1a8f041b77 tests: Add `array_storage` test. 2020-09-15 02:20:11 -07:00
David Wendt 34ba1643dd tests: Add test for reading properties of an array 2020-09-15 02:20:11 -07:00
David Wendt 5a29b781ec avm2: Ensure `ArrayObject` offers access to it's array properties for reading and writing. 2020-09-15 02:20:11 -07:00
David Wendt e054456286 avm2: Add method to check if a particular namespace is the public namespace. 2020-09-15 02:20:11 -07:00
David Wendt 1d3f5d80be tests: Add test for `new Array`'s arguments. 2020-09-15 02:20:11 -07:00
David Wendt a09ba9d263 avm2: Implement `length`. 2020-09-15 02:20:11 -07:00
David Wendt aaf586e3a7 avm2: `define_instance_trait` should actually define instance traits. 2020-09-15 02:20:11 -07:00
David Wendt 45c95cae02 avm2: Impl `Array.concat` 2020-09-15 02:20:11 -07:00
David Wendt 1092bf2bc5 avm2: Add the ability to wrap an already-constructed array in an object. 2020-09-15 02:20:11 -07:00
David Wendt bd35ebb793 avm2: Impl `Array` constructor 2020-09-15 02:20:11 -07:00
David Wendt bedd5fa007 avm2: Add a method for mutating the array storage of an object. 2020-09-15 02:20:11 -07:00
David Wendt d92d3023e7 avm2: Restore `as_number`.
This is for the sake of methods that want to change behavior based on if they're working with a number or some other kind of value. It should not be used otherwise.
2020-09-15 02:20:11 -07:00
David Wendt 16e1a1bdf3 avm2: Add Array class.
This code also ensures that the prototypes of each system object are created in the appropriate `TObject` impl. This ensures that, for example, `new Array` hands you back an actual array.
2020-09-15 02:20:11 -07:00
David Wendt 88fc9b1538 avm2: Implement base types for array-shaped objects. 2020-09-15 02:20:11 -07:00
dependabot-preview[bot] f0976cffc7 build(deps): bump syn from 1.0.40 to 1.0.41
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.40 to 1.0.41.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.40...1.0.41)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-14 12:02:03 -07:00
Nathan Adams 3ff399ca6b core: Trace only to the log backend, but have the default log backend trace to the log crate 2020-09-13 13:51:39 -07:00
Nathan Adams 319efabb47 tests: Make tests capture trace output through new backend 2020-09-13 13:51:39 -07:00
Nathan Adams e25e03a841 core: Log to new avm_trace method where we want things to show up 2020-09-13 13:51:39 -07:00
Nathan Adams de009c7673 core: Add Log backend, for capturing trace output specific to a movie 2020-09-13 13:51:39 -07:00
dependabot-preview[bot] 491526cc93 build(deps): bump bitstream-io from 0.8.5 to 0.9.0
Bumps [bitstream-io](https://github.com/tuffy/bitstream-io) from 0.8.5 to 0.9.0.
- [Release notes](https://github.com/tuffy/bitstream-io/releases)
- [Commits](https://github.com/tuffy/bitstream-io/compare/v0.8.5...v0.9.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-11 21:17:24 -07:00
Adrian Wielgosik 0fe88f23bb
avm1: Use fnv hash in PropertyMap 2020-09-09 10:44:52 -07:00
CUB3D 8a5434c956 core: Switch to enum for differentiating callable values from uncallable ones 2020-09-07 13:14:48 -07:00
CUB3D efa7e862fd core: Propagate this through scope and get_variable 2020-09-07 13:14:48 -07:00
CUB3D 91d5e0f74b core: Update tests 2020-09-07 13:14:48 -07:00
CUB3D 136a5664b0 core: Pass the correct this for CallFunction when in a with scope
fixes #805, #945, #1018
2020-09-07 13:14:48 -07:00
Mike Welsh a18e80baf2 chore: Fix clippy lints 2020-09-07 12:18:41 -07:00
dependabot-preview[bot] 08f1299595 build(deps): bump syn from 1.0.39 to 1.0.40
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.39 to 1.0.40.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.39...1.0.40)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-07 11:14:14 -07:00
dependabot-preview[bot] 07a6075765 build(deps): bump indexmap from 1.5.2 to 1.6.0
Bumps [indexmap](https://github.com/bluss/indexmap) from 1.5.2 to 1.6.0.
- [Release notes](https://github.com/bluss/indexmap/releases)
- [Commits](https://github.com/bluss/indexmap/compare/1.5.2...1.6.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-07 11:13:54 -07:00
David Wendt 35b589b2ac avm2: `in` should only ever query non-namespaced/public properties. 2020-09-07 11:07:07 -07:00
David Wendt 3b5411547a avm2: Implement `in` 2020-09-07 11:07:07 -07:00
David Wendt 11b8354905 avm2: `resolve_any` should resolve prototype properties. 2020-09-07 11:07:07 -07:00
Mike Welsh 64679e8796 avm1: typeof button/text should be object (fix #1110) 2020-09-04 11:33:40 -07:00
Nathan Adams b2dc564628 avm1: Fix String.lastIndexOf(undefined) 2020-09-04 11:32:16 -07:00
Nathan Adams ea7a9758c4 avm1: Fix String.indexOf(undefined) 2020-09-04 11:32:16 -07:00
Mike Welsh 86ab300ee8 core: Call post_instantiate on initial empty root (fix #946)
The `fake_root` did not have an object, which could cause the
player to panic if the SWF was not completely loaded when playing.
Calling `post_instantiate` ensures that this dummy root has an
object.
2020-09-04 11:31:04 -07:00
Mike Welsh 3a813f1f15 tests: Test for #1104 2020-09-03 19:09:48 -07:00
Mike Welsh 5ea06b0ce6 swf: Use Option for more PlaceObject parameters
There is a difference between empty/default (change value to default)
and none (don't modify), so make this explicit for some PlaceObject
parameters where it wasn't.

Fixes #1104.
2020-09-03 19:09:48 -07:00
Mike Welsh 151b13a424 avm1: ExternalInterface properties are read only 2020-09-03 18:17:44 -07:00
Nathan Adams b5531a48d0 web: Allow reentrant ExternalInterface callbacks 2020-09-03 18:17:44 -07:00
Nathan Adams a49e8d8587 web: Implement two-way communication with ExternalInterface 2020-09-03 18:17:44 -07:00
Nathan Adams 687c912067 core: Allow for reentry from ExternalInterface methods 2020-09-03 18:17:44 -07:00
Nathan Adams 32de953822 core: Allow passing arguments and returning values to/from ExternalInterface 2020-09-03 18:17:44 -07:00
Nathan Adams e1b3ac79d6 core: Add ability to call out to ExternalInterfaceProviders 2020-09-03 18:17:44 -07:00
Nathan Adams 502ea98ed4 core: Add ability to call in to ExternalInterface callbacks from outside of the player (+ test) 2020-09-03 18:17:44 -07:00
Nathan Adams 169c61bf96 tests: Added ability for tests to have a before_start and before_end, and added basic ExternalInterface test that uses it 2020-09-03 18:17:44 -07:00
Nathan Adams 3784f411b4 core: Add ExternalInterface::addCallback 2020-09-03 18:17:44 -07:00
Nathan Adams b66e9f8d16 avm1: Add ExternalInterface with only 'available' property right now 2020-09-03 18:17:44 -07:00
Nathan Adams 8f11141426 core: Add initial ExternalInterface structs 2020-09-03 18:17:44 -07:00
Nathan Adams c5ac707fb5 avm1: Iterating xmlnode attributes should list every attribute 2020-09-03 17:03:43 -07:00
Nathan Adams bcb64b9a62 avm1: Fix calling Function() as a function - fixes #1074 2020-09-03 17:01:20 -07:00
Nathan Adams 40cdb84656 tests: Add test for avm1 Function(foo) 2020-09-03 17:01:20 -07:00
Mike Welsh ce2b360ab7 core: Provide default impl for DisplayObject:hit_test_bounds 2020-09-02 17:51:55 -07:00
Mike Welsh b0c9795cad core: Graphic::from_swf_tag takes ownership of Shape 2020-09-02 17:51:55 -07:00
Mike Welsh f2f70cc882 core: Mouse picking for buttons uses shape hit tests 2020-09-02 17:51:55 -07:00
Mike Welsh d7a186b2cd avm1: Implement shape hit testing 2020-09-02 17:51:55 -07:00
Mike Welsh 2da3c0d319 tests: Add hitTest shapeflag test 2020-09-02 17:51:55 -07:00
Nathan Adams ec407a9514 avm1: Don't blanket impl From<i64> for Value, convert it explicitly where we know it's okay 2020-09-02 17:12:31 -07:00
Nathan Adams 0b5713557b desktop: Implement LocaleBackend for desktop 2020-09-02 17:12:31 -07:00
Nathan Adams f50b29151c avm1: If a NaN is provided to new Date(timestamp), fail immediately 2020-09-02 17:12:31 -07:00
Nathan Adams 9dfc20e1ba avm1: Implement Date.UTC 2020-09-02 17:12:31 -07:00
Nathan Adams 86eb6f2e50 avm1: Implement Date - #249 2020-09-02 17:12:31 -07:00
Nathan Adams 3d30ec67e2 test: Add more cases to registerClass tests 2020-09-02 15:18:59 -07:00
Nathan Adams 2178beec87 core: When constructing objects for DisplayObjects, make sure frames are run at the right moment 2020-09-02 15:18:59 -07:00
Mike Welsh 537cca7c38 tests: Add test for #1086 2020-09-02 13:25:53 -07:00
Mike Welsh bc08971066 core: Return version from MovieClip::swf_version (fix #1086)
MovieClip was not returning the proper SWF version, causing it to
default to the newest SWF version in some cases when it shouldn't.
2020-09-02 13:25:53 -07:00
dependabot-preview[bot] 03dcdcd494 build(deps): bump indexmap from 1.5.1 to 1.5.2
Bumps [indexmap](https://github.com/bluss/indexmap) from 1.5.1 to 1.5.2.
- [Release notes](https://github.com/bluss/indexmap/releases)
- [Commits](https://github.com/bluss/indexmap/compare/1.5.1...1.5.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-02 12:39:18 -07:00
CUB3D e95c1ff758 core: Make blurX and blurY floating point 2020-09-02 10:59:00 -07:00
CUB3D 143ba03754 core: Fix clippy lints and format 2020-09-02 10:59:00 -07:00
CUB3D a2c151677b core: Add blurFilter and test 2020-09-02 10:59:00 -07:00
CUB3D d1ad095bad core: Add tests for bitmap_filter 2020-09-02 10:59:00 -07:00
CUB3D 34f485ca21 core: Add basic flash.filters.(BlurFilter|BitmapFilter) 2020-09-02 10:59:00 -07:00
Nathan Adams cb2461920b core: HTTP request values need to preserve order 2020-08-28 11:53:32 -07:00
dependabot-preview[bot] 4137a1cac0 build(deps): bump minimp3 from 0.4.0 to 0.5.0
Bumps [minimp3](https://github.com/germangb/minimp3-rs) from 0.4.0 to 0.5.0.
- [Release notes](https://github.com/germangb/minimp3-rs/releases)
- [Commits](https://github.com/germangb/minimp3-rs/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-27 13:20:14 -07:00
dependabot-preview[bot] 9db07eb997 build(deps): bump minimp3 from 0.3.5 to 0.4.0
Bumps [minimp3](https://github.com/germangb/minimp3-rs) from 0.3.5 to 0.4.0.
- [Release notes](https://github.com/germangb/minimp3-rs/releases)
- [Commits](https://github.com/germangb/minimp3-rs/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-26 09:57:40 -07:00
Mike Welsh f55bac2014 text: HTML tags and attributes are case insensitive (fix #1021)
Use eq_ignore_ascii_case when parsing HTML tags. Different versions
of Flash may export HTML tags with different cases, so this will
work a little better; however, we'll need a true HTML parser to
handle this robustly (for opening and closing tags with different
cases, for example).
2020-08-24 11:27:14 -07:00
Mike Welsh febada8a8e text: Fix duplicated characters when parsing HTML entities (fix #1026) 2020-08-24 11:27:14 -07:00
Mike Welsh e8178c35a3 core: Add MouseWheel player event 2020-08-23 13:38:59 -07:00
kmeisthax 559bc05b6a
avm2: Implement avm2 math opcodes (merge #1037)
* Implement `add`, with tests.

* Implement `add_i`.

There's no test, because for whatever reason, I can't figure out how to emit this from Animate CC 2020.

* avm2: Implement `bitand` with tests.

* Implement `bitnot` with tests.

* Implement `bitor` with tests.

* avm2: Implement `bitxor`

* avm2: Implement `declocal`, `declocal_i`, `decrement`, and `decrement_i`.

* tests: `swf_approx` tests should be allowed to print NaNs.

* avm2: Implement `divide`.

* avm2: Implement `inclocal`, `inclocal_i`, `increment`, and `increment_i`.

* avm2: Implement `lshift`.

* Implement `modulo`.

* avm2: Implement `multiply` and `multiply_i` (no tests for the latter)

* avm2: Implement `negate` and `negate_i` (no tests for the latter)

* avm2: Implement `rshift`

* avm2: Implement `subtract` and `subtract_i` (the latter without tests)

* avm2: Implement `urshift`.
2020-08-23 13:38:38 -07:00
Mike Welsh ba05894901 avm1: Don't mutably borrow self in TObject 2020-08-23 02:19:53 -07:00
Mike Welsh 2a84d924bb chore: Don't mutably borrow self in TDisplayObject 2020-08-22 11:56:19 -07:00
dependabot-preview[bot] 5d2ba7fee6 build(deps): bump syn from 1.0.38 to 1.0.39
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.38 to 1.0.39.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.38...1.0.39)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-21 12:54:02 -07:00
Mike Welsh 06b6d14367 avm1: Fix removeMovieClip depth range
removeMovieClip should only function on objects within a certain
depth range, usually to prevent removing timeline clips. However,
this wasn't working properly in some cases because the depth was
being biased incorrectly (removeMovieClip never takes a depth
parameter, so we should not bias the depth).
2020-08-21 00:55:35 -07:00
Mike Welsh 528b52ac7c tests: Activate unused remove_movie_clip test 2020-08-21 00:55:35 -07:00
Mike Welsh 1e6a053c56 avm1: Implement TargetPath 2020-08-20 18:14:01 -07:00
Mike Welsh bbc5e01009 tests: Add test for targetPath action 2020-08-20 18:14:01 -07:00
Mike Welsh e9f9cda34d tests: Rename target_path test to string_path 2020-08-20 18:14:01 -07:00
Mike Welsh b8f5a405b9 tests: Add test for flash.geom.Transform 2020-08-20 17:29:04 -07:00
Mike Welsh ca3ed34c2c avm1: Implement flash.geom.Transform 2020-08-20 17:29:04 -07:00
Mike Welsh 0a81dae7bb avm1: toString for display objects 2020-08-18 01:18:15 -07:00
Mike Welsh cefc0ce5c1 core: Add button children to execution list
Children of buttons were not getting linked up into the execution
list, which would cause certain methods to be incorrect (such as
button._width).
2020-08-18 01:18:15 -07:00
Mike Welsh d2c49c0f33 core: Remove some mut from TDisplayObject methods 2020-08-18 01:18:15 -07:00
Mike Welsh 544c1becc2 tests: Add test for button children 2020-08-18 01:18:15 -07:00
Mike Welsh 59ebd0167e core: Fix priority of conflicting instance names 2020-08-18 01:18:15 -07:00
Mike Welsh b5c7e1dab0 tests: Add test for conflicting instance names 2020-08-18 01:18:15 -07:00
Mike Welsh 13b4b6bbbb chore: Fix unused variable warning in url_from_relative_path 2020-08-16 18:44:57 -07:00
Floens 95acc14190 avm1: fix array unshift
update array_trivial test for it
2020-08-16 04:27:09 -07:00
Mike Welsh f782ea8020
avm2: AVM2 built-in class suport (merge #802)
Initial support for defining built-ins in AVM2
2020-08-16 03:45:02 -07:00
David Wendt 4c824fcefe Rename `trait.rs` to `traits.rs` to avoid the use of reserved keyword syntax. 2020-08-14 21:20:41 -04:00
David Wendt 7b7f0b20e6 Consolidate all of our copied `CollectWrapper`s. 2020-08-14 20:52:09 -04:00
Albert Safin e03373bceb avm1: parseInt 2020-08-13 00:40:20 -07:00
Mike Welsh cbd448522a chore: Allow unknown clippy lints
same_item_push was added on nightly, but is currently throwing
a false negative. I added an allow for it, but this causes a
warning on stable for an unknown lints, so allow unknown lints for
now.
2020-08-12 23:51:12 -07:00
Mike Welsh 6c89869210 chore: Fix clippy lints 2020-08-12 19:04:14 -07:00
dependabot-preview[bot] 9b6dd45439 build(deps): bump smallvec from 1.4.1 to 1.4.2
Bumps [smallvec](https://github.com/servo/rust-smallvec) from 1.4.1 to 1.4.2.
- [Release notes](https://github.com/servo/rust-smallvec/releases)
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.4.1...v1.4.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-12 11:13:33 -07:00
David Wendt 825eb34c67 avm1: `Button` should not hold write locks on itself when instantiating children.
This fixes a bug where a nested textfield within a button with variable linkages would panic in Ruffle.
2020-08-12 11:08:27 -07:00
David Wendt 354b194b69 avm1: Add test for nested text fields in buttons. 2020-08-12 11:08:27 -07:00
David Wendt 32aad6176b `FunctionObject::from_builtin_constr` should pull the scope and class off of it's given prototype and copy it onto the constructor function it returns. 2020-08-11 00:04:13 -04:00
David Wendt 11ddccfa6a Remove the two-step initialization process and construct an ES4 class for `Object`, `Function`, and `Class`.
This has some particularly annoying consequences for initialization order: notably, we can't actually create any ES4 classes using the standard machinery until after the three objects I just mentioned get created. Ergo, we have to create them through lower-level means, handing prototypes around, and then initialize AVM2's system prototypes list for it.

When we start adding more system prototypes, we'll also have to fill the extras with blank objects and then slot them in as we create them.
2020-08-11 00:02:12 -04:00
David Wendt 16d8c85d20 Load player globals as soon as possible.
We're about to massively change the initialization process, and we really don't want to create another situation where the player can get caught with it's pants down.
2020-08-10 23:35:37 -04:00
David Wendt a8e267ed16 Allow system prototypes to be initialized after the fact. 2020-08-10 23:35:37 -04:00
David Wendt b1bcceaa78 Allow accessing the `Class` off of a constructor or prototype that references it. 2020-08-10 23:35:33 -04:00
David Wendt 22ec96b85e `install_trait` and `install_foreign_trait` should return the value of the thing they installed. 2020-08-10 23:23:35 -04:00
David Wendt df95482eb1 Allow setting `slot_id` or `disp_id` (depending on kind). 2020-08-10 23:23:34 -04:00
David Wendt 4ed5050f56 Add function to change trait attributes. 2020-08-10 23:23:34 -04:00
David Wendt a5b62e833e Add trait attributes, similar to that of class attributes 2020-08-10 23:23:31 -04:00
David Wendt 60d42fa558 Allow creating slot/const traits. 2020-08-10 23:19:22 -04:00
David Wendt 3ca8dfd21a Allow constructing traits for getters, setters, and unbound free functions. 2020-08-10 23:19:22 -04:00
David Wendt d366ceab0e Allow setting the protected namespace of a builtin class. 2020-08-10 23:19:21 -04:00
David Wendt 9dc6cbe1ce Allow creating builtin traits from methods. 2020-08-10 23:19:21 -04:00
David Wendt 5e932bcb75 Allow implementing interfaces in built-in classes. 2020-08-10 23:19:20 -04:00
David Wendt 94d5170277 When manually instantiating classes for globals, make sure that the classes get the global scope object when instantiated. 2020-08-10 23:19:15 -04:00
David Wendt 3585cf983b Convert our stub implementations of all non-ECMA classes into `Class`es.
This was surprisingly tricky - due to the need to look up superclasses, class trait instantiation requires an active `Activation` and `UpdateContext`. We can't get those during VM instance creation, since the player needs the VM first before it can give it a context to work with. Ergo, we have to tear the global scope initialization in two. At the first possible moment, the player calls a new `load_player_globals` method that initializes all class traits in global scope.
2020-08-10 23:16:07 -04:00
David Wendt 6f284f60eb Allow constructing a trait from a class. 2020-08-10 23:09:16 -04:00
David Wendt b0b6cec117 Allow expanding a `QName` into a `Multiname` that selects exactly the `QName` and no more. 2020-08-10 23:09:15 -04:00
David Wendt f09c35c4b9 `From<NativeMethod<'gc>>` doesn't always work, but using an explicit non-trait method sometimes does.
I have no idea why this is necessary - I was in a context where what *should* have been a `NativeMethod<'gc>` was instead being interpreted as some different function type with all the same lifetimes, but with an extra `'gc` lifetime as well. Funneling this through a non-trait method bypasses whatever is going on with the trait solver, and then at that point the trait solver knows what to do. Consider this an extra level of conversion.
2020-08-10 23:09:15 -04:00
David Wendt 4a2a456666 `Class::new` should also take the superclass name. 2020-08-10 23:09:13 -04:00
David Wendt d96596fd8a Add a function to manually change attributes. 2020-08-10 23:07:16 -04:00
David Wendt 44b8e5d9c7 Wrap up the existing sealed/final/interface bits in a `ClassAttributes` enumset. 2020-08-10 23:07:13 -04:00
David Wendt bf6ccfeee1 Add some convenience functions for defining native classes. 2020-08-10 23:02:42 -04:00
David Wendt c2cdc302c3 Remove further unnecessary primitive comparison checks 2020-08-10 16:38:04 -07:00
David Wendt 993f56798e Extract all of the numerical conversions into a separate module and leverage them where appropriate in AVM2 2020-08-10 16:38:04 -07:00
David Wendt 566b262d60 Move all our custom object implementations into a separate module, and use a macro to implement them. 2020-08-10 16:38:04 -07:00
David Wendt 5bcd1be270 Remove another instance of `abs` for zero-checks. 2020-08-10 16:38:04 -07:00
David Wendt 2f55c08e37 `pushbyte` should generate signed integers rather than `Number`s. 2020-08-10 16:38:04 -07:00
David Wendt 7f479f24b9 Adjust `coerce_to_string` to be less silly. 2020-08-10 16:38:04 -07:00
David Wendt a12f51903f Non-finite covers everything here. 2020-08-10 16:38:04 -07:00
David Wendt 2e8acfe6f7 Apparantly, Rust already does not care about negative zero, so we don't need to, either. 2020-08-10 16:38:04 -07:00
David Wendt 1bb6f84beb Avoid hitting `coerce_to_number` for integer comparison cases. 2020-08-10 16:38:04 -07:00
David Wendt 4e92352813 Don't promote to `f64` in strict-equality comparisons if we can promote to `i64` instead. 2020-08-10 16:38:04 -07:00
David Wendt a211698464 Handle strict and abstract equality of our various number subtypes as if they were all the same type.
ECMA-262 3rd ed. doesn't mention anything about different number types, so the standard as-if rule applies. If we are going to distinguish number types, we have to treat them as if they were the same type, promoting to `f64` as necessary to facilitate the conversion. I took a cursory look at an ECMA-262 4th ed. draft and it appears to do the same, although it calls everything `GeneralNumber` and has some really confusing psuedo-Pascal syntax for some reason.

I am extremely glad AVM2 does not provide access to 64-bit integer types (for now, at least).
2020-08-10 16:38:04 -07:00
David Wendt f3e47cb596 Further adjustments due to the massive refactor of `Activation`, `AvmX`, and `UpdateContext`. 2020-08-10 16:38:04 -07:00
David Wendt ea4c42a6d1 Split `Value::Number` into separate floating-point, integer, and unsigned representations to match the three numerical classes provided by AS3. 2020-08-10 16:38:04 -07:00
David Wendt a0895e843c Fix `matches!` lint in nightly Rust being tripped. 2020-08-10 16:38:04 -07:00
David Wendt b779dccdc1 Allow objects to provide a coercion hint for cases where a more obvious one is not available. 2020-08-10 16:38:04 -07:00
David Wendt d14fa845c2 Remove `Value::Namespace`.
Namespaces as values adds a bunch of extra special cases to the coercion and equality rules that don't really belong there. Namespace itself just returns it's URI as a string, so we can just make `NamespaceObject` do that and then treat it the same way we treat boxed primitives.
2020-08-10 16:38:04 -07:00
David Wendt e6aac48ae2 Add `NamespaceObject` to hold `Namespace`s.
The reason for this will become very apparent, very shortly.
2020-08-10 16:38:04 -07:00
David Wendt aeb1752d0f `PrimitiveObject`'s `toString` and `valueOf` should always yield their boxed values. 2020-08-10 16:38:04 -07:00
David Wendt 65b4392642 Remove `as_number`.
The only code that used it was the enumeration operations in AVM2.
2020-08-10 16:38:04 -07:00
David Wendt 4906c5a3f1 Remove uses of `as_string` in various places.
These include:

 * Name resolution in `newobject`
 * All runtime & late-bound multinames
 * `Object.hasOwnProperty`
 * `Object.propertyIsEnumerable`
 * `Object.setPropertyIsEnumerable`
2020-08-10 16:38:04 -07:00
David Wendt c040997be2 *Actually* fix the conversion.
So, I overlooked this reading the 1.45 documentation, but the first thing they did is completely change f64 conversions. Apparantly, what I was doing (and what JavaScript spec dictates) is actually considered UB in LLVM, and my ability to actually write a concise wrapping u32 conversion is actually a soundness hole in Rust. Ergo, I'm now emulating the wrapping and sign calculation, which makes this both passing it's tests again and free of soundness holes and UB.
2020-08-10 16:38:04 -07:00
David Wendt 473414e167 Explicitly request `u64` be involved with `u32` coercions.
I don't know why I'm doing this - tests are failing in CI but not locally, and I can only assume that the most obvious conversion is broken in some way on whatever other architecture GitHub Actions uses. This will explicitly mask the integer result as a u64, and then convert it down to u32. A not-broken compiler should treat this code identically.
2020-08-10 16:38:04 -07:00
David Wendt 962f6aa54c Remove `as_object`.
AVM2 is based on ES4, which as far as I'm aware, does not distinguish between "primitive values" and "objects". Thus, it is expedient to interpret any statement requiring something to be an Object to mean "not null or undefined".

Since we internally represent register values with primitive types, it is important that the VM always coerces to object before doing any other sort of type checking. Hence, something like `as_object` is unhelpful as it accidentally enforces a primitive/object distinction that ES4 attempted to remove.
2020-08-10 16:38:04 -07:00
David Wendt 8de063a916 Implement automatic primitive boxing via `coerce_to_object`. 2020-08-10 16:38:04 -07:00
David Wendt f12f67650b Stub all primitive type classes. 2020-08-10 16:38:04 -07:00
David Wendt cb0f1e9099 Add a new object variant for boxed primitives. 2020-08-10 16:38:04 -07:00
David Wendt 6ec1d453b8 Add tests for `greaterequals`, `greaterthan`, `lessequals`, and `lessthan`. 2020-08-10 16:38:04 -07:00
David Wendt b7dfce51b8 Implement `greaterequals`, `greaterthan`, `lessequals`, and `lessthan`. 2020-08-10 16:38:04 -07:00
David Wendt f88f2e225a Add tests for `>`, `<`, `<=`, and `>=`.
Note that this does NOT completely test the full range of if instructions for abstract relational comparison. Notably, the Adobe Animate CC compiler compiles each operator into it's negated equivalent, e.g. `<` becomes `ifnlt`.

I do not know how to get it to emit `ifge` or the like, which differ only by how they handle `NaN`s.
2020-08-10 16:38:04 -07:00
David Wendt 730c47cf29 Implement `ifge`, `ifgt`, `ifle`, `iflt`, `ifnge`, `ifngt`, `ifnle`, and `ifnlt`. 2020-08-10 16:38:04 -07:00
David Wendt 70a27ccb81 Implement ECMA abstract relational comparison 2020-08-10 16:38:04 -07:00
David Wendt 2ef03c6019 Allow no-hint primitive coercion 2020-08-10 16:38:04 -07:00
David Wendt 76ab8570e4 Implement and test `equals`.
The test is also far more in-depth than the `if_eq`/`if_ne` tests, which use the same set of vectors as the strict-equality tests from a while ago. Interestingly, this test passed on first run
2020-08-10 16:38:04 -07:00
David Wendt 5da4e2f118 Test for `iseq` and `isne` 2020-08-10 16:38:04 -07:00
David Wendt 29d5ae9989 Implement `ifeq` and `ifne`. 2020-08-10 16:38:04 -07:00
David Wendt ccc478e7dd Implement ECMA-262 abstract equality. 2020-08-10 16:38:04 -07:00
David Wendt 0125a14d1f Partially implement `ToObject` coercion.
Implementation is limited to generating exceptions on `null` or `undefined`. I'm not sure if primitive values don't exist in AVM2 or if this is supposed to box them like ES3, so I have decided to handle neither at this time.
2020-08-10 16:38:04 -07:00
David Wendt 86965eb674 Test for `coerce_s`.
I cannot yet figure out how to generate tests that use `convert_s`, so it's not covered.
2020-08-10 16:38:04 -07:00
David Wendt 0138300b5a Implement `coerce_s` and `convert_s`. 2020-08-10 16:38:04 -07:00
David Wendt 90d2964adf Properly handle all cases of ECMA-262 string coercions.
This code is slightly over/under-precise compared to AVM2. This is because we handle precision limiting in binary floats rather than as part of the float printing process. Flash Player may also be rounding differently than us. However, I'm pretty sure ECMA-262 allows us to slightly differ here.
2020-08-10 16:38:04 -07:00
David Wendt 35f939cb15 Add and test for `convert_u` using `ToUint32` from ECMA-262 2020-08-10 16:38:04 -07:00
David Wendt 6eb41035cf Add & test ECMA-262 ToInt32 and `convert_i` opcode.
The ECMA-262 documentation is awfully overwrought for something that boils down to "chop off the non-whole part, wrap to 32 bits, then reinterpret as signed". Bitwise operations are *hell* to describe mathematically, and such descriptions are even harder to understand.
2020-08-10 16:38:04 -07:00
David Wendt 351fe026e9 Add a test for all the above numerical coercions. 2020-08-10 16:38:04 -07:00
David Wendt 4c1489a814 Promote bytes to signed representation before pushing.
For whatever reason, `pushbyte` appears to be processed as a *signed* byte, despite the clear wording of "*byte_value* is an unsigned byte" in avm2overview.pdf. I guess it's supposed to be manually converted and promoted in this manner.
2020-08-10 16:38:04 -07:00
David Wendt 736a94a244 Implement numerical coercions according to ECMA-262 3rd Edition spec. 2020-08-10 16:38:04 -07:00
David Wendt 24fd30652d Allow tracing numbers to the console. 2020-08-10 16:38:04 -07:00
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