Commit Graph

2745 Commits

Author SHA1 Message Date
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 345a244ed4 `read_i32` no longer panics if more than 28 bits are defined within the read-in integer constant.
The underlying problem is actually shift overflow - on the fifth byte in the sequence, it attempts to mask bits by shifting them off the left of the value, which doesn't work here, as we'll be shifting by -3. For those unaware, shifting by a negative does NOT shift in the opposite direction, it instead gives your C compiler permission to stuff demons up your nose.

I wouldn't be surprised if this is just outright UB in Flash Player.
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
David Wendt 95ca978034 f64 constants in ABC files are not stored in Flash mixed-endian. 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] 962187bb89 build(deps-dev): bump @wdio/static-server-service in /web
Bumps [@wdio/static-server-service](https://github.com/webdriverio/webdriverio) from 6.1.14 to 6.4.0.
- [Release notes](https://github.com/webdriverio/webdriverio/releases)
- [Changelog](https://github.com/webdriverio/webdriverio/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webdriverio/webdriverio/compare/v6.1.14...v6.4.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-06 17:12:04 -07:00
dependabot-preview[bot] 40e92616cd build(deps-dev): bump @wdio/mocha-framework from 6.3.6 to 6.4.0 in /web
Bumps [@wdio/mocha-framework](https://github.com/webdriverio/webdriverio) from 6.3.6 to 6.4.0.
- [Release notes](https://github.com/webdriverio/webdriverio/releases)
- [Changelog](https://github.com/webdriverio/webdriverio/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webdriverio/webdriverio/compare/v6.3.6...v6.4.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-06 17:11:52 -07:00
dependabot-preview[bot] 629177372f build(deps-dev): bump @wdio/sync from 6.3.6 to 6.4.0 in /web
Bumps [@wdio/sync](https://github.com/webdriverio/webdriverio) from 6.3.6 to 6.4.0.
- [Release notes](https://github.com/webdriverio/webdriverio/releases)
- [Changelog](https://github.com/webdriverio/webdriverio/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webdriverio/webdriverio/compare/v6.3.6...v6.4.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-06 17:11:41 -07:00
dependabot-preview[bot] f67733f6f2 build(deps-dev): bump @wdio/local-runner from 6.3.6 to 6.4.0 in /web
Bumps [@wdio/local-runner](https://github.com/webdriverio/webdriverio) from 6.3.6 to 6.4.0.
- [Release notes](https://github.com/webdriverio/webdriverio/releases)
- [Changelog](https://github.com/webdriverio/webdriverio/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webdriverio/webdriverio/compare/v6.3.6...v6.4.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-06 17:11:28 -07:00
dependabot-preview[bot] 3bc0a66dd7 build(deps-dev): bump @wdio/spec-reporter from 6.3.6 to 6.4.0 in /web
Bumps [@wdio/spec-reporter](https://github.com/webdriverio/webdriverio) from 6.3.6 to 6.4.0.
- [Release notes](https://github.com/webdriverio/webdriverio/releases)
- [Changelog](https://github.com/webdriverio/webdriverio/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webdriverio/webdriverio/compare/v6.3.6...v6.4.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-06 17:11:17 -07:00
dependabot-preview[bot] 8c9aec93e2 build(deps-dev): bump @wdio/cli from 6.3.6 to 6.4.0 in /web
Bumps [@wdio/cli](https://github.com/webdriverio/webdriverio) from 6.3.6 to 6.4.0.
- [Release notes](https://github.com/webdriverio/webdriverio/releases)
- [Changelog](https://github.com/webdriverio/webdriverio/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webdriverio/webdriverio/compare/v6.3.6...v6.4.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-06 17:11:06 -07:00
Mike Welsh 94771a49c6 desktop: Rollback to winit 0.22.1 (fix #757 and #980) 2020-08-06 15:11:07 -07:00
dependabot-preview[bot] 29060984e2 build(deps-dev): bump mocha from 8.1.0 to 8.1.1 in /web
Bumps [mocha](https://github.com/mochajs/mocha) from 8.1.0 to 8.1.1.
- [Release notes](https://github.com/mochajs/mocha/releases)
- [Changelog](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mochajs/mocha/compare/v8.1.0...v8.1.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-05 16:34:07 -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