Nathan Adams
c9c4749bb0
core: Added battery of tests for lessthan, greaterthan, equals and strictequals between swf4-swf7
2019-11-28 20:41:23 -05:00
Nathan Adams
3f4597f081
Add tests for lessthan
2019-11-28 20:31:02 -05:00
David Wendt
504f962256
Add a test for every string coercion I could find.
2019-11-28 20:28:46 -05:00
David Wendt
129d50bfa6
Implement ECMAScript compliant type coercions.
...
This includes ECMA-262 2ed `ToNumber`, `ToPrimitive` (Number), `ToString`, and abstract equality and less-than implementations. Note that `ToPrimitive` is only the "number hint" variant, and Flash specifically *never* calls `toString` like how ECMA-262 specifies.
Several builtins inherit numerical coercion - I'm not 100% sure if that's correct.
The following ActionScript opcodes now perform ECMA-262 style coercions:
`ActionAdd2` (uses `valueOf` / "ToPrimitive hint Number")
`ActionDecrement` (uses `valueOf`)
`ActionEquals2` (uses `valueOf`)
`ActionGetMember` (member names, uses `toString`)
`ActionIncrement` (uses `valueOf`)
`ActionLess2` (uses `valueOf`)
`ActionGreater` (uses `valueOf`)
`ActionSetMember` (member names, uses `toString`)
`ActionStringEquals` (uses `toString`)
`ActionStringGreater` (uses `toString`)
`ActionStringLess` (uses `toString`)
`ActionToNumber` (uses `valueOf`)
`ActionToString` (uses `toString`)
`ActionTrace` (uses `toString`)
The following functions now gained user-specified coercions via `toString`:
`_global.number` (uses `valueOf`)
`_global.is_nan` (uses `valueOf`)
Every function in `Math` (uses `valueOf`)
2019-11-28 20:23:39 -05:00
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
6eaab8efdf
core: Merge #113 , interworking of Rust + ActionScript
...
Internal support for interworking Rust and ActionScript code
2019-11-25 04:27:05 -08: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
Nathan Adams
ae064b62be
chore: Change to no_drop from empty_drop for new gc-arena
2019-11-22 17:53:05 +00:00
dependabot-preview[bot]
238c575f16
build(deps): bump gc-arena from 0.1.1 to 0.2.0
...
Bumps [gc-arena](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 17:53:05 +00:00
David Wendt
bae0476113
Don't panic when double-locking a stack frame.
2019-11-20 14:30:34 -05:00
David Wendt
17215cc787
Remove the `NoResult` variant of `ReturnValue` as it is no longer useful or in use.
2019-11-20 14:30:33 -05:00
David Wendt
8c1d25b0f7
Add conversions for all the same conversions regular `Value`s have, so that you don't have to constantly mark things as `ReturnValue::Immediate`
2019-11-20 14:30:33 -05:00
David Wendt
e4eb930d44
Remove all references to stack continuations from our documentation.
2019-11-20 14:30:33 -05:00
David Wendt
5bf90653c4
Add implicit coercions to remove most instances of manually constructing a `ReturnValue`.
2019-11-20 14:30:33 -05:00
David Wendt
4b824370f4
Remove the stack continuation system. If we decide to structure this system in the same way in the future, we'll probably use async functions or something like that.
2019-11-20 14:30:33 -05:00
David Wendt
2aa5b62b44
Make most code that might touch user-defined functions falliable.
2019-11-20 14:30:32 -05:00
David Wendt
a49af7815c
Resolve all existing return values on the Rust stack.
2019-11-20 14:30:32 -05:00
David Wendt
bb1cde5557
Avoid double borrow panic caused by unreasonably long lifetime of `.write()` temporary
2019-11-20 14:30:32 -05:00
David Wendt
7284794c0b
Store the return value on the activation object when it's retired.
2019-11-20 14:30:32 -05:00
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
Nathan Adams
0ba9cef2f0
chore: Take Into<Value> for tests
2019-10-21 12:44:21 +02:00
Nathan Adams
f24ab37810
chore: Impl From<&str> for Value, better dev ergonomics
2019-10-21 12:33:49 +02:00
Nathan Adams
796c641b3b
chore: Impl From<String> for Value, better dev ergonomics
2019-10-21 12:30:59 +02:00
Mike Welsh
84cb00b44b
chore: Fix clippy lint in Value::as_bool
2019-10-21 02:11:50 -07:00
Will Brindle
019ea79551
core: return true for objects as boolean
2019-10-20 10:00:18 +01:00
Will Brindle
d3006cb37b
chore fix formatting
2019-10-19 10:36:24 +01:00
Will Brindle
5b298a0814
chore: refactor test code to share common methods
2019-10-19 10:31:37 +01:00
Will Brindle
3fa198d8f2
core: Add extra test cases for Number function and resolve the issues they highlight
2019-10-19 10:29:26 +01:00
Will Brindle
463d0fc352
core: implement isNaN and Number functions. Involves updating to_number function in Value. Note: this varies a little from the ECMA spec such as not allowing spaces in numbers (i.e. ' 5' => NaN). No definitive reference for this but was found experimentally. Same with not supporting 'Infinity'
2019-10-19 10:29:26 +01:00
Will Brindle
38c66b5b8d
core: implement Boolean function
2019-10-19 10:29:26 +01:00
Mike Welsh
b0624a3654
tests: Add define_function2 and register test
2019-10-15 17:20:48 -07:00
Mike Welsh
f5710854b2
avm1: Fix off-by-one bug in Activation::has_local_register
2019-10-15 17:10:34 -07:00
Mike Welsh
e315fcb6b3
swf: Store register count from DefineFunction2
...
Also update avm1::Function to use register_count.
2019-10-15 17:09:14 -07:00
David Wendt
ad17166c63
Store the player version in `Avm1` so that `current_swf_version` doesn't require the context.
2019-10-13 18:55:39 -04:00
David Wendt
7e2cf03789
Implement register underflow behavior.
...
This has the side effect of letting us remove the `Option` on register_count since setting this to `0` is equivalent now. Furthermore, we can skip an allocation if a function requests no registers.
2019-10-13 18:41:07 -04:00
David Wendt
911cf64cb0
Fix clippy lints
2019-10-13 17:58:21 -04:00
David Wendt
e830273fe5
Don't pull multiple borrows on the same `GcCell`
2019-10-13 17:54:09 -04:00
David Wendt
911de06584
Only version MovieClips. Unversioned display objects recursively read their parents' versions, or the default version otherwise.
2019-10-13 17:27:04 -04:00
David Wendt
269775c0e1
Implement the SWF5 version negotiation algorithm.
...
On SWF5, the SWF version of the callee depends on it's this parameter. Calling it as a function rather than a method downgrades the callee. SWF6+ use the callee's inherent SWF version and do not allow changing the SWF version like this.
2019-10-12 10:39:55 -04:00
David Wendt
d543e67528
Inline the first 8 registers with a `SmallVec`.
2019-10-12 10:39:54 -04:00
David Wendt
ff7fe94e90
Add test for `_global`, `_root`, and `_parent` as movie clip properties
2019-10-12 10:39:54 -04:00
David Wendt
b3c955b4d8
Install the remainder of tests that currently pass, but needed to have child clips removed
2019-10-12 10:39:54 -04:00
David Wendt
d909fb01bb
Use player version as a fallback when the current SWF version is requested without a valid stack.
2019-10-12 10:39:53 -04:00
David Wendt
17b1e0429c
Explicitly allow `_global` and `_root` to be overwritten.
2019-10-12 10:39:53 -04:00
David Wendt
4709d2d0b4
Revert "Allow overwriting virtual properties via setting `set` to `None`."
...
This reverts commit 0a8adfca6e5fce8835552c1c7aba063649ba3aeb.
2019-10-12 10:39:53 -04:00
David Wendt
59dc35b8a4
Allow scope chain resolution to retrieve virtual properties
2019-10-12 10:39:53 -04:00
David Wendt
a92190a456
Support pre-resolving `_parent`
2019-10-12 10:39:52 -04:00
David Wendt
0f04d97002
Move `_global` and `_root` to the MovieClip object, and implement `_parent` while we're in here.
2019-10-12 10:39:52 -04:00
David Wendt
d35e36def5
Allow overwriting virtual properties via setting `set` to `None`.
2019-10-12 10:39:52 -04:00
David Wendt
feaa3dd203
Add a version parameter to every DisplayObject impl
2019-10-12 10:39:52 -04:00
David Wendt
8668d47403
Add a player version parameter and expose it to AVM
2019-10-12 10:39:51 -04:00
David Wendt
2f257c83e8
Remove the representation split between functions defined with `DefineFunction` and `DefineFunction2`. Both are now represented with a single struct and enum.
2019-10-12 10:39:51 -04:00
David Wendt
caa36bfecc
Add `closure_scope` and `variable_args` tests.
2019-10-12 10:39:51 -04:00
David Wendt
b4ddd323f2
Use the same methodology to construct new scopes for tellTarget.
2019-10-12 10:39:51 -04:00
David Wendt
1b62ead082
Construct the closure scope chain in one pass, which lets us skip the vec allocation.
2019-10-12 10:39:50 -04:00
Mike Welsh
3b42c70e48
core: Disable LZMA support by default
2019-10-12 00:09:10 -07:00
Mike Welsh
1ab5211bfe
swf: Fix compiling with lzma feature
2019-10-11 23:18:57 -07:00
Mike Welsh
7a5b2607d4
chore: Renormalize line endings in misc files
2019-10-11 16:53:36 -07:00
Mike Welsh
4aec120ffb
core: Add Bitmap display object
...
Converts the Bitmap character to a proper display object. This can
be instantiated directly in a PlaceObject tag in SWFv9 movies,
compared to the previous versions which indirectly references
bitmaps from Shape tags.
2019-10-11 16:33:58 -07:00
Mike Welsh
800147043a
swf: Try to recover from incorrect zlib streams
...
Some SWFs are compressed incorrectly, often with incorrect
compressed/uncompressed lengths, causing the zlib decoders
to vomit if you try to decompress them fully. However, often times
the data still decompresses all the way to the End tag, and we
still want to try to play it even if it's corrupt.
Now these errors only omit a warning, and we'll continue to run
the SWF.
Addresses #86 .
2019-10-10 13:41:43 -07:00
Mike Welsh
40722dcef0
avm1: Merge#81, add property attributes
...
Added object property attributes
2019-10-09 10:24:21 -07:00
Will Brindle
ba939fc00b
chore: add comment explaining the weird NaN situation
2019-10-09 06:17:41 +01:00
Will Brindle
32554e271f
chore: remove trailing whitespace
2019-10-08 21:40:15 +01:00
Will Brindle
f84f807bf1
core: refactor to make use of equality implementation
2019-10-08 21:36:50 +01:00
Will Brindle
70b7b1c807
chore: fix clippy & fmt issues
2019-10-08 21:04:26 +01:00
Will Brindle
6508ec6b6c
core: nan equality
2019-10-08 20:51:21 +01:00
Will Brindle
0814b17fd8
chore: add tests for equality and greaterthan
2019-10-08 20:45:39 +01:00
Will Brindle
e2c7af5cda
core: fix boolean strict comparison
2019-10-08 19:59:32 +01:00
Will Brindle
9cf381b0e0
core: add support for actions GreaterThan, StringGreaterThan and StrictEquals
2019-10-08 19:59:32 +01:00
Nathan Adams
d697d03cf0
Drop the `Attribute::` everywhere
2019-10-08 20:35:23 +02:00
Mike Welsh
fb442688cb
chore: Change edit_text.rs to LF line endings
2019-10-08 11:15:15 -07:00
Nathan Adams
3d09ec81e2
Add Attribute::DontEnum
2019-10-08 16:36:39 +02:00
Nathan Adams
f782aaee18
Add Attribute::ReadOnly
2019-10-08 15:24:57 +02:00
Nathan Adams
f2a4000ee2
Added object property attributes (initially just DontDelete)
2019-10-08 14:30:36 +02:00
Will Brindle
4856efe7d8
chore: add integration tests for typeof
2019-10-08 02:59:26 -07:00
Will Brindle
2e3748438a
core: define globals for NaN, Infinity, -Infinity. Should fix `typeof NaN`
2019-10-08 02:59:26 -07:00
Mike Welsh
3b288272d4
text: Hack to skip HTML in dynamic text fields
2019-10-07 23:23:45 -07:00
Mike Welsh
eded29ce6d
text: Add dummy implementation of device text
...
Embed an SWF version of Noto Sans (core/assets/*) into the player.
The player will load this font and use it to render device text.
This is a quicky implementation to get dynamic device text
rendering.
2019-10-07 23:23:45 -07:00
Mike Welsh
de1cedb653
core: Initial EditText implementation
2019-10-07 23:23:45 -07:00
Mike Welsh
9084524580
core: Render DefineFont3 at proper size ( fixes #47 )
...
Per SWF19, shape coordinates in DefineFont3 are at 20x the size of
DefineFont1/2.
2019-10-07 12:05:27 -07:00
Mike Welsh
574ede0541
avm1: Return proper root object for Avm1::root_object
...
Was returning start_clip instead. Also call
DisplayObject::post_instantiation for root after it's created in
Player::new.
2019-10-07 01:36:05 -07:00
Mike Welsh
4477e8458f
avm1: Return dummy value 1 for getBytesLoaded/getBytesTotal
...
Previously returned 0 which would cause divide by 0 in many
preloaders.
2019-10-07 00:33:30 -07:00
Mike Welsh
7ed4ea0a2b
tests: Rename integration_tests -> regression_tests
2019-10-06 23:58:52 -07:00
Mike Welsh
18a3494de2
chore: Typo supress -> suppress
2019-10-06 15:24:38 -07:00
Mike Welsh
b6eba80ebd
chore: cargo fmt
2019-10-06 14:57:43 -07:00
Mike Welsh
1c3e4406b3
chore: Fix clippy lints
...
* Remove clone calls from Copy objects
* Used Iterator::cloned() instead of manually cloning
* Pass swf::Function into AvmFunction2::new()
* Use action_clone_sprite
2019-10-06 14:57:36 -07:00
David Wendt
2d365856a7
Fix tellTarget being broken by the introduction of scopes. We now create a new scope chain based off the selected active clip.
2019-10-06 13:02:31 -07:00
David Wendt
588b2bb061
Fixes to make tests compile again
2019-10-06 13:02:31 -07:00
David Wendt
5873eefb06
Since it is possible to have virtual properties in the scope chain, overwriting them should trigger their setters.
...
Define, since it's intended for setting locals only, always uses force-set and does not trigger setters.
2019-10-06 13:02:31 -07:00
David Wendt
06d0cf5ed1
Add a stern warning to be triggered if multiple readers are open at once.
2019-10-06 13:02:31 -07:00
David Wendt
8ed09e22ba
Refactor: Since `function.rs` handles calling conventions it should just hand the avm an activation object directly
2019-10-06 13:02:31 -07:00
David Wendt
cf5420e2e1
Implement register preloading, for variables we already have implemented.
2019-10-06 13:02:31 -07:00
David Wendt
8734c036a7
Removed unused function
2019-10-06 13:02:31 -07:00
David Wendt
91cbbb4e9c
`ActionWaitForFrame`/`2` should not create their own readers either.
2019-10-06 13:02:31 -07:00
David Wendt
a5865d7c7d
Implement DefineFunction2
2019-10-06 13:02:31 -07:00
David Wendt
ec1b5c457e
Allow activations to hold their own private register set.
2019-10-06 13:02:31 -07:00
David Wendt
d822a35404
Fix `ActionIf` and `ActionJump`
2019-10-06 13:02:31 -07:00
David Wendt
171cb9f014
GetMember needs to support string coercions (e.g. `array[1]` should work)
2019-10-06 13:02:31 -07:00
David Wendt
deecd85c81
Implement `SetMember`
2019-10-06 13:02:31 -07:00
David Wendt
697a02bd05
Implement `GetMember`
2019-10-06 13:02:31 -07:00
David Wendt
51a7b426fd
Implement registers, including register pushes and `ActionStoreRegister`.
2019-10-06 13:02:31 -07:00
David Wendt
582b3a8968
Adjust GetVariable/SetVariable based on test results
2019-10-06 13:02:31 -07:00
David Wendt
17482b8810
ActionDelete and ActionDelete2 return a bool
2019-10-06 13:02:31 -07:00
David Wendt
002dd9904c
Implement `ActionDelete` / `ActionDelete2`
2019-10-06 13:02:31 -07:00
David Wendt
9b81a92516
Fix a number of bugs preventing the with-scope test from working at all:
...
1. We no longer implicitly return Undefined unless we're specifically returning from a function (this also keeps actions from filling the stack with Undefined)
2. With scopes are now always inserted behind the current set of locals rather than overriding them
3. `ActionSubtract` now subtracts (instead of adds)
2019-10-06 13:02:31 -07:00
David Wendt
fc1ce7692b
Implement ActionWith
2019-10-06 13:02:31 -07:00
David Wendt
7bf6e22714
Minor refactor/adjustment of GetVariable/SetVariable impl to explicitly check for slashpaths
2019-10-06 13:02:31 -07:00
David Wendt
face06f268
Impl `ActionEnumerate`
2019-10-06 13:02:31 -07:00
David Wendt
22f75b7a4c
Implement closure scope
2019-10-06 13:02:31 -07:00
David Wendt
d757ce0cd2
Implement arguments object.
2019-10-06 13:02:31 -07:00
David Wendt
90b0140ac2
Don't lock up when running scope operations
2019-10-06 13:02:31 -07:00
David Wendt
9ede91df4f
Move `this` into the activation object.
...
Also, change the implicit `this` on functions to `active_clip` as per the `ActionContext` docstrings.
2019-10-06 13:02:31 -07:00
David Wendt
ca1fb713a3
Execute actions in MovieClip scope
2019-10-06 13:02:31 -07:00
David Wendt
215d4f2df4
Provide arguments as local variables as some functions look for these
2019-10-06 13:02:31 -07:00