Commit Graph

316 Commits

Author SHA1 Message Date
David Wendt e2dcf47c56 Add a method to force resolve a `ReturnValue` on the Rust stack via recursion. 2019-11-20 14:30:31 -05:00
David Wendt bc74b2fc4a Track the no-double-reader flag on a per-frame basis, and add a "run until current frame exits" routine. 2019-11-20 14:30:31 -05:00
David Wendt dd4462c104 Warn when attempting to attach a second continuation onto an existing stack frame, since we don't support that use case. 2019-11-20 14:30:31 -05:00
David Wendt a2ee7f9e3a Replace `Option<Value<'gc>>` with a dedicated `ReturnValue<'gc>` type with associated methods.
This type explicitly signals if an immediate value is to be returned, if a value is to be returned on the stack, or if no return value is to be generated. Holders of a `ReturnValue` can also use `and_then` to schedule a `StackContinuation` to be executed when and if that value is ready.

`StackContinuations` now yield `ReturnValues` as well, so they have a moderate level of composability. For example, if you need to get a property from an object and push it on the stack, you can return the result of calling `get` directly and the machinery ensures it eventually gets there.
2019-11-20 14:30:31 -05:00
David Wendt 2a3d324a33 Implement the "reschedule same continuation" behavior in AVM 2019-11-20 14:30:31 -05:00
David Wendt 40dbc535fc Remove force_get now that everything can read virtual properties correctly. 2019-11-20 14:30:30 -05:00
David Wendt e36a0d8350 Allow native functions to resolve on the AVM stack for whatever reason. 2019-11-20 14:30:30 -05:00
David Wendt 4dffe448e4 Get rid of the automatic `this` on stack continuations 2019-11-20 14:30:30 -05:00
David Wendt 9d422dc269 Allow getters to resolve on the AVM1 stack.
This involved yet another macro, `and_then!`, to avoid a ridiculous amount of duplicate code. It calls a continuation whenever it's value is ready, even if the value resolved on the Rust stack.

`locals_into_form_values` does not currently support this. It skips any property that does not resolve on the Rust stack. Future work is required to resolve this.
2019-11-20 14:30:30 -05:00
David Wendt a59fffbc4e Ensure that the value of the newly constructed `this` is returned in all cases.
This involves the use of a "stack continuation" system. Due to previous lifetime issues with using closures directly (see `8ea6c6234dba925ec5fbc61502627fb62b05916c`), we instead use a macro that constructs a `Collect`able type holding the things the continuation needs to continue working with. The syntax is largely similar to Rust closures but with the addition of an explicit list of bound variables, all of which must be `Collect`.
2019-11-20 14:30:29 -05:00
David Wendt a95861d596 Stack continuations can now directly manipulate the return value of an ActionScript function. 2019-11-20 14:30:29 -05:00
David Wendt 8485e919db Add a notion of "and_then" to activation objects.
This effectively constitutes the ability to assign arbitrary native contiuations to the AVM stack.
2019-11-20 14:30:29 -05:00
dependabot-preview[bot] 387feaf76c
build(deps): bump rand from 0.6.5 to 0.7.2 (#124) 2019-11-20 18:30:54 +00:00
dependabot-preview[bot] 6d124a6ac2 build(deps): bump smallvec from 0.6.13 to 1.0.0
Bumps [smallvec](https://github.com/servo/rust-smallvec) from 0.6.13 to 1.0.0.
- [Release notes](https://github.com/servo/rust-smallvec/releases)
- [Commits](https://github.com/servo/rust-smallvec/compare/v0.6.13...v1.0.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-19 18:51:19 +00:00
Mike Welsh e3d0d9031d core: Handle empty JPEGTables tags (fix #116) 2019-11-11 17:08:08 -05:00
David Wendt 1236b5491e Ensure calls to `getURL`, invocations of `ActionGetURL`, and other functionality that writes locals doesn't panic due to double mutable borrows. 2019-11-11 14:09:25 -05:00
David Wendt 4e16c91dbb Add tests for `locals_into_form_values`. 2019-11-11 14:09:25 -05:00
Mike Welsh b05745da01 audio: Fix uninit warnings in MP3 decoder in Rust 1.39 2019-11-11 14:06:41 -05:00
Mike Welsh 7d98c87a33 desktop: Implement event sound envelopes 2019-10-30 19:26:19 -07:00
David Wendt 0d4e21162a Implement `ActionEnumerate2`. 2019-10-30 19:26:06 -07:00
Mike Welsh 63be104739 docs: Add module documentation for MovieClip
(Really an excuse to kick CI to re-run)
2019-10-30 10:59:53 -07:00
Mike Welsh ab58c37feb core: Handle gaps between StreamSoundBlocks 2019-10-29 23:36:51 -07:00
Mike Welsh 443dcfaeea core: Stop stream sound when gaps are encountered
Generally there is one SoundStreamBlock per frame in a MovieClip.
However, if there are gaps between stream sounds, the stream must
stop and then pick up when the next block is encountered.

TODO: Sometimes Flash will do weird stuff and export a stream that
is plainly out of sync if there are gaps between sounds (the old
trick was to put a silent stream across the entire timeline to fix
this). This happens when the streams are too close together with
MP3 encoding. Investigate this more.
2019-10-29 23:36:51 -07:00
Mike Welsh 1a7959b96d audio: Initial syncing of stream sound to MovieClip timeline 2019-10-29 23:36:51 -07:00
Mike Welsh 9e83f27afd tests: Add test for DoInitAction 2019-10-29 11:11:25 -07:00
David Wendt 6a81b5327d Implement `DoInitAction`.
This pushes an extra `undefined` onto the stack to fix underflow in AS2 interface declarations.

It is currently unknown if this is a miscompilation or if some other value is supposed to be there.

# Conflicts:
#	core/src/avm1.rs
#	core/src/avm1/object.rs
2019-10-29 11:11:25 -07:00
Mike Welsh 33c0bbd0ce desktop: Fix incorrect rendering of bitmaps w/ color transforms
The premultiplied alpha was not properly considered when there was
a color transform on a bitmap. Now the shader unmultiplies the
alpha before applying the color transform, and the remultiplies it.
2019-10-29 00:03:29 -07:00
Mike Welsh 35be57553e desktop: Improve animation sync
The timing on desktop was causing the movie to run too slow,
causing it to get out of sync. Now it should run at the correct
speed.
2019-10-28 21:05:18 -07:00
Mike Welsh cb26342a24 core: Fix regression in goto when replacing a previous child
Goto forward that did a replace was not replacing the previous child.
TODO: Figure out how to write a regression test for this; will
need a special test harness probably because this only happens with
Graphics, not MovieClips, so we can't attach AS to them to get
trace output.
2019-10-28 03:47:57 -07:00
Mike Welsh eaea6aaf20 audio: Fix audio for ADPCM stream sounds
When a stream sound uses ADPCM compression, the ADPCM header is
included in each SoundStreamBlock (as opposed to stream sounds
in the other formats). This header wasn't being parsed, resulting
in corrupted audio (see https://homestarrunner.com/main12.swf).
2019-10-28 02:51:46 -07:00
Mike Welsh 01f47d675c core: Move UpdateContext into context submodule 2019-10-27 13:49:47 -07:00
Mike Welsh dddfb42e1e core: Merge ActionContext into UpdateContext 2019-10-27 13:49:47 -07:00
Mike Welsh c4c895c6c9 core: Move display objects to display_object module 2019-10-26 15:04:52 -07:00
Mike Welsh 2cdb8d3656 tests: execution_order -> execution_order1 2019-10-26 03:35:58 -07:00
Mike Welsh 247fd3b9c6 core: Run gotos immediately
Gotos now goto the specified frames immediately as opposed to
queuing. Actions on the new frame will still be queued,
and are executed after any current actions are completed.
2019-10-26 03:35:58 -07:00
Mike Welsh e78be0f06f core: Remove avm from UpdateContext 2019-10-26 02:21:48 -07:00
Mike Welsh c718a6c8cb core: Add more properties to ActionContext
ActionContext needs to be able to call goto, so it needs access
to most of UpdateContext.

TODO: Remove ActionContext, and only have UpdateContext?
2019-10-26 02:21:46 -07:00
Mike Welsh 09fa755405 core: Make Library::device_font optional 2019-10-26 02:20:42 -07:00
Mike Welsh 57a737357b core: Remove RefMut/Ref from UpdateContext 2019-10-26 02:20:42 -07:00
Mike Welsh 838944b5a1 tests: Add tests for goto execution order 2019-10-26 02:20:42 -07:00
Mike Welsh 863801371b tests: Better output when regression test fails 2019-10-26 01:52:42 -07:00
Mike Welsh 6da55f4fc2 tests: Remove ignore on execution order test 2019-10-26 01:52:42 -07:00
Mike Welsh a4bed6c643 core: Improve execution order of AS 2019-10-26 01:52:42 -07:00
Mike Welsh 666075c651 tests: Allow attributes in swf_tests macro
Also ignore failing execution_order test
2019-10-26 01:52:42 -07:00
Mike Welsh 008581f1bd tests: Add test for parent-child execution order
(currently fails)
2019-10-26 01:52:42 -07:00
Nathan Adams 6a2806b44a chore: Allow Into<Value> for test results 2019-10-21 17:22:03 +02:00
Nathan Adams 348e7f6adb chore: Impl From<numeric> for Value, better dev ergonomics 2019-10-21 17:14:00 +02:00
Nathan Adams 83b7d679ed chore: Impl From<GcCell<'gc, Object<'gc>>> for Value, better dev ergonomics 2019-10-21 13:00:52 +02:00
Nathan Adams fa5616a4f9 chore: Impl From<bool> for Value, better dev ergonomics 2019-10-21 12:55:17 +02:00
Nathan Adams 4c81ac8a6d chore: Take Into<Value> for Object.(force_)set 2019-10-21 12:48:45 +02:00