Commit Graph

4960 Commits

Author SHA1 Message Date
David Wendt c8cd6e0322 avm2: Split native and script instance initializers for non-constructable classes.
This also includes new errors for attempting to construct non-constructables like `System`.
2021-07-20 21:58:04 -04:00
David Wendt dcbb5e4284 avm2: Add a notion of native instance initializers.
Native initializers are a separate, parallel initialization chain intended for all object construction that is not directly triggered by `Op::Construct` and friends. This allows us to implement classes that cannot be directly constructed by user code, but can be constructed by native code or supercalled into from non-native.
2021-07-20 21:58:03 -04:00
David Wendt 4bc1d37029 avm2: Remove unnecessary manual accesses of the `constructor` property on prototypes.
All native object allocation in the project now pulls prototypes or constructors as necessary from the following sources:

 * System prototype or constructor lists
 * Instance `constr`s

This also resulted in the removal of a few unnecessary prototype accesses.
2021-07-20 21:57:56 -04:00
David Wendt afd5a65a1e avm2: Create a new list of system constructors alongside the existing list of system prototypes. 2021-07-20 21:55:30 -04:00
David Wendt b0c38c9d4a avm2: `Graphic` construction shouldn't use the `Shape` proto as it's base constructor.
This fixes the last broken test.
2021-07-20 21:55:29 -04:00
David Wendt 6deaa6f441 avm2: Remove the prototype setter exception as prototypes no longer provide setters to instances. 2021-07-20 21:55:29 -04:00
David Wendt a8fd0622b2 avm2: Filter traits in `call_instance_xyz` by the trait type before actually getting trait fields.
Fixes the `as3_virtual_properties` test, where the old approach would accidentally grab a `Getter` and then think there's no setter (there is, you just have to look further down the list).
2021-07-20 21:55:29 -04:00
David Wendt a2cd7443e8 avm2: Do not attempt to `super_init` the `LoaderInfo` object.
This is a temporary fix for failing tests; it is invalid in the sense that attempting to grab loader events will now fail. We can't actually correctly init the loader without two planned changes:

1. Moving all object initialization into the object helper functions (e.g. `LoaderInfoObject::from_movie`)
2. A notion of "native-only" constructors separate from the existing constructor chain

Once those are in place, loaders should be proper event dispatchers again.
2021-07-20 21:55:29 -04:00
David Wendt 1ad512e3c9 avm2: Allow constructing activation objects (since we now force instance constructors to run) 2021-07-20 21:55:28 -04:00
David Wendt 323da9ded3 avm2: Move the class association from prototypes to instances.
This also incurred a large number of ancillary changes, as it turns out nearly every native object is currently pulling a prototype and sticking it into an object. Right now, I have it instead pulling the constructor out of the prototype, but a future PR will also remove `system_prototypes` as well.

Other ancillary changes include:

 * `Domain` now supports partial initialization to avoid an order-of-events issue. Accessing domain memory on a partially-initialized `Domain` will panic.
 * `Domain` construction requires a full `activation` now, except for `global_scope` which needs to be initialized later with valid domain memory before user code runs.
 * Pretty much every native object constructor now takes a proto/constr pair
 * Trait lookup was rewritten to handle this. It's still buggy - seven tests don't work
 * `TObject.construct` now actually does the full object construction dance. This allows `ClassObject` to implement the ES4 object construction pathway directly while `FunctionObject` maintains ES3 compatibility.

This is a tentative commit; there are still seven failing tests that I need to fix.
2021-07-20 21:55:25 -04:00
David Wendt f26f193508 avm2: Store instance derivers as a `Class` property instead of keeping them only as a globals concept 2021-07-20 21:47:00 -04:00
David Wendt 47de2364c1 avm2: Split `Class` and `Function` object types 2021-07-20 21:46:54 -04:00
relrelb d2eb46d3be chore: Reserve capacity for vectors
This avoids unnecessary re-allocations and thus should improve
performance in both memory and time terms.
2021-07-20 16:25:23 -07:00
dependabot[bot] ca2d17ade6 chore: Bump env_logger from 0.8.4 to 0.9.0
Bumps [env_logger](https://github.com/env-logger-rs/env_logger) from 0.8.4 to 0.9.0.
- [Release notes](https://github.com/env-logger-rs/env_logger/releases)
- [Changelog](https://github.com/env-logger-rs/env_logger/blob/main/CHANGELOG.md)
- [Commits](https://github.com/env-logger-rs/env_logger/compare/v0.8.4...v0.9.0)

---
updated-dependencies:
- dependency-name: env_logger
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-19 23:49:40 +03:00
relrelb 536526a342 avm1: Rename `set_watcher` and `remove_watcher` to `watch` and `unwatch`
This better reflects their correspondence to `Object.watch` and
`Object.unwatch` respectively.
2021-07-18 23:19:19 +03:00
relrelb e8e0467673 avm1: Replace `get` + `call` with `call_method` 2021-07-18 23:19:19 +03:00
relrelb 3576a199cd avm1: Replace `set` + `set_attributes` with `define_value` 2021-07-18 23:19:19 +03:00
relrelb c609fa937d avm1: Remove unnecessary type annotations 2021-07-18 23:19:19 +03:00
relrelb ea73dbc367 avm1: Remove `StageObject::as_executable`
It was identical to the default implementation of `TObject`, and
thus unnecessary.
2021-07-18 23:19:19 +03:00
relrelb 3ddd8ff31c tests: Add as_set_prop_flags 2021-07-18 20:03:52 +03:00
relrelb 0367f6a8d4 avm1: Correct `ASSetPropFlags`
* The properties parameter is evaluated last. This is observable by
the order the `toString`/`valueOf` methods of the parameters are
called.
* Only `null` in the property list parameter configures all properties,
as opposed to `undefined`, `null`, numbers and booleans previously.
* Objects in the property list parameter are not handled specially.
Instead, they're also coerced to string and split by comma.
2021-07-18 20:03:52 +03:00
relrelb 49e26338bc web: Fix and cleanup npm build scripts
* Remove `buildProduction` as it was equivalent to `build`.
* Fix `build:avm_debug` and change it to `build:debug`, which also
disables Webpack optimizations.
2021-07-17 11:40:25 +03:00
relrelb 5dde3ecabf swf: Optimize `read_f64_me` and `write_f64_me`
Each function is reduced to just 3 opcodes on x86:
https://godbolt.org/z/n6q6zxnh6

WebAssembly benefits as well: https://godbolt.org/z/fcETE9GYn

This should improve load-time performance because read_f64_me is
used frequently (for each AVM1 double constant).
2021-07-16 01:29:49 +03:00
relrelb f9be5c2230 web: Unify "menu_item" and "active" CSS classes
It seems that these two classes were totally equivalent, so simply
drop "active" and use only "menu_item".
Also, don't highlight disabled context menu items on hover.
2021-07-13 23:45:18 +03:00
divinity76 c94ebf133a open "not yet supported more info" in new tab
i fully intended to press "run anyway" just to see what happened, and it was annoying that Ruffle took me to another page so i had to re-load the flash.. (from a page with 10 seconds worth of ads before playing the flash, even)
2021-07-13 21:42:50 +03:00
dependabot[bot] c241ac6ace chore: Bump regress from 0.3.0 to 0.4.1
Bumps [regress](https://github.com/ridiculousfish/regress) from 0.3.0 to 0.4.1.
- [Release notes](https://github.com/ridiculousfish/regress/releases)
- [Commits](https://github.com/ridiculousfish/regress/commits)

---
updated-dependencies:
- dependency-name: regress
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-12 23:37:11 +03:00
dependabot[bot] 19e0a4109a chore: Bump instant from 0.1.9 to 0.1.10
Bumps [instant](https://github.com/sebcrozet/instant) from 0.1.9 to 0.1.10.
- [Release notes](https://github.com/sebcrozet/instant/releases)
- [Commits](https://github.com/sebcrozet/instant/commits)

---
updated-dependencies:
- dependency-name: instant
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-12 23:36:27 +03:00
relrelb a33066f666 demo: Small cleanups 2021-07-12 23:21:14 +03:00
relrelb df47c53f5c web: Remove unused `RufflePlayer._trace_observer` 2021-07-12 23:21:14 +03:00
relrelb 803da71e9c web: Remove `RufflePlayer.playButtonClicked`
Replace its few usages with `play` which is part of the public API.
Also made little cleanups to the selfhosted test utils along the way.
2021-07-12 23:21:14 +03:00
relrelb 76849c485e core: Cleanup `tag_utils.rs` 2021-07-12 23:09:29 +03:00
relrelb 3d7199d81e core: Remove unused `SwfMovie::from_movie_and_subdata` 2021-07-12 23:09:29 +03:00
relrelb c2378416a9 tests: Simplify `read_tag_bytes_from_file_with_index`
Let the `Reader` outlive outside the loop, so it tracks its own
position, instead of doing so manually.
Also move `read_from_file` outside and reuse it.
2021-07-12 23:09:29 +03:00
relrelb 99deb90a1f swf: Avoid using `Reader::input` directly
Change two cases to use `Reader::read_slice` instead of `self.input`.
Not only this avoids relying on an implementation detail, this also
raises an `UnexpectedEof` error if the read is beyond the SWF.
2021-07-12 23:09:29 +03:00
relrelb ef9c073d26 swf: General cleanup
Just mechanical cleanups to ease future refactors.
2021-07-12 23:09:29 +03:00
Chris Midgley 8e7ce18cc2 avm1: alphabetise text_field properties 2021-07-10 21:19:20 +03:00
Chris Midgley 156a4494aa avm1: update attributes of text_field properties 2021-07-10 21:19:20 +03:00
Adrian Wielgosik 633c23c7f3 avm2: Do timeout check every 2000 actions, same as avm1 2021-07-09 22:09:13 +02:00
relrelb 9e18e32b40 swf: Fix read_i24
Only the third byte should be cast to i8 in order to sign extend correctly.
avmplus reference: https://github.com/adobe/avmplus/blob/master/core/AvmCore-inlines.h#L387-L395
2021-07-09 19:56:52 +03:00
relrelb 32c6d8dba0 swf: Fix write_i24
It was writing in the wrong endian.
2021-07-09 19:56:52 +03:00
relrelb 1cbbdecccf swf: Introduce and use `Color::to_rgba` 2021-07-09 19:56:52 +03:00
relrelb 580d8c3562 chore: Use to_le_bytes in more places 2021-07-09 19:56:52 +03:00
relrelb 87e9dda250 chore: Use from_le_bytes in more places 2021-07-09 19:56:52 +03:00
relrelb 29b3225772 core: Fix ADPCM decoder
Store samples and steps as i16 instead of i32.
2021-07-09 19:55:09 +03:00
relrelb 25b8013a99 core: Refactor PCM decoder a bit
Extract a `read_sample` method to avoid code duplication, and use
the byteorder crate as already done in other places.
2021-07-09 19:52:30 +03:00
Callum Thomson 939d467897
avm1: Correct ToInteger
* Coerce objects as well.
* Wrap numbers around i32.
2021-07-09 03:39:07 +03:00
Daniel Jacobs bdf693c9c4 Remove error report link from could not download wasm module 2021-07-08 20:20:57 +02:00
Chris Midgley ac0fc40345
avm1: implement scroll, maxscroll and bottomScroll for TextField (#4698)
* tests: add tests for scroll

* avm1: implement scroll, maxscroll, bottomScroll

* chore: fmt

* docs: note that scroll is 1-based

* fix: non-word wrapped text with manual breaks is scrollable

* chore: move magic number to const

* chore: avoid mut with extra if

* chore: moving clamping behaviour into core

* refactor: eagerly compute line data

* fix: make scroll work when text is aligned right

* chore: clippy

* docs: add more information about line_data

* tests: add more test cases for scroll
2021-07-08 19:23:30 +02:00
EmperorBale d334e30259
avm1: Fix apply_to_display_object (#4377) (#4743)
* avm1: Fix apply_to_display_object
2021-07-06 17:32:14 +02:00
Adrian Wielgosik 35d543b610 desktop: Add a flag to disable AS3 warning popup 2021-07-06 17:03:45 +02:00