Nathan Adams
adceceed5d
avm1: Removed redundant double registration of Key
2020-01-17 15:11:38 -08:00
David Wendt
0af248d81f
Expose `childNodes` to ActionScript
2020-01-04 19:00:14 -05:00
David Wendt
4f5ac09b73
Expose XML document constructor, including text parsing ability
2020-01-04 19:00:09 -05:00
David Wendt
554f0dc1e5
Add XMLNode class and constructor impl
2020-01-04 19:00:07 -05:00
Mike Welsh
36b3e5b34f
avm1: Implement Color class
2020-01-03 20:31:32 -08:00
Mike Welsh
63dd92259b
avm1: First pass of Sound object
2020-01-03 17:11:00 -08:00
Nathan Adams
eedc4bbe24
core: Added Input backend, currently unimplemented, for polling user input
2019-12-21 19:08:06 -08:00
Nathan Adams
f6f358b4de
avm1: Expose TextFields and allow setting their .text
2019-12-19 10:19:43 -08:00
Nathan Adams
5f6eea6f25
chore: Refactor system listeners into a reusable system
2019-12-18 15:15:56 -08:00
Mike Welsh
3ebc1ed928
avm1: Stub out Stage properties
...
This is a very rough stub out of Stage.width and height to get
basic V-cams to start functioning.
TODO: Implement the different stage scaling modes. We will probably
want to add a "Stage" display object to handle this.
2019-12-17 22:28:44 -08:00
Mike Welsh
d33a8278d7
avm1: Implement MovieClip.duplicateMovieClip
2019-12-17 03:00:56 -08:00
Nathan Adams
45e497826b
avm1: Implement `Mouse` listeners & events (excluding scroll)
2019-12-16 19:22:10 -08:00
David Wendt
71d9655f6d
Implement `ASSetPropFlags`
2019-12-15 13:17:41 -08:00
Nathan Adams
32a1eda080
core: Implement Arrays & array prototype
2019-12-15 12:33:24 -08:00
Mike Welsh
23ca66a7e3
avm1: Use enum_trait_object for avm1::Object
2019-12-10 01:36:01 -08:00
Nathan Adams
eb185982cd
Add more Number(x) tests, and corrected primitive_as_number to match
2019-11-29 16:07:35 -08:00
Nathan Adams
85b9ffe102
core: Merge both test macros into a generic test_method
2019-11-29 13:12:00 -08:00
Nathan Adams
999bb128de
core: Allow global test_std to test multiple swf versions
2019-11-29 13:12:00 -08:00
David Wendt
9ec85c3892
Add tests for SWF6 numerical coercions.
2019-11-28 21:32:10 -05:00
Nathan Adams
638231e7fb
swf4 doesn't have NaN or Infinity
2019-11-28 20:53:20 -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
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
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
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
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
2f965d1c64
First stab at moving system builtins to explicit prototypes
2019-11-26 14:51:03 -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
5bf90653c4
Add implicit coercions to remove most instances of manually constructing a `ReturnValue`.
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
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
e36a0d8350
Allow native functions to resolve on the AVM stack for whatever reason.
2019-11-20 14:30:30 -05:00
Mike Welsh
dddfb42e1e
core: Merge ActionContext into UpdateContext
2019-10-27 13:49:47 -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
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
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
Nathan Adams
3d09ec81e2
Add Attribute::DontEnum
2019-10-08 16:36:39 +02:00
Nathan Adams
f2a4000ee2
Added object property attributes (initially just DontDelete)
2019-10-08 14:30:36 +02:00
Will Brindle
2e3748438a
core: define globals for NaN, Infinity, -Infinity. Should fix `typeof NaN`
2019-10-08 02:59:26 -07:00
Nathan Adams
2b54791cbb
Changed storage of object values to allow for dynamic (vs stored) properties
2019-10-02 10:49:08 -07:00
Mike Welsh
b38552204d
chore: cargo fmt
2019-09-26 11:45:45 -07:00
David Wendt
b61f264ac7
Add a check for `fscommand:` URLs
2019-09-20 15:11:33 -04:00
Mike Welsh
82c1116c42
chore: cargo fmt
2019-09-16 20:37:11 -07:00
David Wendt
f00e938299
Clean up unused functionality in preparation of a PR.
2019-09-16 20:04:30 -07:00
David Wendt
b40b10daf6
Support form submission from `getURL` function
2019-09-16 20:04:30 -07:00
David Wendt
130d9736bc
Allow builtins access to the AVM1 state directly.
2019-09-16 20:04:30 -07:00
David Wendt
359d3e4780
Propagate the RNG to the action context. This lets random work.
2019-09-16 20:04:30 -07:00
David Wendt
70d4f6c7c2
Implement more math builtins.
...
Random is currently a stub.
2019-09-16 20:04:30 -07:00
David Wendt
4e9fb2676b
Add `getURL` global builtin
2019-09-16 20:04:30 -07:00
Nathan Adams
a4cdbc4f70
Added `Math` unit tests, first avm tests :)
2019-09-02 22:19:09 +02:00
Nathan Adams
63f85446b7
Renamed builtins to globals, `_global` is a reference to the globals object
2019-09-02 20:45:19 +02:00